Open tbrowder opened 1 year ago
Unfortunately, fontconfig doesn't have a good ability to select fonts with kerning and isn't really extensible. The newly introduced :best($n)
and :all
options does at least make it possible to get a list of fonts, that can then be filtered by additional critera. For example:
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;
When