views:

184

answers:

2

Hi guys,

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 library.

+3  A: 

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.

Aaron Digulla
the char is in the font (it is the same I use on my OS and there these chars are displayed.)
Hippo
In that case, it's an encoding issue.
Aaron Digulla
A: 

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.

Hippo