Open Pomax opened 4 years ago
(note: font.js should still offer built in high-level deconstruction, but not operator/operand unpacking)
+1. Right now I could use being able to tell whether a glyph contains any outlines at all.
Can you sketch a use-case? Are you trying to determine if a glyph is printable from font, rather than from charset spec?
Oh, it’s nothing really. I’m making a string generator to use with pattern fonts. Some of them will use a subset of the basic Latin alphabet for their pattern modules and have the remaining glyph slots empty instead of just leaving them out of the font. So being able to tell a glyph is empty would help automate the glyph selection process. Maybe there’s another way to do so, without having to parse CFF/CFF2?
That seems like solving the symptom rather than the problem: don't include empty glyphs in your subset fonts, and you're done? Rather than parsing glyph outline strings, now it's back to a simple matter of "does font support codepoint X".
Obviously. But sometimes curing the symptoms is all the doctor can do. I’m not working with my own fonts, and as the goal is to use a still smaller selection of the existing functional glyphs at any given time, manual glyph selection is still involved. I just thought I would detect and pre-select the filled glyphs after loading the font so that the users that come with their own custom-made, ad-hoc, imperfect fonts have a few clicks less.
I see. In that case, you're probably better off loading a full-fat font library like OpenType.js, and then checking each glyph's metrics. I've implemented several TTF and CFF parsers in the past, and it's enough of an absolute nonsense job that unless someone's willing to fund the effort, I'm unlikely to get to it until I personally need it again.
(Mind you, if you need this because you work for a company and this helps you achieve a task set by your team/manager/company etc, please do talk to whoever has the power to fund third party work, because I'm more than happy to work on this library in exchange for monetary compensation =)
While this lib may not be intended to be a text shaper, it might be useful to offer a separate CFF/CFF2 parser that can be loaded alongside Font.js, to allow Font.js to dig into the CFF/CFF2 blocks (without doing charstring interpretation), to add additional "raw data" inspection of the font.