freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Getting the charcode Value when the Glyph ID is known


From: Werner LEMBERG
Subject: Re: [ft] Getting the charcode Value when the Glyph ID is known
Date: Tue, 26 Apr 2011 19:22:00 +0200 (CEST)

> 1.  While using the FT_Get_First_Char and FT_Get_Next_Char to
> iterate the glyphs id's one by one to retrieve all the glyphs
> present in the font file, it fails to get all the glyph id's from
> the font file, some of the glyph id's are gone missing.

This means that the cmap (which you have selected manually, or which
has been selected as a default by FreeType) doesn't map a character
code to the particular glyph.  Especially with rich-featured OpenType
fonts there are a lot of such glyphs because the `GSUB' table can
further manipulate glyph IDs.  Just think of Indic fonts which need a
lot of ligatures which don't have a character code.  If you want to
iterate over all glyphs you shouldn't use FT_*_Char functions.

> 2.  In order to suppress the previous problem, I did a work around
> by putting a for loop to retrieve all the glyph id's present in the
> range between 1 to 256, so far its working fine, but my concern with
> this is:
> 
> a.  Now that I am retrieving the glyph's, how can I get the character
> code for each glyph ID?

There is no one-to-one mapping between character codes and glyph IDs!
Please read the OpenType specification for more details.  The same is
true for PS fonts; some fonts contain named glyphs with no proper
corresponding (Unicode) character code.  Ditto for CID-keyed fonts.

> b.  Can the glyph ID exceed the range of 1-255?

Yes, of course.  Usually, it's in the range 0x0000-0xFFFF, but some
font formats support even higher glyph index values (e.g. BDF).


    Werner



reply via email to

[Prev in Thread] Current Thread [Next in Thread]