Unicode issues in FreeType

So, I have an implementation that parses xml, which, among other things, contains the positions and lines of the Wikipedia main page. Parsing is done using quickxml, after which the strings are converted from UTF-8 to UTF-32 using http://utfcpp.sourceforge.net/ . Then the UTF-32 code is used in freetype:

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 displayed in OpenGL.

Now I can not get the flashy characters to work, neither Chinese, nor Japanese, nor viet, I'm sure * p matches the correct code, and I would be grateful for any pointers I can get.

For these fonts, Microsoft arial.ttf is used, from the Arch linux package and from what I saw in fontviewing programs, this should contain the characters that I want.

+6
source share
2 answers

Two things to offer:

First, did you call FT_Select_Charmap to indicate that you are using Unicode encoding?

 FT_Select_Charmap(face , ft_encoding_unicode); 

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

+7
source

Remember to set the font size immediately after loading the face.

 FT_Error err = FT_Set_Pixel_Sizes(face, (width), (height)); 
+1
source

Source: https://habr.com/ru/post/920568/


All Articles