freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Get non-ASCII font family name


From: mpsuzuki
Subject: Re: [ft] Get non-ASCII font family name
Date: Fri, 14 Jul 2006 09:58:56 +0900

Hi

On Thu, 13 Jul 2006 15:52:23 -0700
"Tom Fukushima" <address@hidden> wrote:
>What does the last sentence mean?

Since FreeType2 provides "unified" API for various font formats,
the fundamental API is designed for ASCII font name: because
some font formats cannot include localized font names.
If you want to prioritize localized font names,
you may restrict your application to TrueType variants,
so you cannot use format-independent API of FreeType2.
You should use format-dependent API of FreeType2.

>It seems relevant to what I need: I'm trying to get the family
>names from msgothic.ttc on Windows XP, but I only get the ASCII
>versions of the names back (MS Gothic, MS PGothic).

FT_Face object itself is designed to be format-independent,
so it does not include localized font names.
Thus, the process will be something like:
step 1. Collect all available font pathnames
        (or file handles, memory images etc)
step 2. Open the font file by FreeType2
step 3. Search the localized string in the internal data.
step 4. If anything you expect is available,
        store the localized string into your own database
        mapping the localized string and FT_Face object.
        
FreeType2 provides the API to access internal "string objects"
in TrueType fonts: FT_Get_Sfnt_Name_Count(), FT_Get_Sfnt_Name().
http://www.freetype.org/freetype2/docs/reference/ft2-sfnt_names.html#FT_Get_Sfnt_Name_Count
http://www.freetype.org/freetype2/docs/reference/ft2-sfnt_names.html#FT_Get_Sfnt_Name

By FT_Get_Sfnt_Name_Count(), you can count the number of
all strings stored in TrueType font. Then, you can load
a string object at a time. The string object includes the
informations of "which platform this is", "which encoding
this is", ...
http://www.freetype.org/freetype2/docs/reference/ft2-sfnt_names.html#FT_SfntName
So, by these informations, you can detect: this is localized?
this is font name? etc etc. By repeating this check for all
string object, you can determine "localized font name exist
in this font", and you can get localized font name if there
is.

However, sometimes cheap CJK TrueType fonts include false
encoding declaration: the name is encoded by Shift-JIS but
the encoding is declared as Unicode. Please use irrefrangible
algorithm against broken strings.

Regards,
mpsuzuki




reply via email to

[Prev in Thread] Current Thread [Next in Thread]