Unicode troubles in FreeType

Jonathan Gustafsson picture Jonathan Gustafsson · Jul 16, 2012 · Viewed 8.6k times · Source

So, I've got an implementation that parses an xml that, among other things, positions and strings of Wikipedia's main page. The parsing is done with rapidxml after which the strings are converted from UTF-8 to UTF-32 by http://utfcpp.sourceforge.net/. The UTF-32 code is then used in freetype's:

unsigned long c = FT_Get_Char_Index(face,*p);
FT_Load_Glyph(face,c,FT_LOAD_RENDER);

where *p is the UTF-32 char code. This glyph is then rendered in OpenGL.

Now, I can't seem to get cryllic characters to work, nor any chinese or japanese or viet, I am sure that *p corresponds to the correct code, and I would be thankful for any pointers I can get.

For these fonts Microsofts arial.ttf is used, from the Arch linux package and from what I've seen in fontviewing programs, it should contain the characters that I want.

Answer

Roddy picture Roddy · Jul 16, 2012

Two things to suggest:

First, have you called FT_Select_Charmap to specify you're using a Unicode encoding?

FT_Select_Charmap(face , ft_encoding_unicode);

Second, not all Arial fonts have all characters, and some font viewers (on Windows, anyway) can mislead by automatically substituting glyphs from different faces. Try ArialUni.ttf if you can find it.