FontConfig-raku

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

class FontConfig::Pattern

FontConfig patterns and searching

Description

This class represents an input pattern for font matching.

Methods

This class inherits from FontConfig and has all its methods available.

new

method new(*%atts --> FontConfig::Pattern)

Create a new pattern for font matching purposes

parse

method parse(Str $patt --> FontConfig::Pattern)

Create a new pattern from a parsed FontConfig pattern.

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

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

This module 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>;

match

method match(--> FontConfig::Match)

This method returns a FontConfig object for the system font that best matches this pattern.

The matched object is populated with the actual font properties. The file property contains the path to the font.

my FontConfig $match = $pattern.match;
say 'matched font: ' ~ $match<fullname>;
say 'actual weight: ' ~ $match<weight>;
say 'font file: ' ~ $match<file>;

parse

method parse(Str $patt --> FontConfig::Pattern)

Create a new pattern from a parsed FontConfig pattern.

match-series

method match(UInt :$best, --> FontConfig::Match::Series)

This method returns a series of FontConfig::Match objects ordered by closest match first.

This method sorted, but does not filter the list of available fonts. The :$best option can be used to limit the maximum number of fonts returned. For example :best(5), or :best (best matching font only).