Skip to content

Commit

Permalink
Fix font-shaping
Browse files Browse the repository at this point in the history
Font caching is now invalid. Take it out.
  • Loading branch information
dwarring committed Feb 26, 2024
1 parent 0646e21 commit ea7fa54
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/PDF/Font/Loader/FontObj.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,8 @@ method kern(Str $text) {
@chunks, self.stringwidth($text) + $kernwidth.round;
}
has $!harfbuzz-font;
method !harfbuzz-font(:@features) {
$!harfbuzz-font //= $!face.font-format ~~ 'TrueType'|'OpenType'
$!face.font-format ~~ 'TrueType'|'OpenType'
?? HarfBuzz::Font.COERCE: %( :blob($!font-buf), :@features)
!! HarfBuzz::Font::FreeType.COERCE: %( :ft-face($!face), :@features);
}
Expand Down
2 changes: 1 addition & 1 deletion t/load-font.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ is $vera.stringwidth("RVX", :kern), 2064 - 55, 'stringwidth :kern';
is-deeply $vera.kern("RVX" ), (['R', -55, 'VX'], 2064 - 55), '.kern(...)';
is-deeply $vera.kern('ABCD' ), (['AB', -18, 'CD'], 2820), '.kern(...)';
is-json-equiv $vera.shape("RVX" ), (["\0\c[53]", 56+0i, "\0\c[57]"~"\0\c[59]"], 2064 - 56), '.shape(...)';
todo "kerning not disabled?";

is-json-equiv $vera.shape("RVX", :!kern ), (["\0\c[53]" ~ "\0\c[57]"~"\0\c[59]"], 2064), '.shape(:!kern)';

is $vera.glyph-width('V'), 684;
Expand Down

0 comments on commit ea7fa54

Please sign in to comment.