dfrg / swash

Font introspection, complex text shaping and glyph rendering.
Apache License 2.0
636 stars 36 forks source link

use units_per_em to scale CFF font matrix #32

Closed danielronnkvist closed 1 year ago

danielronnkvist commented 1 year ago

Encountered a couple of fonts that were using CFF to generate paths, but their settings was a bit unusual by having the em size set to 2000. That resulted in swash rendering the fonts in half their real size. By scaling the font_matrix using the font's units_per_em instead they where rendered correctly.

I'm a bit uncertain if I should pass the metrics along the functions to where it's needed or if it's better to read the units_per_em by parsing the data once again. Any recommendations?

Closes #27

danielronnkvist commented 1 year ago

@dfrg could you review this when you have time?

dfrg commented 1 year ago

Yes, sorry for the delay. At a glance, I do think the CFF table should just read upem again rather than feeding the full metrics struct through. If you make that change, I’ll go ahead and merge.

danielronnkvist commented 1 year ago

@dfrg I've made an update now where the CFF table reads upem again and removed the passing of metrics.

dfrg commented 1 year ago

This looks great. Thank you for the fix!