[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freetype] display Kanji
From: |
David Turner |
Subject: |
Re: [Freetype] display Kanji |
Date: |
Fri, 27 Dec 2002 15:59:08 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2a) Gecko/20020910 |
Hello Achim,
Achim Mueller wrote:
Hi,
I want to display Text in Kanji. But since the symbols are split into 13
TTF files KANJIA.TTF to KANJIL.TTF I want to create a lookup table which
symbol is in which file. The idea was to iterate with Get_First_Char and
Get_Next_Char over the charmaps to create this unified mapping table.
My problem is now, that this works well with e.g. VERDANA.TTF but not
with the required KANJI fonts.
mvError = FT_Init_FreeType( &mLibrary );
if ( mvError ) {return FAILED;}
mvError = FT_New_Memory_Face( mLibrary,
( const FT_Byte * ) data.cchrptr(),
data.length(), 0, &mFace );
if ( mvError ) {return FAILED;}
//FT_Select_Charmap( mFace, FT_ENCODING_MS_SJIS );
//FT_Select_Charmap( mFace, FT_ENCODING_UNICODE );
//FT_Select_Charmap( mFace, FT_ENCODING_MS_BIG5 );
FT_UInt FirstGlyphCode;
FT_ULong FirstCharCode = FT_Get_First_Char( mFace, &FirstGlyphCode );
cout << FirstCharCode << ",\t";
while ( FirstGlyphCode != 0 )
{
FirstCharCode = FT_Get_Next_Char( mFace,
FirstCharCode, &FirstGlyphCode );
cout << FirstCharCode << ",\t";
};
With the KANJI fonts or even the simple 1-file KANA.TTF font the
iterator returns always 0. And a brute force lookup does it either.
FT_UInt gi = FT_Get_Char_Index( mFace, 0x4ee0 );
cout << "char 0x4ee0 -> glyph: " << gi << "\n";
That's not very surprising, "ftdump" shows that KANA.TTF
doesn't have any Unicode charmap, in such cases, FreeType's
behaviour is perfectly normal.
By the way, these are the 2 charmaps in the font:
(1,0) ( Macintosh, Roman ) (probably useless)
(3,0) ( Windows, Symbol )
I don't know how to convert from Symbol to Unicode, or the other
way around, but I suppose that your other fonts exhibit the same
problem..
You should try to select the FT_ENCODING_MS_SYMBOL charmap and
parse it to see how it is organized..
Regards,
- David Turner
- The FreeType Project (www.freetype.org)