开发者

Unicode issue with freetype (C)

I currently working on a library for the NekoVM to create a binding to Freetype 2. It is written in plain c and it all works really nice, except when the user enters some unicode chars like "ü", "Ä" or "ß" they will be transformed into to some ugly square-like letters.

When I recieve the data from the NekoVM you use val_string which returns a char*. The function (FT_Load_Char) where you push the data into freetype expects a unsigned long as char code. (Every letter is processed on its own.)

What to do get the characters rendered correctly? I also have the option to convert them into any ISO-8859-XX code page before submitting them into the c written li开发者_StackOverflow社区brary.


A little square box means that your character isn't contained in the font. That can mean two things:

  1. Use a font which contains these characters

  2. Use the correct encoding. See FT_CharMap and FT_Encoding.


The solution was quite simple:

for (i=0;i<l;i++) {
    unsigned long c = FT_Get_Char_Index(face,r[i]);
    FT_Load_Glyph(face,uc,FT_LOAD_RENDER);
    ....
}

This makes freetype handle all the "encoding-stuff" at it own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜