4 ms·
The information you're after to measure line heights, glyph sizes, em-height, etc. is generally in the 'head' [1] and 'OS/2' [2] tables of an OpenType font. Don
by pcwalton 5y ago
The information you're after to measure line heights, glyph sizes, em-height, etc. is generally in the 'head' [1] and 'OS/2' [2] tables of an OpenType font. Don't be afraid to parse these tables if you need to; it's not hard to do, even in JavaScript. (Of course, to have access to the tables in the first place you'll need to be using a webfont that you control.)
[1]: https://docs.microsoft.com/en-us/typography/opentype/spec/head https://docs.microsoft.com/en-us/typography/opentype/spec/he...
[2]: https://docs.microsoft.com/en-us/typography/opentype/spec/os2 https://docs.microsoft.com/en-us/typography/opentype/spec/os...
- chrismorgan 5y ago> it's not hard to do, even in JavaScript But if you’re going to try to do anything fancy like this, it’s practically certainly better to do it as a build step, because otherwise you’ll be shipping extra parser code, doing extra work, and either loading the font twice or slowing down the CSS pipeline by putting JavaScript into the critical path. Also, remember that the font may not load (e.g. user preference overriding all fonts), so don’t depend on this sort of thing for fine detail unless you’ve confirmed the font is actually being used.