Further to my answer, I think freetype generally tries to present a 
"consistent" view of the font to users (assuming the font is shipping/released 
and any anomalies /inconsistency is a bug in the font), and there are internal 
mechanisms resolving say, glyph counts from maxp table, head table and glyf 
table being different and inconsistent, and take one as authoritative. You 
probably have to go quite low-level in freetype to get what you want - find out 
if a CID-font contains extra glyphs outsides its advertised usage, and may find 
that some of freetype's auto-correction gets in your way. You probably are 
better off using font editor APIs like fontforge or ttx to examine "unusual" 
fonts, or fonts with extra / redundant data at least.
     On Monday 30 December 2024 at 18:14:27 GMT, Hin-Tak Leung 
<[email protected]> wrote:  
 
  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 <[email protected]> 
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
    

Reply via email to