Closed tbrowder closed 1 year ago
Thanks Tom, I am working on FontConfig to add the ability to return a list of fonts, sorted by best-matching first.
Thanks, David, you're the best!
Options added to latest PDF::Font::Loader 0.7.4 and FontConfig 0.1.4.
:best(20)
will return up to the best 20 matching fonts. Example taken from doco which tries to find the best font with kerning:
use PDF::Font::Loader;
use Font::FreeType;
use Font::FreeType::Face;
my Font::FreeType $ft .= new;
my $series = PDF::Font::Loader.find-font(:best(10), :!serif, :weight<bold>,);
my Str @best = $series.Array;
# prefer a font with kerning
my Str $best-font = @best.first: -> $file {
my Font::FreeType::Face $face = $ft.face: $file;
$face.has-kerning;
}
# fall-back to best matching font without kerning
$best-font //= @best.head;
note "best font: " ~ $best-font;
There's also an :all
option the returns all fonts sorted by best match first, if you want to exhaustively scan all fonts on the system, see doco.
Thanks, David!
The user may have thousands of fonts available meeting the input criteria and want to make his own choice.