[Raku PDF Project] / [FontConfig Module] / FontConfig :: Pattern
FontConfig patterns and searching
This class represents an input pattern for font matching.
This class inherits from FontConfig and has all its methods available.
method new(*%atts --> FontConfig::Pattern)
Create a new pattern for font matching purposes
method parse(Str $patt --> FontConfig::Pattern)
Create a new pattern from a parsed FontConfig pattern.
$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>;
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>;
method parse(Str $patt --> FontConfig::Pattern)
Create a new pattern from a parsed FontConfig pattern.
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).