You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using following code to read and iterate over all glyphs in a font
let font = fontkit.create(Buffer.from(buffer));
font.characterSet.forEach(character => {
const glyphObj = font.glyphForCodePoint(character);
});
however when i try to load calibri font, in characterSet object i am getting around 3k glyphs but actually it contains 6.5 k glyphs.
While debugging i came to know that characterSet object doesn't contain non-Unicode characters.
Is there any way to iterate over non-Unicode characters ?
The text was updated successfully, but these errors were encountered:
The readme does mention that over in https://github.com/foliojs/fontkit#other-properties, the characterSet property is specifically for Unicode codepoint glyphs only. If you compare its length to numGlyphs, though, you will see that Fontkit does know that Calibri has over 6.5k glyphs:
So if you want to work with the non-unicode glyphs, you'll have to build that list, but then you might still not be able to actually access those characters given that Fontkit's API is built around working specifically with Unicode codepoints.
However, also note that a ton of glyphs are not "letters": glyphs are just vector graphics, and while some glyphs are actual letters, with an associated code point, plenty are just "components" that used in other glyphs, and would make no sense when rendered in isolation: if you load Calibri in an actual font editor, you'll see it contains 3378 "unmapped" glyphs, meaning they are not meant to ever be rendered in isolation, only to be used as parts of other, real, glyphs. In terms of glyphs that you should actually be able to "use" for Calibri, there are only 3660 glyphs with outlines, plus three "empty" glyphs (notdef, the nonmarking return, and space)
I am using following code to read and iterate over all glyphs in a font
however when i try to load calibri font, in characterSet object i am getting around 3k glyphs but actually it contains 6.5 k glyphs.
While debugging i came to know that characterSet object doesn't contain non-Unicode characters.
Is there any way to iterate over non-Unicode characters ?
The text was updated successfully, but these errors were encountered: