OK. Since no one is risking... I'm gonna try again.
I think this can be done. I'll try to draft a few steps:
1. Get the charmap for the UNICODE encoding.
This can be done as following:
FT_CMap cmap = FT_CMAP( face->charmap );
Keep in mind that perfect would be to first select the unicode charmap in the face. But in most faces that charmap is the default.
2. Dig pretty deep in freetype code and docs.
I can only tell you the reverse function for what you want to achieve.
Since you're working with true type fonts, you need the reverse of this:
FT_CALLBACK_DEF( FT_UInt )
tt_cmap0_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
return char_code < 256 ? table[6 + char_code] : 0;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap0_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
return char_code < 256 ? table[6 + char_code] : 0;
}
To copy to clipboard, switch view to plain text mode
This is from ttcmap.c. Every font type has a particular implementation for retrieving the glyph index.
In your situation, you will actually pass the glyph index. you will have to iterate in "table" to search for the index matching yours.
Once you find it, return the table index that gave you your glyph index.
I do not pretend to know everything about what's under the hood in freetype( not sure how many people actually know ), but you should really get familiar about how charmap lookup tables are built/loaded and what exceptional cases there may be.
In the mean time, you might even find another solution to your problem.
Regards
Bookmarks