Giter Site home page Giter Site logo

fontconfig-raku's Introduction

[Raku PDF Project] / [FontConfig Module] Actions Status

FontConfig-raku

Raku interface to the FontConfig native library

Synopsis

use FontConfig;
use FontConfig::Pattern;
use FontConfig::Match;
# optional: fontconfig uses the default system configuration, by default 
INIT FontConfig.set-config-file: 'my-fonts.conf';

my FontConfig::Pattern $patt;
$patt .= parse: 'Arial,sans:style<italic>';
# -- OR --
$patt .= new: :family<Arial sans>, :style<italic>;

$patt.weight = 'bold';
say $patt.Str;
# Arial,sans:style=italic:weight=205

my FontConfig::Match $match = $patt.match;
say $match.file;
say $match.format('%{file}');
# e.g. /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf

Description

This module provides Raku bindings to the FontConfig library for system-wide font configuration and access.

At this stage, enough library bindings are implemented to enable FontConfig patterns to be parsed or built, and the best matching font to be located.

Property Accessors

The Raku FontConfig bindings provide automatic accessors for known properties

$patt.weight = 'bold';
say $patt.weight;

FontConfig Configuration

By default, fontconfig uses system-wide font configuration files. Their location may depend on your particular distribution and system.

There are several environment variables that can be set to define files and search paths, including: FONTCONFIG_FILE and FONTCONFIG_PATH.

This may need to be set, prior to running your programs, to provide a custom configuration file, or if FontConfig is giving an error "Cannot load default config file".

The FontConfig class has one method set-config-file($path) that can be called from the current process to set FONTCONFIG_FILE. This acts globally and should be called once, before using any other methods.

Classes in this distribution

Install

This module requires a development version of fontconfig:

  • Debian/Ubuntu Linux: sudo apt-get install libfontconfig1-dev
  • Alpine/Linux: doas apk add fontconfig-dev
  • Mac OS X: brew install fontconfig

fontconfig-raku's People

Contributors

dwarring avatar melezhik avatar

Watchers

 avatar

Forkers

melezhik tbrowder

fontconfig-raku's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.