开发者

Retrieving a specified glyph from freetype (SHIFT JIS encoded)?

Until now I used a texture (bitmapfont) for font rendering, but I'm trying to get freetype2 working. All my strings are SHIFT_JIS encoded and my only Problem is now to get from freetype the right glyph to a proper SHIFT_JIS bitsequence. But it seems harder than I expected. To example "亜" has the charcode "0x889F" (byte 1 is set to 136 and byte 2 is 159) - that's according to the SHIFT_JIS encoding. So I called the function:

FT_Select_Charmap(face, FT_ENCODING_SJIS);

and try then to load a glyph with that charcode:

FT_Load_Char(face, 0x889F, FT_LOAD_RENDER ); 

But I receive some random glyph. It cant be a font-specific problem, because I tried already different fonts with the same result (and yeah, they provide a shift-jis charmap). To example "0" (zero) should be at position 0x0030 - but its in fact at 0x002D. Not all characters have an constant offset of 3, otherwise there would be no problem... I think my "FT_Load_Char" call, pass the charcode parameter in a wrong way - but cant gu开发者_JAVA技巧ess how it would be right. Already tried:

FT_Load_Char(face, FT_Get_Char_Index(face, 0x889F), FT_LOAD_RENDER ); 

But then I receive another random glyph. So, how can I pass the charcode to FT_Load_Char if not the default charmap is selected?

Any advice would be really helpful. Thank you.


If anyone will find this later with a similiar problem: I ended up with converting the character codes on the fly to unicode (using icu4c). It seems like there`s a problem with a lot of japanese SJIS font headers (they can not selected via the freetype enums - only if you list all available charsets of one of these fonts and then choose the right manually - platform ID & encoding ID aren't identical for all of these fonts too). But that wasn't a proper solution for my needings (because using different fonts), so I finally decided to use Icu4c.

Hopefully this will be helpful to someone.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜