From 48b6ddb8a86d54f73b4b2d3387d4625f064f5a63 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 22 Dec 2003 23:01:20 +0000 Subject: [PATCH] * include/freetype/ftwinfnt.h (FT_WinFNT_ID_*): New definitions to describe the `charset' field in FT_WinFNT_HeaderRec. * src/winfonts/winfnt.c (FNT_Face_Init): Set encoding to FT_ENCODING_NONE except for FT_WinFNT_ID_MAC. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * include/freetype/freetype.h (FT_Encoding): Improve comment, based on work by Detlef Würkner . * docs/CHANGES: Updated. --- ChangeLog | 81 ++++++++++++++---------- docs/CHANGES | 7 ++ include/freetype/freetype.h | 31 +++++++++ include/freetype/ftwinfnt.h | 123 +++++++++++++++++++++++++++++++++++- src/winfonts/winfnt.c | 13 +++- 5 files changed, 216 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 084679b17..fc8f0dcb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,47 +1,58 @@ +2003-12-22 Werner Lemberg + + * include/freetype/ftwinfnt.h (FT_WinFNT_ID_*): New definitions + to describe the `charset' field in FT_WinFNT_HeaderRec. + * src/winfonts/winfnt.c (FNT_Face_Init): Set encoding to + FT_ENCODING_NONE except for FT_WinFNT_ID_MAC. + + * include/freetype/freetype.h (FT_Encoding): Improve comment, + based on work by Detlef Würkner . + + * docs/CHANGES: Updated. + 2003-12-22 David Turner - * include/freetype/ftcache.h, - include/freetype/cache/ftcmanag.h, - include/freetype/cache/ftccache.h, - include/freetype/cache/ftcmanag.h, - include/freetype/cache/ftcmru.h (added), - include/freetype/cache/ftlru.h (removed), - include/freetype/cache/ftcsbits.h, - include/freetype/cache/ftcimage.h, - include/freetype/cache/ftcglyph.h, - src/cache/ftcmru.c, - src/cache/ftcmanag.c, - src/cache/ftccache.c, - src/cache/ftcglyph.c, - src/cache/ftcimage.c, - src/cache/ftcsbits.c, - src/cache/ftccmap.c, - src/cache/ftcbasic.c (added), - src/cache/ftclru.c (removed): + * include/freetype/ftcache.h, + include/freetype/cache/ftcmanag.h, + include/freetype/cache/ftccache.h, + include/freetype/cache/ftcmanag.h, + include/freetype/cache/ftcmru.h (added), + include/freetype/cache/ftlru.h (removed), + include/freetype/cache/ftcsbits.h, + include/freetype/cache/ftcimage.h, + include/freetype/cache/ftcglyph.h, + src/cache/ftcmru.c, + src/cache/ftcmanag.c, + src/cache/ftccache.c, + src/cache/ftcglyph.c, + src/cache/ftcimage.c, + src/cache/ftcsbits.c, + src/cache/ftccmap.c, + src/cache/ftcbasic.c (added), + src/cache/ftclru.c (removed): - *Complete* rewrite of the cache sub-system to "solve" the - following points: + *Complete* rewrite of the cache sub-system to "solve" the + following points: - - all public APIs have been moved to FT_CACHE_H, everything - under "include/freetype/cache" is only needed by client - applications that want to implement their own caches + - all public APIs have been moved to FT_CACHE_H, everything + under "include/freetype/cache" is only needed by client + applications that want to implement their own caches - - a new function named FTC_Manager_RemoveFaceID to deal - with the uninstallation of FaceIDs + - a new function named FTC_Manager_RemoveFaceID to deal + with the uninstallation of FaceIDs - - the image and sbit cache are now abstract classes, that - can be extended much more easily by client applications + - the image and sbit cache are now abstract classes, that + can be extended much more easily by client applications - - better performance in certain areas. Further optimizations - to come shortly anyway... + - better performance in certain areas. Further optimizations + to come shortly anyway... - - the FTC_CMapCache_Lookup function has changed its signature, - charmaps can now only be retrieved by index - - - FTC_Manager_Lookup_Face => FTC_Manager_LookupFace - FTC_Manager_Lookup_Size => FTC_Manager_LookupSize (still in - private header for the moment) + - the FTC_CMapCache_Lookup function has changed its signature, + charmaps can now only be retrieved by index + - FTC_Manager_Lookup_Face => FTC_Manager_LookupFace + FTC_Manager_Lookup_Size => FTC_Manager_LookupSize (still in + private header for the moment) 2003-12-21 Werner Lemberg diff --git a/docs/CHANGES b/docs/CHANGES index 09026b9a4..5e5c1ea9c 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -17,6 +17,13 @@ LATEST CHANGES BETWEEN 2.1.8 and 2.1.7 - The FT_FACE_FLAGS_GLYPH_NAMES is now set correctly for all font formats. + - Some subsetted Type 1 fonts weren't parsed correctly. This bug + has been introduced in 2.1.7. + + - The WinFNT driver now correctly reports FT_ENCODING_NONE for all + but one encoding. Use the new FT_WinFNT_ID_XXX values together + with FT_Get_WinFNT_Header() to get the WinFNT charset ID. + II. IMPORTANT CHANGES diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index de5bf3a43..ace2a048f 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -590,6 +590,37 @@ FT_BEGIN_HEADER /* the font file, for the cases when they are needed, with the Adobe */ /* values as well. */ /* */ + /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ + /* is not Unicode or ISO-8859-1 (otherwise it is set to */ + /* FT_ENCODING_UNICODE). Use `FT_Get_BDF_Charset_ID' to find out */ + /* which encoding is really present. If, for example, the */ + /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ + /* the font is encoded in KOI8-R. */ + /* */ + /* FT_ENCODING_NONE is always set (with a single exception) by the */ + /* winfonts driver. Use `FT_Get_WinFNT_Header' and examine the */ + /* `charset' field of the `FT_WinFNT_HeaderRec' structure to find out */ + /* which encoding is really present. For example, FT_WinFNT_ID_CP1251 */ + /* (204) means Windows code page 1251 (for Russian). */ + /* */ + /* FT_ENCODING_NONE is set if `platform_id' is `TT_PLATFORM_MACINTOSH' */ + /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */ + /* FT_ENCODING_APPLE_ROMAN). */ + /* */ + /* If `platform_id' is `TT_PLATFORM_MACINTOSH', use the function */ + /* `FT_Get_CMap_Language_ID' to query the Mac language ID which may be */ + /* needed to be able to distinguish Apple encoding variants. See */ + /* */ + /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT */ + /* */ + /* to get an idea how to do that. Basically, if the language ID is 0, */ + /* dont use it, otherwise subtract 1 from the language ID. Then */ + /* examine `encoding_id'. If, for example, `encoding_id' is */ + /* `TT_MAC_ID_ROMAN' and the language ID (minus 1) is */ + /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ + /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */ + /* variant the Arabic encoding. */ + /* */ typedef enum FT_Encoding_ { FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), diff --git a/include/freetype/ftwinfnt.h b/include/freetype/ftwinfnt.h index 61234d4ce..9f3e8c5a0 100644 --- a/include/freetype/ftwinfnt.h +++ b/include/freetype/ftwinfnt.h @@ -49,10 +49,131 @@ FT_BEGIN_HEADER /* */ /*************************************************************************/ + + /************************************************************************* + * + * @enum: + * FT_WinFNT_ID_XXX + * + * @description: + * A list of valid values for the `charset' byte in + * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX + * encodings (except for cp1361) can be found at ftp://ftp.unicode.org + * in the MAPPINGS/VENDORS/MICSFT/WINDOWS subdirectory. + * + * @values: + * FT_WinFNT_ID_DEFAULT :: + * This is used for font enumeration and font creation as a + * `don't care' value. Valid font files don't contain this value. + * When querying for information about the character set of the font + * that is currently selected into a specified device context, this + * return value (of the related Windows API) simply denotes failure. + * + * FT_WinFNT_ID_SYMBOL :: + * There is no known mapping table available. + * + * FT_WinFNT_ID_MAC :: + * Mac Roman encoding. + * + * FT_WinFNT_ID_OEM :: + * From Michael Pöttgen : + * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM + * is used for the charset of vector fonts, like `modern.fon', + * `roman.fon', and `script.fon' on Windows. + * + * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value + * specifies a character set that is operating-system dependent. + * + * The `IFIMETRICS' documentation from the `Windows Driver + * Development Kit' says: This font supports an OEM-specific + * character set. The OEM character set is system dependent. + * + * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the + * second default codepage that most international versions of + * Windows have. It is one of the OEM codepages from + * + * http://www.microsoft.com/globaldev/reference/cphome.mspx, + * + * and is used for the `DOS boxes', to support legacy applications. + * A German Windows version for example usually uses ANSI codepage + * 1252 and OEM codepage 850. + * + * FT_WinFNT_ID_CP874 :: + * A superset of Thai TIS 620 and ISO 8859-11. + * + * FT_WinFNT_ID_CP932 :: + * A superset of Japanese Shift-JIS (with minor deviations). + * + * FT_WinFNT_ID_CP936 :: + * A superset of simplified Chinese GB 2312-1980 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP949 :: + * A superset of Korean Hangul KS C 5601-1987 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP950 :: + * A superset of traditional Chinese Big 5 ETen (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP1250 :: + * A superset of East European ISO 8859-2 (with slightly different + * ordering). + * + * FT_WinFNT_ID_CP1251 :: + * A superset of Russian ISO 8859-5 (with different ordering). + * + * FT_WinFNT_ID_CP1252 :: + * ANSI encoding. A superset of ISO 8859-1. + * + * FT_WinFNT_ID_CP1253 :: + * A superset of Greek ISO 8859-7 (with minor modifications). + * + * FT_WinFNT_ID_CP1254 :: + * A superset of Turkish ISO 8859-9. + * + * FT_WinFNT_ID_CP1255 :: + * A superset of Hebrew ISO 8859-8 (with some modifications). + * + * FT_WinFNT_ID_CP1256 :: + * A superset of Arabic ISO 8859-6 (with different ordering). + * + * FT_WinFNT_ID_CP1257 :: + * A superset of Baltic ISO 8859-13 (with some deviations). + * + * FT_WinFNT_ID_CP1258 :: + * For Vietnamese. This encoding doesn't cover all necessary + * characters. + * + * FT_WinFNT_ID_CP1361 :: + * Korean (Johab). + */ + +#define FT_WinFNT_ID_CP1252 0 +#define FT_WinFNT_ID_DEFAULT 1 +#define FT_WinFNT_ID_SYMBOL 2 +#define FT_WinFNT_ID_MAC 77 +#define FT_WinFNT_ID_CP932 128 +#define FT_WinFNT_ID_CP949 129 +#define FT_WinFNT_ID_CP1361 130 +#define FT_WinFNT_ID_CP936 134 +#define FT_WinFNT_ID_CP950 136 +#define FT_WinFNT_ID_CP1253 161 +#define FT_WinFNT_ID_CP1254 162 +#define FT_WinFNT_ID_CP1258 163 +#define FT_WinFNT_ID_CP1255 177 +#define FT_WinFNT_ID_CP1256 178 +#define FT_WinFNT_ID_CP1257 186 +#define FT_WinFNT_ID_CP1251 204 +#define FT_WinFNT_ID_CP874 222 +#define FT_WinFNT_ID_CP1250 238 +#define FT_WinFNT_ID_OEM 255 + + /*************************************************************************/ /* */ /* */ - /* FT_WinFNT_HeaderRec_ */ + /* FT_WinFNT_HeaderRec */ /* */ /* */ /* Windows FNT Header info. */ diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index 5f605fe01..9aaebdd2a 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -476,11 +476,18 @@ FT_CharMapRec charmap; - charmap.encoding = FT_ENCODING_UNICODE; - charmap.platform_id = 3; - charmap.encoding_id = 1; + charmap.encoding = FT_ENCODING_NONE; + charmap.platform_id = 0; + charmap.encoding_id = 0; charmap.face = root; + if ( font->header.charset == FT_WinFNT_ID_MAC ) + { + charmap.encoding = FT_ENCODING_APPLE_ROMAN; + charmap.platform_id = 1; +/* charmap.encoding_id = 0; */ + } + error = FT_CMap_New( fnt_cmap_class, NULL, &charmap,