[ft] How to get a glyph index of Japanese charactor

2008-08-27 Thread Hongyu Zhang
Hello, every one:

I am a beginner of freeType2 library.
I have a problem about how to get a glyph index of Japanese charactor.

I use the function FT_Get_Char_Index to get a glyph index.
This function needs a parameter named charcode.
For a English charactor, its charcode is indeed the ASCII code (binary 
code),
but for a Japanese charactor, I don't know what the charcode should be?
I am using the default FT_ENCODING_UNICODE charmap which contains Japanese 
font.
When I set the charcode to be its binary code (eg. 0xE38193), glyph index 0 
is returned.

There is anyone who can get the glyph index of the charactor in a Japanese 
text ?
please help me.

Thank you for your support.

 Regards

 Hongyu Zhang
 [EMAIL PROTECTED]

___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft] How to get a glyph index of Japanese charactor

2008-08-27 Thread suzuki toshiya
Hi,

Hongyu Zhang wrote (2008/08/27 20:10):
 I am using the default FT_ENCODING_UNICODE charmap which contains Japanese 
 font.

Basically it's OK. Some legacy fonts designed for classic MacOS
have only Shift-JIS encoding (no Unicode encoding interface),
but most fonts produced recently have Unicode interfaces.
In such case, you have to use some character encoding conversion
library (e.g. iconv). FreeType2 does not provide encoding conversion
mechanism.

 When I set the charcode to be its binary code (eg. 0xE38193), glyph index 0 
 is returned.

Hmm, I'm not sure what the encoding you wanted use.
Regarding the 24bit length of 0xE38193, I guess you
wanted to use UTF-8. Please try UCS-4 codepoint
(e.g. 0x3042, the UCS-4 codepoint of hiragana A).

Regards,
mpsuzuki


___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft] How to get a glyph index of Japanese charactor

2008-08-27 Thread suzuki toshiya
suzuki toshiya wrote (2008/08/27 22:25):
 When I set the charcode to be its binary code (eg. 0xE38193), glyph index 0 
 is returned.
 
 Hmm, I'm not sure what the encoding you wanted use.
 Regarding the 24bit length of 0xE38193, I guess you
 wanted to use UTF-8. Please try UCS-4 codepoint
 (e.g. 0x3042, the UCS-4 codepoint of hiragana A).

I slipped to note why you can use UCS-4 but
you cannot UTF-8. As I've written in previous
post, FreeType2 does not have the convertor
of character encoding, even if it's simple
mathematics (like UTF8 - UCS-4). So, what
kind of character encoding is available?
is completely defined by the contents of font
file. At present, TrueType fonts supports
UCS-2, UCS-4, Shift-JIS, GB 2312, Big 5,
Wansung, etc, but no support for UTF-8.
So, you cannot use UTF-8 to lookup a glyph
in Japanese TrueType font.

Regards,
mpsuzuki


___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype