foliojs / fontkit

An advanced font engine for Node and the browser
1.46k stars 219 forks source link

OS/2 vs hhea font metrics for ascender/descender #339

Open null77 opened 1 month ago

null77 commented 1 month ago

Quite a while ago this change:

https://github.com/foliojs/fontkit/commit/9d1ffe47ed1c4569501530ed9624417e685a5739

Moved from using OS/2 to hhea metrics for ascender/descender/etc. I'm wondering if there's any record of what motivated this change?

For context, I'm trying to align the rendering output from PDFKit with a WebGL font library (https://www.npmjs.com/package/troika-three-text) and during my investigation I found that PDFKit and the troika text library disagree on these font metrics. This only affects some fonts, e.g. Trirong Regular (https://fonts.google.com/specimen/Trirong?query=trirong).

More context at https://github.com/protectwise/troika/issues/320 . In particular the maintainer noted the library is consistent with the CSS spec and the MS OpenType format docs. Is fontkit potentially doing the wrong thing? Is there a different spec that fontkit uses for its metrics init?