pdf-raku / PDF-Font-Loader-raku

Font loader for the PDF tool-chain
Artistic License 2.0
1 stars 3 forks source link

Metrics mismatch for core fonts #14

Closed dwarring closed 2 years ago

dwarring commented 2 years ago

Currently, FontConfig is used to load any system font that best matches the core font and takes the metrics from there.

This may cause problems depending on the font selected and how well it matches the core font metrics.

I'm seeing evidence of this with PDF::To::Cairo rendering of Pod::To::PDF::API6 produced PDF's with core fonts.

Note that other un-embedded fonts use widths (/Widths or /W). So also setting the widths using core fonts metrics is probably better.

Ideal solution is to choose, or have fonts available that closely match core font metrics.

More investigation needed.

dwarring commented 2 years ago

Attributes sx and sy have been added to glyphs. These represent the actual widths of a substituted font. In the case of core fonts, ax now falls back to the standard AFM metrics size for the font.

This is enough for PDF::To::Cairo to do a much better job of scaling and placing replacement glyphs while rendering.