FontConfig

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

Description

FontConfig is the base class for FontConfig::Pattern (queries) and FontConfig::Match (matches).

Font Properties

Common font properties include:

The full list of properties is extensive and implementation dependant. For more properties,

  • see FontConfig properties, which lists many properties.

  • The query-info method returns a pattern with all suported properties for a given face

  • FontConfig command-line tools such as fc-query and fc-match can be used to query fonts and properties.

Methods

constant

method constant(Str $name --> UInt)

Fontconfig has symbolic constants for numeric properties. For example, in the pattern: Ariel;weight=bold, bold, evaluates to 200. The constant() method can be used to look-up these constants.

my \bold = FontConfig.constant("bold"); # 200
if $match<bold> >= bold {
    say "matching font is bold";
}

Note that the Raku bindings resolve symbolic constants when a string is assigned to a numeric property. So:

$match<weight> = "extrabold";

Is equivalent to:

$match<weight> = FontConfig.constant("extrabold");

query-ft-face

method query-ft-face(Pointer() $face, Str() :$file, UInt :$id --> FontConfig)

This method computes a FontConfig pattern based on the attributes of an existing FreeType font. It can be used to discover FontConfig attributes for a specific font.

The match() method will find the best font, reachable by FontConfig's configuration, that matches the original font, which may or may not be the original font.

The following example requires installation of the Font::FreeType module.

use FontConfig;
use Font::FreeType;
my $file = "t/fonts/Vera.ttf";
my Font::FreeType::Face $face = Font::FreeType.face($file);
my FontConfig $patt .= query-ft-face($face, :$file);
say $patt.fullname; # Bitstream Vera Sans
say $patt.file;     # t/fonts/Vera.ttf
say $patt.weight;   # 80

AT-KEY, ASSIGN-KEY, keys, elems, pairs, values

$patt<weight> = 205;
$patt<weight> = 'bold';
say $patt<weight>;
$patt<weight>:delete;

This class provides am associative interface to FontConfig properties.

Numeric values in the pattern may be set to ranges:

$patt<weight> = 195..205;

Values may also hold a list, such as a list of font families:

$patt<family> = <Arial sans>;

Str

The Str method serializes a pattern to a string representation;

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

version

method version returns Version

This method returns the installed fontconfig library version. Please note that the minimum supported version is v2.13.1.

FontConfig v0.1.9

FontConfig native bindings

Authors

  • David Warring

License

Artistic-2.0

Dependencies

MacOS::NativeLibLibraryMake

Test Dependencies

Provides

  • FontConfig
  • FontConfig::Defs
  • FontConfig::Match
  • FontConfig::Match::Series
  • FontConfig::Pattern
  • FontConfig::Raw

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.