What does "ftdump" show as glyph count?
Think about what you are asking: CID-keyed fonts are, by definition, where glyph ids have specific meanings, and are encoded according to a character collection. So you are asking if it is possible (using freetype) to find glyphs with glyph ids outside of the corresponding character collection's range - using gaps etc to index and encode extra glyphs, or to detect glyph data in a font without glyph ids. The former is probably considered a malformed font, the latter might be a work in progress. Freetype tends to cater for "shipping /released" fonts, so probably lacking a bit in doing either. Have you considered using APIs of one of the font editors instead? If you have a font for which either type of the anomalies exists? Fontforge has a python extension, and there is ttx/fonttools too. You are basically asking for APIs to examine the glyf / CFF / CFF2 table for anomalies in freetype.
On Monday 30 December 2024 at 09:33:08 GMT, Francesco Pretto <ceztko@gmail.com> wrote:
Hello,
I noticed there exists FT_Get_CID_From_Glyph_Index[1] that allows you
to access glyphs by a contiguous random index, albeit it may be
suboptimal because it still ends requiring glyphs to be accessed with
the fetched CID. While this works, I am still missing a method that
can return the exact number of contiguous glyphs in a CID keyed font,
which can be quite informative. FT_FaceRec.num_glyphs for CID keyed
fonts is really the number of last CID - 1, so it's not the correct
number. Questions are:
- Is there any existing API that I can hack to retrieve the real
number of contiguous glyphs in the font?
- why isn't there simply a couple of specialized methods to retrieve
the real glyph count and to load the glyph by contiguous indices?
Cheers,
Francesco
[1] https://freetype.org/freetype2/docs/reference/ft2-cid_fonts.html#ft_get_cid_from_glyph_index
[2] https://freetype.org/freetype2/docs/reference/ft2-face_creation.html#ft_facerec