Skip to content

Conversation

tobil4sk
Copy link
Member

The original code didn't work for emojis, but the stack overflow discussion since then includes a fix for this issue. See the comment:

https://stackoverflow.com/questions/2948308/how-do-i-read-utf-8-characters-via-a-pointer#comment72311507_2953960

Now readNextChar can extract the unicode value correctly, however, it still does not result in a correct glyph index being found.

The original code didn't work for emojis, but the stack overflow
discussion since then includes a fix for this issue. See the comment:

https://stackoverflow.com/questions/2948308/how-do-i-read-utf-8-characters-via-a-pointer#comment72311507_2953960
@tobil4sk
Copy link
Member Author

I was able to get it working properly by adding in FT_Select_Charmap((FT_Face)face, FT_ENCODING_UNICODE);. We already have some code to set the char map, so that probably needs to be updated or replaced:

/* Set charmap
*
* See http://www.microsoft.com/typography/otspec/name.htm for a list of
* some possible platform-encoding pairs. We're interested in 0-3 aka 3-1
* - UCS-2. Otherwise, fail. If a font has some unicode map, but lacks
* UCS-2 - it is a broken or irrelevant font. What exactly Freetype will
* select on face load (it promises most wide unicode, and if that will be
* slower that UCS-2 - left as an excercise to check.
*/
for (int i = 0; i < ((FT_Face)face)->num_charmaps; i++) {
FT_UShort pid = ((FT_Face)face)->charmaps[i]->platform_id;
FT_UShort eid = ((FT_Face)face)->charmaps[i]->encoding_id;
if (((pid == 0) && (eid == 3)) || ((pid == 3) && (eid == 1))) {
FT_Set_Charmap ((FT_Face)face, ((FT_Face)face)->charmaps[i]);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant