diff --git a/build/jam/FreetypeRules b/build/jam/FreetypeRules index 1eed2714dc..fcee016945 100644 --- a/build/jam/FreetypeRules +++ b/build/jam/FreetypeRules @@ -8,7 +8,6 @@ FT2_SRC = [ FDirName $(HAIKU_TOP) src libs freetype2 ] ; FT2_LIB = freetype ; FT2_COMPONENTS ?= gzip # support for gzip-compressed files. - autohint # auto-hinter autofit base # base component (public APIs) bdf # BDF font driver @@ -16,7 +15,6 @@ FT2_COMPONENTS ?= gzip # support for gzip-compressed files. cff # CFF/CEF font driver cid # Postscript CID-keyed font driver lzw # LZW routines - otvalid pcf # PCF font driver pfr # PFR/TrueDoc font driver psaux # Common Postscript routines module @@ -65,6 +63,8 @@ rule FT2_Library # The name of the library. # The sources. + DEFINES += FT2_BUILD_LIBRARY ; + local library = lib$(1).so ; local sources = $(2) ; diff --git a/headers/libs/freetype2/freetype/cache/ftccmap.h b/headers/libs/freetype2/freetype/cache/ftccmap.h deleted file mode 100644 index a41989b282..0000000000 --- a/headers/libs/freetype2/freetype/cache/ftccmap.h +++ /dev/null @@ -1,216 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftccmap.h */ -/* */ -/* FreeType charmap cache (specification). */ -/* */ -/* Copyright 2000-2001, 2003 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTCCMAP_H__ -#define __FTCCMAP_H__ - -#include -#include FT_CACHE_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /*
*/ - /* cache_subsystem */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* @type: */ - /* FTC_CMapCache */ - /* */ - /* @description: */ - /* An opaque handle used to manager a charmap cache. This cache is */ - /* to hold character codes -> glyph indices mappings. */ - /* */ - typedef struct FTC_CMapCacheRec_* FTC_CMapCache; - - - /*************************************************************************/ - /* */ - /* @type: */ - /* FTC_CMapDesc */ - /* */ - /* @description: */ - /* A handle to an @FTC_CMapDescRec structure used to describe a given */ - /* charmap in a charmap cache. */ - /* */ - /* Each @FTC_CMapDesc describes which charmap (of which @FTC_FaceID) */ - /* we want to use in @FTC_CMapCache_Lookup. */ - /* */ - typedef struct FTC_CMapDescRec_* FTC_CMapDesc; - - - /*************************************************************************/ - /* */ - /* @enum: */ - /* FTC_CMapType */ - /* */ - /* @description: */ - /* The list of valid @FTC_CMapDesc types. They indicate how we want */ - /* to address a charmap within an @FTC_FaceID. */ - /* */ - /* @values: */ - /* FTC_CMAP_BY_INDEX :: */ - /* Address a charmap by its index in the corresponding @FT_Face. */ - /* */ - /* FTC_CMAP_BY_ENCODING :: */ - /* Use a @FT_Face charmap that corresponds to a given encoding. */ - /* */ - /* FTC_CMAP_BY_ID :: */ - /* Use an @FT_Face charmap that corresponds to a given */ - /* (platform,encoding) ID. See @FTC_CMapIdRec. */ - /* */ - typedef enum FTC_CMapType_ - { - FTC_CMAP_BY_INDEX = 0, - FTC_CMAP_BY_ENCODING = 1, - FTC_CMAP_BY_ID = 2 - - } FTC_CMapType; - - - /*************************************************************************/ - /* */ - /* @struct: */ - /* FTC_CMapIdRec */ - /* */ - /* @description: */ - /* A short structure to identify a charmap by a (platform,encoding) */ - /* pair of values. */ - /* */ - /* @fields: */ - /* platform :: The platform ID. */ - /* */ - /* encoding :: The encoding ID. */ - /* */ - typedef struct FTC_CMapIdRec_ - { - FT_UInt platform; - FT_UInt encoding; - - } FTC_CMapIdRec; - - - /*************************************************************************/ - /* */ - /* @struct: */ - /* FTC_CMapDescRec */ - /* */ - /* @description: */ - /* A structure to describe a given charmap to @FTC_CMapCache. */ - /* */ - /* @fields: */ - /* face_id :: @FTC_FaceID of the face this charmap belongs to. */ - /* */ - /* type :: The type of charmap, see @FTC_CMapType. */ - /* */ - /* u.index :: For @FTC_CMAP_BY_INDEX types, this is the charmap */ - /* index (within a @FT_Face) we want to use. */ - /* */ - /* u.encoding :: For @FTC_CMAP_BY_ENCODING types, this is the charmap */ - /* encoding we want to use. see @FT_Encoding. */ - /* */ - /* u.id :: For @FTC_CMAP_BY_ID types, this is the */ - /* (platform,encoding) pair we want to use. see */ - /* @FTC_CMapIdRec and @FT_CharMapRec. */ - /* */ - typedef struct FTC_CMapDescRec_ - { - FTC_FaceID face_id; - FTC_CMapType type; - - union - { - FT_UInt index; - FT_Encoding encoding; - FTC_CMapIdRec id; - - } u; - - } FTC_CMapDescRec; - - - /*************************************************************************/ - /* */ - /* @function: */ - /* FTC_CMapCache_New */ - /* */ - /* @description: */ - /* Creates a new charmap cache. */ - /* */ - /* @input: */ - /* manager :: A handle to the cache manager. */ - /* */ - /* @output: */ - /* acache :: A new cache handle. NULL in case of error. */ - /* */ - /* @return: */ - /* FreeType error code. 0 means success. */ - /* */ - /* @note: */ - /* Like all other caches, this one will be destroyed with the cache */ - /* manager. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_CMapCache_New( FTC_Manager manager, - FTC_CMapCache *acache ); - - - /*************************************************************************/ - /* */ - /* @function: */ - /* FTC_CMapCache_Lookup */ - /* */ - /* @description: */ - /* Translates a character code into a glyph index, using the charmap */ - /* cache. */ - /* */ - /* @input: */ - /* cache :: A charmap cache handle. */ - /* */ - /* cmap_desc :: A charmap descriptor handle. */ - /* */ - /* char_code :: The character code (in the corresponding charmap). */ - /* */ - /* @return: */ - /* Glyph index. 0 means "no glyph". */ - /* */ - /* @note: */ - /* This function doesn't return @FTC_Node handles, since there is no */ - /* real use for them with typical uses of charmaps. */ - /* */ - FT_EXPORT( FT_UInt ) - FTC_CMapCache_Lookup( FTC_CMapCache cache, - FTC_CMapDesc cmap_desc, - FT_UInt32 char_code ); - - /* */ - - -FT_END_HEADER - - -#endif /* __FTCCMAP_H__ */ - - -/* END */ diff --git a/headers/libs/freetype2/freetype/config/ftconfig.h b/headers/libs/freetype2/freetype/config/ftconfig.h index e878efba18..ef50a0ea1e 100644 --- a/headers/libs/freetype2/freetype/config/ftconfig.h +++ b/headers/libs/freetype2/freetype/config/ftconfig.h @@ -4,7 +4,7 @@ /* */ /* ANSI-specific configuration file (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -201,7 +201,7 @@ FT_BEGIN_HEADER #elif defined( __GNUC__ ) - /* GCC provides the "long long" type */ + /* GCC provides the `long long' type */ #define FT_LONG64 #define FT_INT64 long long int @@ -265,9 +265,9 @@ FT_BEGIN_HEADER #ifndef FT_BASE_DEF #ifdef __cplusplus -#define FT_BASE_DEF( x ) extern "C" x +#define FT_BASE_DEF( x ) x #else -#define FT_BASE_DEF( x ) extern x +#define FT_BASE_DEF( x ) x #endif #endif /* !FT_BASE_DEF */ diff --git a/headers/libs/freetype2/freetype/config/ftheader.h b/headers/libs/freetype2/freetype/config/ftheader.h index a6df10d2ad..7d663d9943 100644 --- a/headers/libs/freetype2/freetype/config/ftheader.h +++ b/headers/libs/freetype2/freetype/config/ftheader.h @@ -4,7 +4,7 @@ /* */ /* Build macros of the FreeType 2 library. */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -96,58 +96,62 @@ /* configuration files */ - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CONFIG_CONFIG_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* FreeType 2 configuration data. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CONFIG_CONFIG_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType 2 configuration data. + * + */ #ifndef FT_CONFIG_CONFIG_H #define FT_CONFIG_CONFIG_H #endif - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CONFIG_STANDARD_LIBRARY_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* FreeType 2 configuration data. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CONFIG_STANDARD_LIBRARY_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType 2 interface to the standard C library functions. + * + */ #ifndef FT_CONFIG_STANDARD_LIBRARY_H #define FT_CONFIG_STANDARD_LIBRARY_H #endif - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CONFIG_OPTIONS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* FreeType 2 project-specific configuration options. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CONFIG_OPTIONS_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType 2 project-specific configuration options. + * + */ #ifndef FT_CONFIG_OPTIONS_H #define FT_CONFIG_OPTIONS_H #endif - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CONFIG_MODULES_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the list of FreeType 2 modules that are statically linked to new */ - /* library instances in @FT_Init_FreeType. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CONFIG_MODULES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType 2 modules that are statically linked to new library + * instances in @FT_Init_FreeType. + * + */ #ifndef FT_CONFIG_MODULES_H #define FT_CONFIG_MODULES_H #endif @@ -155,436 +159,543 @@ /* public headers */ - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_FREETYPE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the base FreeType 2 API. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_FREETYPE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * base FreeType 2 API. + * + */ #define FT_FREETYPE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_ERRORS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the list of FreeType 2 error codes (and messages). */ - /* */ - /* It is included by @FT_FREETYPE_H. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_ERRORS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType 2 error codes (and messages). + * + * It is included by @FT_FREETYPE_H. + * + */ #define FT_ERRORS_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_MODULE_ERRORS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the list of FreeType 2 module error offsets (and messages). */ - /* */ + /************************************************************************* + * + * @macro: + * FT_MODULE_ERRORS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType 2 module error offsets (and messages). + * + */ #define FT_MODULE_ERRORS_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_SYSTEM_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the FreeType 2 interface to low-level operations (i.e. memory */ - /* management and stream i/o). */ - /* */ - /* It is included by @FT_FREETYPE_H. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_SYSTEM_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 interface to low-level operations (i.e., memory management + * and stream i/o). + * + * It is included by @FT_FREETYPE_H. + * + */ #define FT_SYSTEM_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_IMAGE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* types definitions related to glyph images (i.e. bitmaps, outlines, */ - /* scan-converter parameters). */ - /* */ - /* It is included by @FT_FREETYPE_H. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_IMAGE_H + * + * @description: + * A macro used in #include statements to name the file containing types + * definitions related to glyph images (i.e., bitmaps, outlines, + * scan-converter parameters). + * + * It is included by @FT_FREETYPE_H. + * + */ #define FT_IMAGE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_TYPES_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the basic data types defined by FreeType 2. */ - /* */ - /* It is included by @FT_FREETYPE_H. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_TYPES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * basic data types defined by FreeType 2. + * + * It is included by @FT_FREETYPE_H. + * + */ #define FT_TYPES_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_LIST_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the list management API of FreeType 2. */ - /* */ - /* (Most applications will never need to include this file.) */ - /* */ + /************************************************************************* + * + * @macro: + * FT_LIST_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list management API of FreeType 2. + * + * (Most applications will never need to include this file.) + * + */ #define FT_LIST_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_OUTLINE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the scalable outline management API of FreeType 2. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_OUTLINE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * scalable outline management API of FreeType 2. + * + */ #define FT_OUTLINE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_SIZES_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the API used to manage multiple @FT_Size objects per face. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_SIZES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API used to manage multiple @FT_Size objects per face. + * + */ #define FT_SIZES_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_MODULE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the module management API of FreeType 2. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_MODULE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * module management API of FreeType 2. + * + */ #define FT_MODULE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_RENDER_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the renderer module management API of FreeType 2. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_RENDER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * renderer module management API of FreeType 2. + * + */ #define FT_RENDER_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_TYPE1_TABLES_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the types and API specific to the Type 1 format. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_TYPE1_TABLES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * types and API specific to the Type 1 format. + * + */ #define FT_TYPE1_TABLES_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_TRUETYPE_IDS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the enumeration values used to identify name strings, languages, */ - /* encodings, etc. This file really contains a _large_ set of */ - /* constant macro definitions, taken from the TrueType and OpenType */ - /* specifications. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_IDS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * enumeration values used to identify name strings, languages, + * encodings, etc. This file really contains a _large_ set of constant + * macro definitions, taken from the TrueType and OpenType + * specifications. + * + */ #define FT_TRUETYPE_IDS_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_TRUETYPE_TABLES_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the types and API specific to the TrueType (as well as OpenType) */ - /* format. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_TABLES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * types and API specific to the TrueType (as well as OpenType) format. + * + */ #define FT_TRUETYPE_TABLES_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_TRUETYPE_TAGS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the definitions of TrueType 4-byte `tags' used to identify blocks */ - /* in SFNT-based font formats (i.e. TrueType and OpenType). */ - /* */ + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_TAGS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of TrueType four-byte `tags' used to identify blocks in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ #define FT_TRUETYPE_TAGS_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_BDF_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the definitions of an API to access BDF-specific strings from a */ - /* face. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_BDF_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API to access BDF-specific strings from a face. + * + */ #define FT_BDF_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_GZIP_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the definitions of an API to support for gzip-compressed files. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_GZIP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API to support for gzip-compressed files. + * + */ #define FT_GZIP_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_LZW_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the definitions of an API to support for LZW-compressed files. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_LZW_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API to support for LZW-compressed files. + * + */ #define FT_LZW_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_WINFONTS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the definitions of an API to support Windows .FNT files */ - /* */ + /************************************************************************* + * + * @macro: + * FT_WINFONTS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API to support Windows FNT files. + * + */ #define FT_WINFONTS_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_GLYPH_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the API of the optional glyph management component. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_GLYPH_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional glyph management component. + * + */ #define FT_GLYPH_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_BITMAP_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the API of the optional bitmap conversion component. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_BITMAP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional bitmap conversion component. + * + */ #define FT_BITMAP_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_BBOX_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the API of the optional exact bounding box computation routines. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_BBOX_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional exact bounding box computation routines. + * + */ #define FT_BBOX_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CACHE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the API of the optional FreeType 2 cache sub-system. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CACHE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional FreeType 2 cache sub-system. + * + */ #define FT_CACHE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CACHE_IMAGE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the `glyph image' API of the FreeType 2 cache sub-system. */ - /* */ - /* It is used to define a cache for @FT_Glyph elements. You can also */ - /* see the API defined in @FT_CACHE_SMALL_BITMAPS_H if you only need */ - /* to store small glyph bitmaps, as it will use less memory. */ - /* */ - /* This macro is deprecated. Simply include @FT_CACHE_H to have all */ - /* glyph image-related cache declarations. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CACHE_IMAGE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * `glyph image' API of the FreeType 2 cache sub-system. + * + * It is used to define a cache for @FT_Glyph elements. You can also + * see the API defined in @FT_CACHE_SMALL_BITMAPS_H if you only need to + * store small glyph bitmaps, as it will use less memory. + * + * This macro is deprecated. Simply include @FT_CACHE_H to have all + * glyph image-related cache declarations. + * + */ #define FT_CACHE_IMAGE_H FT_CACHE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CACHE_SMALL_BITMAPS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the `small bitmaps' API of the FreeType 2 cache sub-system. */ - /* */ - /* It is used to define a cache for small glyph bitmaps in a */ - /* relatively memory-efficient way. You can also use the API defined */ - /* in @FT_CACHE_IMAGE_H if you want to cache arbitrary glyph images, */ - /* including scalable outlines. */ - /* */ - /* This macro is deprecated. Simply include @FT_CACHE_H to have all */ - /* small bitmaps-related cache declarations. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_CACHE_SMALL_BITMAPS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * `small bitmaps' API of the FreeType 2 cache sub-system. + * + * It is used to define a cache for small glyph bitmaps in a relatively + * memory-efficient way. You can also use the API defined in + * @FT_CACHE_IMAGE_H if you want to cache arbitrary glyph images, + * including scalable outlines. + * + * This macro is deprecated. Simply include @FT_CACHE_H to have all + * small bitmaps-related cache declarations. + * + */ #define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_CACHE_CHARMAP_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the `charmap' API of the FreeType 2 cache sub-system. */ - /* */ - /* This macro is deprecated. Simply include @FT_CACHE_H to have all */ - /* charmap-based cache declarations. */ - /* */ -#define FT_CACHE_CHARMAP_H FT_CACHE_H + /************************************************************************* + * + * @macro: + * FT_CACHE_CHARMAP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * `charmap' API of the FreeType 2 cache sub-system. + * + * This macro is deprecated. Simply include @FT_CACHE_H to have all + * charmap-based cache declarations. + * + */ +#define FT_CACHE_CHARMAP_H FT_CACHE_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_MAC_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the Macintosh-specific FreeType 2 API. The latter is used to */ - /* access fonts embedded in resource forks. */ - /* */ - /* This header file must be explicitly included by client */ - /* applications compiled on the Mac (note that the base API still */ - /* works though). */ - /* */ + /************************************************************************* + * + * @macro: + * FT_MAC_H + * + * @description: + * A macro used in #include statements to name the file containing the + * Macintosh-specific FreeType 2 API. The latter is used to access + * fonts embedded in resource forks. + * + * This header file must be explicitly included by client applications + * compiled on the Mac (note that the base API still works though). + * + */ #define FT_MAC_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_MULTIPLE_MASTERS_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the optional multiple-masters management API of FreeType 2. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_MULTIPLE_MASTERS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional multiple-masters management API of FreeType 2. + * + */ #define FT_MULTIPLE_MASTERS_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_SFNT_NAMES_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the optional FreeType 2 API used to access embedded `name' strings */ - /* in SFNT-based font formats (i.e. TrueType and OpenType). */ - /* */ + /************************************************************************* + * + * @macro: + * FT_SFNT_NAMES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType 2 API used to access embedded `name' strings in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ #define FT_SFNT_NAMES_H - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_OPENTYPE_VALIDATE_H */ - /* */ - /* @description: */ - /* A macro used in #include statements to name the file containing */ - /* the optional FreeType 2 API used to validate OpenType tables */ - /* (BASE, GDEF, GPOS, GSUB, JSTF). */ - /* */ + /************************************************************************* + * + * @macro: + * FT_OPENTYPE_VALIDATE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType 2 API used to validate OpenType tables (BASE, GDEF, + * GPOS, GSUB, JSTF). + * + */ #define FT_OPENTYPE_VALIDATE_H + /************************************************************************* + * + * @macro: + * FT_GX_VALIDATE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType 2 API used to validate TrueTypeGX/AAT tables (feat, + * mort, morx, bsln, just, kern, opbd, trak, prop). + * + */ +#define FT_GX_VALIDATE_H + + + /************************************************************************* + * + * @macro: + * FT_PFR_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 API used to access PFR-specific data. + * + */ +#define FT_PFR_H + + + /************************************************************************* + * + * @macro: + * FT_STROKER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 API used to stroke outline path. + */ +#define FT_STROKER_H + + + /************************************************************************* + * + * @macro: + * FT_SYNTHESIS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 API used to perform artificial obliquing and emboldening. + */ +#define FT_SYNTHESIS_H + + + /************************************************************************* + * + * @macro: + * FT_XFREE86_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 API used to provide functions specific to the XFree86 and + * X.Org X11 servers. + */ +#define FT_XFREE86_H + + + /************************************************************************* + * + * @macro: + * FT_TRIGONOMETRY_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 API used to perform trigonometric computations (e.g., + * cosines and arc tangents). + */ +#define FT_TRIGONOMETRY_H + /* */ -#define FT_TRIGONOMETRY_H -#define FT_STROKER_H -#define FT_SYNTHESIS_H #define FT_ERROR_DEFINITIONS_H -#define FT_CACHE_MANAGER_H -#define FT_CACHE_INTERNAL_MRU_H -#define FT_CACHE_INTERNAL_MANAGER_H -#define FT_CACHE_INTERNAL_CACHE_H -#define FT_CACHE_INTERNAL_GLYPH_H -#define FT_CACHE_INTERNAL_IMAGE_H -#define FT_CACHE_INTERNAL_SBITS_H + /* The internals of the cache sub-system are no longer exposed. We */ + /* default to FT_CACHE_H at the moment just in case, but we know of */ + /* no rogue client that uses them. */ + /* */ +#define FT_CACHE_MANAGER_H +#define FT_CACHE_INTERNAL_MRU_H +#define FT_CACHE_INTERNAL_MANAGER_H +#define FT_CACHE_INTERNAL_CACHE_H +#define FT_CACHE_INTERNAL_GLYPH_H +#define FT_CACHE_INTERNAL_IMAGE_H +#define FT_CACHE_INTERNAL_SBITS_H -#define FT_XFREE86_H - #define FT_INCREMENTAL_H #define FT_TRUETYPE_UNPATENTED_H - /* now include internal headers definitions from */ + /* + * Include internal headers definitions from + * only when building the library. + */ +#ifdef FT2_BUILD_LIBRARY #define FT_INTERNAL_INTERNAL_H #include FT_INTERNAL_INTERNAL_H +#endif /* FT2_BUILD_LIBRARY */ #endif /* __FT2_BUILD_H__ */ diff --git a/headers/libs/freetype2/freetype/config/ftmodule.h b/headers/libs/freetype2/freetype/config/ftmodule.h index b8f67bb048..d92b0ee6a1 100644 --- a/headers/libs/freetype2/freetype/config/ftmodule.h +++ b/headers/libs/freetype2/freetype/config/ftmodule.h @@ -1,3 +1,15 @@ +/* + * This file registers the FreeType modules compiled into the library. + * + * If you use GNU make, this file IS NOT USED! Instead, it is created in + * the objects directory (normally `/objs/') based on information + * from `/modules.cfg'. + * + * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile + * FreeType without GNU make. + * + */ + FT_USE_MODULE(autofit_module_class) FT_USE_MODULE(tt_driver_class) FT_USE_MODULE(t1_driver_class) @@ -15,5 +27,6 @@ FT_USE_MODULE(sfnt_module_class) FT_USE_MODULE(ft_smooth_renderer_class) FT_USE_MODULE(ft_smooth_lcd_renderer_class) FT_USE_MODULE(ft_smooth_lcdv_renderer_class) -FT_USE_MODULE(otv_module_class) FT_USE_MODULE(bdf_driver_class) + +/* EOF */ diff --git a/headers/libs/freetype2/freetype/config/ftoption.h b/headers/libs/freetype2/freetype/config/ftoption.h index e6f34b4310..8a2a79f956 100644 --- a/headers/libs/freetype2/freetype/config/ftoption.h +++ b/headers/libs/freetype2/freetype/config/ftoption.h @@ -4,7 +4,7 @@ /* */ /* User-selectable configuration macros (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -38,22 +38,22 @@ FT_BEGIN_HEADER /* library from a single source directory. */ /* */ /* - You can put a copy of this file in your build directory, more */ - /* precisely in "$BUILD/freetype/config/ftoption.h", where "$BUILD" */ + /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ /* is the name of a directory that is included _before_ the FreeType */ /* include path during compilation. */ /* */ /* The default FreeType Makefiles and Jamfiles use the build */ - /* directory "builds/" by default, but you can easily change */ + /* directory `builds/' by default, but you can easily change */ /* that for your own projects. */ /* */ - /* - Copy the file to "$BUILD/ft2build.h" and modify it */ + /* - Copy the file to `$BUILD/ft2build.h' and modify it */ /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ /* locate this file during the build. For example, */ /* */ /* #define FT_CONFIG_OPTIONS_H */ /* #include */ /* */ - /* will use "$BUILD/myftoptions.h" instead of this file for macro */ + /* will use `$BUILD/myftoptions.h' instead of this file for macro */ /* definitions. */ /* */ /* Note also that you can similarly pre-define the macro */ @@ -89,7 +89,7 @@ FT_BEGIN_HEADER /* building the library. */ /* */ /* ObNote: The compiler-specific 64-bit integers are detected in the */ - /* file "ftconfig.h" either statically or through the */ + /* file `ftconfig.h' either statically or through the */ /* `configure' script on supported platforms. */ /* */ #undef FT_CONFIG_OPTION_FORCE_INT64 @@ -100,7 +100,7 @@ FT_BEGIN_HEADER /* LZW-compressed file support. */ /* */ /* FreeType now handles font files that have been compressed with the */ - /* 'compress' program. This is mostly used to parse many of the PCF */ + /* `compress' program. This is mostly used to parse many of the PCF */ /* files that come with various X11 distributions. The implementation */ /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ /* (see src/lzw/ftgzip.c). */ @@ -115,7 +115,7 @@ FT_BEGIN_HEADER /* Gzip-compressed file support. */ /* */ /* FreeType now handles font files that have been compressed with the */ - /* 'gzip' program. This is mostly used to parse many of the PCF files */ + /* `gzip' program. This is mostly used to parse many of the PCF files */ /* that come with XFree86. The implementation uses `zlib' to */ /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ /* */ @@ -328,7 +328,7 @@ FT_BEGIN_HEADER /* should define FT_DEBUG_MEMORY here. */ /* */ /* Note that the memory debugger is only activated at runtime when */ - /* when the _environment_ variable "FT2_DEBUG_MEMORY" is defined also! */ + /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ /* */ /* Do not #undef this macro here since the build system might define */ /* it for certain configurations only. */ @@ -471,7 +471,7 @@ FT_BEGIN_HEADER /* component offsets in composite glyphs. */ /* */ /* Apple and MS disagree on the default behavior of component offsets */ - /* in composites. Apple says that they should be scaled by the scale */ + /* in composites. Apple says that they should be scaled by the scaling */ /* factors in the transformation matrix (roughly, it's more complex) */ /* while MS says they should not. OpenType defines two bits in the */ /* composite flags array which can be used to disambiguate, but old */ @@ -493,6 +493,14 @@ FT_BEGIN_HEADER #define TT_CONFIG_OPTION_GX_VAR_SUPPORT + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ + /* an embedded `BDF ' table within SFNT-based bitmap formats. */ + /* */ +#define TT_CONFIG_OPTION_BDF + + /*************************************************************************/ /*************************************************************************/ /**** ****/ @@ -547,14 +555,44 @@ FT_BEGIN_HEADER /* */ #undef T1_CONFIG_OPTION_NO_MM_SUPPORT + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Compile autofit module with CJK script support. */ + /* */ +#define AF_CONFIG_OPTION_CJK + + /* */ -/* - * This temporary macro is used to control various optimizations for - * reducing the heap footprint of memory-mapped TrueType files. - * - */ -/* #define FT_OPTIMIZE_MEMORY */ + /* + * This temporary macro is used to control various optimizations for + * reducing the heap footprint of memory-mapped TrueType files. + */ +#define FT_OPTIMIZE_MEMORY + + + /* + * Define this variable if you want to keep the layout of internal + * structures that was used prior to FreeType 2.2. This also compiles in + * a few obsolete functions to avoid linking problems on typical Unix + * distributions. + * + * For embedded systems or building a new distribution from scratch, it + * is recommended to disable the macro since it reduces the library's code + * size and activates a few memory-saving optimizations as well. + */ +#define FT_CONFIG_OPTION_OLD_INTERNALS + FT_END_HEADER diff --git a/headers/libs/freetype2/freetype/config/ftstdlib.h b/headers/libs/freetype2/freetype/config/ftstdlib.h index 4b9b398b25..aaba8b3b1b 100644 --- a/headers/libs/freetype2/freetype/config/ftstdlib.h +++ b/headers/libs/freetype2/freetype/config/ftstdlib.h @@ -5,7 +5,7 @@ /* ANSI-specific library and header configuration file (specification */ /* only). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -51,22 +51,23 @@ /* old Crays where `int' is 36 bits), we do not make any guarantee */ /* about the correct behaviour of FT2 with all fonts. */ /* */ - /* In these case, "ftconfig.h" will refuse to compile anyway with a */ - /* message like "couldn't find 32-bit type" or something similar. */ + /* In these case, `ftconfig.h' will refuse to compile anyway with a */ + /* message like `couldn't find 32-bit type' or something similar. */ /* */ /* IMPORTANT NOTE: We do not define aliases for heap management and */ /* i/o routines (i.e. malloc/free/fopen/fread/...) */ /* since these functions should all be encapsulated */ /* by platform-specific implementations of */ - /* "ftsystem.c". */ + /* `ftsystem.c'. */ /* */ /**********************************************************************/ #include -#define FT_UINT_MAX UINT_MAX +#define FT_CHAR_BIT CHAR_BIT #define FT_INT_MAX INT_MAX +#define FT_UINT_MAX UINT_MAX #define FT_ULONG_MAX ULONG_MAX @@ -80,14 +81,15 @@ #include #define ft_isalnum isalnum -#define ft_isupper isupper -#define ft_islower islower #define ft_isdigit isdigit +#define ft_islower islower +#define ft_isupper isupper #define ft_isxdigit isxdigit #include +#define ft_memchr memchr #define ft_memcmp memcmp #define ft_memcpy memcpy #define ft_memmove memmove @@ -101,8 +103,21 @@ #define ft_strrchr strrchr + /**********************************************************************/ + /* */ + /* file handling */ + /* */ + /**********************************************************************/ + + #include +#define FT_FILE FILE +#define ft_fclose fclose +#define ft_fopen fopen +#define ft_fread fread +#define ft_fseek fseek +#define ft_ftell ftell #define ft_sprintf sprintf @@ -116,9 +131,32 @@ #include #define ft_qsort qsort + #define ft_exit exit /* only used to exit from unhandled exceptions */ + + /**********************************************************************/ + /* */ + /* memory allocation */ + /* */ + /**********************************************************************/ + + +#define ft_scalloc calloc +#define ft_sfree free +#define ft_smalloc malloc +#define ft_srealloc realloc + + + /**********************************************************************/ + /* */ + /* miscellaneous */ + /* */ + /**********************************************************************/ + + #define ft_atol atol +#define ft_labs labs /**********************************************************************/ @@ -134,13 +172,13 @@ /* jmp_buf is defined as a macro */ /* on certain platforms */ +#define ft_longjmp longjmp /* likewise */ #define ft_setjmp setjmp /* same thing here */ -#define ft_longjmp longjmp /* " */ - /* the following is only used for debugging purposes, i.e. when */ - /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ - /* */ + /* the following is only used for debugging purposes, i.e., if */ + /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ + #include diff --git a/headers/libs/freetype2/freetype/freetype.h b/headers/libs/freetype2/freetype/freetype.h index 7b2a96c385..8f5755d63c 100644 --- a/headers/libs/freetype2/freetype/freetype.h +++ b/headers/libs/freetype2/freetype/freetype.h @@ -4,7 +4,7 @@ /* */ /* FreeType high-level API and common types (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,26 +25,16 @@ #endif -#ifndef __FREETYPE_H__ -#define __FREETYPE_H__ - - /*************************************************************************/ /* */ /* The `raster' component duplicates some of the declarations in */ /* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */ /* */ - - /*************************************************************************/ - /* */ - /* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */ - /* new FreeType design, which is able to host several kinds of font */ - /* drivers. It starts at 2.0. */ - /* */ -#define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 1 -#define FREETYPE_PATCH 10 + + +#ifndef __FREETYPE_H__ +#define __FREETYPE_H__ #include @@ -56,6 +46,28 @@ FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /*
*/ + /* user_allocation */ + /* */ + /* */ + /* User allocation */ + /* */ + /* <Abstract> */ + /* How client applications should allocate FreeType data structures. */ + /* */ + /* <Description> */ + /* FreeType assumes that structures allocated by the user and passed */ + /* as arguments are zeroed out except for the actual data. With */ + /* other words, it is recommended to use `calloc' (or variants of it) */ + /* instead of `malloc' for allocation. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ /*************************************************************************/ /* */ @@ -100,6 +112,7 @@ FT_BEGIN_HEADER /* FT_FACE_FLAG_GLYPH_NAMES */ /* FT_FACE_FLAG_EXTERNAL_STREAM */ /* FT_FACE_FLAG_FAST_GLYPHS */ + /* FT_FACE_FLAG_HINTER */ /* */ /* FT_STYLE_FLAG_BOLD */ /* FT_STYLE_FLAG_ITALIC */ @@ -115,7 +128,6 @@ FT_BEGIN_HEADER /* */ /* FT_Init_FreeType */ /* FT_Done_FreeType */ - /* FT_Library_Version */ /* */ /* FT_New_Face */ /* FT_Done_Face */ @@ -128,6 +140,10 @@ FT_BEGIN_HEADER /* */ /* FT_Set_Char_Size */ /* FT_Set_Pixel_Sizes */ + /* FT_Request_Size */ + /* FT_Select_Size */ + /* FT_Size_Request_Type */ + /* FT_Size_Request */ /* FT_Set_Transform */ /* FT_Load_Glyph */ /* FT_Get_Char_Index */ @@ -166,6 +182,7 @@ FT_BEGIN_HEADER /* FT_Render_Mode */ /* FT_Get_Kerning */ /* FT_Kerning_Mode */ + /* FT_Get_Track_Kerning */ /* FT_Get_Glyph_Name */ /* FT_Get_Postscript_Name */ /* */ @@ -185,8 +202,8 @@ FT_BEGIN_HEADER /* <Description> */ /* A structure used to model the metrics of a single glyph. The */ /* values are expressed in 26.6 fractional pixel format; if the flag */ - /* FT_LOAD_NO_SCALE is used, values are returned in font units */ - /* instead. */ + /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ + /* are expressed in font units instead. */ /* */ /* <Fields> */ /* width :: */ @@ -235,47 +252,32 @@ FT_BEGIN_HEADER /* FT_Bitmap_Size */ /* */ /* <Description> */ - /* This structure models the size of a bitmap strike (i.e., a bitmap */ - /* instance of the font for a given resolution) in a fixed-size font */ - /* face. It is used for the `available_sizes' field of the */ - /* @FT_FaceRec structure. */ + /* This structure models the metrics of a bitmap strike (i.e., a set */ + /* of glyphs for a given point size and resolution) in a bitmap font. */ + /* It is used for the `available_sizes' field of @FT_Face. */ /* */ /* <Fields> */ - /* height :: The (vertical) baseline-to-baseline distance in pixels. */ - /* It makes most sense to define the height of a bitmap */ - /* font in this way. */ + /* height :: The vertical distance, in pixels, between two */ + /* consecutive baselines. It is always positive. */ /* */ - /* width :: The average width of the font (in pixels). Since the */ - /* algorithms to compute this value are different for the */ - /* various bitmap formats, it can only give an additional */ - /* hint if the `height' value isn't sufficient to select */ - /* the proper font. For monospaced fonts the average width */ - /* is the same as the maximum width. */ + /* width :: The average width, in pixels, of all glyphs in the */ + /* strike. */ /* */ - /* size :: The point size in 26.6 fractional format this font shall */ - /* represent (for a given vertical resolution). */ + /* size :: The nominal size of the strike in 26.6 fractional */ + /* points. This field is not very useful. */ /* */ - /* x_ppem :: The horizontal ppem value (in 26.6 fractional format). */ + /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ + /* pixels. */ /* */ - /* y_ppem :: The vertical ppem value (in 26.6 fractional format). */ - /* Usually, this is the `nominal' pixel height of the font. */ + /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ + /* pixels. */ /* */ /* <Note> */ - /* The values in this structure are taken from the bitmap font. If */ - /* the font doesn't provide a parameter it is set to zero to indicate */ - /* that the information is not available. */ - /* */ - /* The following formula converts from dpi to ppem: */ - /* */ - /* ppem = size * dpi / 72 */ - /* */ - /* where `size' is in points. */ - /* */ /* Windows FNT: */ - /* The `size' parameter is not reliable: There exist fonts (e.g., */ - /* app850.fon) which have a wrong size for some subfonts; x_ppem */ - /* and y_ppem are thus set equal to pixel width and height given in */ - /* in the Windows FNT header. */ + /* The nominal size given in a FNT font is not reliable. Thus when */ + /* the driver finds it incorrect, it sets `size' to some calculated */ + /* values and sets `x_ppem' and `y_ppem' to the pixel width and */ + /* height given in the font, respectively. */ /* */ /* TrueType embedded bitmaps: */ /* `size', `width', and `height' values are not contained in the */ @@ -316,6 +318,9 @@ FT_BEGIN_HEADER /* It also embeds a memory manager (see @FT_Memory), as well as a */ /* scan-line converter object (see @FT_Raster). */ /* */ + /* For multi-threading applications each thread should have its own */ + /* FT_Library object. */ + /* */ /* <Note> */ /* Library objects are normally created by @FT_Init_FreeType, and */ /* destroyed with @FT_Done_FreeType. */ @@ -393,21 +398,26 @@ FT_BEGIN_HEADER /* FT_Size */ /* */ /* <Description> */ - /* A handle to a given size object. Such an object models the data */ - /* that depends on the current _resolution_ and _character size_ in a */ - /* given @FT_Face. */ + /* A handle to an object used to model a face scaled to a given */ + /* character size. */ /* */ /* <Note> */ - /* Each face object owns one or more sizes. There is however a */ - /* single _active_ size for the face at any time that will be used by */ - /* functions like @FT_Load_Glyph, @FT_Get_Kerning, etc. */ + /* Each @FT_Face has an _active_ @FT_Size object that is used by */ + /* functions like @FT_Load_Glyph to determine the scaling */ + /* transformation which is used to load and hint glyphs and metrics. */ /* */ - /* You can use the @FT_Activate_Size API to change the current */ - /* active size of any given face. */ + /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ + /* @FT_Request_Size or even @FT_Select_Size to change the content */ + /* (i.e., the scaling values) of the active @FT_Size. */ + /* */ + /* You can use @FT_New_Size to create additional size objects for a */ + /* given @FT_Face, but they won't be used by other functions until */ + /* you activate it through @FT_Activate_Size. Only one size can be */ + /* activated at any given time per face. */ /* */ /* <Also> */ /* The @FT_SizeRec structure details the publicly accessible fields */ - /* of a given face object. */ + /* of a given size object. */ /* */ typedef struct FT_SizeRec_* FT_Size; @@ -424,7 +434,7 @@ FT_BEGIN_HEADER /* */ /* In other words, each time you call @FT_Load_Glyph or */ /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ - /* i.e. the glyph's metrics, its image (bitmap or outline), and */ + /* i.e., the glyph's metrics, its image (bitmap or outline), and */ /* other control information. */ /* */ /* <Also> */ @@ -445,12 +455,12 @@ FT_BEGIN_HEADER /* font. */ /* */ /* Each face object owns zero or more charmaps, but only one of them */ - /* can be "active" and used by @FT_Get_Char_Index or @FT_Load_Char. */ + /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */ /* */ /* The list of available charmaps in a face is available through the */ - /* "face->num_charmaps" and "face->charmaps" fields of @FT_FaceRec. */ + /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ /* */ - /* The currently active charmap is available as "face->charmap". */ + /* The currently active charmap is available as `face->charmap'. */ /* You should call @FT_Set_Charmap to change it. */ /* */ /* <Note> */ @@ -471,15 +481,17 @@ FT_BEGIN_HEADER /* FT_ENC_TAG */ /* */ /* <Description> */ - /* This macro converts four letter tags into an unsigned long. It is */ - /* used to define "encoding" identifiers (see @FT_Encoding). */ + /* This macro converts four-letter tags into an unsigned long. It is */ + /* used to define `encoding' identifiers (see @FT_Encoding). */ /* */ /* <Note> */ /* Since many 16bit compilers don't like 32bit enumerations, you */ /* should redefine this macro in case of problems to something like */ /* this: */ /* */ + /* { */ /* #define FT_ENC_TAG( value, a, b, c, d ) value */ + /* } */ /* */ /* to get a simple enumeration without assigning special numbers. */ /* */ @@ -500,17 +512,17 @@ FT_BEGIN_HEADER /* FT_Encoding */ /* */ /* <Description> */ - /* An enumeration used to specify encodings supported by charmaps. */ - /* Used in the @FT_Select_Charmap API function. */ + /* An enumeration used to specify character sets supported by */ + /* charmaps. Used in the @FT_Select_Charmap API function. */ /* */ /* <Note> */ + /* Despite the name, this enumeration lists specific character */ + /* repertories (i.e., charsets), and not text encoding methods (e.g., */ + /* UTF-8, UTF-16, GB2312_EUC, etc.). */ + /* */ /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */ /* all character codes must be expressed as FT_Longs. */ /* */ - /* The values of this type correspond to specific character */ - /* repertories (i.e. charsets), and not to text encoding methods */ - /* (like UTF-8, UTF-16, GB2312_EUC, etc.). */ - /* */ /* Other encodings might be defined in the future. */ /* */ /* <Values> */ @@ -596,29 +608,30 @@ FT_BEGIN_HEADER /* <Note> */ /* By default, FreeType automatically synthetizes a Unicode charmap */ /* for Postscript fonts, using their glyph names dictionaries. */ - /* However, it will also report the encodings defined explicitly in */ - /* the font file, for the cases when they are needed, with the Adobe */ + /* However, it also reports the encodings defined explicitly in 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 neither Unicode nor 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_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). */ + /* 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_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 */ + /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function c */ + /* @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 */ @@ -626,9 +639,9 @@ FT_BEGIN_HEADER /* 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_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 */ + /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */ /* variant the Arabic encoding. */ /* */ typedef enum FT_Encoding_ @@ -672,24 +685,6 @@ FT_BEGIN_HEADER /* These constants are deprecated; use the corresponding @FT_Encoding */ /* values instead. */ /* */ - /* <Values> */ - /* ft_encoding_none :: see @FT_ENCODING_NONE */ - /* ft_encoding_unicode :: see @FT_ENCODING_UNICODE */ - /* ft_encoding_latin_2 :: see @FT_ENCODING_OLD_LATIN_2 */ - /* ft_encoding_symbol :: see @FT_ENCODING_MS_SYMBOL */ - /* ft_encoding_sjis :: see @FT_ENCODING_SJIS */ - /* ft_encoding_gb2312 :: see @FT_ENCODING_GB2312 */ - /* ft_encoding_big5 :: see @FT_ENCODING_BIG5 */ - /* ft_encoding_wansung :: see @FT_ENCODING_WANSUNG */ - /* ft_encoding_johab :: see @FT_ENCODING_JOHAB */ - /* */ - /* ft_encoding_adobe_standard :: see @FT_ENCODING_ADOBE_STANDARD */ - /* ft_encoding_adobe_expert :: see @FT_ENCODING_ADOBE_EXPERT */ - /* ft_encoding_adobe_custom :: see @FT_ENCODING_ADOBE_CUSTOM */ - /* ft_encoding_latin_1 :: see @FT_ENCODING_ADOBE_LATIN_1 */ - /* */ - /* ft_encoding_apple_roman :: see @FT_ENCODING_APPLE_ROMAN */ - /* */ #define ft_encoding_none FT_ENCODING_NONE #define ft_encoding_unicode FT_ENCODING_UNICODE #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL @@ -755,7 +750,7 @@ FT_BEGIN_HEADER /* FT_Face_Internal */ /* */ /* <Description> */ - /* An opaque handle to an FT_Face_InternalRec structure, used to */ + /* An opaque handle to an `FT_Face_InternalRec' structure, used to */ /* model private data of a given @FT_Face object. */ /* */ /* This structure might change between releases of FreeType 2 and is */ @@ -770,33 +765,30 @@ FT_BEGIN_HEADER /* FT_FaceRec */ /* */ /* <Description> */ - /* FreeType root face class structure. A face object models the */ - /* resolution and point-size independent data found in a font file. */ + /* FreeType root face class structure. A face object models a */ + /* typeface in a font file. */ /* */ /* <Fields> */ - /* num_faces :: In the case where the face is located in a */ - /* collection (i.e., a file which embeds */ - /* several faces), this is the total number of */ - /* faces found in the resource. 1 by default. */ - /* Accessing non-existent face indices causes */ - /* an error. */ + /* num_faces :: The number of faces in the font file. Some */ + /* font formats can have multiple faces in */ + /* a font file. */ /* */ - /* face_index :: The index of the face in its font file. */ - /* Usually, this is 0 for all normal font */ - /* formats. It can be > 0 in the case of */ - /* collections (which embed several fonts in a */ - /* single resource/file). */ + /* face_index :: The index of the face in the font file. It */ + /* is set to 0 if there is only one face in */ + /* the font file. */ /* */ /* face_flags :: A set of bit flags that give important */ - /* information about the face; see the */ - /* @FT_FACE_FLAG_XXX constants for details. */ + /* information about the face; see */ + /* @FT_FACE_FLAG_XXX for the details. */ /* */ /* style_flags :: A set of bit flags indicating the style of */ - /* the face (i.e., italic, bold, underline, */ - /* etc). See the @FT_STYLE_FLAG_XXX */ - /* constants. */ + /* the face; see @FT_STYLE_FLAG_XXX for the */ + /* details. */ /* */ - /* num_glyphs :: The total number of glyphs in the face. */ + /* num_glyphs :: The number of glyphs in the face. If the */ + /* face is scalable and has sbits (see */ + /* `num_fixed_sizes'), it is set to the number */ + /* of outline glyphs. */ /* */ /* family_name :: The face's family name. This is an ASCII */ /* string, usually in English, which describes */ @@ -815,78 +807,58 @@ FT_BEGIN_HEADER /* formats provide a style name, so this field */ /* is optional, and can be set to NULL. As */ /* for `family_name', some formats provide */ - /* localized/Unicode versions of this string. */ - /* Applications should use the format specific */ - /* interface to access them. */ + /* localized and Unicode versions of this */ + /* string. Applications should use the format */ + /* specific interface to access them. */ /* */ - /* num_fixed_sizes :: The number of fixed sizes available in this */ - /* face. This should be set to 0 for scalable */ - /* fonts, unless its face includes a set of */ - /* glyphs (called a `strike') for the */ - /* specified sizes. */ + /* num_fixed_sizes :: The number of bitmap strikes in the face. */ + /* Even if the face is scalable, there might */ + /* still be bitmap strikes, which are called */ + /* `sbits' in that case. */ /* */ - /* available_sizes :: An array of sizes specifying the available */ - /* bitmap/graymap sizes that are contained in */ - /* in the font face. Should be set to NULL if */ - /* the field `num_fixed_sizes' is set to 0. */ + /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ + /* strikes in the face. It is set to NULL if */ + /* there is no bitmap strike. */ /* */ - /* num_charmaps :: The total number of character maps in the */ - /* face. */ + /* num_charmaps :: The number of charmaps in the face. */ /* */ - /* charmaps :: A table of pointers to the face's charmaps. */ - /* Used to scan the list of available charmaps */ - /* -- this table might change after a call to */ - /* @FT_Attach_File or @FT_Attach_Stream (e.g. */ - /* if used to hook an additional encoding or */ - /* CMap to the face object). */ + /* charmaps :: An array of the charmaps of the face. */ /* */ /* generic :: A field reserved for client uses. See the */ /* @FT_Generic type description. */ /* */ /* bbox :: The font bounding box. Coordinates are */ - /* expressed in font units (see units_per_EM). */ - /* The box is large enough to contain any */ - /* glyph from the font. Thus, bbox.yMax can */ - /* be seen as the `maximal ascender', */ - /* bbox.yMin as the `minimal descender', and */ - /* the maximal glyph width is given by */ - /* `bbox.xMax-bbox.xMin' (not to be confused */ - /* with the maximal _advance_width_). Only */ - /* relevant for scalable formats. */ + /* expressed in font units (see */ + /* `units_per_EM'). The box is large enough */ + /* to contain any glyph from the font. Thus, */ + /* `bbox.yMax' can be seen as the `maximal */ + /* ascender', and `bbox.yMin' as the `minimal */ + /* descender'. Only relevant for scalable */ + /* formats. */ /* */ /* units_per_EM :: The number of font units per EM square for */ /* this face. This is typically 2048 for */ - /* TrueType fonts, 1000 for Type1 fonts, and */ - /* should be set to the (unrealistic) value 1 */ - /* for fixed-sizes fonts. Only relevant for */ + /* TrueType fonts, and 1000 for Type 1 fonts. */ + /* Only relevant for scalable formats. */ + /* */ + /* ascender :: The typographic ascender of the face, */ + /* expressed in font units. For font formats */ + /* not having this information, it is set to */ + /* `bbox.yMax'. Only relevant for scalable */ + /* formats. */ + /* */ + /* descender :: The typographic descender of the face, */ + /* expressed in font units. For font formats */ + /* not having this information, it is set to */ + /* `bbox.yMin'. Note that this field is */ + /* usually negative. Only relevant for */ /* scalable formats. */ /* */ - /* ascender :: The face's ascender is the vertical */ - /* distance from the baseline to the topmost */ - /* point of any glyph in the face. This */ - /* field's value is positive, expressed in */ - /* font units. Some font designs use a value */ - /* different from `bbox.yMax'. Only relevant */ - /* for scalable formats. */ - /* */ - /* descender :: The face's descender is the vertical */ - /* distance from the baseline to the */ - /* bottommost point of any glyph in the face. */ - /* This field's value is *negative* for values */ - /* below the baseline. It is expressed in */ - /* font units. Some font designs use a value */ - /* different from `bbox.yMin'. Only relevant */ - /* for scalable formats. */ - /* */ - /* height :: The face's height is the vertical distance */ - /* from one baseline to the next when writing */ - /* several lines of text. Its value is always */ - /* positive, expressed in font units. The */ - /* value can be computed as */ - /* `ascender+descender+line_gap' where the */ - /* value of `line_gap' is also called */ - /* `external leading'. Only relevant for */ - /* scalable formats. */ + /* height :: The height is the vertical distance */ + /* between two consecutive baselines, */ + /* expressed in font units. It is always */ + /* positive. Only relevant for scalable */ + /* formats. */ /* */ /* max_advance_width :: The maximal advance width, in font units, */ /* for all glyphs in this face. This can be */ @@ -896,10 +868,10 @@ FT_BEGIN_HEADER /* */ /* max_advance_height :: The maximal advance height, in font units, */ /* for all glyphs in this face. This is only */ - /* relevant for vertical layouts, and should */ - /* be set to the `height' for fonts that do */ - /* not provide vertical metrics. Only */ - /* relevant for scalable formats. */ + /* relevant for vertical layouts, and is set */ + /* to `height' for fonts that do not provide */ + /* vertical metrics. Only relevant for */ + /* scalable formats. */ /* */ /* underline_position :: The position, in font units, of the */ /* underline line for this face. It's the */ @@ -910,17 +882,16 @@ FT_BEGIN_HEADER /* underline for this face. Only relevant for */ /* scalable formats. */ /* */ - /* glyph :: The face's associated glyph slot(s). This */ - /* object is created automatically with a new */ - /* face object. However, certain kinds of */ - /* applications (mainly tools like converters) */ - /* can need more than one slot to ease their */ - /* task. */ + /* glyph :: The face's associated glyph slot(s). */ /* */ /* size :: The current active size for this face. */ /* */ /* charmap :: The current active charmap for this face. */ /* */ + /* <Note> */ + /* Fields may be changed after a call to @FT_Attach_File or */ + /* @FT_Attach_Stream. */ + /* */ typedef struct FT_FaceRec_ { FT_Long num_faces; @@ -990,14 +961,13 @@ FT_BEGIN_HEADER /* */ /* <Values> */ /* FT_FACE_FLAG_SCALABLE :: */ - /* Indicates that the face provides vectorial outlines. This */ - /* doesn't prevent embedded bitmaps, i.e., a face can have both */ - /* this bit and @FT_FACE_FLAG_FIXED_SIZES set. */ + /* Indicates that the face contains outline glyphs. This doesn't */ + /* prevent bitmap strikes, i.e., a face can have both this and */ + /* and @FT_FACE_FLAG_FIXED_SIZES set. */ /* */ /* FT_FACE_FLAG_FIXED_SIZES :: */ - /* Indicates that the face contains `fixed sizes', i.e., bitmap */ - /* strikes for some given pixel sizes. See the `num_fixed_sizes' */ - /* and `available_sizes' fields of @FT_FaceRec. */ + /* Indicates that the face contains bitmap strikes. See also the */ + /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ /* */ /* FT_FACE_FLAG_FIXED_WIDTH :: */ /* Indicates that the face contains fixed-width characters (like */ @@ -1018,8 +988,9 @@ FT_BEGIN_HEADER /* FT_FACE_FLAG_KERNING :: */ /* Indicates that the face contains kerning information. If set, */ /* the kerning distance can be retrieved through the function */ - /* @FT_Get_Kerning. Note that if unset, this function will always */ - /* return the vector (0,0). */ + /* @FT_Get_Kerning. Otherwise the function always return the */ + /* vector (0,0). Note that FreeType doesn't handle kerning data */ + /* from the `GPOS' table (as present in some OpenType fonts). */ /* */ /* FT_FACE_FLAG_FAST_GLYPHS :: */ /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ @@ -1040,6 +1011,12 @@ FT_BEGIN_HEADER /* provided by the client application and should not be destroyed */ /* when @FT_Done_Face is called. Don't read or test this flag. */ /* */ + /* FT_FACE_FLAG_HINTER :: */ + /* Set if the font driver has a hinting machine of its own. For */ + /* example, with TrueType fonts, it makes sense to use data from */ + /* the SFNT `gasp' table only if the native TrueType hinting engine */ + /* (with the bytecode interpreter) is available and active. */ + /* */ #define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) @@ -1051,152 +1028,159 @@ FT_BEGIN_HEADER #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) +#define FT_FACE_FLAG_HINTER ( 1L << 11 ) /* */ - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_HORIZONTAL( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains */ - /* horizontal metrics (this is true for all font formats though). */ - /* */ - /* @also: */ - /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_HAS_HORIZONTAL( face ) + * + * @description: + * A macro that returns true whenever a face object contains + * horizontal metrics (this is true for all font formats though). + * + * @also: + * @FT_HAS_VERTICAL can be used to check for vertical metrics. + * + */ #define FT_HAS_HORIZONTAL( face ) \ ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_VERTICAL( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains vertical */ - /* metrics. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_HAS_VERTICAL( face ) + * + * @description: + * A macro that returns true whenever a face object contains vertical + * metrics. + * + */ #define FT_HAS_VERTICAL( face ) \ ( face->face_flags & FT_FACE_FLAG_VERTICAL ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_KERNING( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains kerning */ - /* data that can be accessed with @FT_Get_Kerning. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_HAS_KERNING( face ) + * + * @description: + * A macro that returns true whenever a face object contains kerning + * data that can be accessed with @FT_Get_Kerning. + * + */ #define FT_HAS_KERNING( face ) \ ( face->face_flags & FT_FACE_FLAG_KERNING ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_IS_SCALABLE( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains a */ - /* scalable font face (true for TrueType, Type 1, CID, and */ - /* OpenType/CFF font formats. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_IS_SCALABLE( face ) + * + * @description: + * A macro that returns true whenever a face object contains a scalable + * font face (true for TrueType, Type 1, Type 42, CID, OpenType/CFF, + * and PFR font formats. + * + */ #define FT_IS_SCALABLE( face ) \ ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_IS_SFNT( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains a font */ - /* whose format is based on the SFNT storage scheme. This usually */ - /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */ - /* embedded bitmap fonts. */ - /* */ - /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */ - /* and @FT_TRUETYPE_TABLES_H are available. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_IS_SFNT( face ) + * + * @description: + * A macro that returns true whenever a face object contains a font + * whose format is based on the SFNT storage scheme. This usually + * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded + * bitmap fonts. + * + * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and + * @FT_TRUETYPE_TABLES_H are available. + * + */ #define FT_IS_SFNT( face ) \ ( face->face_flags & FT_FACE_FLAG_SFNT ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_IS_FIXED_WIDTH( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains a font */ - /* face that contains fixed-width (or "monospace", "fixed-pitch", */ - /* etc.) glyphs. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_IS_FIXED_WIDTH( face ) + * + * @description: + * A macro that returns true whenever a face object contains a font face + * that contains fixed-width (or `monospace', `fixed-pitch', etc.) + * glyphs. + * + */ #define FT_IS_FIXED_WIDTH( face ) \ ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_FIXED_SIZES( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains some */ - /* embedded bitmaps. See the `available_sizes' field of the */ - /* @FT_FaceRec structure. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_HAS_FIXED_SIZES( face ) + * + * @description: + * A macro that returns true whenever a face object contains some + * embedded bitmaps. See the `available_sizes' field of the + * @FT_FaceRec structure. + * + */ #define FT_HAS_FIXED_SIZES( face ) \ ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) - - /* */ + /* */ - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_FAST_GLYPHS( face ) */ - /* */ - /* @description: */ - /* Deprecated; indicates that the face contains so-called "fast" */ - /* glyph bitmaps. */ - /* */ -#define FT_HAS_FAST_GLYPHS( face ) \ - ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS ) + /************************************************************************* + * + * @macro: + * FT_HAS_FAST_GLYPHS( face ) + * + * @description: + * Deprecated. + * + */ +#define FT_HAS_FAST_GLYPHS( face ) 0 - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_GLYPH_NAMES( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains some */ - /* glyph names that can be accessed through @FT_Get_Glyph_Name. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_HAS_GLYPH_NAMES( face ) + * + * @description: + * A macro that returns true whenever a face object contains some glyph + * names that can be accessed through @FT_Get_Glyph_Name. + * + */ #define FT_HAS_GLYPH_NAMES( face ) \ ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_HAS_MULTIPLE_MASTERS( face ) */ - /* */ - /* @description: */ - /* A macro that returns true whenever a face object contains some */ - /* multiple masters. The functions provided by */ - /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */ - /* design you want. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_HAS_MULTIPLE_MASTERS( face ) + * + * @description: + * A macro that returns true whenever a face object contains some + * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H + * are then available to choose the exact design you want. + * + */ #define FT_HAS_MULTIPLE_MASTERS( face ) \ ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) @@ -1227,7 +1211,7 @@ FT_BEGIN_HEADER /* FT_Size_Internal */ /* */ /* <Description> */ - /* An opaque handle to an FT_Size_InternalRec structure, used to */ + /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ /* model private data of a given FT_Size object. */ /* */ typedef struct FT_Size_InternalRec_* FT_Size_Internal; @@ -1239,61 +1223,60 @@ FT_BEGIN_HEADER /* FT_Size_Metrics */ /* */ /* <Description> */ - /* The size metrics structure returned scaled important distances for */ - /* a given size object. */ + /* The size metrics structure gives the metrics of a size object. */ /* */ /* <Fields> */ - /* x_ppem :: The character width, expressed in integer pixels. */ - /* This is the width of the EM square expressed in */ - /* pixels, hence the term `ppem' (pixels per EM). */ + /* x_ppem :: The width of the scaled EM square in pixels, hence */ + /* the term `ppem' (pixels per EM). It is also */ + /* referred to as `nominal width'. */ /* */ - /* y_ppem :: The character height, expressed in integer pixels. */ - /* This is the height of the EM square expressed in */ - /* pixels, hence the term `ppem' (pixels per EM). */ + /* y_ppem :: The height of the scaled EM square in pixels, */ + /* hence the term `ppem' (pixels per EM). It is also */ + /* referred to as `nominal height'. */ /* */ - /* x_scale :: A simple 16.16 fixed point format coefficient used */ - /* to scale horizontal distances expressed in font */ - /* units to fractional (26.6) pixel coordinates. */ + /* x_scale :: A 16.16 fractional scaling value used to convert */ + /* horizontal metrics from font units to 26.6 */ + /* fractional pixels. Only relevant for scalable */ + /* font formats. */ /* */ - /* y_scale :: A simple 16.16 fixed point format coefficient used */ - /* to scale vertical distances expressed in font */ - /* units to fractional (26.6) pixel coordinates. */ + /* y_scale :: A 16.16 fractional scaling value used to convert */ + /* vertical metrics from font units to 26.6 */ + /* fractional pixels. Only relevant for scalable */ + /* font formats. */ /* */ - /* ascender :: The ascender, expressed in 26.6 fixed point */ - /* pixels. Positive for ascenders above the */ - /* baseline. */ + /* ascender :: The ascender in 26.6 fractional pixels. See */ + /* @FT_FaceRec for the details. */ /* */ - /* descender :: The descender, expressed in 26.6 fixed point */ - /* pixels. Negative for descenders below the */ - /* baseline. */ + /* descender :: The descender in 26.6 fractional pixels. See */ + /* @FT_FaceRec for the details. */ /* */ - /* height :: The text height, expressed in 26.6 fixed point */ - /* pixels. Always positive. */ + /* height :: The height in 26.6 fractional pixels. See */ + /* @FT_FaceRec for the details. */ /* */ - /* max_advance :: Maximum horizontal advance, expressed in 26.6 */ - /* fixed point pixels. Always positive. */ + /* max_advance :: The maximal advance width in 26.6 fractional */ + /* pixels. See @FT_FaceRec for the details. */ /* */ /* <Note> */ - /* For scalable fonts, the values of `ascender', `descender', and */ - /* `height' are scaled versions of `face->ascender', */ - /* `face->descender', and `face->height', respectively. */ + /* The scaling values, if relevant, are determined first during a */ + /* size changing operation. The remaining fields are then set by the */ + /* driver. For scalable formats, they are usually set to scaled */ + /* values of the corresponding fields in @FT_FaceRec. */ /* */ - /* Unfortunately, due to glyph hinting, these values might not be */ - /* exact for certain fonts. They thus must be treated as unreliable */ + /* Note that due to glyph hinting, these values might not be exact */ + /* for certain fonts. Thus they must be treated as unreliable */ /* with an error margin of at least one pixel! */ /* */ - /* Indeed, the only way to get the exact pixel ascender and descender */ - /* is to render _all_ glyphs. As this would be a definite */ - /* performance hit, it is up to client applications to perform such */ - /* computations. */ + /* Indeed, the only way to get the exact metrics is to render _all_ */ + /* glyphs. As this would be a definite performance hit, it is up to */ + /* client applications to perform such computations. */ /* */ typedef struct FT_Size_Metrics_ { FT_UShort x_ppem; /* horizontal pixels per EM */ FT_UShort y_ppem; /* vertical pixels per EM */ - FT_Fixed x_scale; /* two scales used to convert font units */ - FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates */ + FT_Fixed x_scale; /* scaling values used to convert font */ + FT_Fixed y_scale; /* units to 26.6 fractional pixels */ FT_Pos ascender; /* ascender in 26.6 frac. pixels */ FT_Pos descender; /* descender in 26.6 frac. pixels */ @@ -1309,8 +1292,8 @@ FT_BEGIN_HEADER /* FT_SizeRec */ /* */ /* <Description> */ - /* FreeType root size class structure. A size object models the */ - /* resolution and pointsize dependent data of a given face. */ + /* FreeType root size class structure. A size object models a face */ + /* object at a given size. */ /* */ /* <Fields> */ /* face :: Handle to the parent face object. */ @@ -1345,6 +1328,9 @@ FT_BEGIN_HEADER /* The subglyph implementation is not part of the high-level API, */ /* hence the forward structure declaration. */ /* */ + /* You can however retrieve subglyph information with */ + /* @FT_Get_SubGlyph_Info. */ + /* */ typedef struct FT_SubGlyphRec_* FT_SubGlyph; @@ -1354,7 +1340,7 @@ FT_BEGIN_HEADER /* FT_Slot_Internal */ /* */ /* <Description> */ - /* An opaque handle to an FT_Slot_InternalRec structure, used to */ + /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ /* model private data of a given FT_GlyphSlot object. */ /* */ typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; @@ -1367,8 +1353,8 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* FreeType root glyph slot class structure. A glyph slot is a */ - /* container where individual glyphs can be loaded, be they */ - /* vectorial or bitmap/graymaps. */ + /* container where individual glyphs can be loaded, be they in */ + /* outline or bitmap format. */ /* */ /* <Fields> */ /* library :: A handle to the FreeType library instance */ @@ -1396,36 +1382,33 @@ FT_BEGIN_HEADER /* Note that even when the glyph image is */ /* transformed, the metrics are not. */ /* */ - /* linearHoriAdvance :: For scalable formats only, this field holds */ - /* the linearly scaled horizontal advance width */ - /* for the glyph (i.e. the scaled and unhinted */ - /* value of the hori advance). This can be */ + /* linearHoriAdvance :: The advance width of the unhinted glyph. */ + /* Its value is expressed in 16.16 fractional */ + /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ + /* when loading the glyph. This field can be */ /* important to perform correct WYSIWYG layout. */ + /* Only relevant for outline glyphs. */ /* */ - /* Note that this value is expressed by default */ - /* in 16.16 pixels. However, when the glyph is */ - /* loaded with the FT_LOAD_LINEAR_DESIGN flag, */ - /* this field contains simply the value of the */ - /* advance in original font units. */ - /* */ - /* linearVertAdvance :: For scalable formats only, this field holds */ - /* the linearly scaled vertical advance height */ - /* for the glyph. See linearHoriAdvance for */ - /* comments. */ + /* linearVertAdvance :: The advance height of the unhinted glyph. */ + /* Its value is expressed in 16.16 fractional */ + /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ + /* when loading the glyph. This field can be */ + /* important to perform correct WYSIWYG layout. */ + /* Only relevant for outline glyphs. */ /* */ /* advance :: This is the transformed advance width for the */ /* glyph. */ /* */ /* format :: This field indicates the format of the image */ /* contained in the glyph slot. Typically */ - /* FT_GLYPH_FORMAT_BITMAP, */ - /* FT_GLYPH_FORMAT_OUTLINE, and */ - /* FT_GLYPH_FORMAT_COMPOSITE, but others are */ + /* @FT_GLYPH_FORMAT_BITMAP, */ + /* @FT_GLYPH_FORMAT_OUTLINE, or */ + /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */ /* possible. */ /* */ /* bitmap :: This field is used as a bitmap descriptor */ /* when the slot format is */ - /* FT_GLYPH_FORMAT_BITMAP. Note that the */ + /* @FT_GLYPH_FORMAT_BITMAP. Note that the */ /* address and content of the bitmap buffer can */ /* change between calls of @FT_Load_Glyph and a */ /* few other functions. */ @@ -1433,7 +1416,7 @@ FT_BEGIN_HEADER /* bitmap_left :: This is the bitmap's left bearing expressed */ /* in integer pixels. Of course, this is only */ /* valid if the format is */ - /* FT_GLYPH_FORMAT_BITMAP. */ + /* @FT_GLYPH_FORMAT_BITMAP. */ /* */ /* bitmap_top :: This is the bitmap's top bearing expressed in */ /* integer pixels. Remember that this is the */ @@ -1443,7 +1426,10 @@ FT_BEGIN_HEADER /* */ /* outline :: The outline descriptor for the current glyph */ /* image if its format is */ - /* FT_GLYPH_FORMAT_OUTLINE. */ + /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ + /* loaded, `outline' can be transformed, */ + /* distorted, embolded, etc. However, it must */ + /* not be freed. */ /* */ /* num_subglyphs :: The number of subglyphs in a composite glyph. */ /* This field is only valid for the composite */ @@ -1465,9 +1451,9 @@ FT_BEGIN_HEADER /* data. */ /* */ /* other :: Really wicked formats can use this pointer to */ - /* present their own glyph image to client apps. */ - /* Note that the app will need to know about the */ - /* image format. */ + /* present their own glyph image to client */ + /* applications. Note that the application */ + /* needs to know about the image format. */ /* */ /* lsb_delta :: The difference between hinted and unhinted */ /* left side bearing while autohinting is */ @@ -1480,8 +1466,8 @@ FT_BEGIN_HEADER /* <Note> */ /* If @FT_Load_Glyph is called with default flags (see */ /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ - /* its native format (e.g. a vectorial outline for TrueType and */ - /* Type 1 formats). */ + /* its native format (e.g., an outline glyph for TrueType and Type 1 */ + /* formats). */ /* */ /* This image can later be converted into a bitmap by calling */ /* @FT_Render_Glyph. This function finds the current renderer for */ @@ -1493,8 +1479,8 @@ FT_BEGIN_HEADER /* */ /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ /* to specify the position of the bitmap relative to the current pen */ - /* position (e.g. coordinates [0,0] on the baseline). Of course, */ - /* `slot->format' is also changed to `FT_GLYPH_FORMAT_BITMAP' . */ + /* position (e.g., coordinates (0,0) on the baseline). Of course, */ + /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ /* */ /* <Note> */ /* Here a small pseudo code fragment which shows how to use */ @@ -1576,7 +1562,7 @@ FT_BEGIN_HEADER /* FT_Init_FreeType */ /* */ /* <Description> */ - /* Initializes a new FreeType library object. The set of modules */ + /* Initialize a new FreeType library object. The set of modules */ /* that are registered by this function is determined at build time. */ /* */ /* <Output> */ @@ -1589,49 +1575,13 @@ FT_BEGIN_HEADER FT_Init_FreeType( FT_Library *alibrary ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Library_Version */ - /* */ - /* <Description> */ - /* Return the version of the FreeType library being used. This is */ - /* useful when dynamically linking to the library, since one cannot */ - /* use the macros FT_FREETYPE_MAJOR, FT_FREETYPE_MINOR, and */ - /* FT_FREETYPE_PATCH. */ - /* */ - /* <Input> */ - /* library :: A source library handle. */ - /* */ - /* <Output> */ - /* amajor :: The major version number. */ - /* */ - /* aminor :: The minor version number. */ - /* */ - /* apatch :: The patch version number. */ - /* */ - /* <Note> */ - /* The reason why this function takes a 'library' argument is because */ - /* certain programs implement library initialization in a custom way */ - /* that doesn't use `FT_Init_FreeType'. */ - /* */ - /* In such cases, the library version might not be available before */ - /* the library object has been created. */ - /* */ - FT_EXPORT( void ) - FT_Library_Version( FT_Library library, - FT_Int *amajor, - FT_Int *aminor, - FT_Int *apatch ); - - /*************************************************************************/ /* */ /* <Function> */ /* FT_Done_FreeType */ /* */ /* <Description> */ - /* Destroys a given FreeType library object and all of its childs, */ + /* Destroy a given FreeType library object and all of its childs, */ /* including resources, drivers, faces, sizes, etc. */ /* */ /* <Input> */ @@ -1663,7 +1613,7 @@ FT_BEGIN_HEADER /* */ /* FT_OPEN_DRIVER :: Use the `driver' field. */ /* */ - /* FT_OPEN_PARAMS :: Use the `num_params' & `params' field. */ + /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ /* */ /* ft_open_memory :: Deprecated; use @FT_OPEN_MEMORY instead. */ /* */ @@ -1702,12 +1652,12 @@ FT_BEGIN_HEADER /* to @FT_Open_Face. */ /* */ /* <Fields> */ - /* tag :: A 4-byte identification tag. */ + /* tag :: A four-byte identification tag. */ /* */ /* data :: A pointer to the parameter data. */ /* */ /* <Note> */ - /* The id and function of parameters are driver-specific. */ + /* The ID and function of parameters are driver-specific. */ /* */ typedef struct FT_Parameter_ { @@ -1723,9 +1673,9 @@ FT_BEGIN_HEADER /* FT_Open_Args */ /* */ /* <Description> */ - /* A structure used to indicate how to open a new font file/stream. */ - /* A pointer to such a structure can be used as a parameter for the */ - /* functions @FT_Open_Face and @FT_Attach_Stream. */ + /* A structure used to indicate how to open a new font file or */ + /* stream. A pointer to such a structure can be used as a parameter */ + /* for the functions @FT_Open_Face and @FT_Attach_Stream. */ /* */ /* <Fields> */ /* flags :: A set of bit flags indicating how to use the */ @@ -1741,8 +1691,8 @@ FT_BEGIN_HEADER /* */ /* driver :: This field is exclusively used by @FT_Open_Face; */ /* it simply specifies the font driver to use to open */ - /* the face. If set to 0, FreeType will try to load */ - /* the face with each one of the drivers in its list. */ + /* the face. If set to 0, FreeType tries to load the */ + /* face with each one of the drivers in its list. */ /* */ /* num_params :: The number of extra parameters. */ /* */ @@ -1754,7 +1704,10 @@ FT_BEGIN_HEADER /* are tested in the following order by @FT_Open_Face: */ /* */ /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */ - /* memory file of `memory_size' bytes,located at `memory_address'. */ + /* memory file of `memory_size' bytes, located at `memory_address'. */ + /* The data are are not copied, and the client is responsible for */ + /* releasing and destroying them _after_ the corresponding call to */ + /* @FT_Done_Face. */ /* */ /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */ /* custom input stream `stream' is used. */ @@ -1762,12 +1715,11 @@ FT_BEGIN_HEADER /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */ /* is a normal file and use `pathname' to open it. */ /* */ - /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face will only try to */ + /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face only tries to */ /* open the file with the driver whose handler is in `driver'. */ /* */ /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */ - /* `num_params' and `params' will be used. They are ignored */ - /* otherwise. */ + /* `num_params' and `params' is used. They are ignored otherwise. */ /* */ typedef struct FT_Open_Args_ { @@ -1789,8 +1741,7 @@ FT_BEGIN_HEADER /* FT_New_Face */ /* */ /* <Description> */ - /* Creates a new face object from a given resource and typeface index */ - /* using a pathname to the font file. */ + /* This function calls @FT_Open_Face to open a font by its pathname. */ /* */ /* <InOut> */ /* library :: A handle to the library resource. */ @@ -1798,29 +1749,17 @@ FT_BEGIN_HEADER /* <Input> */ /* pathname :: A path to the font file. */ /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ + /* face_index :: The index of the face within the font. The first */ + /* face has index 0. */ /* */ /* <Output> */ - /* aface :: A handle to a new face object. */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* See @FT_Open_Face for more details. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ - /* <Note> */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* @FT_New_Face can be used to determine and/or check the font format */ - /* of a given font resource. If the `face_index' field is negative, */ - /* the function will _not_ return any face handle in `aface'; the */ - /* return value is 0 if the font format is recognized, or non-zero */ - /* otherwise. */ - /* */ - /* Each new face object created with this function also owns a */ - /* default @FT_Size object, accessible as `face->size'. */ - /* */ FT_EXPORT( FT_Error ) FT_New_Face( FT_Library library, const char* filepathname, @@ -1834,8 +1773,8 @@ FT_BEGIN_HEADER /* FT_New_Memory_Face */ /* */ /* <Description> */ - /* Creates a new face object from a given resource and typeface index */ - /* using a font file already loaded into memory. */ + /* This function calls @FT_Open_Face to open a font which has been */ + /* loaded into memory. */ /* */ /* <InOut> */ /* library :: A handle to the library resource. */ @@ -1845,31 +1784,17 @@ FT_BEGIN_HEADER /* */ /* file_size :: The size of the memory chunk used by the font data. */ /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ + /* face_index :: The index of the face within the font. The first */ + /* face has index 0. */ /* */ /* <Output> */ - /* aface :: A handle to a new face object. */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* See @FT_Open_Face for more details. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ - /* <Note> */ - /* The font data bytes are used _directly_ by the @FT_Face object. */ - /* This means that they are not copied, and that the client is */ - /* responsible for releasing/destroying them _after_ the */ - /* corresponding call to @FT_Done_Face . */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* @FT_New_Memory_Face can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `aface'; the return value is 0 if the font format is recognized, */ - /* or non-zero otherwise. */ - /* */ FT_EXPORT( FT_Error ) FT_New_Memory_Face( FT_Library library, const FT_Byte* file_base, @@ -1884,9 +1809,8 @@ FT_BEGIN_HEADER /* FT_Open_Face */ /* */ /* <Description> */ - /* Opens a face object from a given resource and typeface index using */ - /* an `FT_Open_Args' structure. If the face object doesn't exist, it */ - /* will be created. */ + /* Create a face object from a given resource described by */ + /* @FT_Open_Args. */ /* */ /* <InOut> */ /* library :: A handle to the library resource. */ @@ -1895,11 +1819,13 @@ FT_BEGIN_HEADER /* args :: A pointer to an `FT_Open_Args' structure which must */ /* be filled by the caller. */ /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ + /* face_index :: The index of the face within the font. The first */ + /* face has index 0. */ /* */ /* <Output> */ - /* aface :: A handle to a new face object. */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* See note below. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ @@ -1909,11 +1835,18 @@ FT_BEGIN_HEADER /* slot for the face object which can be accessed directly through */ /* `face->glyph'. */ /* */ - /* @FT_Open_Face can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `*aface'; the function's return value is 0 if the font format is */ - /* recognized, or non-zero otherwise. */ + /* FT_Open_Face can be used to quickly check whether the font */ + /* format of a given font resource is supported by FreeType. If the */ + /* `face_index' field is negative, the function's return value is 0 */ + /* if the font format is recognized, or non-zero otherwise; */ + /* the function returns a more or less empty face handle in `*aface' */ + /* (if `aface' isn't NULL). The only useful field in this special */ + /* case is `face->num_faces' which gives the number of faces within */ + /* the font file. After examination, the returned @FT_Face structure */ + /* should be deallocated with a call to @FT_Done_Face. */ + /* */ + /* Each new face object created with this function also owns a */ + /* default @FT_Size object, accessible as `face->size'. */ /* */ FT_EXPORT( FT_Error ) FT_Open_Face( FT_Library library, @@ -1928,32 +1861,17 @@ FT_BEGIN_HEADER /* FT_Attach_File */ /* */ /* <Description> */ - /* `Attaches' a given font file to an existing face. This is usually */ - /* to read additional information for a single face object. For */ - /* example, it is used to read the AFM files that come with Type 1 */ - /* fonts in order to add kerning data and other metrics. */ + /* This function calls @FT_Attach_Stream to attach a file. */ /* */ /* <InOut> */ /* face :: The target face object. */ /* */ /* <Input> */ - /* filepathname :: An 8-bit pathname naming the `metrics' file. */ + /* filepathname :: The pathname. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ - /* <Note> */ - /* If your font file is in memory, or if you want to provide your */ - /* own input stream object, use @FT_Attach_Stream. */ - /* */ - /* The meaning of the `attach' action (i.e., what really happens when */ - /* the new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ FT_EXPORT( FT_Error ) FT_Attach_File( FT_Face face, const char* filepathname ); @@ -1965,20 +1883,23 @@ FT_BEGIN_HEADER /* FT_Attach_Stream */ /* */ /* <Description> */ - /* This function is similar to @FT_Attach_File with the exception */ - /* that it reads the attachment from an arbitrary stream. */ + /* `Attach' data to a face object. Normally, this is used to read */ + /* additional information for the face object. For example, you can */ + /* attach an AFM file that comes with a Type 1 font to get the */ + /* kerning values and other metrics. */ /* */ /* <InOut> */ /* face :: The target face object. */ /* */ /* <Input> */ - /* parameters :: A pointer to an FT_Open_Args structure used to */ - /* describe the input stream to FreeType. */ + /* parameters :: A pointer to @FT_Open_Args which must be filled by */ + /* the caller. */ + /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* The meaning of the `attach' (i.e. what really happens when the */ + /* The meaning of the `attach' (i.e., what really happens when the */ /* new file is read) is not fixed by FreeType itself. It really */ /* depends on the font format (and thus the font driver). */ /* */ @@ -1997,8 +1918,8 @@ FT_BEGIN_HEADER /* FT_Done_Face */ /* */ /* <Description> */ - /* Discards a given face object, as well as all of its child slots */ - /* and sizes. */ + /* Discard a given face object, as well as all of its child slots and */ + /* sizes. */ /* */ /* <Input> */ /* face :: A handle to a target face object. */ @@ -2013,37 +1934,174 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Function> */ - /* FT_Set_Char_Size */ + /* FT_Select_Size */ /* */ /* <Description> */ - /* Sets the character dimensions of a given face object. The */ - /* `char_width' and `char_height' values are used for the width and */ - /* height, respectively, expressed in 26.6 fractional points. */ - /* */ - /* If the horizontal or vertical resolution values are zero, a */ - /* default value of 72dpi is used. Similarly, if one of the */ - /* character dimensions is zero, its value is set equal to the other. */ + /* Select a bitmap strike. */ /* */ /* <InOut> */ - /* face :: A handle to a target face object. */ + /* face :: A handle to a target face object. */ /* */ /* <Input> */ - /* char_width :: The character width, in 26.6 fractional points. */ + /* strike_index :: The index of the bitmap strike in the */ + /* `available_sizes' field of @FT_FaceRec structure. */ /* */ - /* char_height :: The character height, in 26.6 fractional */ - /* points. */ + /* <Return> */ + /* FreeType error code. 0 means success. */ /* */ - /* horz_resolution :: The horizontal resolution. */ + FT_EXPORT( FT_Error ) + FT_Select_Size( FT_Face face, + FT_Int strike_index ); + + + /*************************************************************************/ /* */ - /* vert_resolution :: The vertical resolution. */ + /* <Enum> */ + /* FT_Size_Request_Type */ + /* */ + /* <Description> */ + /* An enumeration type that lists the supported size request types. */ + /* */ + /* <Values> */ + /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ + /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ + /* used to determine both scaling values. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ + /* The real dimension. The sum of the the `Ascender' and (minus */ + /* of) the `Descender' fields of @FT_FaceRec are used to determine */ + /* both scaling values. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_BBOX :: */ + /* The font bounding box. The width and height of the `bbox' field */ + /* of @FT_FaceRec are used to determine the horizontal and vertical */ + /* scaling value, respectively. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_CELL :: */ + /* The `max_advance_width' field of @FT_FaceRec is used to */ + /* determine the horizontal scaling value; the vertical scaling */ + /* value is determined the same way as */ + /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ + /* values are set to the smaller one. This type is useful if you */ + /* want to specify the font size for, say, a window of a given */ + /* dimension and 80x24 cells. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_SCALES :: */ + /* Specify the scaling values directly. */ + /* */ + /* <Note> */ + /* The above descriptions only apply to scalable formats. For bitmap */ + /* formats, the behaviour is up to the driver. */ + /* */ + /* See the note section of @FT_Size_Metrics if you wonder how size */ + /* requesting relates to scaling values. */ + /* */ + typedef enum FT_Size_Request_Type_ + { + FT_SIZE_REQUEST_TYPE_NOMINAL, + FT_SIZE_REQUEST_TYPE_REAL_DIM, + FT_SIZE_REQUEST_TYPE_BBOX, + FT_SIZE_REQUEST_TYPE_CELL, + FT_SIZE_REQUEST_TYPE_SCALES, + + FT_SIZE_REQUEST_TYPE_MAX + + } FT_Size_Request_Type; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_RequestRec */ + /* */ + /* <Description> */ + /* A structure used to model a size request. */ + /* */ + /* <Fields> */ + /* type :: See @FT_Size_Request_Type. */ + /* */ + /* width :: The desired width. */ + /* */ + /* height :: The desired height. */ + /* */ + /* horiResolution :: The horizontal resolution. If set to zero, */ + /* `width' is treated as a 26.6 fractional pixel */ + /* value. */ + /* */ + /* vertResolution :: The vertical resolution. If set to zero, */ + /* `height' is treated as a 26.6 fractional pixel */ + /* value. */ + /* */ + /* <Note> */ + /* If `width' is zero, then the horizontal scaling value is set */ + /* equal to the vertical scaling value, and vice versa. */ + /* */ + typedef struct FT_Size_RequestRec_ + { + FT_Size_Request_Type type; + FT_Long width; + FT_Long height; + FT_UInt horiResolution; + FT_UInt vertResolution; + + } FT_Size_RequestRec, *FT_Size_Request; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Request_Size */ + /* */ + /* <Description> */ + /* Resize the scale of the active @FT_Size object in a face. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* req :: A pointer to a @FT_Size_RequestRec. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* For BDF and PCF formats, this function uses the `PIXEL_SIZE' */ - /* property of the bitmap font; the `char_width' parameter is */ - /* ignored. */ + /* Although drivers may select the bitmap strike matching the */ + /* request, you should not rely on this if you intend to select a */ + /* particular bitmap strike. Use @FT_Select_Size instead in that */ + /* case. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Request_Size( FT_Face face, + FT_Size_Request req ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Char_Size */ + /* */ + /* <Description> */ + /* This function calls @FT_Request_Size to request the nominal size */ + /* (in points). */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* char_width :: The nominal width, in 26.6 fractional points. */ + /* */ + /* char_height :: The nominal height, in 26.6 fractional points. */ + /* */ + /* horz_resolution :: The horizontal resolution in dpi. */ + /* */ + /* vert_resolution :: The vertical resolution in dpi. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* If either the horizontal or vertical resolution is zero, it is set */ + /* to a default value of 72dpi. */ /* */ FT_EXPORT( FT_Error ) FT_Set_Char_Size( FT_Face face, @@ -2059,46 +2117,20 @@ FT_BEGIN_HEADER /* FT_Set_Pixel_Sizes */ /* */ /* <Description> */ - /* Sets the character dimensions of a given face object. The width */ - /* and height are expressed in integer pixels. */ - /* */ - /* If one of the character dimensions is zero, its value is set equal */ - /* to the other. */ + /* This function calls @FT_Request_Size to request the nominal size */ + /* (in pixels). */ /* */ /* <InOut> */ /* face :: A handle to the target face object. */ /* */ /* <Input> */ - /* pixel_width :: The character width, in integer pixels. */ + /* pixel_width :: The nominal width, in pixels. */ /* */ - /* pixel_height :: The character height, in integer pixels. */ + /* pixel_height :: The nominal height, in pixels. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ - /* <Note> */ - /* The values of `pixel_width' and `pixel_height' correspond to the */ - /* pixel values of the _typographic_ character size, which are NOT */ - /* necessarily the same as the dimensions of the glyph `bitmap */ - /* cells'. */ - /* */ - /* The `character size' is really the size of an abstract square */ - /* called the `EM', used to design the font. However, depending */ - /* on the font design, glyphs will be smaller or greater than the */ - /* EM. */ - /* */ - /* This means that setting the pixel size to, say, 8x8 doesn't */ - /* guarantee in any way that you will get glyph bitmaps that all fit */ - /* within an 8x8 cell (sometimes even far from it). */ - /* */ - /* For bitmap fonts, `pixel_height' usually is a reliable value for */ - /* the height of the bitmap cell. Drivers for bitmap font formats */ - /* which contain a single bitmap strike only (BDF, PCF, FNT) ignore */ - /* `pixel_width'. */ - /* */ - /* For BDF and PCF formats, this function uses the sum of the */ - /* `FONT_ASCENT' and `FONT_DESCENT' properties of the bitmap font. */ - /* */ FT_EXPORT( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, FT_UInt pixel_width, @@ -2111,12 +2143,12 @@ FT_BEGIN_HEADER /* FT_Load_Glyph */ /* */ /* <Description> */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size. */ + /* A function used to load a single glyph into the glyph slot of a */ + /* face object. */ /* */ /* <InOut> */ /* face :: A handle to the target face object where the glyph */ - /* will be loaded. */ + /* is loaded. */ /* */ /* <Input> */ /* glyph_index :: The index of the glyph in the font file. For */ @@ -2133,13 +2165,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* If the glyph image is not a bitmap, and if the bit flag */ - /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ - /* transformed with the information passed to a previous call to */ - /* @FT_Set_Transform. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ + /* The loaded glyph may be transformed. See @FT_Set_Transform for */ + /* the details. */ /* */ FT_EXPORT( FT_Error ) FT_Load_Glyph( FT_Face face, @@ -2153,12 +2180,12 @@ FT_BEGIN_HEADER /* FT_Load_Char */ /* */ /* <Description> */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size, according to its character code. */ + /* A function used to load a single glyph into the glyph slot of a */ + /* face object, according to its character code. */ /* */ /* <InOut> */ /* face :: A handle to a target face object where the glyph */ - /* will be loaded. */ + /* is loaded. */ /* */ /* <Input> */ /* char_code :: The glyph's character code, according to the */ @@ -2174,17 +2201,7 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* If the face has no current charmap, or if the character code */ - /* is not defined in the charmap, this function will return an */ - /* error. */ - /* */ - /* If the glyph image is not a bitmap, and if the bit flag */ - /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ - /* transformed with the information passed to a previous call to */ - /* @FT_Set_Transform. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ + /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ /* */ FT_EXPORT( FT_Error ) FT_Load_Char( FT_Face face, @@ -2192,144 +2209,132 @@ FT_BEGIN_HEADER FT_Int32 load_flags ); - /*************************************************************************** - * - * @enum: - * FT_LOAD_XXX - * - * @description: - * A list of bit-field constants, used with @FT_Load_Glyph to indicate - * what kind of operations to perform during glyph loading. - * - * @values: - * FT_LOAD_DEFAULT :: - * Corresponding to 0, this value is used a default glyph load. In this - * case, the following will happen: - * - * 1. FreeType looks for a bitmap for the glyph corresponding to the - * face's current size. If one is found, the function returns. The - * bitmap data can be accessed from the glyph slot (see note below). - * - * 2. If no embedded bitmap is searched or found, FreeType looks for a - * scalable outline. If one is found, it is loaded from the font - * file, scaled to device pixels, then "hinted" to the pixel grid in - * order to optimize it. The outline data can be accessed from the - * glyph slot (see note below). - * - * Note that by default, the glyph loader doesn't render outlines into - * bitmaps. The following flags are used to modify this default - * behaviour to more specific and useful cases. - * - * FT_LOAD_NO_SCALE :: - * Don't scale the vector outline being loaded to 26.6 fractional - * pixels, but kept in font units. Note that this also disables - * hinting and the loading of embedded bitmaps. You should only use it - * when you want to retrieve the original glyph outlines in font units. - * - * FT_LOAD_NO_HINTING :: - * Don't hint glyph outlines after their scaling to device pixels. - * This generally generates "blurrier" glyphs in anti-aliased modes. - * - * This flag is ignored if @FT_LOAD_NO_SCALE is set. - * - * FT_LOAD_RENDER :: - * Render the glyph outline immediately into a bitmap before the glyph - * loader returns. By default, the glyph is rendered for the - * @FT_RENDER_MODE_NORMAL mode, which corresponds to 8-bit anti-aliased - * bitmaps using 256 opacity levels. You can use either - * @FT_LOAD_TARGET_MONO or @FT_LOAD_MONOCHROME to render 1-bit - * monochrome bitmaps. - * - * This flag is ignored if @FT_LOAD_NO_SCALE is set. - * - * FT_LOAD_NO_BITMAP :: - * Don't look for bitmaps when loading the glyph. Only scalable - * outlines will be loaded when available, and scaled, hinted, or - * rendered depending on other bit flags. - * - * This does not prevent you from rendering outlines to bitmaps - * with @FT_LOAD_RENDER, however. - * - * FT_LOAD_VERTICAL_LAYOUT :: - * Prepare the glyph image for vertical text layout. This basically - * means that `face.glyph.advance' will correspond to the vertical - * advance height (instead of the default horizontal advance width), - * and that the glyph image will be translated to match the vertical - * bearings positions. - * - * FT_LOAD_FORCE_AUTOHINT :: - * Force the use of the FreeType auto-hinter when a glyph outline is - * loaded. You shouldn't need this in a typical application, since it - * is mostly used to experiment with its algorithm. - * - * FT_LOAD_CROP_BITMAP :: - * Indicates that the glyph loader should try to crop the bitmap (i.e., - * remove all space around its black bits) when loading it. This is - * only useful when loading embedded bitmaps in certain fonts, since - * bitmaps rendered with @FT_LOAD_RENDER are always cropped by default. - * - * FT_LOAD_PEDANTIC :: - * Indicates that the glyph loader should perform pedantic - * verifications during glyph loading, rejecting invalid fonts. This - * is mostly used to detect broken glyphs in fonts. By default, - * FreeType tries to handle broken fonts also. - * - * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: - * Indicates that the glyph loader should ignore the global advance - * width defined in the font. For historical reasons (to support - * buggy CJK fonts), FreeType uses the value of the `advanceWidthMax' - * field in the `htmx' table for all glyphs if the font is monospaced. - * Activating this flags makes FreeType use the metric values given in - * the `htmx' table. - * - * FT_LOAD_NO_RECURSE :: - * This flag is only used internally. It merely indicates that the - * glyph loader should not load composite glyphs recursively. Instead, - * it should set the `num_subglyph' and `subglyphs' values of the glyph - * slot accordingly, and set "glyph->format" to - * @FT_GLYPH_FORMAT_COMPOSITE. - * - * The description of sub-glyphs is not available to client - * applications for now. - * - * FT_LOAD_IGNORE_TRANSFORM :: - * Indicates that the glyph loader should not try to transform the - * loaded glyph image. This doesn't prevent scaling, hinting, or - * rendering. - * - * FT_LOAD_MONOCHROME :: - * This flag is used with @FT_LOAD_RENDER to indicate that you want - * to render a 1-bit monochrome glyph bitmap from a vectorial outline. - * - * Note that this has no effect on the hinting algorithm used by the - * glyph loader. You should better use @FT_LOAD_TARGET_MONO if you - * want to render monochrome-optimized glyph images instead. - * - * FT_LOAD_LINEAR_DESIGN :: - * Return the linearly scaled metrics expressed in original font units - * instead of the default 16.16 pixel values. - * - * FT_LOAD_NO_AUTOHINT :: - * Indicates that the auto-hinter should never be used to hint glyph - * outlines. This doesn't prevent native format-specific hinters from - * being used. This can be important for certain fonts where unhinted - * output is better than auto-hinted one. - * - * FT_LOAD_TARGET_NORMAL :: - * Use hinting for @FT_RENDER_MODE_NORMAL. - * - * FT_LOAD_TARGET_LIGHT :: - * Use hinting for @FT_RENDER_MODE_LIGHT. - * - * FT_LOAD_TARGET_MONO :: - * Use hinting for @FT_RENDER_MODE_MONO. - * - * FT_LOAD_TARGET_LCD :: - * Use hinting for @FT_RENDER_MODE_LCD. - * - * FT_LOAD_TARGET_LCD_V :: - * Use hinting for @FT_RENDER_MODE_LCD_V. - */ + /************************************************************************* + * + * @enum: + * FT_LOAD_XXX + * + * @description: + * A list of bit-field constants used with @FT_Load_Glyph to indicate + * what kind of operations to perform during glyph loading. + * + * @values: + * FT_LOAD_DEFAULT :: + * Corresponding to 0, this value is used as the default glyph load + * operation. In this case, the following happens: + * + * 1. FreeType looks for a bitmap for the glyph corresponding to the + * face's current size. If one is found, the function returns. + * The bitmap data can be accessed from the glyph slot (see note + * below). + * + * 2. If no embedded bitmap is searched or found, FreeType looks for a + * scalable outline. If one is found, it is loaded from the font + * file, scaled to device pixels, then `hinted' to the pixel grid + * in order to optimize it. The outline data can be accessed from + * the glyph slot (see note below). + * + * Note that by default, the glyph loader doesn't render outlines into + * bitmaps. The following flags are used to modify this default + * behaviour to more specific and useful cases. + * + * FT_LOAD_NO_SCALE :: + * Don't scale the outline glyph loaded, but keep it in font units. + * + * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and + * unsets @FT_LOAD_RENDER. + * + * FT_LOAD_NO_HINTING :: + * Disable hinting. This generally generates `blurrier' bitmap glyph + * when the glyph is rendered in any of the anti-aliased modes. See + * also the note below. + * + * This flag is implied by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_RENDER :: + * Call @FT_Render_Glyph after the glyph is loaded. By default, the + * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be + * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. + * + * This flag is unset by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_NO_BITMAP :: + * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this + * flag. + * + * @FT_LOAD_NO_SCALE always sets this flag. + * + * FT_LOAD_VERTICAL_LAYOUT :: + * Load the glyph for vertical text layout. _Don't_ use it as it is + * problematic currently. + * + * FT_LOAD_FORCE_AUTOHINT :: + * Indicates that the auto-hinter is preferred over the font's native + * hinter. See also the note below. + * + * FT_LOAD_CROP_BITMAP :: + * Indicates that the font driver should crop the loaded bitmap glyph + * (i.e., remove all space around its black bits). Not all drivers + * implement this. + * + * FT_LOAD_PEDANTIC :: + * Indicates that the font driver should perform pedantic verifications + * during glyph loading. This is mostly used to detect broken glyphs + * in fonts. By default, FreeType tries to handle broken fonts also. + * + * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: + * Indicates that the font driver should ignore the global advance + * width defined in the font. By default, that value is used as the + * advance width for all glyphs when the face has + * @FT_FACE_FLAG_FIXED_WIDTH set. + * + * This flag exists for historical reasons (to support buggy CJK + * fonts). + * + * FT_LOAD_NO_RECURSE :: + * This flag is only used internally. It merely indicates that the + * font driver should not load composite glyphs recursively. Instead, + * it should set the `num_subglyph' and `subglyphs' values of the + * glyph slot accordingly, and set `glyph->format' to + * @FT_GLYPH_FORMAT_COMPOSITE. + * + * The description of sub-glyphs is not available to client + * applications for now. + * + * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. + * + * FT_LOAD_IGNORE_TRANSFORM :: + * Indicates that the tranform matrix set by @FT_Set_Transform should + * be ignored. + * + * FT_LOAD_MONOCHROME :: + * This flag is used with @FT_LOAD_RENDER to indicate that you want to + * render an outline glyph to a 1-bit monochrome bitmap glyph, with + * 8 pixels packed into each byte of the bitmap data. + * + * Note that this has no effect on the hinting algorithm used. You + * should use @FT_LOAD_TARGET_MONO instead so that the + * monochrome-optimized hinting algorithm is used. + * + * FT_LOAD_LINEAR_DESIGN :: + * Indicates that the `linearHoriAdvance' and `linearVertAdvance' + * fields of @FT_GlyphSlotRec should be kept in font units. See + * @FT_GlyphSlotRec for details. + * + * FT_LOAD_NO_AUTOHINT :: + * Disable auto-hinter. See also the note below. + * + * @note: + * By default, hinting is enabled and the font's native hinter (see + * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can + * disable hinting by setting @FT_LOAD_NO_HINTING or change the + * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set + * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be + * used at all. + * + * Besides deciding which hinter to use, you can also decide which + * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. + */ #define FT_LOAD_DEFAULT 0x0 #define FT_LOAD_NO_SCALE 0x1 #define FT_LOAD_NO_HINTING 0x2 @@ -2351,8 +2356,72 @@ FT_BEGIN_HEADER /* */ + + /************************************************************************** + * + * @enum: + * FT_LOAD_TARGET_XXX + * + * @description: + * A list of values that are used to select a specific hinting algorithm + * to use by the hinter. You should OR one of these values to your + * `load_flags' when calling @FT_Load_Glyph. + * + * Note that font's native hinters may ignore the hinting algorithm you + * have specified (e.g., the TrueType bytecode interpreter). You can set + * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. + * + * Also note that @FT_LOAD_TARGET_LIGHT is an exception, in that it + * always implies @FT_LOAD_FORCE_AUTOHINT. + * + * @values: + * FT_LOAD_TARGET_NORMAL :: + * This corresponds to the default hinting algorithm, optimized for + * standard gray-level rendering. For monochrome output, use + * @FT_LOAD_TARGET_MONO instead. + * + * FT_LOAD_TARGET_LIGHT :: + * A lighter hinting algorithm for non-monochrome modes. Many + * generated glyphs are more fuzzy but better resemble its original + * shape. A bit like rendering on Mac OS X. + * + * As a special exception, this target implies @FT_LOAD_FORCE_AUTOHINT. + * + * FT_LOAD_TARGET_MONO :: + * Strong hinting algorithm that should only be used for monochrome + * output. The result is probably unpleasant if the glyph is rendered + * in non-monochrome modes. + * + * FT_LOAD_TARGET_LCD :: + * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally + * decimated LCD displays. + * + * FT_LOAD_TARGET_LCD_V :: + * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically + * decimated LCD displays. + * + * @note: + * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your + * `load_flags'. They can't be ORed. + * + * If @FT_LOAD_RENDER is also set, the glyph is rendered in the + * corresponding mode (i.e., the mode which matches the used algorithm + * best) unless @FT_LOAD_MONOCHROME is set. + * + * You can use a hinting algorithm that doesn't correspond to the same + * rendering mode. As an example, it is possible to use the `light' + * hinting algorithm and have the results rendered in horizontal LCD + * pixel mode, with code like + * + * { + * FT_Load_Glyph( face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT ); + * + * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * } + */ + #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) -#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) @@ -2360,6 +2429,18 @@ FT_BEGIN_HEADER #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) + + /* + * @macro: + * FT_LOAD_TARGET_MODE + * + * @description: + * Return the @FT_Render_Mode corresponding to a given + * @FT_LOAD_TARGET_XXX value. + */ + +#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) + /* */ @@ -2388,6 +2469,9 @@ FT_BEGIN_HEADER /* the transformation and is performed on the character size given in */ /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ /* */ + /* Note that this also transforms the `face.glyph.advance' field, but */ + /* *not* the values in `face.glyph.metrics'. */ + /* */ FT_EXPORT( void ) FT_Set_Transform( FT_Face face, FT_Matrix* matrix, @@ -2402,8 +2486,7 @@ FT_BEGIN_HEADER /* <Description> */ /* An enumeration type that lists the render modes supported by */ /* FreeType 2. Each mode corresponds to a specific type of scanline */ - /* conversion performed on the outline, as well as specific */ - /* hinting optimizations. */ + /* conversion performed on the outline. */ /* */ /* For bitmap fonts the `bitmap->pixel_mode' field in the */ /* @FT_GlyphSlotRec structure gives the format of the returned */ @@ -2415,34 +2498,30 @@ FT_BEGIN_HEADER /* anti-aliased bitmaps, using 256 levels of opacity. */ /* */ /* FT_RENDER_MODE_LIGHT :: */ - /* This is similar to @FT_RENDER_MODE_NORMAL -- you have to use */ - /* @FT_LOAD_TARGET_LIGHT in calls to @FT_Load_Glyph to get any */ - /* effect since the rendering process no longer influences the */ - /* positioning of glyph outlines. */ - /* */ - /* The resulting glyph shapes are more similar to the original, */ - /* while being a bit more fuzzy (`better shapes' instead of `better */ - /* contrast', so to say. */ + /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ + /* defined as a separate value because render modes are also used */ + /* indirectly to define hinting algorithm selectors. See */ + /* @FT_LOAD_TARGET_XXX for details. */ /* */ /* FT_RENDER_MODE_MONO :: */ /* This mode corresponds to 1-bit bitmaps. */ /* */ /* FT_RENDER_MODE_LCD :: */ - /* This mode corresponds to horizontal RGB/BGR sub-pixel displays, */ - /* like LCD-screens. It produces 8-bit bitmaps that are 3 times */ - /* the width of the original glyph outline in pixels, and which use */ - /* the @FT_PIXEL_MODE_LCD mode. */ + /* This mode corresponds to horizontal RGB and BGR sub-pixel */ + /* displays, like LCD-screens. It produces 8-bit bitmaps that are */ + /* 3 times the width of the original glyph outline in pixels, and */ + /* which use the @FT_PIXEL_MODE_LCD mode. */ /* */ /* FT_RENDER_MODE_LCD_V :: */ - /* This mode corresponds to vertical RGB/BGR sub-pixel displays */ + /* This mode corresponds to vertical RGB and BGR sub-pixel displays */ /* (like PDA screens, rotated LCD displays, etc.). It produces */ /* 8-bit bitmaps that are 3 times the height of the original */ /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ /* */ /* <Note> */ /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph are */ - /* _not filtered_ to reduce color-fringes. It is up to the caller to */ - /* perform this pass. */ + /* _not_ _filtered_ to reduce color-fringes. It is up to the caller */ + /* to perform this pass. */ /* */ typedef enum FT_Render_Mode_ { @@ -2463,7 +2542,7 @@ FT_BEGIN_HEADER /* ft_render_mode_xxx */ /* */ /* <Description> */ - /* These constats are deprecated. Use the corresponding */ + /* These constants are deprecated. Use the corresponding */ /* @FT_Render_Mode values instead. */ /* */ /* <Values> */ @@ -2480,9 +2559,9 @@ FT_BEGIN_HEADER /* FT_Render_Glyph */ /* */ /* <Description> */ - /* Converts a given glyph image to a bitmap. It does so by */ - /* inspecting the glyph image format, find the relevant renderer, and */ - /* invoke it. */ + /* Convert a given glyph image to a bitmap. It does so by inspecting */ + /* the glyph image format, finding the relevant renderer, and */ + /* invoking it. */ /* */ /* <InOut> */ /* slot :: A handle to the glyph slot containing the image to */ @@ -2490,8 +2569,8 @@ FT_BEGIN_HEADER /* */ /* <Input> */ /* render_mode :: This is the render mode used to render the glyph */ - /* image into a bitmap. See FT_Render_Mode for a list */ - /* of possible values. */ + /* image into a bitmap. See @FT_Render_Mode for a */ + /* list of possible values. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ @@ -2571,7 +2650,7 @@ FT_BEGIN_HEADER /* FT_Get_Kerning */ /* */ /* <Description> */ - /* Returns the kerning vector between two glyphs of a same face. */ + /* Return the kerning vector between two glyphs of a same face. */ /* */ /* <Input> */ /* face :: A handle to a source face object. */ @@ -2581,7 +2660,7 @@ FT_BEGIN_HEADER /* right_glyph :: The index of the right glyph in the kern pair. */ /* */ /* kern_mode :: See @FT_Kerning_Mode for more information. */ - /* Determines the scale/dimension of the returned */ + /* Determines the scale and dimension of the returned */ /* kerning vector. */ /* */ /* <Output> */ @@ -2606,14 +2685,43 @@ FT_BEGIN_HEADER FT_Vector *akerning ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Track_Kerning */ + /* */ + /* <Description> */ + /* Return the track kerning for a given face object at a given size. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* point_size :: The point size in 16.16 fractional points. */ + /* */ + /* degree :: The degree of tightness. */ + /* */ + /* <Output> */ + /* akerning :: The kerning in 16.16 fractional points. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Track_Kerning( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ); + + /*************************************************************************/ /* */ /* <Function> */ /* FT_Get_Glyph_Name */ /* */ /* <Description> */ - /* Retrieves the ASCII name of a given glyph in a face. This only */ - /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */ + /* Retrieve the ASCII name of a given glyph in a face. This only */ + /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns */ + /* TRUE. */ /* */ /* <Input> */ /* face :: A handle to a source face object. */ @@ -2624,7 +2732,7 @@ FT_BEGIN_HEADER /* buffer. */ /* */ /* <Output> */ - /* buffer :: A pointer to a target buffer where the name will be */ + /* buffer :: A pointer to a target buffer where the name is */ /* copied to. */ /* */ /* <Return> */ @@ -2633,14 +2741,14 @@ FT_BEGIN_HEADER /* <Note> */ /* An error is returned if the face doesn't provide glyph names or if */ /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' will be set to 0 to indicate an empty name. */ + /* byte of `buffer' is set to 0 to indicate an empty name. */ /* */ /* The glyph name is truncated to fit within the buffer if it is too */ /* long. The returned string is always zero-terminated. */ /* */ /* This function is not compiled within the library if the config */ - /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */ - /* `include/freetype/config/ftoptions.h' */ + /* macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in */ + /* `include/freetype/config/ftoptions.h'. */ /* */ FT_EXPORT( FT_Error ) FT_Get_Glyph_Name( FT_Face face, @@ -2655,7 +2763,7 @@ FT_BEGIN_HEADER /* FT_Get_Postscript_Name */ /* */ /* <Description> */ - /* Retrieves the ASCII Postscript name of a given face, if available. */ + /* Retrieve the ASCII Postscript name of a given face, if available. */ /* This only works with Postscript and TrueType fonts. */ /* */ /* <Input> */ @@ -2665,8 +2773,8 @@ FT_BEGIN_HEADER /* A pointer to the face's Postscript name. NULL if unavailable. */ /* */ /* <Note> */ - /* The returned pointer is owned by the face and will be destroyed */ - /* with it. */ + /* The returned pointer is owned by the face and is destroyed with */ + /* it. */ /* */ FT_EXPORT( const char* ) FT_Get_Postscript_Name( FT_Face face ); @@ -2678,20 +2786,20 @@ FT_BEGIN_HEADER /* FT_Select_Charmap */ /* */ /* <Description> */ - /* Selects a given charmap by its encoding tag (as listed in */ + /* Select a given charmap by its encoding tag (as listed in */ /* `freetype.h'). */ /* */ /* <InOut> */ /* face :: A handle to the source face object. */ /* */ /* <Input> */ - /* encoding :: A handle to the selected charmap. */ + /* encoding :: A handle to the selected encoding. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* This function will return an error if no charmap in the face */ + /* This function returns an error if no charmap in the face */ /* corresponds to the encoding queried here. */ /* */ FT_EXPORT( FT_Error ) @@ -2705,8 +2813,7 @@ FT_BEGIN_HEADER /* FT_Set_Charmap */ /* */ /* <Description> */ - /* Selects a given charmap for character code to glyph index */ - /* decoding. */ + /* Select a given charmap for character code to glyph index mapping. */ /* */ /* <InOut> */ /* face :: A handle to the source face object. */ @@ -2718,8 +2825,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* This function will return an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the face->charmaps[] */ + /* This function returns an error if the charmap is not part of */ + /* the face (i.e., if it is not listed in the `face->charmaps' */ /* table). */ /* */ FT_EXPORT( FT_Error ) @@ -2727,21 +2834,23 @@ FT_BEGIN_HEADER FT_CharMap charmap ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Get_Charmap_Index */ - /* */ - /* @description: */ - /* Retrieve index of a given charmap. */ - /* */ - /* @input: */ - /* charmap :: A handle to a charmap. */ - /* */ - /* @return: */ - /* The index into the array of character maps within the face to */ - /* which `charmap' belongs. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Get_Charmap_Index + * + * @description: + * Retrieve index of a given charmap. + * + * @input: + * charmap :: + * A handle to a charmap. + * + * @return: + * The index into the array of character maps within the face to which + * `charmap' belongs. + * + */ FT_EXPORT( FT_Int ) FT_Get_Charmap_Index( FT_CharMap charmap ); @@ -2752,8 +2861,8 @@ FT_BEGIN_HEADER /* FT_Get_Char_Index */ /* */ /* <Description> */ - /* Returns the glyph index of a given character code. This function */ - /* uses a charmap object to do the translation. */ + /* Return the glyph index of a given character code. This function */ + /* uses a charmap object to do the mapping. */ /* */ /* <Input> */ /* face :: A handle to the source face object. */ @@ -2764,10 +2873,11 @@ FT_BEGIN_HEADER /* The glyph index. 0 means `undefined character code'. */ /* */ /* <Note> */ - /* FreeType computes its own glyph indices which are not necessarily */ - /* the same as used in the font in case the font is based on glyph */ - /* indices. Reason for this behaviour is to assure that index 0 is */ - /* never used, representing the missing glyph. */ + /* If you use FreeType to manipulate the contents of font files */ + /* directly, be aware that the glyph index returned by this function */ + /* doesn't always correspond to the internal indices used within */ + /* the file. This is done to ensure that value 0 always corresponds */ + /* to the `missing glyph'. */ /* */ FT_EXPORT( FT_UInt ) FT_Get_Char_Index( FT_Face face, @@ -2781,7 +2891,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* This function is used to return the first character code in the */ - /* current charmap of a given face. It will also return the */ + /* current charmap of a given face. It also returns the */ /* corresponding glyph index. */ /* */ /* <Input> */ @@ -2813,9 +2923,9 @@ FT_BEGIN_HEADER /* } */ /* } */ /* */ - /* Note that `*agindex' will be set to 0 if the charmap is empty. */ - /* The result itself can be 0 in two cases: if the charmap is empty */ - /* or when the value 0 is the first valid character code. */ + /* Note that `*agindex' is set to 0 if the charmap is empty. The */ + /* result itself can be 0 in two cases: if the charmap is empty or */ + /* when the value 0 is the first valid character code. */ /* */ FT_EXPORT( FT_ULong ) FT_Get_First_Char( FT_Face face, @@ -2829,7 +2939,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* This function is used to return the next character code in the */ - /* current charmap of a given face following the value 'char_code', */ + /* current charmap of a given face following the value `char_code', */ /* as well as the corresponding glyph index. */ /* */ /* <Input> */ @@ -2845,11 +2955,11 @@ FT_BEGIN_HEADER /* */ /* <Note> */ /* You should use this function with @FT_Get_First_Char to walk */ - /* through all character codes available in a given charmap. See */ - /* the note for this function for a simple code example. */ + /* over all character codes available in a given charmap. See the */ + /* note for this function for a simple code example. */ /* */ - /* Note that `*agindex' will be set to 0 when there are no more codes */ - /* in the charmap. */ + /* Note that `*agindex' is set to 0 when there are no more codes in */ + /* the charmap. */ /* */ FT_EXPORT( FT_ULong ) FT_Get_Next_Char( FT_Face face, @@ -2863,7 +2973,7 @@ FT_BEGIN_HEADER /* FT_Get_Name_Index */ /* */ /* <Description> */ - /* Returns the glyph index of a given glyph name. This function uses */ + /* Return the glyph index of a given glyph name. This function uses */ /* driver specific objects to do the translation. */ /* */ /* <Input> */ @@ -2879,6 +2989,85 @@ FT_BEGIN_HEADER FT_String* glyph_name ); + /************************************************************************* + * + * @macro: + * FT_SUBGLYPH_FLAG_XXX + * + * @description: + * A list of constants used to describe subglyphs. Please refer to the + * TrueType specification for the meaning of the various flags. + * + * @values: + * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: + * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: + * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: + * FT_SUBGLYPH_FLAG_SCALE :: + * FT_SUBGLYPH_FLAG_XY_SCALE :: + * FT_SUBGLYPH_FLAG_2X2 :: + * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: + * + */ +#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 +#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 +#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 +#define FT_SUBGLYPH_FLAG_SCALE 8 +#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 +#define FT_SUBGLYPH_FLAG_2X2 0x80 +#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 + + + /************************************************************************* + * + * @func: + * FT_Get_SubGlyph_Info + * + * @description: + * Retrieve a description of a given subglyph. Only use it if + * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE, or an error is + * returned. + * + * @input: + * glyph :: + * The source glyph slot. + * + * sub_index :: + * The index of subglyph. Must be less than `glyph->num_subglyphs'. + * + * @output: + * p_index :: + * The glyph index of the subglyph. + * + * p_flags :: + * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * + * p_arg1 :: + * The subglyph's first argument (if any). + * + * p_arg2 :: + * The subglyph's second argument (if any). + * + * p_transform :: + * The subglyph transformation (if any). + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be + * interpreted depending on the flags returned in `*p_flags'. See the + * TrueType specification for details. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ); + /*************************************************************************/ /* */ @@ -3062,7 +3251,7 @@ FT_BEGIN_HEADER /* FT_Vector_Transform */ /* */ /* <Description> */ - /* Transforms a single vector through a 2x2 matrix. */ + /* Transform a single vector through a 2x2 matrix. */ /* */ /* <InOut> */ /* vector :: The target vector to transform. */ @@ -3078,6 +3267,85 @@ FT_BEGIN_HEADER const FT_Matrix* matrix ); + /*************************************************************************/ + /* */ + /* <Section> */ + /* version */ + /* */ + /* <Title> */ + /* FreeType Version */ + /* */ + /* <Abstract> */ + /* Functions and macros related to FreeType versions. */ + /* */ + /* <Description> */ + /* Note that those functions and macros are of limited use because */ + /* even a new release of FreeType with only documentation changes */ + /* increases the version number. */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @enum: + * FREETYPE_XXX + * + * @description: + * These three macros identify the FreeType source code version. + * Use @FT_Library_Version to access them at runtime. + * + * @values: + * FREETYPE_MAJOR :: The major version number. + * FREETYPE_MINOR :: The minor version number. + * FREETYPE_PATCH :: The patch level. + * + * @note: + * The version number of FreeType if built as a dynamic link library + * with the `libtool' package is _not_ controlled by these three + * macros. + */ +#define FREETYPE_MAJOR 2 +#define FREETYPE_MINOR 2 +#define FREETYPE_PATCH 1 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Library_Version */ + /* */ + /* <Description> */ + /* Return the version of the FreeType library being used. This is */ + /* useful when dynamically linking to the library, since one cannot */ + /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ + /* @FREETYPE_PATCH. */ + /* */ + /* <Input> */ + /* library :: A source library handle. */ + /* */ + /* <Output> */ + /* amajor :: The major version number. */ + /* */ + /* aminor :: The minor version number. */ + /* */ + /* apatch :: The patch version number. */ + /* */ + /* <Note> */ + /* The reason why this function takes a `library' argument is because */ + /* certain programs implement library initialization in a custom way */ + /* that doesn't use @FT_Init_FreeType. */ + /* */ + /* In such cases, the library version might not be available before */ + /* the library object has been created. */ + /* */ + FT_EXPORT( void ) + FT_Library_Version( FT_Library library, + FT_Int *amajor, + FT_Int *aminor, + FT_Int *apatch ); + + /* */ diff --git a/headers/libs/freetype2/freetype/ftbbox.h b/headers/libs/freetype2/freetype/ftbbox.h index f98c89eb2d..5f79c32740 100644 --- a/headers/libs/freetype2/freetype/ftbbox.h +++ b/headers/libs/freetype2/freetype/ftbbox.h @@ -61,7 +61,7 @@ FT_BEGIN_HEADER /* Computes the exact bounding box of an outline. This is slower */ /* than computing the control box. However, it uses an advanced */ /* algorithm which returns _very_ quickly when the two boxes */ - /* coincide. Otherwise, the outline Bezier arcs are walked over to */ + /* coincide. Otherwise, the outline Bézier arcs are walked over to */ /* extract their extrema. */ /* */ /* <Input> */ @@ -87,3 +87,8 @@ FT_END_HEADER /* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/headers/libs/freetype2/freetype/ftbdf.h b/headers/libs/freetype2/freetype/ftbdf.h index 493bca5115..9555694811 100644 --- a/headers/libs/freetype2/freetype/ftbdf.h +++ b/headers/libs/freetype2/freetype/ftbdf.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing BDF-specific strings (specification). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -182,7 +182,7 @@ FT_BEGIN_HEADER * otherwise. It also returns an error if the property is not in the * font. * - * In case of error, "aproperty->type" is always set to + * In case of error, `aproperty->type' is always set to * @BDF_PROPERTY_TYPE_NONE. */ FT_EXPORT( FT_Error ) diff --git a/headers/libs/freetype2/freetype/ftbitmap.h b/headers/libs/freetype2/freetype/ftbitmap.h index 319dd08694..39b22c0a2f 100644 --- a/headers/libs/freetype2/freetype/ftbitmap.h +++ b/headers/libs/freetype2/freetype/ftbitmap.h @@ -5,7 +5,7 @@ /* FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */ /* bitmaps into 8bpp format (specification). */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -57,7 +57,7 @@ FT_BEGIN_HEADER /* FT_Bitmap_New */ /* */ /* <Description> */ - /* Initialize a pointer to an FT_Bitmap structure. */ + /* Initialize a pointer to an @FT_Bitmap structure. */ /* */ /* <InOut> */ /* abitmap :: A pointer to the bitmap structure. */ @@ -85,7 +85,7 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_DEF( FT_Error ) + FT_EXPORT( FT_Error ) FT_Bitmap_Copy( FT_Library library, const FT_Bitmap *source, FT_Bitmap *target); @@ -120,10 +120,10 @@ FT_BEGIN_HEADER /* The current implementation restricts `xStrength' to be less than */ /* or equal to 8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ /* */ - /* Don't embolden the bitmap owned by a @FT_GlyphSlot directly! Call */ - /* @FT_Bitmap_Copy to get a copy and work on the copy instead. */ + /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ + /* you should call `FT_GlyphSlot_Own_Bitmap' on the slot first. */ /* */ - FT_EXPORT_DEF( FT_Error ) + FT_EXPORT( FT_Error ) FT_Bitmap_Embolden( FT_Library library, FT_Bitmap* bitmap, FT_Pos xStrength, diff --git a/headers/libs/freetype2/freetype/ftcache.h b/headers/libs/freetype2/freetype/ftcache.h index 985641c1b4..38b956c0ac 100644 --- a/headers/libs/freetype2/freetype/ftcache.h +++ b/headers/libs/freetype2/freetype/ftcache.h @@ -4,7 +4,7 @@ /* */ /* FreeType Cache subsystem (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -16,21 +16,6 @@ /***************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********* *********/ - /********* WARNING, THIS IS BETA CODE. *********/ - /********* *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - #ifndef __FTCACHE_H__ #define __FTCACHE_H__ @@ -42,51 +27,105 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* cache_subsystem */ - /* */ - /* <Title> */ - /* Cache Sub-System */ - /* */ - /* <Abstract> */ - /* How to cache face, size, and glyph data with FreeType 2. */ - /* */ - /* <Description> */ - /* This section describes the FreeType 2 cache sub-system which is */ - /* still in beta. */ - /* */ - /* <Order> */ - /* FTC_Manager */ - /* FTC_FaceID */ - /* FTC_Face_Requester */ - /* */ - /* FTC_Manager_New */ - /* FTC_Manager_Reset */ - /* FTC_Manager_Done */ - /* FTC_Manager_LookupFace */ - /* FTC_Manager_LookupSize */ - /* FTC_Manager_RemoveFaceID */ - /* */ - /* FTC_Node */ - /* FTC_Node_Unref */ - /* */ - /* FTC_Font */ - /* FTC_ImageCache */ - /* FTC_ImageCache_New */ - /* FTC_ImageCache_Lookup */ - /* */ - /* FTC_SBit */ - /* FTC_SBitCache */ - /* FTC_SBitCache_New */ - /* FTC_SBitCache_Lookup */ - /* */ - /* FTC_CMapCache */ - /* FTC_CMapCache_New */ - /* FTC_CMapCache_Lookup */ - /* */ - /*************************************************************************/ + /************************************************************************* + * + * <Section> + * cache_subsystem + * + * <Title> + * Cache Sub-System + * + * <Abstract> + * How to cache face, size, and glyph data with FreeType 2. + * + * <Description> + * This section describes the FreeType 2 cache sub-system, which is used + * to limit the number of concurrently opened @FT_Face and @FT_Size + * objects, as well as caching information like character maps and glyph + * images while limiting their maximum memory usage. + * + * Note that all types and functions begin with the `FTC_' prefix. + * + * The cache is highly portable and thus doesn't know anything about the + * fonts installed on your system, or how to access them. This implies + * the following scheme: + * + * First, available or installed font faces are uniquely identified by + * @FTC_FaceID values, provided to the cache by the client. Note that + * the cache only stores and compares these values, and doesn't try to + * interpret them in any way. + * + * Second, the cache calls, only when needed, a client-provided function + * to convert a @FTC_FaceID into a new @FT_Face object. The latter is + * then completely managed by the cache, including its termination + * through @FT_Done_Face. + * + * Clients are free to map face IDs to anything else. The most simple + * usage is to associate them to a (pathname,face_index) pair that is + * used to call @FT_New_Face. However, more complex schemes are also + * possible. + * + * Note that for the cache to work correctly, the face ID values must be + * *persistent*, which means that the contents they point to should not + * change at runtime, or that their value should not become invalid. + * + * If this is unavoidable (e.g., when a font is uninstalled at runtime), + * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let + * the cache get rid of any references to the old @FTC_FaceID it may + * keep internally. Failure to do so will lead to incorrect behaviour + * or even crashes. + * + * To use the cache, start with calling @FTC_Manager_New to create a new + * @FTC_Manager object, which models a single cache instance. You can + * then look up @FT_Face and @FT_Size objects with + * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively. + * + * If you want to use the charmap caching, call @FTC_CMapCache_New, then + * later use @FTC_CMapCache_Lookup to perform the equivalent of + * @FT_Get_Char_Index, only much faster. + * + * If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then + * later use @FTC_ImageCache_Lookup to retrieve the corresponding + * @FT_Glyph objects from the cache. + * + * If you need lots of small bitmaps, it is much more memory efficient + * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This + * returns @FTC_SBitRec structures, which are used to store small + * bitmaps directly. (A small bitmap is one whose metrics and + * dimensions all fit into 8-bit integers). + * + * We hope to also provide a kerning cache in the near future. + * + * + * <Order> + * FTC_Manager + * FTC_FaceID + * FTC_Face_Requester + * + * FTC_Manager_New + * FTC_Manager_Reset + * FTC_Manager_Done + * FTC_Manager_LookupFace + * FTC_Manager_LookupSize + * FTC_Manager_RemoveFaceID + * + * FTC_Node + * FTC_Node_Unref + * + * FTC_ImageCache + * FTC_ImageCache_New + * FTC_ImageCache_Lookup + * + * FTC_SBit + * FTC_SBitCache + * FTC_SBitCache_New + * FTC_SBitCache_Lookup + * + * FTC_CMapCache + * FTC_CMapCache_New + * FTC_CMapCache_Lookup + * + *************************************************************************/ /*************************************************************************/ @@ -100,108 +139,84 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_FaceID */ - /* */ - /* <Description> */ - /* An opaque pointer type that is used to identity face objects. The */ - /* contents of such objects is application-dependent. */ - /* */ + /************************************************************************* + * + * @type: FTC_FaceID + * + * @description: + * An opaque pointer type that is used to identity face objects. The + * contents of such objects is application-dependent. + * + * These pointers are typically used to point to a user-defined + * structure containing a font file path, and face index. + * + * @note: + * Never use NULL as a valid @FTC_FaceID. + * + * Face IDs are passed by the client to the cache manager, which calls, + * when needed, the @FTC_Face_Requester to translate them into new + * @FT_Face objects. + * + * If the content of a given face ID changes at runtime, or if the value + * becomes invalid (e.g., when uninstalling a font), you should + * immediately call @FTC_Manager_RemoveFaceID before any other cache + * function. + * + * Failure to do so will result in incorrect behaviour or even + * memory leaks and crashes. + */ typedef struct FTC_FaceIDRec_* FTC_FaceID; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FTC_Face_Requester */ - /* */ - /* <Description> */ - /* A callback function provided by client applications. It is used */ - /* to translate a given @FTC_FaceID into a new valid @FT_Face object. */ - /* */ - /* <Input> */ - /* face_id :: The face ID to resolve. */ - /* */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* data :: Application-provided request data. */ - /* */ - /* <Output> */ - /* aface :: A new @FT_Face handle. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The face requester should not perform funny things on the returned */ - /* face object, like creating a new @FT_Size for it, or setting a */ - /* transformation through @FT_Set_Transform! */ - /* */ + /************************************************************************ + * + * @functype: + * FTC_Face_Requester + * + * @description: + * A callback function provided by client applications. It is used by + * the cache manager to translate a given @FTC_FaceID into a new valid + * @FT_Face object, on demand. + * + * <Input> + * face_id :: + * The face ID to resolve. + * + * library :: + * A handle to a FreeType library object. + * + * req_data :: + * Application-provided request data (see note below). + * + * <Output> + * aface :: + * A new @FT_Face handle. + * + * <Return> + * FreeType error code. 0 means success. + * + * <Note> + * The third parameter `req_data' is the same as the one passed by the + * client when @FTC_Manager_New is called. + * + * The face requester should not perform funny things on the returned + * face object, like creating a new @FT_Size for it, or setting a + * transformation through @FT_Set_Transform! + */ typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face* aface ); + /* */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_FontRec */ - /* */ - /* <Description> */ - /* A simple structure used to describe a given `font' to the cache */ - /* manager. Note that a `font' is the combination of a given face */ - /* with a given character size. */ - /* */ - /* <Fields> */ - /* face_id :: The ID of the face to use. */ - /* */ - /* pix_width :: The character width in integer pixels. */ - /* */ - /* pix_height :: The character height in integer pixels. */ - /* */ - typedef struct FTC_FontRec_ - { - FTC_FaceID face_id; - FT_UShort pix_width; - FT_UShort pix_height; +#define FT_POINTER_TO_ULONG( p ) ( (FT_ULong)(FT_Pointer)(p) ) - } FTC_FontRec; - - - /* */ - - -#define FTC_FONT_COMPARE( f1, f2 ) \ - ( (f1)->face_id == (f2)->face_id && \ - (f1)->pix_width == (f2)->pix_width && \ - (f1)->pix_height == (f2)->pix_height ) - -#define FT_POINTER_TO_ULONG( p ) ((FT_ULong)(FT_Pointer)(p)) - -#define FTC_FACE_ID_HASH( i ) \ - ((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^ \ +#define FTC_FACE_ID_HASH( i ) \ + ((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^ \ ( FT_POINTER_TO_ULONG( i ) << 7 ) ) ) -#define FTC_FONT_HASH( f ) \ - (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \ - ((f)->pix_width << 8) ^ \ - ((f)->pix_height) ) - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Font */ - /* */ - /* <Description> */ - /* A simple handle to an @FTC_FontRec structure. */ - /* */ - typedef FTC_FontRec* FTC_Font; - /*************************************************************************/ /*************************************************************************/ @@ -220,8 +235,20 @@ FT_BEGIN_HEADER /* FTC_Manager */ /* */ /* <Description> */ - /* This object is used to cache one or more @FT_Face objects, along */ - /* with corresponding @FT_Size objects. */ + /* This object corresponds to one instance of the cache-subsystem. */ + /* It is used to cache one or more @FT_Face objects, along with */ + /* corresponding @FT_Size objects. */ + /* */ + /* The manager intentionally limits the total number of opened */ + /* @FT_Face and @FT_Size objects to control memory usage. See the */ + /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */ + /* */ + /* The manager is also used to cache `nodes' of various types while */ + /* limiting their total memory usage. */ + /* */ + /* All limitations are enforced by keeping lists of managed objects */ + /* in most-recently-used order, and flushing old nodes to make room */ + /* for new ones. */ /* */ typedef struct FTC_ManagerRec_* FTC_Manager; @@ -236,9 +263,9 @@ FT_BEGIN_HEADER /* reference-counted. A node with a count of 0 might be flushed */ /* out of a full cache whenever a lookup request is performed. */ /* */ - /* If you lookup nodes, you have the ability to "acquire" them, i.e., */ + /* If you lookup nodes, you have the ability to `acquire' them, i.e., */ /* to increment their reference count. This will prevent the node */ - /* from being flushed out of the cache until you explicitly "release" */ + /* from being flushed out of the cache until you explicitly `release' */ /* it (see @FTC_Node_Unref). */ /* */ /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ @@ -255,16 +282,23 @@ FT_BEGIN_HEADER /* Creates a new cache manager. */ /* */ /* <Input> */ - /* library :: The parent FreeType library handle to use. */ + /* library :: The parent FreeType library handle to use. */ /* */ - /* max_bytes :: Maximum number of bytes to use for cached data. */ - /* Use 0 for defaults. */ + /* max_faces :: Maximum number of opened @FT_Face objects managed by */ + /* this cache instance. Use 0 for defaults. */ /* */ - /* requester :: An application-provided callback used to translate */ - /* face IDs into real @FT_Face objects. */ + /* max_sizes :: Maximum number of opened @FT_Size objects managed by */ + /* this cache instance. Use 0 for defaults. */ /* */ - /* req_data :: A generic pointer that is passed to the requester */ - /* each time it is called (see @FTC_Face_Requester). */ + /* max_bytes :: Maximum number of bytes to use for cached data nodes. */ + /* Use 0 for defaults. Note that this value does not */ + /* account for managed @FT_Face and @FT_Size objects. */ + /* */ + /* requester :: An application-provided callback used to translate */ + /* face IDs into real @FT_Face objects. */ + /* */ + /* req_data :: A generic pointer that is passed to the requester */ + /* each time it is called (see @FTC_Face_Requester). */ /* */ /* <Output> */ /* amanager :: A handle to a new manager object. 0 in case of */ @@ -346,6 +380,14 @@ FT_BEGIN_HEADER /* the @FT_Set_Transform function) on a returned face! If you need */ /* to transform glyphs, do it yourself after glyph loading. */ /* */ + /* When you perform a lookup, out-of-memory errors are detected */ + /* _within_ the lookup and force incremental flushes of the cache */ + /* until enough memory is released for the lookup to succeed. */ + /* */ + /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ + /* already been completely flushed, and still no memory was available */ + /* for the operation. */ + /* */ FT_EXPORT( FT_Error ) FTC_Manager_LookupFace( FTC_Manager manager, FTC_FaceID face_id, @@ -402,7 +444,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Retrieve the @FT_Size object that corresponds to a given */ - /* @FTC_Scaler through a cache manager. */ + /* @FTC_ScalerRec pointer through a cache manager. */ /* */ /* <Input> */ /* manager :: A handle to the cache manager. */ @@ -423,6 +465,15 @@ FT_BEGIN_HEADER /* if you need it. Note that this object is also owned by the */ /* manager. */ /* */ + /* <Note> */ + /* When you perform a lookup, out-of-memory errors are detected */ + /* _within_ the lookup and force incremental flushes of the cache */ + /* until enough memory is released for the lookup to succeed. */ + /* */ + /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ + /* already been completely flushed, and still no memory is available */ + /* for the operation. */ + /* */ FT_EXPORT( FT_Error ) FTC_Manager_LookupSize( FTC_Manager manager, FTC_Scaler scaler, @@ -449,7 +500,33 @@ FT_BEGIN_HEADER FTC_Manager manager ); - /* remove all nodes belonging to a given face_id */ + /************************************************************************* + * + * @function: + * FTC_Manager_RemoveFaceID + * + * @description: + * A special function used to indicate to the cache manager that + * a given @FTC_FaceID is no longer valid, either because its + * content changed, or because it was deallocated or uninstalled. + * + * @input: + * manager :: + * The cache manager handle. + * + * face_id :: + * The @FTC_FaceID to be removed. + * + * @note: + * This function flushes all nodes from the cache corresponding to this + * `face_id', with the exception of nodes with a non-null reference + * count. + * + * Such nodes are however modified internally so as to never appear + * in later lookups with the same `face_id' value, and to be immediately + * destroyed when released by all their users. + * + */ FT_EXPORT( void ) FTC_Manager_RemoveFaceID( FTC_Manager manager, FTC_FaceID face_id ); @@ -462,65 +539,74 @@ FT_BEGIN_HEADER /* */ /*************************************************************************/ - /************************************************************************ + /************************************************************************* * * @type: - * FTC_CMapCache + * FTC_CMapCache * * @description: - * An opaque handle used to manager a charmap cache. This cache is - * to hold character codes -> glyph indices mappings. + * An opaque handle used to model a charmap cache. This cache is to + * hold character codes -> glyph indices mappings. + * */ typedef struct FTC_CMapCacheRec_* FTC_CMapCache; - /*************************************************************************/ - /* */ - /* @function: */ - /* FTC_CMapCache_New */ - /* */ - /* @description: */ - /* Create a new charmap cache. */ - /* */ - /* @input: */ - /* manager :: A handle to the cache manager. */ - /* */ - /* @output: */ - /* acache :: A new cache handle. NULL in case of error. */ - /* */ - /* @return: */ - /* FreeType error code. 0 means success. */ - /* */ - /* @note: */ - /* Like all other caches, this one will be destroyed with the cache */ - /* manager. */ - /* */ + /************************************************************************* + * + * @function: + * FTC_CMapCache_New + * + * @description: + * Create a new charmap cache. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * @output: + * acache :: + * A new cache handle. NULL in case of error. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * Like all other caches, this one will be destroyed with the cache + * manager. + * + */ FT_EXPORT( FT_Error ) FTC_CMapCache_New( FTC_Manager manager, FTC_CMapCache *acache ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FTC_CMapCache_Lookup */ - /* */ - /* @description: */ - /* Translate a character code into a glyph index, using the charmap */ - /* cache. */ - /* */ - /* @input: */ - /* cache :: A charmap cache handle. */ - /* */ - /* face_id :: The source face ID. */ - /* */ - /* cmap_index :: The index of the charmap in the source face. */ - /* */ - /* char_code :: The character code (in the corresponding charmap). */ - /* */ - /* @return: */ - /* Glyph index. 0 means `no glyph'. */ - /* */ + /************************************************************************ + * + * @function: + * FTC_CMapCache_Lookup + * + * @description: + * Translate a character code into a glyph index, using the charmap + * cache. + * + * @input: + * cache :: + * A charmap cache handle. + * + * face_id :: + * The source face ID. + * + * cmap_index :: + * The index of the charmap in the source face. + * + * char_code :: + * The character code (in the corresponding charmap). + * + * @return: + * Glyph index. 0 means `no glyph'. + * + */ FT_EXPORT( FT_UInt ) FTC_CMapCache_Lookup( FTC_CMapCache cache, FTC_FaceID face_id, @@ -546,26 +632,63 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ + + /************************************************************************* + * + * @struct: + * FTC_ImageTypeRec + * + * @description: + * A structure used to model the type of images in a glyph cache. + * + * @fields: + * face_id :: + * The face ID. + * + * width :: + * The width in pixels. + * + * height :: + * The height in pixels. + * + * flags :: + * The load flags, as in @FT_Load_Glyph. + * + */ typedef struct FTC_ImageTypeRec_ { - FTC_FaceID face_id; - FT_Int width; - FT_Int height; - FT_Int32 flags; + FTC_FaceID face_id; + FT_Int width; + FT_Int height; + FT_Int32 flags; } FTC_ImageTypeRec; - typedef struct FTC_ImageTypeRec_* FTC_ImageType; - /* */ + /************************************************************************* + * + * @type: + * FTC_ImageType + * + * @description: + * A handle to an @FTC_ImageTypeRec structure. + * + */ + typedef struct FTC_ImageTypeRec_* FTC_ImageType; -#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ - ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \ - (d1)->flags == (d2)->flags ) -#define FTC_IMAGE_TYPE_HASH( d ) \ - (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \ - ( (d)->flags << 4 ) ) + /* */ + + +#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ + ( (d1)->face_id == (d2)->face_id && \ + (d1)->width == (d2)->width && \ + (d1)->flags == (d2)->flags ) + +#define FTC_IMAGE_TYPE_HASH( d ) \ + (FT_UFast)( FTC_FACE_ID_HASH( (d)->face_id ) ^ \ + ( (d)->width << 8 ) ^ (d)->height ^ \ + ( (d)->flags << 4 ) ) /*************************************************************************/ @@ -636,12 +759,12 @@ FT_BEGIN_HEADER /* */ /* If `anode' is _not_ NULL, it receives the address of the cache */ /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the FT_Glyph) will */ + /* count. This ensures that the node (as well as the @FT_Glyph) will */ /* always be kept in the cache until you call @FTC_Node_Unref to */ /* `release' it. */ /* */ /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the FT_Glyph could be flushed out of the cache on the next */ + /* that the @FT_Glyph could be flushed out of the cache on the next */ /* call to one of the caching sub-system APIs. Don't assume that it */ /* is persistent! */ /* */ @@ -807,6 +930,66 @@ FT_BEGIN_HEADER FTC_Node *anode ); + /* */ + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + /*@***********************************************************************/ + /* */ + /* <Struct> */ + /* FTC_FontRec */ + /* */ + /* <Description> */ + /* A simple structure used to describe a given `font' to the cache */ + /* manager. Note that a `font' is the combination of a given face */ + /* with a given character size. */ + /* */ + /* <Fields> */ + /* face_id :: The ID of the face to use. */ + /* */ + /* pix_width :: The character width in integer pixels. */ + /* */ + /* pix_height :: The character height in integer pixels. */ + /* */ + typedef struct FTC_FontRec_ + { + FTC_FaceID face_id; + FT_UShort pix_width; + FT_UShort pix_height; + + } FTC_FontRec; + + + /* */ + + +#define FTC_FONT_COMPARE( f1, f2 ) \ + ( (f1)->face_id == (f2)->face_id && \ + (f1)->pix_width == (f2)->pix_width && \ + (f1)->pix_height == (f2)->pix_height ) + +#define FTC_FONT_HASH( f ) \ + (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \ + ((f)->pix_width << 8) ^ \ + ((f)->pix_height) ) + + typedef FTC_FontRec* FTC_Font; + + + FT_EXPORT( FT_Error ) + FTC_Manager_Lookup_Face( FTC_Manager manager, + FTC_FaceID face_id, + FT_Face *aface ); + + FT_EXPORT( FT_Error ) + FTC_Manager_Lookup_Size( FTC_Manager manager, + FTC_Font font, + FT_Face *aface, + FT_Size *asize ); + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + /* */ FT_END_HEADER diff --git a/headers/libs/freetype2/freetype/ftchapters.h b/headers/libs/freetype2/freetype/ftchapters.h index 781160bd2c..477daa5b96 100644 --- a/headers/libs/freetype2/freetype/ftchapters.h +++ b/headers/libs/freetype2/freetype/ftchapters.h @@ -6,6 +6,20 @@ /***************************************************************************/ +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* general_remarks */ +/* */ +/* <Title> */ +/* General Remarks */ +/* */ +/* <Sections> */ +/* user_allocation */ +/* */ +/***************************************************************************/ + + /***************************************************************************/ /* */ /* <Chapter> */ @@ -15,6 +29,7 @@ /* Core API */ /* */ /* <Sections> */ +/* version */ /* basic_types */ /* base_interface */ /* glyph_management */ @@ -24,6 +39,7 @@ /* */ /***************************************************************************/ + /***************************************************************************/ /* */ /* <Chapter> */ @@ -40,7 +56,6 @@ /* bdf_fonts */ /* pfr_fonts */ /* winfnt_fonts */ -/* ot_validation */ /* */ /***************************************************************************/ diff --git a/headers/libs/freetype2/freetype/fterrdef.h b/headers/libs/freetype2/freetype/fterrdef.h index 2f73c08589..ab8c3f7d92 100644 --- a/headers/libs/freetype2/freetype/fterrdef.h +++ b/headers/libs/freetype2/freetype/fterrdef.h @@ -4,7 +4,7 @@ /* */ /* FreeType error codes (specification). */ /* */ -/* Copyright 2002, 2004 by */ +/* Copyright 2002, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -52,6 +52,8 @@ "broken table" ) FT_ERRORDEF_( Invalid_Offset, 0x09, \ "broken offset within table" ) + FT_ERRORDEF_( Array_Too_Large, 0x0A, \ + "array allocation size too large" ) /* glyph/character errors */ @@ -226,6 +228,8 @@ "`ENCODING' field missing" ) FT_ERRORDEF_( Missing_Bbx_Field, 0xB6, \ "`BBX' field missing" ) + FT_ERRORDEF_( Bbx_Too_Big, 0xB7, \ + "`BBX' too big" ) /* END */ diff --git a/headers/libs/freetype2/freetype/ftglyph.h b/headers/libs/freetype2/freetype/ftglyph.h index 14050a21d9..08058dadd1 100644 --- a/headers/libs/freetype2/freetype/ftglyph.h +++ b/headers/libs/freetype2/freetype/ftglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType convenience functions to handle glyphs (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -134,10 +134,10 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* A structure used for bitmap glyph images. This really is a */ - /* `sub-class' of `FT_GlyphRec'. */ + /* `sub-class' of @FT_GlyphRec. */ /* */ /* <Fields> */ - /* root :: The root FT_Glyph fields. */ + /* root :: The root @FT_Glyph fields. */ /* */ /* left :: The left-side bearing, i.e., the horizontal distance */ /* from the current pen position to the left border of the */ @@ -150,11 +150,11 @@ FT_BEGIN_HEADER /* bitmap :: A descriptor for the bitmap. */ /* */ /* <Note> */ - /* You can typecast FT_Glyph to FT_BitmapGlyph if you have */ - /* glyph->format == FT_GLYPH_FORMAT_BITMAP. This lets you access */ + /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ + /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ /* the bitmap's contents easily. */ /* */ - /* The corresponding pixel buffer is always owned by the BitmapGlyph */ + /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ /* and is thus created and destroyed with it. */ /* */ typedef struct FT_BitmapGlyphRec_ @@ -186,21 +186,21 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* A structure used for outline (vectorial) glyph images. This */ - /* really is a `sub-class' of `FT_GlyphRec'. */ + /* really is a `sub-class' of @FT_GlyphRec. */ /* */ /* <Fields> */ - /* root :: The root FT_Glyph fields. */ + /* root :: The root @FT_Glyph fields. */ /* */ /* outline :: A descriptor for the outline. */ /* */ /* <Note> */ - /* You can typecast FT_Glyph to FT_OutlineGlyph if you have */ - /* glyph->format == FT_GLYPH_FORMAT_OUTLINE. This lets you access */ + /* You can typecast a @FT_Glyph to @FT_OutlineGlyph if you have */ + /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ /* the outline's content easily. */ /* */ /* As the outline is extracted from a glyph slot, its coordinates are */ /* expressed normally in 26.6 pixels, unless the flag */ - /* FT_LOAD_NO_SCALE was used in FT_Load_Glyph() or FT_Load_Char(). */ + /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ /* */ /* The outline's tables are always owned by the object and are */ /* destroyed with it. */ @@ -277,8 +277,7 @@ FT_BEGIN_HEADER /* expressed in 1/64th of a pixel. */ /* */ /* <Return> */ - /* FreeType error code (the glyph format is not scalable if it is */ - /* not zero). */ + /* FreeType error code (if not 0, the glyph format is not scalable). */ /* */ /* <Note> */ /* The 2x2 transformation matrix is also applied to the glyph's */ @@ -335,11 +334,11 @@ FT_BEGIN_HEADER /* @FT_Glyph_BBox_Mode values instead. */ /* */ /* <Values> */ - /* ft_glyph_bbox_unscaled :: see @FT_GLYPH_BBOX_UNSCALED */ - /* ft_glyph_bbox_subpixels :: see @FT_GLYPH_BBOX_SUBPIXELS */ - /* ft_glyph_bbox_gridfit :: see @FT_GLYPH_BBOX_GRIDFIT */ - /* ft_glyph_bbox_truncate :: see @FT_GLYPH_BBOX_TRUNCATE */ - /* ft_glyph_bbox_pixels :: see @FT_GLYPH_BBOX_PIXELS */ + /* ft_glyph_bbox_unscaled :: See @FT_GLYPH_BBOX_UNSCALED. */ + /* ft_glyph_bbox_subpixels :: See @FT_GLYPH_BBOX_SUBPIXELS. */ + /* ft_glyph_bbox_gridfit :: See @FT_GLYPH_BBOX_GRIDFIT. */ + /* ft_glyph_bbox_truncate :: See @FT_GLYPH_BBOX_TRUNCATE. */ + /* ft_glyph_bbox_pixels :: See @FT_GLYPH_BBOX_PIXELS. */ /* */ #define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED #define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS @@ -354,11 +353,11 @@ FT_BEGIN_HEADER /* FT_Glyph_Get_CBox */ /* */ /* <Description> */ - /* Returns a glyph's `control box'. The control box encloses all the */ - /* outline's points, including Bezier control points. Though it */ + /* Return a glyph's `control box'. The control box encloses all the */ + /* outline's points, including Bézier control points. Though it */ /* coincides with the exact bounding box for most glyphs, it can be */ /* slightly larger in some situations (like when rotating an outline */ - /* which contains Bezier outside arcs). */ + /* which contains Bézier outside arcs). */ /* */ /* Computing the control box is very fast, while getting the bounding */ /* box can take much more time as it needs to walk over all segments */ @@ -379,32 +378,36 @@ FT_BEGIN_HEADER /* Coordinates are relative to the glyph origin, using the Y-upwards */ /* convention. */ /* */ - /* If the glyph has been loaded with FT_LOAD_NO_SCALE, `bbox_mode' */ - /* must be set to `FT_GLYPH_BBOX_UNSCALED' to get unscaled font */ - /* units in 26.6 pixel format. The value `FT_GLYPH_BBOX_SUBPIXELS' */ + /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ + /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ + /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ /* is another name for this constant. */ /* */ /* Note that the maximum coordinates are exclusive, which means that */ /* one can compute the width and height of the glyph image (be it in */ /* integer or 26.6 pixels) as: */ /* */ + /* { */ /* width = bbox.xMax - bbox.xMin; */ /* height = bbox.yMax - bbox.yMin; */ + /* } */ /* */ /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ - /* `FT_GLYPH_BBOX_GRIDFIT', the coordinates will also be grid-fitted, */ + /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ /* which corresponds to: */ /* */ + /* { */ /* bbox.xMin = FLOOR(bbox.xMin); */ /* bbox.yMin = FLOOR(bbox.yMin); */ /* bbox.xMax = CEILING(bbox.xMax); */ /* bbox.yMax = CEILING(bbox.yMax); */ + /* } */ /* */ /* To get the bbox in pixel coordinates, set `bbox_mode' to */ - /* `FT_GLYPH_BBOX_TRUNCATE'. */ + /* @FT_GLYPH_BBOX_TRUNCATE. */ /* */ /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ - /* to `FT_GLYPH_BBOX_PIXELS'. */ + /* to @FT_GLYPH_BBOX_PIXELS. */ /* */ FT_EXPORT( void ) FT_Glyph_Get_CBox( FT_Glyph glyph, @@ -443,7 +446,7 @@ FT_BEGIN_HEADER /* The glyph image is translated with the `origin' vector before */ /* rendering. */ /* */ - /* The first parameter is a pointer to a FT_Glyph handle, that will */ + /* The first parameter is a pointer to an @FT_Glyph handle, that will */ /* be replaced by this function. Typically, you would use (omitting */ /* error handling): */ /* */ @@ -502,6 +505,8 @@ FT_BEGIN_HEADER FT_EXPORT( void ) FT_Done_Glyph( FT_Glyph glyph ); + /* */ + /* other helpful functions */ @@ -563,3 +568,8 @@ FT_END_HEADER /* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/headers/libs/freetype2/freetype/ftgxval.h b/headers/libs/freetype2/freetype/ftgxval.h new file mode 100644 index 0000000000..c7ea861a0d --- /dev/null +++ b/headers/libs/freetype2/freetype/ftgxval.h @@ -0,0 +1,358 @@ +/***************************************************************************/ +/* */ +/* ftgxval.h */ +/* */ +/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ +/* */ +/* Copyright 2004, 2005, 2006 by */ +/* Masatake YAMATO, Redhat K.K, */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* gxvalid is derived from both gxlayout module and otvalid module. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ +/***************************************************************************/ + + +#ifndef __FTGXVAL_H__ +#define __FTGXVAL_H__ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* gx_validation */ + /* */ + /* <Title> */ + /* TrueTypeGX/AAT Validation */ + /* */ + /* <Abstract> */ + /* An API to validate TrueTypeGX/AAT tables. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions to validate */ + /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ + /* trak, prop, lcar). */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* Warning: Use FT_VALIDATE_XXX to validate a table. */ + /* Following definitions are for gxvalid developers. */ + /* */ + /* */ + /*************************************************************************/ + +#define FT_VALIDATE_feat_INDEX 0 +#define FT_VALIDATE_mort_INDEX 1 +#define FT_VALIDATE_morx_INDEX 2 +#define FT_VALIDATE_bsln_INDEX 3 +#define FT_VALIDATE_just_INDEX 4 +#define FT_VALIDATE_kern_INDEX 5 +#define FT_VALIDATE_opbd_INDEX 6 +#define FT_VALIDATE_trak_INDEX 7 +#define FT_VALIDATE_prop_INDEX 8 +#define FT_VALIDATE_lcar_INDEX 9 +#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX + + + /************************************************************************* + * + * @macro: + * FT_VALIDATE_GX_LENGTH + * + * @description: + * The number of tables checked in this module. Use it as a parameter + * for the `table-length' argument of function @FT_TrueTypeGX_Validate. + */ +#define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1) + + /* */ + + /* Up to 0x1000 is used by otvalid. + Ox2xxx is reserved for feature OT extension. */ +#define FT_VALIDATE_GX_START 0x4000 +#define FT_VALIDATE_GX_BITFIELD( tag ) \ + ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_GXXXX + * + * @description: + * A list of bit-field constants used with @FT_TrueTypeGX_Validate to + * indicate which TrueTypeGX/AAT Type tables should be validated. + * + * @values: + * FT_VALIDATE_feat :: + * Validate `feat' table. + * + * FT_VALIDATE_mort :: + * Validate `mort' table. + * + * FT_VALIDATE_morx :: + * Validate `morx' table. + * + * FT_VALIDATE_bsln :: + * Validate `bsln' table. + * + * FT_VALIDATE_just :: + * Validate `just' table. + * + * FT_VALIDATE_kern :: + * Validate `kern' table. + * + * FT_VALIDATE_opbd :: + * Validate `opbd' table. + * + * FT_VALIDATE_trak :: + * Validate `trak' table. + * + * FT_VALIDATE_prop :: + * Validate `prop' table. + * + * FT_VALIDATE_lcar :: + * Validate `lcar' table. + * + * FT_VALIDATE_GX :: + * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, + * opbd, trak, prop and lcar). + * + */ + +#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) +#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) +#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) +#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) +#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) +#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) +#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) +#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) +#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) +#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) + +#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ + FT_VALIDATE_mort | \ + FT_VALIDATE_morx | \ + FT_VALIDATE_bsln | \ + FT_VALIDATE_just | \ + FT_VALIDATE_kern | \ + FT_VALIDATE_opbd | \ + FT_VALIDATE_trak | \ + FT_VALIDATE_prop | \ + FT_VALIDATE_lcar ) + + + /* */ + + /********************************************************************** + * + * @function: + * FT_TrueTypeGX_Validate + * + * @description: + * Validate various TrueTypeGX tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library which + * actually does the text layout can access those tables without + * error checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field which specifies the tables to be validated. See + * @FT_VALIDATE_GXXXX for possible values. + * + * table_length :: + * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH + * should be passed. + * + * @output: + * tables :: + * The array where all validated sfnt tables are stored. + * The array itself must be allocated by a client. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function only works with TrueTypeGX fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the buffers pointed to by + * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value + * indicates that the table either doesn't exist in the font, the + * application hasn't asked for validation, or the validator doesn't have + * the ability to validate the sfnt table. + */ + FT_EXPORT( FT_Error ) + FT_TrueTypeGX_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ); + + + /* */ + + /********************************************************************** + * + * @function: + * FT_TrueTypeGX_Free + * + * @description: + * Free the buffer allocated by TrueTypeGX validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer allocated by + * @FT_TrueTypeGX_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_TrueTypeGX_Validate only. + */ + FT_EXPORT( void ) + FT_TrueTypeGX_Free( FT_Face face, + FT_Bytes table ); + + + /* */ + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_CKERNXXX + * + * @description: + * A list of bit-field constants used with @FT_ClassicKern_Validate + * to indicate the classic kern dialect or dialects. If the selected + * type doesn't fit, @FT_ClassicKern_Validate regards the table as + * invalid. + * + * @values: + * FT_VALIDATE_MS :: + * Handle the `kern' table as a classic Microsoft kern table. + * + * FT_VALIDATE_APPLE :: + * Handle the `kern' table as a classic Apple kern table. + * + * FT_VALIDATE_CKERN :: + * Handle the `kern' as either classic Apple or Microsoft kern table. + */ +#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) +#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) + +#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) + + + /* */ + + /********************************************************************** + * + * @function: + * FT_ClassicKern_Validate + * + * @description: + * Validate classic (16bit format) kern table to assure that the offsets + * and indices are valid. The idea is that a higher-level library which + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both + * the new 32bit format and the classic 16bit format, while + * FT_ClassicKern_Validate only supports the classic 16bit format. + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field which specifies the dialect to be validated. See + * @FT_VALIDATE_CKERNXXX for possible values. + * + * @output: + * ckern_table :: + * A pointer to the kern table. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * After use, the application should deallocate the buffers pointed to by + * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value + * indicates that the table doesn't exist in the font. + */ + FT_EXPORT( FT_Error ) + FT_ClassicKern_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *ckern_table ); + + + /* */ + + /********************************************************************** + * + * @function: + * FT_ClassicKern_Free + * + * @description: + * Free the buffer allocated by classic Kern validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_ClassicKern_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_ClassicKern_Validate only. + */ + FT_EXPORT( void ) + FT_ClassicKern_Free( FT_Face face, + FT_Bytes table ); + + + /* */ + + +FT_END_HEADER + +#endif /* __FTGXVAL_H__ */ + + +/* END */ diff --git a/headers/libs/freetype2/freetype/ftgzip.h b/headers/libs/freetype2/freetype/ftgzip.h index ded96bec6d..9893437bfa 100644 --- a/headers/libs/freetype2/freetype/ftgzip.h +++ b/headers/libs/freetype2/freetype/ftgzip.h @@ -4,7 +4,7 @@ /* */ /* Gzip-compressed stream support. */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -55,13 +55,15 @@ FT_BEGIN_HEADER * * @description: * Open a new stream to parse gzip-compressed font files. This is - * mainly used to support the compressed *.pcf.gz fonts that come + * mainly used to support the compressed `*.pcf.gz' fonts that come * with XFree86. * * @input: - * stream :: The target embedding stream. + * stream :: + * The target embedding stream. * - * source :: The source stream. + * source :: + * The source stream. * * @return: * FreeType error code. 0 means success. @@ -69,8 +71,8 @@ FT_BEGIN_HEADER * @note: * The source stream must be opened _before_ calling this function. * - * Calling the internal function FT_Stream_Close on the new stream will - * *not* call FT_Stream_Close on the source stream. None of the stream + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream * objects will be released to the heap. * * The stream implementation is very basic and resets the decompression @@ -82,8 +84,8 @@ FT_BEGIN_HEADER * compressed file, the library will try to open a gzipped stream from * it and re-open the face with it. * - * This function may return "FT_Err_Unimplemented" if your build of - * FreeType was not compiled with zlib support. + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with zlib support. */ FT_EXPORT( FT_Error ) FT_Stream_OpenGzip( FT_Stream stream, diff --git a/headers/libs/freetype2/freetype/ftimage.h b/headers/libs/freetype2/freetype/ftimage.h index f1f9aa2762..68629c9bb0 100644 --- a/headers/libs/freetype2/freetype/ftimage.h +++ b/headers/libs/freetype2/freetype/ftimage.h @@ -5,7 +5,7 @@ /* FreeType glyph image formats and default raster interface */ /* (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -129,7 +129,7 @@ FT_BEGIN_HEADER /* FT_PIXEL_MODE_GRAY :: */ /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ /* images. Each pixel is stored in one byte. Note that the number */ - /* of value "gray" levels is stored in the `num_bytes' field of */ + /* of value `gray' levels is stored in the `num_bytes' field of */ /* the @FT_Bitmap structure (it generally is 256). */ /* */ /* FT_PIXEL_MODE_GRAY2 :: */ @@ -144,15 +144,15 @@ FT_BEGIN_HEADER /* */ /* FT_PIXEL_MODE_LCD :: */ /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ - /* images used for display on LCD displays; the bitmap's width is */ - /* three times wider than the original glyph image. See also */ + /* images used for display on LCD displays; the bitmap is three */ + /* times wider than the original glyph image. See also */ /* @FT_RENDER_MODE_LCD. */ /* */ /* FT_PIXEL_MODE_LCD_V :: */ /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ - /* images used for display on rotated LCD displays; the bitmap's */ - /* height is three times taller than the original glyph image. */ - /* See also @FT_RENDER_MODE_LCD_V. */ + /* images used for display on rotated LCD displays; the bitmap */ + /* is three times taller than the original glyph image. See also */ + /* @FT_RENDER_MODE_LCD_V. */ /* */ typedef enum FT_Pixel_Mode_ { @@ -179,11 +179,11 @@ FT_BEGIN_HEADER /* @FT_Pixel_Mode values instead. */ /* */ /* <Values> */ - /* ft_pixel_mode_none :: see @FT_PIXEL_MODE_NONE */ - /* ft_pixel_mode_mono :: see @FT_PIXEL_MODE_MONO */ - /* ft_pixel_mode_grays :: see @FT_PIXEL_MODE_GRAY */ - /* ft_pixel_mode_pal2 :: see @FT_PIXEL_MODE_GRAY2 */ - /* ft_pixel_mode_pal4 :: see @FT_PIXEL_MODE_GRAY4 */ + /* ft_pixel_mode_none :: See @FT_PIXEL_MODE_NONE. */ + /* ft_pixel_mode_mono :: See @FT_PIXEL_MODE_MONO. */ + /* ft_pixel_mode_grays :: See @FT_PIXEL_MODE_GRAY. */ + /* ft_pixel_mode_pal2 :: See @FT_PIXEL_MODE_GRAY2. */ + /* ft_pixel_mode_pal4 :: See @FT_PIXEL_MODE_GRAY4. */ /* */ #define ft_pixel_mode_none FT_PIXEL_MODE_NONE #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO @@ -203,8 +203,8 @@ FT_BEGIN_HEADER /* <Description> */ /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */ /* */ - /* An enumeration type used to describe the format of a bitmap */ - /* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */ + /* An enumeration type to describe the format of a bitmap palette, */ + /* used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */ /* */ /* <Fields> */ /* ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */ @@ -258,7 +258,7 @@ FT_BEGIN_HEADER /* most cases. */ /* */ /* num_grays :: This field is only used with */ - /* `FT_PIXEL_MODE_GRAY'; it gives the number of gray */ + /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ /* levels used in the bitmap. */ /* */ /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ @@ -313,16 +313,16 @@ FT_BEGIN_HEADER /* */ /* n_points :: The number of points in the outline. */ /* */ - /* points :: A pointer to an array of `n_points' FT_Vector */ + /* points :: A pointer to an array of `n_points' @FT_Vector */ /* elements, giving the outline's point coordinates. */ /* */ /* tags :: A pointer to an array of `n_points' chars, giving */ /* each outline point's type. If bit 0 is unset, the */ - /* point is `off' the curve, i.e. a Bezier control */ + /* point is `off' the curve, i.e., a Bézier control */ /* point, while it is `on' when set. */ /* */ /* Bit 1 is meaningful for `off' points only. If set, */ - /* it indicates a third-order Bezier arc control point; */ + /* it indicates a third-order Bézier arc control point; */ /* and a second-order control point if unset. */ /* */ /* contours :: An array of `n_contours' shorts, giving the end */ @@ -333,7 +333,7 @@ FT_BEGIN_HEADER /* */ /* flags :: A set of bit flags used to characterize the outline */ /* and give hints to the scan-converter and hinter on */ - /* how to convert/grid-fit it. See FT_Outline_Flags. */ + /* how to convert/grid-fit it. See @FT_OUTLINE_FLAGS. */ /* */ typedef struct FT_Outline_ { @@ -362,7 +362,7 @@ FT_BEGIN_HEADER /* FT_OUTLINE_NONE :: Value 0 is reserved. */ /* */ /* FT_OUTLINE_OWNER :: If set, this flag indicates that the */ - /* outline's field arrays (i.e. */ + /* outline's field arrays (i.e., */ /* `points', `flags' & `contours') are */ /* `owned' by the outline object, and */ /* should thus be freed when it is */ @@ -486,8 +486,8 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_MoveToFunc)( FT_Vector* to, - void* user ); + (*FT_Outline_MoveToFunc)( const FT_Vector* to, + void* user ); #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc @@ -512,8 +512,8 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_LineToFunc)( FT_Vector* to, - void* user ); + (*FT_Outline_LineToFunc)( const FT_Vector* to, + void* user ); #define FT_Outline_LineTo_Func FT_Outline_LineToFunc @@ -526,7 +526,7 @@ FT_BEGIN_HEADER /* A function pointer type use to describe the signature of a `conic */ /* to' function during outline walking/decomposition. */ /* */ - /* A `conic to' is emitted to indicate a second-order Bezier arc in */ + /* A `conic to' is emitted to indicate a second-order Bézier arc in */ /* the outline. */ /* */ /* <Input> */ @@ -542,9 +542,9 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_ConicToFunc)( FT_Vector* control, - FT_Vector* to, - void* user ); + (*FT_Outline_ConicToFunc)( const FT_Vector* control, + const FT_Vector* to, + void* user ); #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc @@ -557,12 +557,12 @@ FT_BEGIN_HEADER /* A function pointer type used to describe the signature of a `cubic */ /* to' function during outline walking/decomposition. */ /* */ - /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ + /* A `cubic to' is emitted to indicate a third-order Bézier arc. */ /* */ /* <Input> */ - /* control1 :: A pointer to the first Bezier control point. */ + /* control1 :: A pointer to the first Bézier control point. */ /* */ - /* control2 :: A pointer to the second Bezier control point. */ + /* control2 :: A pointer to the second Bézier control point. */ /* */ /* to :: A pointer to the target end point. */ /* */ @@ -573,10 +573,10 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_CubicToFunc)( FT_Vector* control1, - FT_Vector* control2, - FT_Vector* to, - void* user ); + (*FT_Outline_CubicToFunc)( const FT_Vector* control1, + const FT_Vector* control2, + const FT_Vector* to, + void* user ); #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc @@ -588,7 +588,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Beziers, */ + /* decomposition in order to emit segments, conic, and cubic Béziers, */ /* as well as `move to' and `close to' operations. */ /* */ /* <Fields> */ @@ -596,9 +596,9 @@ FT_BEGIN_HEADER /* */ /* line_to :: The segment emitter. */ /* */ - /* conic_to :: The second-order Bezier arc emitter. */ + /* conic_to :: The second-order Bézier arc emitter. */ /* */ - /* cubic_to :: The third-order Bezier arc emitter. */ + /* cubic_to :: The third-order Bézier arc emitter. */ /* */ /* shift :: The shift that is applied to coordinates before they */ /* are sent to the emitter. */ @@ -611,8 +611,10 @@ FT_BEGIN_HEADER /* version of the original coordinates (this is important for high */ /* accuracy during scan-conversion). The transformation is simple: */ /* */ + /* { */ /* x' = (x << shift) - delta */ - /* y' = (y << shift) - delta */ + /* y' = (x << shift) - delta */ + /* } */ /* */ /* Set the value of `shift' and `delta' to 0 to get the original */ /* point coordinates. */ @@ -644,14 +646,16 @@ FT_BEGIN_HEADER /* FT_IMAGE_TAG */ /* */ /* <Description> */ - /* This macro converts four letter tags into an unsigned long. */ + /* This macro converts four-letter tags to an unsigned long type. */ /* */ /* <Note> */ /* Since many 16bit compilers don't like 32bit enumerations, you */ /* should redefine this macro in case of problems to something like */ /* this: */ /* */ + /* { */ /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ + /* } */ /* */ /* to get a simple enumeration without assigning special numbers. */ /* */ @@ -677,7 +681,7 @@ FT_BEGIN_HEADER /* */ /* <Values> */ /* FT_GLYPH_FORMAT_NONE :: */ - /* The value 0 is reserved and does describe a glyph format. */ + /* The value 0 is reserved. */ /* */ /* FT_GLYPH_FORMAT_COMPOSITE :: */ /* The glyph image is a composite of several other images. This */ @@ -690,13 +694,13 @@ FT_BEGIN_HEADER /* the @FT_GlyphSlotRec structure to read it. */ /* */ /* FT_GLYPH_FORMAT_OUTLINE :: */ - /* The glyph image is a vertorial outline made of line segments */ - /* and Bezier arcs; it can be described as an @FT_Outline; you */ + /* The glyph image is a vectorial outline made of line segments */ + /* and Bézier arcs; it can be described as an @FT_Outline; you */ /* generally want to access the `outline' field of the */ /* @FT_GlyphSlotRec structure to read it. */ /* */ /* FT_GLYPH_FORMAT_PLOTTER :: */ - /* The glyph image is a vectorial path with no inside/outside */ + /* The glyph image is a vectorial path with no inside and outside */ /* contours. Some Type 1 fonts, like those in the Hershey family, */ /* contain glyphs in this format. These are described as */ /* @FT_Outline, but FreeType isn't currently capable of rendering */ @@ -724,11 +728,11 @@ FT_BEGIN_HEADER /* @FT_Glyph_Format values instead. */ /* */ /* <Values> */ - /* ft_glyph_format_none :: see @FT_GLYPH_FORMAT_NONE */ - /* ft_glyph_format_composite :: see @FT_GLYPH_FORMAT_COMPOSITE */ - /* ft_glyph_format_bitmap :: see @FT_GLYPH_FORMAT_BITMAP */ - /* ft_glyph_format_outline :: see @FT_GLYPH_FORMAT_OUTLINE */ - /* ft_glyph_format_plotter :: see @FT_GLYPH_FORMAT_PLOTTER */ + /* ft_glyph_format_none :: See @FT_GLYPH_FORMAT_NONE. */ + /* ft_glyph_format_composite :: See @FT_GLYPH_FORMAT_COMPOSITE. */ + /* ft_glyph_format_bitmap :: See @FT_GLYPH_FORMAT_BITMAP. */ + /* ft_glyph_format_outline :: See @FT_GLYPH_FORMAT_OUTLINE. */ + /* ft_glyph_format_plotter :: See @FT_GLYPH_FORMAT_PLOTTER. */ /* */ #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE @@ -809,11 +813,10 @@ FT_BEGIN_HEADER /* */ /* <Note> */ /* This structure is used by the span drawing callback type named */ - /* FT_SpanFunc which takes the y-coordinate of the span as a */ + /* @FT_SpanFunc which takes the y-coordinate of the span as a */ /* a parameter. */ /* */ - /* The coverage value is always between 0 and 255, even if the number */ - /* of gray levels have been set through FT_Set_Gray_Levels(). */ + /* The coverage value is always between 0 and 255. */ /* */ typedef struct FT_Span_ { @@ -851,20 +854,20 @@ FT_BEGIN_HEADER /* given background bitmap, and even perform translucency. */ /* */ /* Note that the `count' field cannot be greater than a fixed value */ - /* defined by the FT_MAX_GRAY_SPANS configuration macro in */ - /* ftoption.h. By default, this value is set to 32, which means that */ - /* if there are more than 32 spans on a given scanline, the callback */ - /* will be called several times with the same `y' parameter in order */ - /* to draw all callbacks. */ + /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */ + /* `ftoption.h'. By default, this value is set to 32, which means */ + /* that if there are more than 32 spans on a given scanline, the */ + /* callback is called several times with the same `y' parameter in */ + /* order to draw all callbacks. */ /* */ /* Otherwise, the callback is only called once per scan-line, and */ /* only for those scanlines that do have `gray' pixels on them. */ /* */ typedef void - (*FT_SpanFunc)( int y, - int count, - FT_Span* spans, - void* user ); + (*FT_SpanFunc)( int y, + int count, + const FT_Span* spans, + void* user ); #define FT_Raster_Span_Func FT_SpanFunc @@ -958,8 +961,8 @@ FT_BEGIN_HEADER /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ /* rendering mode. If set, the output will */ /* be clipped to a box specified in the */ - /* "clip_box" field of the FT_Raster_Params */ - /* structure. */ + /* `clip_box' field of the */ + /* @FT_Raster_Params structure. */ /* */ /* Note that by default, the glyph bitmap */ /* is clipped to the target pixmap, except */ @@ -990,8 +993,8 @@ FT_BEGIN_HEADER /* <Fields> */ /* target :: The target bitmap. */ /* */ - /* source :: A pointer to the source glyph image (e.g. an */ - /* FT_Outline). */ + /* source :: A pointer to the source glyph image (e.g., an */ + /* @FT_Outline). */ /* */ /* flags :: The rendering flags. */ /* */ @@ -1012,11 +1015,11 @@ FT_BEGIN_HEADER /* 26.6 fixed-point units). */ /* */ /* <Note> */ - /* An anti-aliased glyph bitmap is drawn if the FT_RASTER_FLAG_AA bit */ - /* flag is set in the `flags' field, otherwise a monochrome bitmap */ - /* will be generated. */ + /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ + /* bit flag is set in the `flags' field, otherwise a monochrome */ + /* bitmap is generated. */ /* */ - /* If the FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ + /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ /* raster will call the `gray_spans' callback to draw gray pixel */ /* spans, in the case of an aa glyph bitmap, it will call */ /* `black_spans', and `bit_test' and `bit_set' in the case of a */ @@ -1063,9 +1066,9 @@ FT_BEGIN_HEADER /* <Note> */ /* The `memory' parameter is a typeless pointer in order to avoid */ /* un-wanted dependencies on the rest of the FreeType code. In */ - /* practice, it is a FT_Memory, i.e., a handle to the standard */ - /* FreeType memory allocator. However, this field can be completely */ - /* ignored by a given raster implementation. */ + /* practice, it is an @FT_Memory object, i.e., a handle to the */ + /* standard FreeType memory allocator. However, this field can be */ + /* completely ignored by a given raster implementation. */ /* */ typedef int (*FT_Raster_NewFunc)( void* memory, @@ -1160,31 +1163,31 @@ FT_BEGIN_HEADER /* <Input> */ /* raster :: A handle to the raster object. */ /* */ - /* params :: A pointer to a FT_Raster_Params structure used to store */ - /* the rendering parameters. */ + /* params :: A pointer to an @FT_Raster_Params structure used to */ + /* store the rendering parameters. */ /* */ /* <Return> */ /* Error code. 0 means success. */ /* */ /* <Note> */ /* The exact format of the source image depends on the raster's glyph */ - /* format defined in its FT_Raster_Funcs structure. It can be an */ - /* FT_Outline or anything else in order to support a large array of */ + /* format defined in its @FT_Raster_Funcs structure. It can be an */ + /* @FT_Outline or anything else in order to support a large array of */ /* glyph formats. */ /* */ /* Note also that the render function can fail and return a */ - /* FT_Err_Unimplemented_Feature error code if the raster used does */ + /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ /* not support direct composition. */ /* */ /* XXX: For now, the standard raster doesn't support direct */ /* composition but this should change for the final release (see */ - /* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */ - /* examples of distinct implementations which support direct */ + /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ + /* for examples of distinct implementations which support direct */ /* composition). */ /* */ typedef int - (*FT_Raster_RenderFunc)( FT_Raster raster, - FT_Raster_Params* params ); + (*FT_Raster_RenderFunc)( FT_Raster raster, + const FT_Raster_Params* params ); #define FT_Raster_Render_Func FT_Raster_RenderFunc @@ -1228,3 +1231,8 @@ FT_END_HEADER /* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/headers/libs/freetype2/freetype/ftincrem.h b/headers/libs/freetype2/freetype/ftincrem.h index 6a1aa1fc31..d7f4427cb7 100644 --- a/headers/libs/freetype2/freetype/ftincrem.h +++ b/headers/libs/freetype2/freetype/ftincrem.h @@ -4,7 +4,7 @@ /* */ /* FreeType incremental loading (specification). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,6 +31,33 @@ FT_BEGIN_HEADER + /*************************************************************************** + * + * @section: + * incremental + * + * @title: + * Incremental Loading + * + * @abstract: + * Custom Glyph Loading. + * + * @description: + * This section contains various functions used to perform so-called + * `incremental' glyph loading. This is a mode where all glyphs loaded + * from a given @FT_Face are provided by the client application, + * + * Apart from that, all other tables are loaded normally from the font + * file. This mode is useful when FreeType is used within another + * engine, e.g., a Postscript Imaging Processor. + * + * To enable this mode, you must use @FT_Open_Face, passing an + * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an + * @FT_Incremental_Interface value. See the comments for + * @FT_Incremental_InterfaceRec for an example. + * + */ + /*************************************************************************** * @@ -39,8 +66,8 @@ FT_BEGIN_HEADER * * @description: * An opaque type describing a user-provided object used to implement - * "incremental" glyph loading within FreeType. This is used to support - * embedded fonts in certain environments (e.g. Postscript interpreters), + * `incremental' glyph loading within FreeType. This is used to support + * embedded fonts in certain environments (e.g., Postscript interpreters), * where the glyph data isn't in the font file, or must be overridden by * different values. * @@ -77,7 +104,7 @@ FT_BEGIN_HEADER * * @note: * These correspond to horizontal or vertical metrics depending on the - * value of the 'vertical' argument to the function + * value of the `vertical' argument to the function * @FT_Incremental_GetGlyphMetricsFunc. */ typedef struct FT_Incremental_MetricsRec_ @@ -101,8 +128,8 @@ FT_BEGIN_HEADER * * Note that the format of the glyph's data bytes depends on the font * file format. For TrueType, it must correspond to the raw bytes within - * the 'glyf' table. For Postscript formats, it must correspond to the - * *unencrypted* charstring bytes, without any 'lenIV' header. It is + * the `glyf' table. For Postscript formats, it must correspond to the + * *unencrypted* charstring bytes, without any `lenIV' header. It is * undefined for any other format. * * @input: @@ -270,6 +297,18 @@ FT_BEGIN_HEADER } FT_Incremental_InterfaceRec; + /*************************************************************************** + * + * @type: + * FT_Incremental_Interface + * + * @description: + * A pointer to an @FT_Incremental_InterfaceRec structure. + * + */ + typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface; + + /*************************************************************************** * * @constant: diff --git a/headers/libs/freetype2/freetype/ftlist.h b/headers/libs/freetype2/freetype/ftlist.h index ae9801b9d8..c9a51de765 100644 --- a/headers/libs/freetype2/freetype/ftlist.h +++ b/headers/libs/freetype2/freetype/ftlist.h @@ -174,12 +174,12 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* An FT_List iterator function which is called during a list parse */ - /* by FT_List_Iterate(). */ + /* by @FT_List_Iterate. */ /* */ /* <Input> */ /* node :: The current iteration list node. */ /* */ - /* user :: A typeless pointer passed to FT_List_Iterate(). */ + /* user :: A typeless pointer passed to @FT_List_Iterate. */ /* Can be used to point to the iteration's state. */ /* */ typedef FT_Error @@ -219,8 +219,8 @@ FT_BEGIN_HEADER /* FT_List_Destructor */ /* */ /* <Description> */ - /* An FT_List iterator function which is called during a list */ - /* finalization by FT_List_Finalize() to destroy all elements in a */ + /* An @FT_List iterator function which is called during a list */ + /* finalization by @FT_List_Finalize to destroy all elements in a */ /* given list. */ /* */ /* <Input> */ @@ -228,7 +228,7 @@ FT_BEGIN_HEADER /* */ /* data :: The current object to destroy. */ /* */ - /* user :: A typeless pointer passed to FT_List_Iterate(). It can */ + /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ /* be used to point to the iteration's state. */ /* */ typedef void diff --git a/headers/libs/freetype2/freetype/ftlzw.h b/headers/libs/freetype2/freetype/ftlzw.h index 2ebd500809..d950653ebf 100644 --- a/headers/libs/freetype2/freetype/ftlzw.h +++ b/headers/libs/freetype2/freetype/ftlzw.h @@ -4,7 +4,7 @@ /* */ /* LZW-compressed stream support. */ /* */ -/* Copyright 2004 by */ +/* Copyright 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -54,7 +54,7 @@ FT_BEGIN_HEADER * * @description: * Open a new stream to parse LZW-compressed font files. This is - * mainly used to support the compressed *.pcf.Z fonts that come + * mainly used to support the compressed `*.pcf.Z' fonts that come * with XFree86. * * @input: @@ -68,8 +68,8 @@ FT_BEGIN_HEADER * @note: * The source stream must be opened _before_ calling this function. * - * Calling the internal function FT_Stream_Close on the new stream will - * *not* call FT_Stream_Close on the source stream. None of the stream + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream * objects will be released to the heap. * * The stream implementation is very basic and resets the decompression @@ -81,8 +81,8 @@ FT_BEGIN_HEADER * compressed file, the library will try to open a LZW stream from it * and re-open the face with it. * - * This function may return "FT_Err_Unimplemented" if your build of - * FreeType was not compiled with LZW support. + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with LZW support. */ FT_EXPORT( FT_Error ) FT_Stream_OpenLZW( FT_Stream stream, diff --git a/headers/libs/freetype2/freetype/ftmac.h b/headers/libs/freetype2/freetype/ftmac.h index 4ebf716eb7..4b1bb6bac3 100644 --- a/headers/libs/freetype2/freetype/ftmac.h +++ b/headers/libs/freetype2/freetype/ftmac.h @@ -4,7 +4,7 @@ /* */ /* Additional Mac-specific API. */ /* */ -/* Copyright 1996-2001, 2004 by */ +/* Copyright 1996-2001, 2004, 2006 by */ /* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -59,13 +59,13 @@ FT_BEGIN_HEADER /* FT_New_Face_From_FOND */ /* */ /* <Description> */ - /* Creates a new face object from an FOND resource. */ + /* Create a new face object from a FOND resource. */ /* */ /* <InOut> */ /* library :: A handle to the library resource. */ /* */ /* <Input> */ - /* fond :: An FOND resource. */ + /* fond :: A FOND resource. */ /* */ /* face_index :: Only supported for the -1 `sanity check' special */ /* case. */ @@ -77,8 +77,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ /* <Notes> */ - /* This function can be used to create FT_Face abjects from fonts */ - /* that are installed in the system like so: */ + /* This function can be used to create @FT_Face objects from fonts */ + /* that are installed in the system as follows. */ /* */ /* { */ /* fond = GetResource( 'FOND', fontName ); */ @@ -98,10 +98,11 @@ FT_BEGIN_HEADER /* FT_GetFile_From_Mac_Name */ /* */ /* <Description> */ - /* Returns an FSSpec for the disk file containing the named font. */ + /* Return an FSSpec for the disk file containing the named font. */ /* */ /* <Input> */ - /* fontName :: Mac OS name of the font (eg. Times New Roman Bold). */ + /* fontName :: Mac OS name of the font (e.g., Times New Roman */ + /* Bold). */ /* */ /* <Output> */ /* pathSpec :: FSSpec to the file. For passing to @FT_New_Face. */ @@ -112,18 +113,43 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_Name( const char* fontName, + FT_GetFile_From_Mac_Name( const char* fontName, FSSpec* pathSpec, FT_Long* face_index ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFile_From_Mac_ATS_Name */ + /* */ + /* <Description> */ + /* Return an FSSpec for the disk file containing the named font. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font in ATS framework. */ + /* */ + /* <Output> */ + /* pathSpec :: FSSpec to the file. For passing to @FT_New_Face. */ + /* */ + /* face_index :: Index of the face. For passing to @FT_New_Face. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ); + + /*************************************************************************/ /* */ /* <Function> */ /* FT_New_Face_From_FSSpec */ /* */ /* <Description> */ - /* Creates a new face object from a given resource and typeface index */ + /* Create a new face object from a given resource and typeface index */ /* using an FSSpec to the font file. */ /* */ /* <InOut> */ @@ -150,6 +176,40 @@ FT_BEGIN_HEADER FT_Long face_index, FT_Face *aface ); + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FSRef */ + /* */ + /* <Description> */ + /* Create a new face object from a given resource and typeface index */ + /* using an FSRef to the font file. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* spec :: FSRef to the font file. */ + /* */ + /* face_index :: The index of the face within the resource. The */ + /* first face has index 0. */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ + /* it accepts an FSRef instead of a path. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSRef( FT_Library library, + const FSRef *ref, + FT_Long face_index, + FT_Face *aface ); + /* */ diff --git a/headers/libs/freetype2/freetype/ftmm.h b/headers/libs/freetype2/freetype/ftmm.h index 525b5c08eb..a9ccfe7138 100644 --- a/headers/libs/freetype2/freetype/ftmm.h +++ b/headers/libs/freetype2/freetype/ftmm.h @@ -4,7 +4,7 @@ /* */ /* FreeType Multiple Master font interface (specification). */ /* */ -/* Copyright 1996-2001, 2003, 2004 by */ +/* Copyright 1996-2001, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -40,11 +40,11 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* The following types and functions are used to manage Multiple */ - /* Master fonts, i.e. the selection of specific design instances by */ + /* Master fonts, i.e., the selection of specific design instances by */ /* setting design axis coordinates. */ /* */ /* George Williams has extended this interface to make it work with */ - /* both Type 1 Multiple Masters fonts, and GX distortable (var) */ + /* both Type 1 Multiple Masters fonts and GX distortable (var) */ /* fonts. Some of these routines only work with MM fonts, others */ /* will work with both types. They are similar enough that a */ /* consistent interface makes sense. */ @@ -93,7 +93,7 @@ FT_BEGIN_HEADER /* <Fields> */ /* num_axis :: Number of axes. Cannot exceed 4. */ /* */ - /* num_designs :: Number of designs; should ne normally 2^num_axis */ + /* num_designs :: Number of designs; should be normally 2^num_axis */ /* even though the Type 1 specification strangely */ /* allows for intermediate designs to be present. This */ /* number cannot exceed 16. */ diff --git a/headers/libs/freetype2/freetype/ftmodapi.h b/headers/libs/freetype2/freetype/ftmodapi.h index 1929ca025d..4628bdf833 100644 --- a/headers/libs/freetype2/freetype/ftmodapi.h +++ b/headers/libs/freetype2/freetype/ftmodapi.h @@ -4,7 +4,7 @@ /* */ /* FreeType modules public interface (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -84,7 +84,7 @@ FT_BEGIN_HEADER typedef void (*FT_Module_Destructor)( FT_Module module ); - typedef FT_Module_Interface + typedef FT_Module_Interface (*FT_Module_Requester)( FT_Module module, const char* name ); @@ -98,27 +98,28 @@ FT_BEGIN_HEADER /* The module class descriptor. */ /* */ /* <Fields> */ - /* module_flags :: Bit flags describing the module. */ + /* module_flags :: Bit flags describing the module. */ /* */ - /* module_size :: The size of one module object/instance in */ - /* bytes. */ + /* module_size :: The size of one module object/instance in */ + /* bytes. */ /* */ - /* module_name :: The name of the module. */ + /* module_name :: The name of the module. */ /* */ - /* module_version :: The version, as a 16.16 fixed number */ - /* (major.minor). */ + /* module_version :: The version, as a 16.16 fixed number */ + /* (major.minor). */ /* */ - /* module_requires :: The version of FreeType this module requires */ - /* (starts at version 2.0, i.e 0x20000) */ + /* module_requires :: The version of FreeType this module requires, */ + /* as a 16.16 fixed number (major.minor). Starts */ + /* at version 2.0, i.e., 0x20000. */ /* */ - /* module_init :: A function used to initialize (not create) a */ - /* new module object. */ + /* module_init :: A function used to initialize (not create) a */ + /* new module object. */ /* */ - /* module_done :: A function used to finalize (not destroy) a */ - /* given module object */ + /* module_done :: A function used to finalize (not destroy) a */ + /* given module object */ /* */ - /* get_interface :: Queries a given module for a specific */ - /* interface by name. */ + /* get_interface :: Queries a given module for a specific */ + /* interface by name. */ /* */ typedef struct FT_Module_Class_ { @@ -180,8 +181,8 @@ FT_BEGIN_HEADER /* A module handle. 0 if none was found. */ /* */ /* <Note> */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for :-) */ + /* FreeType's internal modules aren't documented very well, and you */ + /* should look up the source code for details. */ /* */ FT_EXPORT( FT_Module ) FT_Get_Module( FT_Library library, @@ -255,7 +256,7 @@ FT_BEGIN_HEADER FT_EXPORT( FT_Error ) FT_Done_Library( FT_Library library ); - +/* */ typedef void (*FT_DebugHook_Func)( void* arg ); @@ -275,8 +276,8 @@ FT_BEGIN_HEADER /* */ /* <Input> */ /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in ftobjs.h, e.g. */ - /* FT_DEBUG_HOOK_TRUETYPE. */ + /* values defined in `ftobjs.h', e.g., */ + /* `FT_DEBUG_HOOK_TRUETYPE'. */ /* */ /* debug_hook :: The function used to debug the interpreter. */ /* */ @@ -284,13 +285,16 @@ FT_BEGIN_HEADER /* Currently, four debug hook slots are available, but only two (for */ /* the TrueType and the Type 1 interpreter) are defined. */ /* */ + /* Since the internal headers of FreeType are no longer installed, */ + /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ + /* This is a bug and will be fixed in a forthcoming release. */ + /* */ FT_EXPORT( void ) FT_Set_Debug_Hook( FT_Library library, FT_UInt hook_index, FT_DebugHook_Func debug_hook ); - /*************************************************************************/ /* */ /* <Function> */ @@ -299,7 +303,7 @@ FT_BEGIN_HEADER /* <Description> */ /* Adds the set of default drivers to a given library object. */ /* This is only useful when you create a library object with */ - /* FT_New_Library() (usually to plug a custom memory manager). */ + /* @FT_New_Library (usually to plug a custom memory manager). */ /* */ /* <InOut> */ /* library :: A handle to a new library object. */ @@ -308,6 +312,89 @@ FT_BEGIN_HEADER FT_Add_Default_Modules( FT_Library library ); + + /************************************************************************** + * + * @section: + * ttengine + * + * @title: + * The TrueType Engine + * + * @abstract: + * TrueType bytecode support. + * + * @description: + * This section contains a function used to query the level of TrueType + * bytecode support compiled in this version of the library. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_TrueTypeEngineType + * + * @description: + * A list of values describing which kind of TrueType bytecode + * engine is implemented in a given FT_Library instance. It is used + * by the @FT_Get_TrueType_Engine_Type function. + * + * @values: + * FT_TRUETYPE_ENGINE_TYPE_NONE :: + * The library doesn't implement any kind of bytecode interpreter. + * + * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: + * The library implements a bytecode interpreter that doesn't + * support the patented operations of the TrueType virtual machine. + * + * Its main use is to load certain Asian fonts which position and + * scale glyph components with bytecode instructions. It produces + * bad output for most other fonts. + * + * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: + * The library implements a bytecode interpreter that covers + * the full instruction set of the TrueType virtual machine. + * See the file `docs/PATENTS' for legal aspects. + * + * @since: + * 2.2 + * + */ + typedef enum + { + FT_TRUETYPE_ENGINE_TYPE_NONE = 0, + FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, + FT_TRUETYPE_ENGINE_TYPE_PATENTED + + } FT_TrueTypeEngineType; + + + /************************************************************************** + * + * @func: + * FT_Get_TrueType_Engine_Type + * + * @description: + * Return a @FT_TrueTypeEngineType value to indicate which level of + * the TrueType virtual machine a given library instance supports. + * + * @input: + * library :: + * A library instance. + * + * @return: + * A value indicating which level is supported. + * + * @since: + * 2.2 + * + */ + FT_EXPORT( FT_TrueTypeEngineType ) + FT_Get_TrueType_Engine_Type( FT_Library library ); + + /* */ diff --git a/headers/libs/freetype2/freetype/ftotval.h b/headers/libs/freetype2/freetype/ftotval.h index a8de58af9d..2bddc6b584 100644 --- a/headers/libs/freetype2/freetype/ftotval.h +++ b/headers/libs/freetype2/freetype/ftotval.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating OpenType tables (specification). */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -64,7 +64,7 @@ FT_BEGIN_HEADER /********************************************************************** * * @enum: - * FT_VALIDATE_XXX + * FT_VALIDATE_OTXXX * * @description: * A list of bit-field constants used with @FT_OpenType_Validate to @@ -121,7 +121,7 @@ FT_BEGIN_HEADER * * validation_flags :: * A bit field which specifies the tables to be validated. See - * @FT_VALIDATE_XXX for possible values. + * @FT_VALIDATE_OTXXX for possible values. * * @output: * BASE_table :: @@ -147,8 +147,9 @@ FT_BEGIN_HEADER * otherwise. * * After use, the application should deallocate the five tables with - * `free'. A NULL value indicates that the table either doesn't exist - * in the font, or the application hasn't asked for validation. + * @FT_OpenType_Free. A NULL value indicates that the table either + * doesn't exist in the font, or the application hasn't asked for + * validation. */ FT_EXPORT( FT_Error ) FT_OpenType_Validate( FT_Face face, @@ -159,6 +160,33 @@ FT_BEGIN_HEADER FT_Bytes *GSUB_table, FT_Bytes *JSTF_table ); + /* */ + + /********************************************************************** + * + * @function: + * FT_OpenType_Free + * + * @description: + * Free the buffer allocated by OpenType validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_OpenType_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_OpenType_Validate only. + */ + FT_EXPORT( void ) + FT_OpenType_Free( FT_Face face, + FT_Bytes table ); + + /* */ diff --git a/headers/libs/freetype2/freetype/ftoutln.h b/headers/libs/freetype2/freetype/ftoutln.h index 76ad60a61f..aa1085a430 100644 --- a/headers/libs/freetype2/freetype/ftoutln.h +++ b/headers/libs/freetype2/freetype/ftoutln.h @@ -5,7 +5,7 @@ /* Support for the FT_Outline type used to store glyph shapes of */ /* most scalable font formats (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -85,7 +85,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Walks over an outline's structure to decompose it into individual */ - /* segments and Bezier arcs. This function is also able to emit */ + /* segments and Bézier arcs. This function is also able to emit */ /* `move to' and `close to' operations to indicate the start and end */ /* of new contours in the outline. */ /* */ @@ -122,8 +122,8 @@ FT_BEGIN_HEADER /* <Input> */ /* library :: A handle to the library object from where the */ /* outline is allocated. Note however that the new */ - /* outline will NOT necessarily be FREED, when */ - /* destroying the library, by FT_Done_FreeType(). */ + /* outline will *not* necessarily be *freed*, when */ + /* destroying the library, by @FT_Done_FreeType. */ /* */ /* numPoints :: The maximal number of points within the outline. */ /* */ @@ -160,7 +160,7 @@ FT_BEGIN_HEADER /* FT_Outline_Done */ /* */ /* <Description> */ - /* Destroys an outline created with FT_Outline_New(). */ + /* Destroys an outline created with @FT_Outline_New. */ /* */ /* <Input> */ /* library :: A handle of the library object used to allocate the */ @@ -176,7 +176,7 @@ FT_BEGIN_HEADER /* descriptor will be released. */ /* */ /* The reason why this function takes an `library' parameter is */ - /* simply to use FT_Free(). */ + /* simply to use ft_mem_free(). */ /* */ FT_EXPORT( FT_Error ) FT_Outline_Done( FT_Library library, @@ -213,10 +213,10 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Returns an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bezier control points. Though it */ + /* the outline's points, including Bézier control points. Though it */ /* coincides with the exact bounding box for most glyphs, it can be */ /* slightly larger in some situations (like when rotating an outline */ - /* which contains Bezier outside arcs). */ + /* which contains Bézier outside arcs). */ /* */ /* Computing the control box is very fast, while getting the bounding */ /* box can take much more time as it needs to walk over all segments */ @@ -296,7 +296,7 @@ FT_BEGIN_HEADER /* matrix :: A pointer to the transformation matrix. */ /* */ /* <Note> */ - /* You can use FT_Outline_Translate() if you need to translate the */ + /* You can use @FT_Outline_Translate if you need to translate the */ /* outline's points. */ /* */ FT_EXPORT( void ) @@ -314,6 +314,9 @@ FT_BEGIN_HEADER /* `strength' pixels wider and higher. You may think of the left and */ /* bottom borders as unchanged. */ /* */ + /* Negative `strength' values to reduce the outline thickness are */ + /* possible also. */ + /* */ /* <InOut> */ /* outline :: A handle to the target outline. */ /* */ @@ -324,7 +327,21 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_DEF( FT_Error ) + /* <Note> */ + /* The used algorithm to increase or decrease the thickness of the */ + /* glyph doesn't change the number of points; this means that certain */ + /* situations like acute angles or intersections are sometimes */ + /* handled incorrectly. */ + /* */ + /* Example call: */ + /* */ + /* { */ + /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ + /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */ + /* FT_Outline_Embolden( &face->slot->outline, strength ); */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) FT_Outline_Embolden( FT_Outline* outline, FT_Pos strength ); @@ -342,7 +359,7 @@ FT_BEGIN_HEADER /* outline :: A pointer to the target outline descriptor. */ /* */ /* <Note> */ - /* This functions toggles the bit flag `FT_OUTLINE_REVERSE_FILL' in */ + /* This functions toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ /* the outline's `flags' field. */ /* */ /* It shouldn't be used by a normal client application, unless it */ @@ -366,7 +383,7 @@ FT_BEGIN_HEADER /* */ /* outline :: A pointer to the source outline descriptor. */ /* */ - /* <Output> */ + /* <InOut> */ /* abitmap :: A pointer to the target bitmap descriptor. */ /* */ /* <Return> */ @@ -391,7 +408,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Renders an outline within a bitmap using the current scan-convert. */ - /* This functions uses an FT_Raster_Params structure as an argument, */ + /* This functions uses an @FT_Raster_Params structure as an argument, */ /* allowing advanced features like direct composition, translucency, */ /* etc. */ /* */ @@ -401,14 +418,14 @@ FT_BEGIN_HEADER /* outline :: A pointer to the source outline descriptor. */ /* */ /* <InOut> */ - /* params :: A pointer to a FT_Raster_Params structure used to */ + /* params :: A pointer to an @FT_Raster_Params structure used to */ /* describe the rendering operation. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* You should know what you are doing and how FT_Raster_Params works */ + /* You should know what you are doing and how @FT_Raster_Params works */ /* to use this function. */ /* */ /* The field `params.source' will be set to `outline' before the scan */ @@ -450,13 +467,19 @@ FT_BEGIN_HEADER * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to * remember that in Postscript, everything that is to the left of * the drawing direction of a contour must be filled. + * + * FT_ORIENTATION_NONE :: + * The orientation cannot be determined. That is, different parts of + * the glyph have different orientation. + * */ typedef enum { FT_ORIENTATION_TRUETYPE = 0, FT_ORIENTATION_POSTSCRIPT = 1, FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE, - FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT + FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT, + FT_ORIENTATION_NONE } FT_Orientation; @@ -496,3 +519,8 @@ FT_END_HEADER /* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/headers/libs/freetype2/freetype/ftpfr.h b/headers/libs/freetype2/freetype/ftpfr.h index 2481659528..e2801fd0f9 100644 --- a/headers/libs/freetype2/freetype/ftpfr.h +++ b/headers/libs/freetype2/freetype/ftpfr.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing PFR-specific data (specification only). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -154,7 +154,7 @@ FT_BEGIN_HEADER * * @note: * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics - * to convert the advance to device sub-pixels (i.e. 1/64th of pixels). + * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). */ FT_EXPORT( FT_Error ) FT_Get_PFR_Advance( FT_Face face, diff --git a/headers/libs/freetype2/freetype/ftrender.h b/headers/libs/freetype2/freetype/ftrender.h index 21b051fc7c..5b07f08c2d 100644 --- a/headers/libs/freetype2/freetype/ftrender.h +++ b/headers/libs/freetype2/freetype/ftrender.h @@ -4,7 +4,7 @@ /* */ /* FreeType renderer modules public interface (specification). */ /* */ -/* Copyright 1996-2001, 2005 by */ +/* Copyright 1996-2001, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -46,9 +46,9 @@ FT_BEGIN_HEADER (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); typedef void - (*FT_Glyph_TransformFunc)( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ); + (*FT_Glyph_TransformFunc)( FT_Glyph glyph, + const FT_Matrix* matrix, + const FT_Vector* delta ); typedef void (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, @@ -85,16 +85,16 @@ FT_BEGIN_HEADER typedef FT_Error - (*FT_Renderer_RenderFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_UInt mode, - FT_Vector* origin ); + (*FT_Renderer_RenderFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_UInt mode, + const FT_Vector* origin ); typedef FT_Error - (*FT_Renderer_TransformFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_Matrix* matrix, - FT_Vector* delta ); + (*FT_Renderer_TransformFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + const FT_Matrix* matrix, + const FT_Vector* delta ); typedef void @@ -124,7 +124,7 @@ FT_BEGIN_HEADER /* The renderer module class descriptor. */ /* */ /* <Fields> */ - /* root :: The root FT_Module_Class fields. */ + /* root :: The root @FT_Module_Class fields. */ /* */ /* glyph_format :: The glyph image format this renderer handles. */ /* */ @@ -133,10 +133,10 @@ FT_BEGIN_HEADER /* */ /* set_mode :: A method used to pass additional parameters. */ /* */ - /* raster_class :: For `FT_GLYPH_FORMAT_OUTLINE' renderers only, this */ + /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. This */ /* is a pointer to its raster's class. */ /* */ - /* raster :: For `FT_GLYPH_FORMAT_OUTLINE' renderers only. this */ + /* raster :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. This */ /* is a pointer to the corresponding raster object, */ /* if any. */ /* */ @@ -176,8 +176,8 @@ FT_BEGIN_HEADER /* An error will be returned if a module already exists by that name, */ /* or if the module requires a version of FreeType that is too great. */ /* */ - /* To add a new renderer, simply use FT_Add_Module(). To retrieve a */ - /* renderer by its name, use FT_Get_Module(). */ + /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ + /* renderer by its name, use @FT_Get_Module. */ /* */ FT_EXPORT( FT_Renderer ) FT_Get_Renderer( FT_Library library, diff --git a/headers/libs/freetype2/freetype/ftsizes.h b/headers/libs/freetype2/freetype/ftsizes.h index 9abd94bc43..622df162d2 100644 --- a/headers/libs/freetype2/freetype/ftsizes.h +++ b/headers/libs/freetype2/freetype/ftsizes.h @@ -4,7 +4,7 @@ /* */ /* FreeType size objects management (specification). */ /* */ -/* Copyright 1996-2001, 2003, 2004 by */ +/* Copyright 1996-2001, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -54,9 +54,9 @@ FT_BEGIN_HEADER /* Managing multiple sizes per face. */ /* */ /* <Description> */ - /* When creating a new face object (e.g. with @FT_New_Face), an */ + /* When creating a new face object (e.g., with @FT_New_Face), an */ /* @FT_Size object is automatically created and used to store all */ - /* pixel-size dependent information, available in the "face->size" */ + /* pixel-size dependent information, available in the `face->size' */ /* field. */ /* */ /* It is however possible to create more sizes for a given face, */ @@ -64,7 +64,7 @@ FT_BEGIN_HEADER /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ /* */ /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ - /* modify the contents of the current "active" size; you thus need */ + /* modify the contents of the current `active' size; you thus need */ /* to use @FT_Activate_Size to change it. */ /* */ /* 99% of applications won't need the functions provided here, */ @@ -80,7 +80,7 @@ FT_BEGIN_HEADER /* FT_New_Size */ /* */ /* <Description> */ - /* Creates a new size object from a given face object. */ + /* Create a new size object from a given face object. */ /* */ /* <Input> */ /* face :: A handle to a parent face object. */ @@ -107,7 +107,7 @@ FT_BEGIN_HEADER /* FT_Done_Size */ /* */ /* <Description> */ - /* Discards a given size object. Note that @FT_Done_Face */ + /* Discard a given size object. Note that @FT_Done_Face */ /* automatically discards all size objects allocated with */ /* @FT_New_Size. */ /* */ @@ -130,9 +130,9 @@ FT_BEGIN_HEADER /* Even though it is possible to create several size objects for a */ /* given face (see @FT_New_Size for details), functions like */ /* @FT_Load_Glyph or @FT_Load_Char only use the last-created one to */ - /* determine the "current character pixel size". */ + /* determine the `current character pixel size'. */ /* */ - /* This function can be used to "activate" a previously created size */ + /* This function can be used to `activate' a previously created size */ /* object. */ /* */ /* <Input> */ @@ -142,8 +142,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* If "face" is the size's parent face object, this function changes */ - /* the value of "face->size" to the input size handle. */ + /* If `face' is the size's parent face object, this function changes */ + /* the value of `face->size' to the input size handle. */ /* */ FT_EXPORT( FT_Error ) FT_Activate_Size( FT_Size size ); diff --git a/headers/libs/freetype2/freetype/ftsnames.h b/headers/libs/freetype2/freetype/ftsnames.h index 0e2d9a4adc..003cbcd129 100644 --- a/headers/libs/freetype2/freetype/ftsnames.h +++ b/headers/libs/freetype2/freetype/ftsnames.h @@ -7,7 +7,7 @@ /* */ /* This is _not_ used to retrieve glyph names! */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -78,12 +78,12 @@ FT_BEGIN_HEADER /* name_id :: An identifier for `string'. */ /* */ /* string :: The `name' string. Note that its format differs */ - /* depending on the (platform,encoding) pair. It can */ - /* be a Pascal String, a UTF-16 one, etc.. */ + /* depending on the (platform,encoding) pair. It can */ + /* be a Pascal String, a UTF-16 one, etc. */ /* */ /* Generally speaking, the string is not */ - /* zero-terminated. Please refer to the TrueType */ - /* specification for details.. */ + /* zero-terminated. Please refer to the TrueType */ + /* specification for details. */ /* */ /* string_len :: The length of `string' in bytes. */ /* */ @@ -92,6 +92,9 @@ FT_BEGIN_HEADER /* and `name_id' are given in the file `ttnameid.h'. For details */ /* please refer to the TrueType or OpenType specification. */ /* */ + /* See also @TT_PLATFORM_XXX, @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ + /* @TT_ISO_ID_XXX, and @TT_MS_ID_XXX. */ + /* */ typedef struct FT_SfntName_ { FT_UShort platform_id; @@ -137,7 +140,7 @@ FT_BEGIN_HEADER /* idx :: The index of the `name' string. */ /* */ /* <Output> */ - /* aname :: The indexed FT_SfntName structure. */ + /* aname :: The indexed @FT_SfntName structure. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ @@ -146,7 +149,7 @@ FT_BEGIN_HEADER /* The `string' array returned in the `aname' structure is not */ /* null-terminated. */ /* */ - /* Use FT_Get_Sfnt_Name_Count() to get the total number of available */ + /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ /* `name' table entries, then do a loop until you get the right */ /* platform, encoding, and name ID. */ /* */ diff --git a/headers/libs/freetype2/freetype/ftstroke.h b/headers/libs/freetype2/freetype/ftstroke.h index c6c96deed5..6e75921a7c 100644 --- a/headers/libs/freetype2/freetype/ftstroke.h +++ b/headers/libs/freetype2/freetype/ftstroke.h @@ -4,7 +4,7 @@ /* */ /* FreeType path stroker (specification). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,16 +29,16 @@ FT_BEGIN_HEADER /************************************************************************ * - * <Section> + * @section: * glyph_stroker * - * <Title> + * @title: * Glyph Stroker * - * <Abstract> + * @abstract: * Generating bordered and stroked glyphs. * - * <Description> + * @description: * This component generates stroked outlines of a given vectorial * glyph. It also allows you to retrieve the `outside' and/or the * `inside' borders of the stroke. @@ -142,8 +142,8 @@ FT_BEGIN_HEADER * * @note: * Applications are generally interested in the `inside' and `outside' - * borders. However, there is no direct mapping between these and - * the `left' / `right' ones, since this really depends on the glyph's + * borders. However, there is no direct mapping between these and the + * `left' and `right' ones, since this really depends on the glyph's * drawing orientation, which varies between font formats. * * You can however use @FT_Outline_GetInsideBorder and @@ -208,17 +208,18 @@ FT_BEGIN_HEADER * Create a new stroker object. * * @input: - * memory :: - * The memory manager handle. + * library :: + * FreeType library handle. * * @output: - * A new stroker object handle. NULL in case of error. + * astroker :: + * A new stroker object handle. NULL in case of error. * * @return: * FreeType error code. 0 means success. */ FT_EXPORT( FT_Error ) - FT_Stroker_New( FT_Memory memory, + FT_Stroker_New( FT_Library library, FT_Stroker *astroker ); @@ -340,7 +341,7 @@ FT_BEGIN_HEADER * * @note: * This function is useful when you need to stroke a path that is - * not stored as a @FT_Outline object. + * not stored as an @FT_Outline object. */ FT_EXPORT( FT_Error ) FT_Stroker_BeginSubPath( FT_Stroker stroker, @@ -406,7 +407,7 @@ FT_BEGIN_HEADER * FT_Stroker_ConicTo * * @description: - * `Draw; a single quadratic bezier in the stroker's current sub-path, + * `Draw' a single quadratic Bézier in the stroker's current sub-path, * from the last position. * * @input: @@ -414,7 +415,7 @@ FT_BEGIN_HEADER * The target stroker handle. * * control :: - * A pointer to a Bézier control point. + * A pointer to a Bézier control point. * * to :: * A pointer to the destination point. @@ -438,7 +439,7 @@ FT_BEGIN_HEADER * FT_Stroker_CubicTo * * @description: - * `Draw' a single cubic Bézier in the stroker's current sub-path, + * `Draw' a single cubic Bézier in the stroker's current sub-path, * from the last position. * * @input: @@ -446,10 +447,10 @@ FT_BEGIN_HEADER * The target stroker handle. * * control1 :: - * A pointer to the first Bézier control point. + * A pointer to the first Bézier control point. * * control2 :: - * A pointer to second Bézier control point. + * A pointer to second Bézier control point. * * to :: * A pointer to the destination point. @@ -474,7 +475,7 @@ FT_BEGIN_HEADER * FT_Stroker_GetBorderCounts * * @description: - * Vall this function once you have finished parsing your paths + * Call this function once you have finished parsing your paths * with the stroker. It will return the number of points and * contours necessary to export one of the `border' or `stroke' * outlines generated by the stroker. @@ -640,8 +641,8 @@ FT_BEGIN_HEADER * Stroke a given outline glyph object with a given stroker. * * @inout: - * pglyph :: Source glyph handle on input, new glyph handle - * on output. + * pglyph :: + * Source glyph handle on input, new glyph handle on output. * * @input: * stroker :: @@ -708,3 +709,8 @@ FT_END_HEADER /* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/headers/libs/freetype2/freetype/ftsynth.h b/headers/libs/freetype2/freetype/ftsynth.h index f0c738532f..36984bf1a7 100644 --- a/headers/libs/freetype2/freetype/ftsynth.h +++ b/headers/libs/freetype2/freetype/ftsynth.h @@ -5,7 +5,7 @@ /* FreeType synthesizing code for emboldening and slanting */ /* (specification). */ /* */ -/* Copyright 2000-2001, 2003 by */ +/* Copyright 2000-2001, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -50,10 +50,12 @@ FT_BEGIN_HEADER + /* Make sure slot owns slot->bitmap. */ + FT_EXPORT( FT_Error ) + FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); - /* This code is completely experimental -- use with care! */ - /* It will probably be completely rewritten in the future */ - /* or even integrated into the library. */ + /* Do not use this function directly! Copy the code to */ + /* your application and modify it to suit your need. */ FT_EXPORT( void ) FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); diff --git a/headers/libs/freetype2/freetype/ftsysio.h b/headers/libs/freetype2/freetype/ftsysio.h deleted file mode 100644 index f8e49543f3..0000000000 --- a/headers/libs/freetype2/freetype/ftsysio.h +++ /dev/null @@ -1,195 +0,0 @@ -#ifndef __FT_SYSTEM_IO_H__ -#define __FT_SYSTEM_IO_H__ - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/ - /***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - /******************************************************************** - * - * designing custom streams is a bit different now - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - -#include <ft2build.h> -#include FT_INTERNAL_OBJECT_H - -FT_BEGIN_HEADER - - /*@******************************************************************* - * - * @type: FT_Stream - * - * @description: - * handle to an input stream object. These are also @FT_Object handles - */ - typedef struct FT_StreamRec_* FT_Stream; - - - /*@******************************************************************* - * - * @type: FT_Stream_Class - * - * @description: - * opaque handle to a @FT_Stream_ClassRec class structure describing - * the methods of input streams - */ - typedef const struct FT_Stream_ClassRec_* FT_Stream_Class; - - - /*@******************************************************************* - * - * @functype: FT_Stream_ReadFunc - * - * @description: - * a method used to read bytes from an input stream into memory - * - * @input: - * stream :: target stream handle - * buffer :: target buffer address - * size :: number of bytes to read - * - * @return: - * number of bytes effectively read. Must be <= 'size'. - */ - typedef FT_ULong (*FT_Stream_ReadFunc)( FT_Stream stream, - FT_Byte* buffer, - FT_ULong size ); - - - /*@******************************************************************* - * - * @functype: FT_Stream_SeekFunc - * - * @description: - * a method used to seek to a new position within a stream - * - * @input: - * stream :: target stream handle - * pos :: new read position, from start of stream - * - * @return: - * error code. 0 means success - */ - typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream, - FT_ULong pos ); - - - /*@******************************************************************* - * - * @struct: FT_Stream_ClassRec - * - * @description: - * a structure used to describe an input stream class - * - * @input: - * clazz :: root @FT_ClassRec fields - * stream_read :: stream byte read method - * stream_seek :: stream seek method - */ - typedef struct FT_Stream_ClassRec_ - { - FT_ClassRec clazz; - FT_Stream_ReadFunc stream_read; - FT_Stream_SeekFunc stream_seek; - - } FT_Stream_ClassRec; - - /* */ - -#define FT_STREAM_CLASS(x) ((FT_Stream_Class)(x)) -#define FT_STREAM_CLASS__READ(x) FT_STREAM_CLASS(x)->stream_read -#define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek; - - /*@******************************************************************* - * - * @struct: FT_StreamRec - * - * @description: - * the input stream object structure. See @FT_Stream_ClassRec for - * its class descriptor - * - * @fields: - * object :: root @FT_ObjectRec fields - * size :: size of stream in bytes (0 if unknown) - * pos :: current position within stream - * base :: for memory-based streams, the address of the stream's - * first data byte in memory. NULL otherwise - * - * cursor :: the current cursor position within an input stream - * frame. Only valid within a FT_FRAME_ENTER .. FT_FRAME_EXIT - * block; NULL otherwise - * - * limit :: the current frame limit within a FT_FRAME_ENTER .. - * FT_FRAME_EXIT block. NULL otherwise - */ - typedef struct FT_StreamRec_ - { - FT_ObjectRec object; - FT_ULong size; - FT_ULong pos; - const FT_Byte* base; - const FT_Byte* cursor; - const FT_Byte* limit; - - } FT_StreamRec; - - /* some useful macros */ -#define FT_STREAM(x) ((FT_Stream)(x)) -#define FT_STREAM_P(x) ((FT_Stream*)(x)) - -#define FT_STREAM__READ(x) FT_STREAM_CLASS__READ(FT_OBJECT__CLASS(x)) -#define FT_STREAM__SEEK(x) FT_STREAM_CLASS__SEEK(FT_OBJECT__CLASS(x)) - -#define FT_STREAM_IS_BASED(x) ( FT_STREAM(x)->base != NULL ) - - /* */ - - /* create new memory-based stream */ - FT_BASE( FT_Error ) ft_stream_new_memory( const FT_Byte* stream_base, - FT_ULong stream_size, - FT_Memory memory, - FT_Stream *astream ); - - FT_BASE( FT_Error ) ft_stream_new_iso( const char* pathanme, - FT_Memory memory, - FT_Stream *astream ); - - - /* handle to default stream class implementation for a given build */ - /* this is used by "FT_New_Face" */ - /* */ - FT_APIVAR( FT_Type ) ft_stream_default_type; - -FT_END_HEADER - -#endif /* __FT_SYSTEM_STREAM_H__ */ diff --git a/headers/libs/freetype2/freetype/ftsysmem.h b/headers/libs/freetype2/freetype/ftsysmem.h deleted file mode 100644 index 8de0c4db03..0000000000 --- a/headers/libs/freetype2/freetype/ftsysmem.h +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef __FT_SYSTEM_MEMORY_H__ -#define __FT_SYSTEM_MEMORY_H__ - -#include <ft2build.h> - -FT_BEGIN_HEADER - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/ - /***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - /*@********************************************************************** - * - * @type: FT_Memory - * - * @description: - * opaque handle to a memory manager handle. Note that since FreeType - * 2.2, the memory manager structure FT_MemoryRec is hidden to client - * applications. - * - * however, you can still define custom allocators easily using the - * @ft_memory_new API - */ - typedef struct FT_MemoryRec_* FT_Memory; - - - /*@********************************************************************** - * - * @functype: FT_Memory_AllocFunc - * - * @description: - * a function used to allocate a block of memory. - * - * @input: - * size :: size of blocks in bytes. Always > 0 !! - * mem_data :: memory-manager specific optional argument - * (see @ft_memory_new) - * - * @return: - * address of new block. NULL in case of memory exhaustion - */ - typedef FT_Pointer (*FT_Memory_AllocFunc)( FT_ULong size, - FT_Pointer mem_data ); - - - /*@********************************************************************** - * - * @functype: FT_Memory_FreeFunc - * - * @description: - * a function used to release a block of memory created through - * @FT_Memory_AllocFunc or @FT_Memory_ReallocFunc - * - * @input: - * block :: address of target memory block. cannot be NULL !! - * mem_data :: memory-manager specific optional argument - * (see @ft_memory_new) - */ - typedef void (*FT_Memory_FreeFunc) ( FT_Pointer block, - FT_Pointer mem_data ); - - - /*@********************************************************************** - * - * @functype: FT_Memory_ReallocFunc - * - * @description: - * a function used to reallocate a memory block. - * - * @input: - * block :: address of target memory block. cannot be NULL !! - * new_size :: new requested size in bytes - * cur_size :: current block size in bytes - * mem_data :: memory-manager specific optional argument - * (see @ft_memory_new) - */ - typedef FT_Pointer (*FT_Memory_ReallocFunc)( FT_Pointer block, - FT_ULong new_size, - FT_ULong cur_size, - FT_Pointer mem_data ); - - - /*@********************************************************************** - * - * @functype: FT_Memory_CreateFunc - * - * @description: - * a function used to create a @FT_Memory object to model a - * memory manager - * - * @input: - * size :: size of memory manager structure in bytes - * init_data :: optional initialisation argument - * - * @output: - * amem_data :: memory-manager specific argument to block management - * routines. - * - * @return: - * handle to new memory manager object. NULL in case of failure - */ - typedef FT_Pointer (*FT_Memory_CreateFunc)( FT_UInt size, - FT_Pointer init_data, - FT_Pointer *amem_data ); - - - /*@********************************************************************** - * - * @functype: FT_Memory_DestroyFunc - * - * @description: - * a function used to destroy a given @FT_Memory manager - * - * @input: - * memory :: target memory manager handle - * mem_data :: option manager-specific argument - */ - typedef void (*FT_Memory_DestroyFunc)( FT_Memory memory, - FT_Pointer mem_data ); - - - /*@********************************************************************** - * - * @struct: FT_Memory_FuncsRec - * - * @description: - * a function used to hold all methods of a given memory manager - * implementation. - * - * @fields: - * mem_alloc :: block allocation routine - * mem_free :: block release routine - * mem_realloc :: block re-allocation routine - * mem_create :: manager creation routine - * mem_destroy :: manager destruction routine - */ - typedef struct FT_Memory_FuncsRec_ - { - FT_Memory_AllocFunc mem_alloc; - FT_Memory_FreeFunc mem_free; - FT_Memory_ReallocFunc mem_realloc; - FT_Memory_CreateFunc mem_create; - FT_Memory_DestroyFunc mem_destroy; - - } FT_Memory_FuncsRec, *FT_Memory_Funcs; - - - /*@********************************************************************** - * - * @type: FT_Memory_Funcs - * - * @description: - * a pointer to a constant @FT_Memory_FuncsRec structure used to - * describe a given memory manager implementation. - */ - typedef const FT_Memory_FuncsRec* FT_Memory_Funcs; - - - /*@********************************************************************** - * - * @function: ft_memory_new - * - * @description: - * create a new memory manager, given a set of memory methods - * - * @input: - * mem_funcs :: handle to memory manager implementation descriptor - * mem_init_data :: optional initialisation argument, passed to - * @FT_Memory_CreateFunc - * - * @return: - * new memory manager handle. NULL in case of failure - */ - FT_BASE( FT_Memory ) - ft_memory_new( FT_Memory_Funcs mem_funcs, - FT_Pointer mem_init_data ); - - - /*@********************************************************************** - * - * @function: ft_memory_destroy - * - * @description: - * destroy a given memory manager - * - * @input: - * memory :: handle to target memory manager - */ - FT_BASE( void ) - ft_memory_destroy( FT_Memory memory ); - -/* */ - -FT_END_HEADER - -#endif /* __FT_SYSTEM_MEMORY_H__ */ diff --git a/headers/libs/freetype2/freetype/ftsystem.h b/headers/libs/freetype2/freetype/ftsystem.h index d1c55f7aea..59cd019822 100644 --- a/headers/libs/freetype2/freetype/ftsystem.h +++ b/headers/libs/freetype2/freetype/ftsystem.h @@ -4,7 +4,7 @@ /* */ /* FreeType low-level system interface definition (specification). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,19 +29,19 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Section> */ - /* system_interface */ + /* system_interface */ /* */ /* <Title> */ - /* System Interface */ + /* System Interface */ /* */ /* <Abstract> */ - /* How FreeType manages memory and i/o. */ + /* How FreeType manages memory and i/o. */ /* */ /* <Description> */ - /* This section contains various definitions related to memory */ - /* management and i/o access. You need to understand this */ - /* information if you want to use a custom memory manager or you own */ - /* input i/o streams. */ + /* This section contains various definitions related to memory */ + /* management and i/o access. You need to understand this */ + /* information if you want to use a custom memory manager or you own */ + /* i/o streams. */ /* */ /*************************************************************************/ @@ -53,80 +53,92 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @type: */ - /* FT_Memory */ - /* */ - /* @description: */ - /* A handle to a given memory manager object, defined with a */ - /* @FT_MemoryRec structure. */ - /* */ + /************************************************************************* + * + * @type: + * FT_Memory + * + * @description: + * A handle to a given memory manager object, defined with an + * @FT_MemoryRec structure. + * + */ typedef struct FT_MemoryRec_* FT_Memory; - /*************************************************************************/ - /* */ - /* @functype: */ - /* FT_Alloc_Func */ - /* */ - /* @description: */ - /* A function used to allocate `size' bytes from `memory'. */ - /* */ - /* @input: */ - /* memory :: A handle to the source memory manager. */ - /* */ - /* size :: The size in bytes to allocate. */ - /* */ - /* @return: */ - /* Address of new memory block. 0 in case of failure. */ - /* */ + /************************************************************************* + * + * @functype: + * FT_Alloc_Func + * + * @description: + * A function used to allocate `size' bytes from `memory'. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * size :: + * The size in bytes to allocate. + * + * @return: + * Address of new memory block. 0 in case of failure. + * + */ typedef void* (*FT_Alloc_Func)( FT_Memory memory, long size ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* FT_Free_Func */ - /* */ - /* @description: */ - /* A function used to release a given block of memory. */ - /* */ - /* @input: */ - /* memory :: A handle to the source memory manager. */ - /* */ - /* block :: The address of the target memory block. */ - /* */ + /************************************************************************* + * + * @functype: + * FT_Free_Func + * + * @description: + * A function used to release a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * block :: + * The address of the target memory block. + * + */ typedef void (*FT_Free_Func)( FT_Memory memory, void* block ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* FT_Realloc_Func */ - /* */ - /* @description: */ - /* a function used to re-allocate a given block of memory. */ - /* */ - /* @input: */ - /* memory :: A handle to the source memory manager. */ - /* */ - /* cur_size :: The block's current size in bytes. */ - /* */ - /* new_size :: The block's requested new size. */ - /* */ - /* block :: The block's current address. */ - /* */ - /* @return: */ - /* New block address. 0 in case of memory shortage. */ - /* */ - /* @note: */ - /* In case of error, the old block must still be available. */ - /* */ + /************************************************************************* + * + * @functype: + * FT_Realloc_Func + * + * @description: + * A function used to re-allocate a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * cur_size :: + * The block's current size in bytes. + * + * new_size :: + * The block's requested new size. + * + * block :: + * The block's current address. + * + * @return: + * New block address. 0 in case of memory shortage. + * + * @note: + * In case of error, the old block must still be available. + * + */ typedef void* (*FT_Realloc_Func)( FT_Memory memory, long cur_size, @@ -134,23 +146,28 @@ FT_BEGIN_HEADER void* block ); - /*************************************************************************/ - /* */ - /* @struct: */ - /* FT_MemoryRec */ - /* */ - /* @description: */ - /* A structure used to describe a given memory manager to FreeType 2. */ - /* */ - /* @fields: */ - /* user :: A generic typeless pointer for user data. */ - /* */ - /* alloc :: A pointer type to an allocation function. */ - /* */ - /* free :: A pointer type to an memory freeing function. */ - /* */ - /* realloc :: A pointer type to a reallocation function. */ - /* */ + /************************************************************************* + * + * @struct: + * FT_MemoryRec + * + * @description: + * A structure used to describe a given memory manager to FreeType 2. + * + * @fields: + * user :: + * A generic typeless pointer for user data. + * + * alloc :: + * A pointer type to an allocation function. + * + * free :: + * A pointer type to an memory freeing function. + * + * realloc :: + * A pointer type to a reallocation function. + * + */ struct FT_MemoryRec_ { void* user; @@ -167,26 +184,28 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @type: */ - /* FT_Stream */ - /* */ - /* @description: */ - /* A handle to an input stream. */ - /* */ + /************************************************************************* + * + * @type: + * FT_Stream + * + * @description: + * A handle to an input stream. + * + */ typedef struct FT_StreamRec_* FT_Stream; - /*************************************************************************/ - /* */ - /* @struct: */ - /* FT_StreamDesc */ - /* */ - /* @description: */ - /* A union type used to store either a long or a pointer. This is */ - /* used to store a file descriptor or a FILE* in an input stream. */ - /* */ + /************************************************************************* + * + * @struct: + * FT_StreamDesc + * + * @description: + * A union type used to store either a long or a pointer. This is used + * to store a file descriptor or a `FILE*' in an input stream. + * + */ typedef union FT_StreamDesc_ { long value; @@ -195,30 +214,35 @@ FT_BEGIN_HEADER } FT_StreamDesc; - /*************************************************************************/ - /* */ - /* @functype: */ - /* FT_Stream_IoFunc */ - /* */ - /* @description: */ - /* A function used to seek and read data from a given input stream. */ - /* */ - /* @input: */ - /* stream :: A handle to the source stream. */ - /* */ - /* offset :: The offset of read in stream (always from start). */ - /* */ - /* buffer :: The address of the read buffer. */ - /* */ - /* count :: The number of bytes to read from the stream. */ - /* */ - /* @return: */ - /* The number of bytes effectively read by the stream. */ - /* */ - /* @note: */ - /* This function might be called to perform a seek or skip operation */ - /* with a `count' of 0. */ - /* */ + /************************************************************************* + * + * @functype: + * FT_Stream_IoFunc + * + * @description: + * A function used to seek and read data from a given input stream. + * + * @input: + * stream :: + * A handle to the source stream. + * + * offset :: + * The offset of read in stream (always from start). + * + * buffer :: + * The address of the read buffer. + * + * count :: + * The number of bytes to read from the stream. + * + * @return: + * The number of bytes effectively read by the stream. + * + * @note: + * This function might be called to perform a seek or skip operation + * with a `count' of 0. + * + */ typedef unsigned long (*FT_Stream_IoFunc)( FT_Stream stream, unsigned long offset, @@ -226,60 +250,73 @@ FT_BEGIN_HEADER unsigned long count ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* FT_Stream_CloseFunc */ - /* */ - /* @description: */ - /* A function used to close a given input stream. */ - /* */ - /* @input: */ - /* stream :: A handle to the target stream. */ - /* */ + /************************************************************************* + * + * @functype: + * FT_Stream_CloseFunc + * + * @description: + * A function used to close a given input stream. + * + * @input: + * stream :: + * A handle to the target stream. + * + */ typedef void (*FT_Stream_CloseFunc)( FT_Stream stream ); - /*************************************************************************/ - /* */ - /* @struct: */ - /* FT_StreamRec */ - /* */ - /* @description: */ - /* A structure used to describe an input stream. */ - /* */ - /* @input: */ - /* base :: For memory-based streams, this is the address of the */ - /* first stream byte in memory. This field should */ - /* always be set to NULL for disk-based streams. */ - /* */ - /* size :: The stream size in bytes. */ - /* */ - /* pos :: The current position within the stream. */ - /* */ - /* descriptor :: This field is a union that can hold an integer or a */ - /* pointer. It is used by stream implementations to */ - /* store file descriptors or FILE* pointers. */ - /* */ - /* pathname :: This field is completely ignored by FreeType. */ - /* However, it is often useful during debugging to use */ - /* it to store the stream's filename (where available). */ - /* */ - /* read :: The stream's input function. */ - /* */ - /* close :: The stream;s close function. */ - /* */ - /* memory :: The memory manager to use to preload frames. This is */ - /* set internally by FreeType and shouldn't be touched */ - /* by stream implementations. */ - /* */ - /* cursor :: This field is set and used internally by FreeType */ - /* when parsing frames. */ - /* */ - /* limit :: This field is set and used internally by FreeType */ - /* when parsing frames. */ - /* */ + /************************************************************************* + * + * @struct: + * FT_StreamRec + * + * @description: + * A structure used to describe an input stream. + * + * @input: + * base :: + * For memory-based streams, this is the address of the first stream + * byte in memory. This field should always be set to NULL for + * disk-based streams. + * + * size :: + * The stream size in bytes. + * + * pos :: + * The current position within the stream. + * + * descriptor :: + * This field is a union that can hold an integer or a pointer. It is + * used by stream implementations to store file descriptors or `FILE*' + * pointers. + * + * pathname :: + * This field is completely ignored by FreeType. However, it is often + * useful during debugging to use it to store the stream's filename + * (where available). + * + * read :: + * The stream's input function. + * + * close :: + * The stream;s close function. + * + * memory :: + * The memory manager to use to preload frames. This is set + * internally by FreeType and shouldn't be touched by stream + * implementations. + * + * cursor :: + * This field is set and used internally by FreeType when parsing + * frames. + * + * limit :: + * This field is set and used internally by FreeType when parsing + * frames. + * + */ typedef struct FT_StreamRec_ { unsigned char* base; diff --git a/headers/libs/freetype2/freetype/fttrigon.h b/headers/libs/freetype2/freetype/fttrigon.h index 0462265e3c..92cf6d9baf 100644 --- a/headers/libs/freetype2/freetype/fttrigon.h +++ b/headers/libs/freetype2/freetype/fttrigon.h @@ -4,7 +4,7 @@ /* */ /* FreeType trigonometric functions (specification). */ /* */ -/* Copyright 2001, 2003 by */ +/* Copyright 2001, 2003, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -33,272 +33,307 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @section: */ + /* <Section> */ /* computations */ /* */ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @type: */ - /* FT_Angle */ - /* */ - /* @description: */ - /* This type is used to model angle values in FreeType. Note that */ - /* the angle is a 16.16 fixed float value expressed in degrees. */ - /* */ + /************************************************************************* + * + * @type: + * FT_Angle + * + * @description: + * This type is used to model angle values in FreeType. Note that the + * angle is a 16.16 fixed float value expressed in degrees. + * + */ typedef FT_Fixed FT_Angle; - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_ANGLE_PI */ - /* */ - /* @description: */ - /* The angle pi expressed in @FT_Angle units. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI + * + * @description: + * The angle pi expressed in @FT_Angle units. + * + */ #define FT_ANGLE_PI ( 180L << 16 ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_ANGLE_2PI */ - /* */ - /* @description: */ - /* The angle 2*pi expressed in @FT_Angle units. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_ANGLE_2PI + * + * @description: + * The angle 2*pi expressed in @FT_Angle units. + * + */ #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_ANGLE_PI2 */ - /* */ - /* @description: */ - /* The angle pi/2 expressed in @FT_Angle units. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI2 + * + * @description: + * The angle pi/2 expressed in @FT_Angle units. + * + */ #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) - /*************************************************************************/ - /* */ - /* @macro: */ - /* FT_ANGLE_PI4 */ - /* */ - /* @description: */ - /* The angle pi/4 expressed in @FT_Angle units. */ - /* */ + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI4 + * + * @description: + * The angle pi/4 expressed in @FT_Angle units. + * + */ #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Sin */ - /* */ - /* @description: */ - /* Return the sinus of a given angle in fixed point format. */ - /* */ - /* @input: */ - /* angle :: The input angle. */ - /* */ - /* @return: */ - /* The sinus value. */ - /* */ - /* @note: */ - /* If you need both the sinus and cosinus for a given angle, use the */ - /* function @FT_Vector_Unit. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Sin + * + * @description: + * Return the sinus of a given angle in fixed point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The sinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ FT_EXPORT( FT_Fixed ) FT_Sin( FT_Angle angle ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Cos */ - /* */ - /* @description: */ - /* Return the cosinus of a given angle in fixed point format. */ - /* */ - /* @input: */ - /* angle :: The input angle. */ - /* */ - /* @return: */ - /* The cosinus value. */ - /* */ - /* @note: */ - /* If you need both the sinus and cosinus for a given angle, use the */ - /* function @FT_Vector_Unit. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Cos + * + * @description: + * Return the cosinus of a given angle in fixed point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The cosinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ FT_EXPORT( FT_Fixed ) FT_Cos( FT_Angle angle ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Tan */ - /* */ - /* @description: */ - /* Return the tangent of a given angle in fixed point format. */ - /* */ - /* @input: */ - /* angle :: The input angle. */ - /* */ - /* @return: */ - /* The tangent value. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Tan + * + * @description: + * Return the tangent of a given angle in fixed point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The tangent value. + * + */ FT_EXPORT( FT_Fixed ) FT_Tan( FT_Angle angle ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Atan2 */ - /* */ - /* @description: */ - /* Return the arc-tangent corresponding to a given vector (x,y) in */ - /* the 2d plane. */ - /* */ - /* @input: */ - /* x :: The horizontal vector coordinate. */ - /* */ - /* y :: The vertical vector coordinate. */ - /* */ - /* @return: */ - /* The arc-tangent value (i.e. angle). */ - /* */ + /************************************************************************* + * + * @function: + * FT_Atan2 + * + * @description: + * Return the arc-tangent corresponding to a given vector (x,y) in + * the 2d plane. + * + * @input: + * x :: + * The horizontal vector coordinate. + * + * y :: + * The vertical vector coordinate. + * + * @return: + * The arc-tangent value (i.e. angle). + * + */ FT_EXPORT( FT_Angle ) FT_Atan2( FT_Fixed x, FT_Fixed y ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Angle_Diff */ - /* */ - /* @description: */ - /* Return the difference between two angles. The result is always */ - /* constrained to the ]-PI..PI] interval. */ - /* */ - /* @input: */ - /* angle1 :: First angle. */ - /* */ - /* angle2 :: Second angle. */ - /* */ - /* @return: */ - /* Contrainted value of `value2-value1'. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Angle_Diff + * + * @description: + * Return the difference between two angles. The result is always + * constrained to the ]-PI..PI] interval. + * + * @input: + * angle1 :: + * First angle. + * + * angle2 :: + * Second angle. + * + * @return: + * Contrainted value of `value2-value1'. + * + */ FT_EXPORT( FT_Angle ) FT_Angle_Diff( FT_Angle angle1, FT_Angle angle2 ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Vector_Unit */ - /* */ - /* @description: */ - /* Return the unit vector corresponding to a given angle. After the */ - /* call, the value of `vec.x' will be `sin(angle)', and the value of */ - /* `vec.y' will be `cos(angle)'. */ - /* */ - /* This function is useful to retrieve both the sinus and cosinus of */ - /* a given angle quickly. */ - /* */ - /* @output: */ - /* vec :: The address of target vector. */ - /* */ - /* @input: */ - /* angle :: The address of angle. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Vector_Unit + * + * @description: + * Return the unit vector corresponding to a given angle. After the + * call, the value of `vec.x' will be `sin(angle)', and the value of + * `vec.y' will be `cos(angle)'. + * + * This function is useful to retrieve both the sinus and cosinus of a + * given angle quickly. + * + * @output: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The address of angle. + * + */ FT_EXPORT( void ) FT_Vector_Unit( FT_Vector* vec, FT_Angle angle ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Vector_Rotate */ - /* */ - /* @description: */ - /* Rotate a vector by a given angle. */ - /* */ - /* @inout: */ - /* vec :: The address of target vector. */ - /* */ - /* @input: */ - /* angle :: The address of angle. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Vector_Rotate + * + * @description: + * Rotate a vector by a given angle. + * + * @inout: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The address of angle. + * + */ FT_EXPORT( void ) FT_Vector_Rotate( FT_Vector* vec, FT_Angle angle ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Vector_Length */ - /* */ - /* @description: */ - /* Return the length of a given vector. */ - /* */ - /* @input: */ - /* vec :: The address of target vector. */ - /* */ - /* @return: */ - /* The vector length, expressed in the same units that the original */ - /* vector coordinates. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Vector_Length + * + * @description: + * Return the length of a given vector. + * + * @input: + * vec :: + * The address of target vector. + * + * @return: + * The vector length, expressed in the same units that the original + * vector coordinates. + * + */ FT_EXPORT( FT_Fixed ) FT_Vector_Length( FT_Vector* vec ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Vector_Polarize */ - /* */ - /* @description: */ - /* Compute both the length and angle of a given vector. */ - /* */ - /* @input: */ - /* vec :: The address of source vector. */ - /* */ - /* @output: */ - /* length :: The vector length. */ - /* angle :: The vector angle. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Vector_Polarize + * + * @description: + * Compute both the length and angle of a given vector. + * + * @input: + * vec :: + * The address of source vector. + * + * @output: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ FT_EXPORT( void ) FT_Vector_Polarize( FT_Vector* vec, FT_Fixed *length, FT_Angle *angle ); - /*************************************************************************/ - /* */ - /* @function: */ - /* FT_Vector_From_Polar */ - /* */ - /* @description: */ - /* Compute vector coordinates from a length and angle. */ - /* */ - /* @output: */ - /* vec :: The address of source vector. */ - /* */ - /* @input: */ - /* length :: The vector length. */ - /* angle :: The vector angle. */ - /* */ + /************************************************************************* + * + * @function: + * FT_Vector_From_Polar + * + * @description: + * Compute vector coordinates from a length and angle. + * + * @output: + * vec :: + * The address of source vector. + * + * @input: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ FT_EXPORT( void ) FT_Vector_From_Polar( FT_Vector* vec, FT_Fixed length, diff --git a/headers/libs/freetype2/freetype/fttypes.h b/headers/libs/freetype2/freetype/fttypes.h index 7727ebb556..44ad625c15 100644 --- a/headers/libs/freetype2/freetype/fttypes.h +++ b/headers/libs/freetype2/freetype/fttypes.h @@ -4,7 +4,7 @@ /* */ /* FreeType simple types definitions (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2004 by */ +/* Copyright 1996-2001, 2002, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -273,8 +273,8 @@ FT_BEGIN_HEADER /* FT_Fixed */ /* */ /* <Description> */ - /* This type is used to store 16.16 fixed float values, like scales */ - /* or matrix coefficients. */ + /* This type is used to store 16.16 fixed float values, like scaling */ + /* values or matrix coefficients. */ /* */ typedef signed long FT_Fixed; @@ -308,7 +308,7 @@ FT_BEGIN_HEADER /* FT_Offset */ /* */ /* <Description> */ - /* This is equivalent to the ANSI C `size_t' type, i.e. the largest */ + /* This is equivalent to the ANSI C `size_t' type, i.e., the largest */ /* _unsigned_ integer type used to express a file size or position, */ /* or a memory block size. */ /* */ @@ -321,7 +321,7 @@ FT_BEGIN_HEADER /* FT_PtrDist */ /* */ /* <Description> */ - /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e. the */ + /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e., the */ /* largest _signed_ integer type used to express the distance */ /* between two pointers. */ /* */ @@ -409,7 +409,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Describes a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the FT_Generic type for */ + /* FreeType object. See the description of the @FT_Generic type for */ /* details of usage. */ /* */ /* <Input> */ @@ -461,7 +461,7 @@ FT_BEGIN_HEADER /* FT_MAKE_TAG */ /* */ /* <Description> */ - /* This macro converts four letter tags which are used to label */ + /* This macro converts four-letter tags which are used to label */ /* TrueType tables into an unsigned long to be used within FreeType. */ /* */ /* <Note> */ @@ -498,8 +498,8 @@ FT_BEGIN_HEADER /* FT_ListNode */ /* */ /* <Description> */ - /* Many elements and objects in FreeType are listed through a */ - /* FT_List record (see FT_ListRec). As its name suggests, a */ + /* Many elements and objects in FreeType are listed through an */ + /* @FT_List record (see @FT_ListRec). As its name suggests, an */ /* FT_ListNode is a handle to a single list element. */ /* */ typedef struct FT_ListNodeRec_* FT_ListNode; @@ -511,7 +511,7 @@ FT_BEGIN_HEADER /* FT_List */ /* */ /* <Description> */ - /* A handle to a list record (see FT_ListRec). */ + /* A handle to a list record (see @FT_ListRec). */ /* */ typedef struct FT_ListRec_* FT_List; diff --git a/headers/libs/freetype2/freetype/ftwinfnt.h b/headers/libs/freetype2/freetype/ftwinfnt.h index 355b7e9042..5849b00337 100644 --- a/headers/libs/freetype2/freetype/ftwinfnt.h +++ b/headers/libs/freetype2/freetype/ftwinfnt.h @@ -77,7 +77,8 @@ FT_BEGIN_HEADER * Mac Roman encoding. * * FT_WinFNT_ID_OEM :: - * From Michael Pöttgen <michael@poettgen.de>: + * From Michael Pöttgen <michael@poettgen.de>: + * * 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. @@ -255,3 +256,8 @@ FT_END_HEADER /* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/headers/libs/freetype2/freetype/internal/ftcalc.h b/headers/libs/freetype2/freetype/internal/ftcalc.h index 0df502c755..53d7a67703 100644 --- a/headers/libs/freetype2/freetype/internal/ftcalc.h +++ b/headers/libs/freetype2/freetype/internal/ftcalc.h @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -44,12 +44,11 @@ FT_BEGIN_HEADER /* <Note> */ /* This function is not very fast. */ /* */ - FT_EXPORT( FT_Int32 ) + FT_BASE( FT_Int32 ) FT_SqrtFixed( FT_Int32 x ); -#define SQRT_32( x ) FT_Sqrt32( x ) - +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS /*************************************************************************/ /* */ @@ -69,6 +68,8 @@ FT_BEGIN_HEADER FT_EXPORT( FT_Int32 ) FT_Sqrt32( FT_Int32 x ); +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + /*************************************************************************/ /* */ diff --git a/headers/libs/freetype2/freetype/internal/ftdebug.h b/headers/libs/freetype2/freetype/internal/ftdebug.h index ce142c54c9..cc02581f37 100644 --- a/headers/libs/freetype2/freetype/internal/ftdebug.h +++ b/headers/libs/freetype2/freetype/internal/ftdebug.h @@ -4,7 +4,7 @@ /* */ /* Debugging and logging component (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004 by */ +/* Copyright 1996-2001, 2002, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -15,7 +15,7 @@ /* */ /* */ /* IMPORTANT: A description of FreeType's debugging support can be */ -/* found in "docs/DEBUG.TXT". Read it if you need to use or */ +/* found in `docs/DEBUG.TXT'. Read it if you need to use or */ /* understand this code. */ /* */ /***************************************************************************/ @@ -113,7 +113,7 @@ FT_BEGIN_HEADER /* This function may be useful if you want to access elements of */ /* the internal `ft_trace_levels' array by an index. */ /* */ - FT_EXPORT( FT_Int ) + FT_BASE( FT_Int ) FT_Trace_Get_Count( void ); @@ -140,7 +140,7 @@ FT_BEGIN_HEADER /* This function may be useful if you want to control FreeType 2's */ /* debug level in your appliaciton. */ /* */ - FT_EXPORT( const char * ) + FT_BASE( const char * ) FT_Trace_Get_Name( FT_Int idx ); @@ -204,7 +204,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* Define 'FT_Message' and 'FT_Panic' when needed */ + /* Define `FT_Message' and `FT_Panic' when needed */ /* */ /*************************************************************************/ @@ -213,11 +213,11 @@ FT_BEGIN_HEADER #include "stdio.h" /* for vprintf() */ /* print a message */ - FT_EXPORT( void ) + FT_BASE( void ) FT_Message( const char* fmt, ... ); /* print a message and exit */ - FT_EXPORT( void ) + FT_BASE( void ) FT_Panic( const char* fmt, ... ); #endif /* FT_DEBUG_LEVEL_ERROR */ diff --git a/headers/libs/freetype2/freetype/internal/ftdriver.h b/headers/libs/freetype2/freetype/internal/ftdriver.h index 02f585d6b0..97f3fd04d9 100644 --- a/headers/libs/freetype2/freetype/internal/ftdriver.h +++ b/headers/libs/freetype2/freetype/internal/ftdriver.h @@ -4,7 +4,7 @@ /* */ /* FreeType font driver interface (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -52,6 +52,16 @@ FT_BEGIN_HEADER (*FT_Slot_DoneFunc)( FT_GlyphSlot slot ); + typedef FT_Error + (*FT_Size_RequestFunc)( FT_Size size, + FT_Size_Request req ); + + typedef FT_Error + (*FT_Size_SelectFunc)( FT_Size size, + FT_ULong size_index ); + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + typedef FT_Error (*FT_Size_ResetPointsFunc)( FT_Size size, FT_F26Dot6 char_width, @@ -64,6 +74,8 @@ FT_BEGIN_HEADER FT_UInt pixel_width, FT_UInt pixel_height ); +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + typedef FT_Error (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, FT_Size size, @@ -129,16 +141,9 @@ FT_BEGIN_HEADER /* */ /* done_slot :: The format-specific slot destructor. */ /* */ - /* set_char_sizes :: A handle to a function used to set the new */ - /* character size in points + resolution. Can be */ - /* set to 0 to indicate default behaviour. */ /* */ - /* set_pixel_sizes :: A handle to a function used to set the new */ - /* character size in pixels. Can be set to 0 to */ - /* indicate default behaviour. */ - /* */ - /* load_glyph :: A function handle to load a given glyph image */ - /* in a slot. This field is mandatory! */ + /* load_glyph :: A function handle to load a glyph to a slot. */ + /* This field is mandatory! */ /* */ /* get_char_index :: A function handle to return the glyph index of */ /* a given character for a given charmap. This */ @@ -156,7 +161,7 @@ FT_BEGIN_HEADER /* face, or a CIDMap on a CID-keyed face. */ /* */ /* get_advances :: A function handle used to return advance */ - /* widths of 'count' glyphs (in font units), */ + /* widths of `count' glyphs (in font units), */ /* starting at `first'. The `vertical' flag must */ /* be set to get vertical advance heights. The */ /* `advances' buffer is caller-allocated. */ @@ -165,6 +170,15 @@ FT_BEGIN_HEADER /* device-independent text layout without loading */ /* a single glyph image. */ /* */ + /* request_size :: A handle to a function used to request the new */ + /* character size. Can be set to 0 if the */ + /* scaling done in the base layer suffices. */ + /* */ + /* select_size :: A handle to a function used to select a new */ + /* fixed size. It is used only if */ + /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ + /* to 0 if the scaling done in the base layer */ + /* suffices. */ /* <Note> */ /* Most function pointers, with the exception of `load_glyph' and */ /* `get_char_index' can be set to 0 to indicate a default behaviour. */ @@ -186,18 +200,50 @@ FT_BEGIN_HEADER FT_Slot_InitFunc init_slot; FT_Slot_DoneFunc done_slot; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_Size_ResetPointsFunc set_char_sizes; FT_Size_ResetPixelsFunc set_pixel_sizes; +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + FT_Slot_LoadFunc load_glyph; FT_Face_GetKerningFunc get_kerning; FT_Face_AttachFunc attach_file; FT_Face_GetAdvancesFunc get_advances; + /* since version 2.2 */ + FT_Size_RequestFunc request_size; + FT_Size_SelectFunc select_size; + } FT_Driver_ClassRec, *FT_Driver_Class; + /* + * The following functions are used as stubs for `set_char_sizes' and + * `set_pixel_sizes'; the code uses `request_size' and `select_size' + * functions instead. + * + * Implementation is in `src/base/ftobjs.c'. + */ +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + FT_BASE( FT_Error ) + ft_stub_set_char_sizes( FT_Size size, + FT_F26Dot6 width, + FT_F26Dot6 height, + FT_UInt horz_res, + FT_UInt vert_res ); + + FT_BASE( FT_Error ) + ft_stub_set_pixel_sizes( FT_Size size, + FT_UInt width, + FT_UInt height ); + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + FT_END_HEADER #endif /* __FTDRIVER_H__ */ diff --git a/headers/libs/freetype2/freetype/internal/ftgloadr.h b/headers/libs/freetype2/freetype/internal/ftgloadr.h index abc56e2566..b2e35fee3b 100644 --- a/headers/libs/freetype2/freetype/internal/ftgloadr.h +++ b/headers/libs/freetype2/freetype/internal/ftgloadr.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph loader (specification). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -43,6 +43,7 @@ FT_BEGIN_HEADER typedef struct FT_GlyphLoaderRec_* FT_GlyphLoader ; +#if 0 /* moved to freetype.h in version 2.2 */ #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 @@ -50,6 +51,7 @@ FT_BEGIN_HEADER #define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 #define FT_SUBGLYPH_FLAG_2X2 0x80 #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 +#endif typedef struct FT_SubGlyphRec_ @@ -59,7 +61,7 @@ FT_BEGIN_HEADER FT_Int arg1; FT_Int arg2; FT_Matrix transform; - + } FT_SubGlyphRec; @@ -117,6 +119,24 @@ FT_BEGIN_HEADER FT_UInt n_points, FT_UInt n_contours ); + +#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ + ( (_count) == 0 || (int)((_loader)->base.outline.n_points + \ + (_loader)->current.outline.n_points + \ + (_count)) <= (int)(_loader)->max_points ) + +#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ + ( (_count) == 0 || (int)((_loader)->base.outline.n_contours + \ + (_loader)->current.outline.n_contours + \ + (_count)) <= (int)(_loader)->max_contours ) + +#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points,_contours ) \ + ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ + FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \ + ? 0 \ + : FT_GlyphLoader_CheckPoints( (_loader), (_points), (_contours) ) ) + + /* check that there is enough space to add `n_subs' sub-glyphs to */ /* a glyph loader */ FT_BASE( FT_Error ) diff --git a/headers/libs/freetype2/freetype/internal/ftmemory.h b/headers/libs/freetype2/freetype/internal/ftmemory.h index d93a077974..a4c1a70008 100644 --- a/headers/libs/freetype2/freetype/internal/ftmemory.h +++ b/headers/libs/freetype2/freetype/internal/ftmemory.h @@ -4,7 +4,7 @@ /* */ /* The FreeType memory management macros (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -56,198 +56,134 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ -#ifdef FT_DEBUG_MEMORY - FT_BASE( FT_Error ) - FT_Alloc_Debug( FT_Memory memory, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ); - - FT_BASE( FT_Error ) - FT_QAlloc_Debug( FT_Memory memory, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ); - - FT_BASE( FT_Error ) - FT_Realloc_Debug( FT_Memory memory, - FT_Long current, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ); - - FT_BASE( FT_Error ) - FT_QRealloc_Debug( FT_Memory memory, - FT_Long current, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ); - - FT_BASE( void ) - FT_Free_Debug( FT_Memory memory, - FT_Pointer block, - const char* file_name, - FT_Long line_no ); + /* + * C++ refuses to handle statements like p = (void*)anything; where `p' + * is a typed pointer. Since we don't have a `typeof' operator in + * standard C++, we have to use ugly casts. + */ +#ifdef __cplusplus +#define FT_ASSIGNP( p, val ) *((void**)&(p)) = (val) +#else +#define FT_ASSIGNP( p, val ) (p) = (val) #endif - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Alloc */ - /* */ - /* <Description> */ - /* Allocates a new block of memory. The returned area is always */ - /* zero-filled; this is a strong convention in many FreeType parts. */ - /* */ - /* <Input> */ - /* memory :: A handle to a given `memory object' which handles */ - /* allocation. */ - /* */ - /* size :: The size in bytes of the block to allocate. */ - /* */ - /* <Output> */ - /* P :: A pointer to the fresh new block. It should be set to */ - /* NULL if `size' is 0, or in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - FT_BASE( FT_Error ) - FT_Alloc( FT_Memory memory, - FT_Long size, - void* *P ); + +#ifdef FT_DEBUG_MEMORY + + FT_BASE( const char* ) _ft_debug_file; + FT_BASE( long ) _ft_debug_lineno; + +#define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ + _ft_debug_lineno = __LINE__, \ + (exp) ) + +#define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ + _ft_debug_lineno = __LINE__, \ + FT_ASSIGNP( p, exp ) ) + +#else /* !FT_DEBUG_MEMORY */ + +#define FT_DEBUG_INNER( exp ) (exp) +#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) + +#endif /* !FT_DEBUG_MEMORY */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_QAlloc */ - /* */ - /* <Description> */ - /* Allocates a new block of memory. The returned area is *not* */ - /* zero-filled, making allocation quicker. */ - /* */ - /* <Input> */ - /* memory :: A handle to a given `memory object' which handles */ - /* allocation. */ - /* */ - /* size :: The size in bytes of the block to allocate. */ - /* */ - /* <Output> */ - /* P :: A pointer to the fresh new block. It should be set to */ - /* NULL if `size' is 0, or in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - FT_BASE( FT_Error ) - FT_QAlloc( FT_Memory memory, - FT_Long size, - void* *p ); + /* + * The allocation functions return a pointer, and the error code + * is written to through the `p_error' parameter. See below for + * for documentation. + */ + FT_BASE( FT_Pointer ) + ft_mem_alloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Realloc */ - /* */ - /* <Description> */ - /* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ - /* from the heap, possibly changing `*P'. The returned area is */ - /* zero-filled. */ - /* */ - /* <Input> */ - /* memory :: A handle to a given `memory object' which handles */ - /* reallocation. */ - /* */ - /* current :: The current block size in bytes. */ - /* */ - /* size :: The new block size in bytes. */ - /* */ - /* <InOut> */ - /* P :: A pointer to the fresh new block. It should be set to */ - /* NULL if `size' is 0, or in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* All callers of FT_Realloc() _must_ provide the current block size */ - /* as well as the new one. */ - /* */ - FT_BASE( FT_Error ) - FT_Realloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void* *P ); + FT_BASE( FT_Pointer ) + ft_mem_qalloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ); + FT_BASE( FT_Pointer ) + ft_mem_realloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_QRealloc */ - /* */ - /* <Description> */ - /* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ - /* from the heap, possibly changing `*P'. The returned area is *not* */ - /* zero-filled, making reallocation quicker. */ - /* */ - /* <Input> */ - /* memory :: A handle to a given `memory object' which handles */ - /* reallocation. */ - /* */ - /* current :: The current block size in bytes. */ - /* */ - /* size :: The new block size in bytes. */ - /* */ - /* <InOut> */ - /* P :: A pointer to the fresh new block. It should be set to */ - /* NULL if `size' is 0, or in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* All callers of FT_Realloc() _must_ provide the current block size */ - /* as well as the new one. */ - /* */ - FT_BASE( FT_Error ) - FT_QRealloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void* *p ); + FT_BASE( FT_Pointer ) + ft_mem_qrealloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ); - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Free */ - /* */ - /* <Description> */ - /* Releases a given block of memory allocated through FT_Alloc(). */ - /* */ - /* <Input> */ - /* memory :: A handle to a given `memory object' which handles */ - /* memory deallocation */ - /* */ - /* P :: This is the _address_ of a _pointer_ which points to the */ - /* allocated block. It is always set to NULL on exit. */ - /* */ - /* <Note> */ - /* If P or *P is NULL, this function should return successfully. */ - /* This is a strong convention within all of FreeType and its */ - /* drivers. */ - /* */ FT_BASE( void ) - FT_Free( FT_Memory memory, - void* *P ); + ft_mem_free( FT_Memory memory, + const void* P ); + + +#define FT_MEM_ALLOC( ptr, size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) ) + +#define FT_MEM_FREE( ptr ) \ + FT_BEGIN_STMNT \ + ft_mem_free( memory, (ptr) ); \ + (ptr) = NULL; \ + FT_END_STMNT + +#define FT_MEM_NEW( ptr ) \ + FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) + +#define FT_MEM_REALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, 1, \ + (cursz), (newsz), \ + (ptr), &error ) ) + +#define FT_MEM_QALLOC( ptr, size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) ) + +#define FT_MEM_QNEW( ptr ) \ + FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) + +#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, 1, \ + (cursz), (newsz), \ + (ptr), &error ) ) + +#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ + (cursz), (newsz), \ + (ptr), &error ) ) + +#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (item_size), \ + 0, (count), \ + NULL, &error ) ) + +#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \ + (oldcnt), (newcnt), \ + (ptr), &error ) ) + +#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \ + 0, (count), \ + NULL, &error ) ) + +#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (itmsz), \ + (oldcnt), (newcnt), \ + (ptr), &error ) ) + + +#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) #define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) @@ -261,6 +197,7 @@ FT_BEGIN_HEADER #define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) ) + #define FT_ARRAY_ZERO( dest, count ) \ FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) ) @@ -281,157 +218,108 @@ FT_BEGIN_HEADER #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) - /*************************************************************************/ - /* */ - /* We first define FT_MEM_ALLOC, FT_MEM_REALLOC, and FT_MEM_FREE. All */ - /* macros use an _implicit_ `memory' parameter to access the current */ - /* memory allocator. */ - /* */ - -#ifdef FT_DEBUG_MEMORY - -#define FT_MEM_ALLOC( _pointer_, _size_ ) \ - FT_Alloc_Debug( memory, _size_, \ - (void**)(void*)&(_pointer_), \ - __FILE__, __LINE__ ) - -#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ - FT_Realloc_Debug( memory, _current_, _size_, \ - (void**)(void*)&(_pointer_), \ - __FILE__, __LINE__ ) - -#define FT_MEM_QALLOC( _pointer_, _size_ ) \ - FT_QAlloc_Debug( memory, _size_, \ - (void**)(void*)&(_pointer_), \ - __FILE__, __LINE__ ) - -#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ - FT_QRealloc_Debug( memory, _current_, _size_, \ - (void**)(void*)&(_pointer_), \ - __FILE__, __LINE__ ) - -#define FT_MEM_FREE( _pointer_ ) \ - FT_Free_Debug( memory, (void**)(void*)&(_pointer_), \ - __FILE__, __LINE__ ) - - -#else /* !FT_DEBUG_MEMORY */ - - -#define FT_MEM_ALLOC( _pointer_, _size_ ) \ - FT_Alloc( memory, _size_, \ - (void**)(void*)&(_pointer_) ) - -#define FT_MEM_FREE( _pointer_ ) \ - FT_Free( memory, \ - (void**)(void*)&(_pointer_) ) - -#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ - FT_Realloc( memory, _current_, _size_, \ - (void**)(void*)&(_pointer_) ) - -#define FT_MEM_QALLOC( _pointer_, _size_ ) \ - FT_QAlloc( memory, _size_, \ - (void**)(void*)&(_pointer_) ) - -#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ - FT_QRealloc( memory, _current_, _size_, \ - (void**)(void*)&(_pointer_) ) - -#endif /* !FT_DEBUG_MEMORY */ - - /*************************************************************************/ /* */ /* The following functions macros expect that their pointer argument is */ /* _typed_ in order to automatically compute array element sizes. */ /* */ -#define FT_MEM_NEW( _pointer_ ) \ - FT_MEM_ALLOC( _pointer_, sizeof ( *(_pointer_) ) ) +#define FT_MEM_NEW_ARRAY( ptr, count ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ + 0, (count), \ + NULL, &error ) ) -#define FT_MEM_NEW_ARRAY( _pointer_, _count_ ) \ - FT_MEM_ALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) ) +#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ + (cursz), (newsz), \ + (ptr), &error ) ) -#define FT_MEM_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ - FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \ - (_new_) * sizeof ( *(_pointer_) ) ) +#define FT_MEM_QNEW_ARRAY( ptr, count ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ + 0, (count), \ + NULL, &error ) ) -#define FT_MEM_QNEW( _pointer_ ) \ - FT_MEM_QALLOC( _pointer_, sizeof ( *(_pointer_) ) ) - -#define FT_MEM_QNEW_ARRAY( _pointer_, _count_ ) \ - FT_MEM_QALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) ) - -#define FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \ - FT_MEM_QREALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \ - (_new_) * sizeof ( *(_pointer_) ) ) +#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ + (cursz), (newsz), \ + (ptr), &error ) ) - /*************************************************************************/ - /* */ - /* the following macros are obsolete but kept for compatibility reasons */ - /* */ +#define FT_ALLOC( ptr, size ) \ + FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) -#define FT_MEM_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - FT_MEM_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) ) +#define FT_REALLOC( ptr, cursz, newsz ) \ + FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) -#define FT_MEM_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \ - FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( _type ), \ - (_new_) * sizeof ( _type_ ) ) +#define FT_ALLOC_MULT( ptr, count, item_size ) \ + FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) + +#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \ + newcnt, itmsz ) ) + +#define FT_QALLOC( ptr, size ) \ + FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) ) + +#define FT_QREALLOC( ptr, cursz, newsz ) \ + FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) ) + +#define FT_QALLOC_MULT( ptr, count, item_size ) \ + FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) ) + +#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \ + newcnt, itmsz ) ) + +#define FT_FREE( ptr ) FT_MEM_FREE( ptr ) + +#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) ) + +#define FT_NEW_ARRAY( ptr, count ) \ + FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) + +#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \ + FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) + +#define FT_QNEW( ptr ) \ + FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) + +#define FT_QNEW_ARRAY( ptr, count ) \ + FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) + +#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ + FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) - /*************************************************************************/ - /* */ - /* The following macros are variants of their FT_MEM_XXXX equivalents; */ - /* they are used to set an _implicit_ `error' variable and return TRUE */ - /* if an error occured (i.e. if 'error != 0'). */ - /* */ +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS -#define FT_ALLOC( _pointer_, _size_ ) \ - FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) ) + FT_BASE( FT_Error ) + FT_Alloc( FT_Memory memory, + FT_Long size, + void* *P ); -#define FT_REALLOC( _pointer_, _current_, _size_ ) \ - FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) ) + FT_BASE( FT_Error ) + FT_QAlloc( FT_Memory memory, + FT_Long size, + void* *p ); -#define FT_QALLOC( _pointer_, _size_ ) \ - FT_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) ) + FT_BASE( FT_Error ) + FT_Realloc( FT_Memory memory, + FT_Long current, + FT_Long size, + void* *P ); -#define FT_QREALLOC( _pointer_, _current_, _size_ ) \ - FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) ) + FT_BASE( FT_Error ) + FT_QRealloc( FT_Memory memory, + FT_Long current, + FT_Long size, + void* *p ); + FT_BASE( void ) + FT_Free( FT_Memory memory, + void* *P ); -#define FT_FREE( _pointer_ ) \ - FT_MEM_FREE( _pointer_ ) - - -#define FT_NEW( _pointer_ ) \ - FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) ) - -#define FT_NEW_ARRAY( _pointer_, _count_ ) \ - FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) ) - -#define FT_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ - FT_REALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \ - sizeof ( *(_pointer_) ) * (_new_) ) - -#define FT_QNEW( _pointer_ ) \ - FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) ) - -#define FT_QNEW_ARRAY( _pointer_, _count_ ) \ - FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) ) - -#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \ - FT_QREALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \ - sizeof ( *(_pointer_) ) * (_new_) ) - - -#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - FT_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) ) - -#define FT_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \ - FT_REALLOC( _pointer, (_old_) * sizeof ( _type_ ), \ - (_new_) * sizeof ( _type_ ) ) +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ /* */ diff --git a/headers/libs/freetype2/freetype/internal/ftobjs.h b/headers/libs/freetype2/freetype/internal/ftobjs.h index e8e3ee79a9..133f360076 100644 --- a/headers/libs/freetype2/freetype/internal/ftobjs.h +++ b/headers/libs/freetype2/freetype/internal/ftobjs.h @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -213,9 +213,10 @@ FT_BEGIN_HEADER /* */ typedef struct FT_Face_InternalRec_ { - FT_UShort max_points; - FT_Short max_contours; - +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_UShort reserved1; + FT_Short reserved2; +#endif FT_Matrix transform_matrix; FT_Vector transform_delta; FT_Int transform_flags; @@ -451,26 +452,58 @@ FT_BEGIN_HEADER /* */ - /* - * Free the bitmap of a given glyphslot when needed - * (i.e., only when it was allocated with ft_glyphslot_alloc_bitmap). - */ +#define FT_REQUEST_WIDTH( req ) \ + ( (req)->horiResolution \ + ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \ + : (req)->width ) + +#define FT_REQUEST_HEIGHT( req ) \ + ( (req)->vertResolution \ + ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \ + : (req)->height ) + + + /* Set the metrics according to a bitmap strike. */ + FT_BASE( void ) + FT_Select_Metrics( FT_Face face, + FT_ULong strike_index ); + + + /* Set the metrics according to a size request. */ + FT_BASE( void ) + FT_Request_Metrics( FT_Face face, + FT_Size_Request req ); + + + /* Match a size request against `available_sizes'. */ + FT_BASE( FT_Error ) + FT_Match_Size( FT_Face face, + FT_Size_Request req, + FT_Bool ignore_width, + FT_ULong* size_index ); + + + /* Use the horizontal metrics to synthesize the vertical metrics. */ + /* If `advance' is zero, it is also synthesized. */ + FT_BASE( void ) + ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, + FT_Pos advance ); + + + /* Free the bitmap of a given glyphslot when needed (i.e., only when it */ + /* was allocated with ft_glyphslot_alloc_bitmap). */ FT_BASE( void ) ft_glyphslot_free_bitmap( FT_GlyphSlot slot ); - /* - * Allocate a new bitmap buffer in a glyph slot. - */ + /* Allocate a new bitmap buffer in a glyph slot. */ FT_BASE( FT_Error ) ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, FT_ULong size ); - /* - * Set the bitmap buffer in a glyph slot to a given pointer. - * The buffer will not be freed by a later call to ft_glyphslot_free_bitmap. - */ + /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */ + /* will not be freed by a later call to ft_glyphslot_free_bitmap. */ FT_BASE( void ) ft_glyphslot_set_bitmap( FT_GlyphSlot slot, FT_Byte* buffer ); @@ -582,17 +615,15 @@ FT_BEGIN_HEADER /*************************************************************************/ -/* this hook is used by the TrueType debugger. It must be set to an alternate - * truetype bytecode interpreter function - */ + /* This hook is used by the TrueType debugger. It must be set to an */ + /* alternate truetype bytecode interpreter function. */ #define FT_DEBUG_HOOK_TRUETYPE 0 -/* set this debug hook to a non-null pointer to force unpatented hinting - * for all faces when both TT_CONFIG_OPTION_BYTECODE_INTERPRETER and - * TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. this is only used - * during debugging - */ + /* Set this debug hook to a non-null pointer to force unpatented hinting */ + /* for all faces when both TT_CONFIG_OPTION_BYTECODE_INTERPRETER and */ + /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. this is only used */ + /* during debugging. */ #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1 @@ -709,7 +740,7 @@ FT_BEGIN_HEADER /* <Return> */ /* A pointer to the new memory object. 0 in case of error. */ /* */ - FT_EXPORT( FT_Memory ) + FT_BASE( FT_Memory ) FT_New_Memory( void ); @@ -724,7 +755,7 @@ FT_BEGIN_HEADER /* <Input> */ /* memory :: A handle to the memory manager. */ /* */ - FT_EXPORT( void ) + FT_BASE( void ) FT_Done_Memory( FT_Memory memory ); #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ diff --git a/headers/libs/freetype2/freetype/internal/ftrfork.h b/headers/libs/freetype2/freetype/internal/ftrfork.h index e7b10024ad..94402bcfa7 100644 --- a/headers/libs/freetype2/freetype/internal/ftrfork.h +++ b/headers/libs/freetype2/freetype/internal/ftrfork.h @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (specification). */ /* */ -/* Copyright 2004 by */ +/* Copyright 2004, 2006 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -154,7 +154,7 @@ FT_BEGIN_HEADER /* offsets :: */ /* The stream offsets for the resource data specified by `tag'. */ /* This array is allocated by the function, so you have to call */ - /* @FT_Free after use. */ + /* @ft_mem_free after use. */ /* */ /* count :: */ /* The length of offsets array. */ diff --git a/headers/libs/freetype2/freetype/internal/ftserv.h b/headers/libs/freetype2/freetype/internal/ftserv.h index 0850f5605b..2666a8746e 100644 --- a/headers/libs/freetype2/freetype/internal/ftserv.h +++ b/headers/libs/freetype2/freetype/internal/ftserv.h @@ -4,7 +4,7 @@ /* */ /* The FreeType services (specification only). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -302,6 +302,8 @@ FT_BEGIN_HEADER #define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h> #define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/svgldict.h> +#define FT_SERVICE_GX_VALIDATE_H <freetype/internal/services/svgxval.h> +#define FT_SERVICE_KERNING_H <freetype/internal/services/svkern.h> #define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/svmm.h> #define FT_SERVICE_OPENTYPE_VALIDATE_H <freetype/internal/services/svotval.h> #define FT_SERVICE_PFR_H <freetype/internal/services/svpfr.h> @@ -309,6 +311,7 @@ FT_BEGIN_HEADER #define FT_SERVICE_POSTSCRIPT_INFO_H <freetype/internal/services/svpsinfo.h> #define FT_SERVICE_POSTSCRIPT_NAME_H <freetype/internal/services/svpostnm.h> #define FT_SERVICE_SFNT_H <freetype/internal/services/svsfnt.h> +#define FT_SERVICE_TRUETYPE_ENGINE_H <freetype/internal/services/svtteng.h> #define FT_SERVICE_TT_CMAP_H <freetype/internal/services/svttcmap.h> #define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h> #define FT_SERVICE_XFREE86_NAME_H <freetype/internal/services/svxf86nm.h> diff --git a/headers/libs/freetype2/freetype/internal/ftstream.h b/headers/libs/freetype2/freetype/internal/ftstream.h index 1fa9db4559..c49d8fc01a 100644 --- a/headers/libs/freetype2/freetype/internal/ftstream.h +++ b/headers/libs/freetype2/freetype/internal/ftstream.h @@ -4,7 +4,7 @@ /* */ /* Stream handling (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -328,7 +328,7 @@ FT_BEGIN_HEADER #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM /* initialize a stream for reading a regular system stream */ - FT_EXPORT( FT_Error ) + FT_BASE( FT_Error ) FT_Stream_Open( FT_Stream stream, const char* filepathname ); @@ -514,18 +514,21 @@ FT_BEGIN_HEADER FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) -#define FT_FRAME_ENTER( size ) \ - FT_SET_ERROR( FT_Stream_EnterFrame( stream, size ) ) +#define FT_FRAME_ENTER( size ) \ + FT_SET_ERROR( \ + FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, size ) ) ) #define FT_FRAME_EXIT() \ - FT_Stream_ExitFrame( stream ) + FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) -#define FT_FRAME_EXTRACT( size, bytes ) \ - FT_SET_ERROR( FT_Stream_ExtractFrame( stream, size, \ - (FT_Byte**)&(bytes) ) ) +#define FT_FRAME_EXTRACT( size, bytes ) \ + FT_SET_ERROR( \ + FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, size, \ + (FT_Byte**)&(bytes) ) ) ) -#define FT_FRAME_RELEASE( bytes ) \ - FT_Stream_ReleaseFrame( stream, (FT_Byte**)&(bytes) ) +#define FT_FRAME_RELEASE( bytes ) \ + FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ + (FT_Byte**)&(bytes) ) ) FT_END_HEADER diff --git a/headers/libs/freetype2/freetype/internal/fttrace.h b/headers/libs/freetype2/freetype/internal/fttrace.h index 1267e167f6..81916fc6ae 100644 --- a/headers/libs/freetype2/freetype/internal/fttrace.h +++ b/headers/libs/freetype2/freetype/internal/fttrace.h @@ -4,7 +4,7 @@ /* */ /* Tracing handling (specification only). */ /* */ -/* Copyright 2002, 2004, 2005 by */ +/* Copyright 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -45,6 +45,7 @@ FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ +FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ @@ -114,5 +115,19 @@ FT_TRACE_DEF( otvgpos ) FT_TRACE_DEF( otvgsub ) FT_TRACE_DEF( otvjstf ) + /* TrueTypeGX/AAT validation components */ +FT_TRACE_DEF( gxvmodule ) +FT_TRACE_DEF( gxvcommon ) +FT_TRACE_DEF( gxvfeat ) +FT_TRACE_DEF( gxvmort ) +FT_TRACE_DEF( gxvmorx ) +FT_TRACE_DEF( gxvbsln ) +FT_TRACE_DEF( gxvjust ) +FT_TRACE_DEF( gxvkern ) +FT_TRACE_DEF( gxvopbd ) +FT_TRACE_DEF( gxvtrak ) +FT_TRACE_DEF( gxvprop ) +FT_TRACE_DEF( gxvlcar ) + /* END */ diff --git a/headers/libs/freetype2/freetype/internal/psaux.h b/headers/libs/freetype2/freetype/internal/psaux.h index cf1abf4c9c..d2e4910009 100644 --- a/headers/libs/freetype2/freetype/internal/psaux.h +++ b/headers/libs/freetype2/freetype/internal/psaux.h @@ -5,7 +5,7 @@ /* Auxiliary functions and data structures related to PostScript fonts */ /* (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -516,9 +516,10 @@ FT_BEGIN_HEADER /* */ /* last :: The last point position. */ /* */ - /* scale_x :: The horizontal scale (FUnits to sub-pixels). */ + /* scale_x :: The horizontal scaling value (FUnits to */ + /* sub-pixels). */ /* */ - /* scale_y :: The vertical scale (FUnits to sub-pixels). */ + /* scale_y :: The vertical scaling value (FUnits to sub-pixels). */ /* */ /* pos_x :: The horizontal translation (if composite glyph). */ /* */ @@ -685,6 +686,70 @@ FT_BEGIN_HEADER } T1_DecoderRec; + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** AFM PARSER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct AFM_ParserRec_* AFM_Parser; + + typedef struct AFM_Parser_FuncsRec_ + { + FT_Error + (*init)( AFM_Parser parser, + FT_Memory memory, + FT_Byte* base, + FT_Byte* limit ); + + void + (*done)( AFM_Parser parser ); + + FT_Error + (*parse)( AFM_Parser parser ); + + } AFM_Parser_FuncsRec; + + typedef struct AFM_StreamRec_* AFM_Stream; + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* AFM_ParserRec */ + /* */ + /* <Description> */ + /* An AFM_Parser is a parser for the AFM files. */ + /* */ + /* <Fields> */ + /* memory :: The object used for memory operations (alloc and */ + /* realloc). */ + /* */ + /* stream :: This is an opaque object. */ + /* */ + /* FontInfo :: The result will be stored here. */ + /* */ + /* get_index :: A user provided function to get a glyph index by its */ + /* name. */ + /* */ + typedef struct AFM_ParserRec_ + { + FT_Memory memory; + AFM_Stream stream; + + AFM_FontInfo FontInfo; + + FT_Int + (*get_index)( const char* name, + FT_UInt len, + void* user_data ); + + void* user_data; + + } AFM_ParserRec; + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -728,6 +793,9 @@ FT_BEGIN_HEADER T1_CMap_Classes t1_cmap_classes; + /* fields after this comment line were added after version 2.1.10 */ + const AFM_Parser_FuncsRec* afm_parser_funcs; + } PSAux_ServiceRec, *PSAux_Service; /* backwards-compatible type definition */ diff --git a/headers/libs/freetype2/freetype/internal/pshints.h b/headers/libs/freetype2/freetype/internal/pshints.h index cd48f6cf32..959866371b 100644 --- a/headers/libs/freetype2/freetype/internal/pshints.h +++ b/headers/libs/freetype2/freetype/internal/pshints.h @@ -4,9 +4,9 @@ /* */ /* Interface to Postscript-specific (Type 1 and Type 2) hints */ /* recorders (specification only). These are used to support native */ -/* T1/T2 hints in the "type1", "cid" and "cff" font drivers. */ +/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */ /* */ -/* Copyright 2001, 2002, 2003 by */ +/* Copyright 2001, 2002, 2003, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -73,212 +73,233 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @type: */ - /* T1_Hints */ - /* */ - /* @description: */ - /* This is a handle to an opaque structure used to record glyph hints */ - /* from a Type 1 character glyph character string. */ - /* */ - /* The methods used to operate on this object are defined by the */ - /* @T1_Hints_FuncsRec structure. Recording glyph hints is normally */ - /* achieved through the following scheme: */ - /* */ - /* - Open a new hint recording session by calling the "open" method. */ - /* This will rewind the recorder and prepare it for new input. */ - /* */ - /* - For each hint found in the glyph charstring, call the */ - /* corresponding method ("stem", "stem3", or "reset"). Note that */ - /* these functions do not return an error code. */ - /* */ - /* - Close the recording session by calling the "close" method. It */ - /* will return an error code if the hints were invalid or something */ - /* strange happened (e.g. memory shortage). */ - /* */ - /* The hints accumulated in the object can later be used by the */ - /* PostScript hinter. */ - /* */ + /************************************************************************* + * + * @type: + * T1_Hints + * + * @description: + * This is a handle to an opaque structure used to record glyph hints + * from a Type 1 character glyph character string. + * + * The methods used to operate on this object are defined by the + * @T1_Hints_FuncsRec structure. Recording glyph hints is normally + * achieved through the following scheme: + * + * - Open a new hint recording session by calling the `open' method. + * This rewinds the recorder and prepare it for new input. + * + * - For each hint found in the glyph charstring, call the corresponding + * method (`stem', `stem3', or `reset'). Note that these functions do + * not return an error code. + * + * - Close the recording session by calling the `close' method. It + * returns an error code if the hints were invalid or something + * strange happened (e.g., memory shortage). + * + * The hints accumulated in the object can later be used by the + * PostScript hinter. + * + */ typedef struct T1_HintsRec_* T1_Hints; - /*************************************************************************/ - /* */ - /* @type: */ - /* T1_Hints_Funcs */ - /* */ - /* @description: */ - /* A pointer to the @T1_Hints_FuncsRec structure that defines the */ - /* API of a given @T1_Hints object. */ - /* */ + /************************************************************************* + * + * @type: + * T1_Hints_Funcs + * + * @description: + * A pointer to the @T1_Hints_FuncsRec structure that defines the API of + * a given @T1_Hints object. + * + */ typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs; - /*************************************************************************/ - /* */ - /* @functype: */ - /* T1_Hints_OpenFunc */ - /* */ - /* @description: */ - /* A method of the @T1_Hints class used to prepare it for a new */ - /* Type 1 hints recording session. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 1 hints recorder. */ - /* */ - /* @note: */ - /* You should always call the @T1_Hints_CloseFunc method in order to */ - /* close an opened recording session. */ - /* */ + /************************************************************************* + * + * @functype: + * T1_Hints_OpenFunc + * + * @description: + * A method of the @T1_Hints class used to prepare it for a new Type 1 + * hints recording session. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * @note: + * You should always call the @T1_Hints_CloseFunc method in order to + * close an opened recording session. + * + */ typedef void (*T1_Hints_OpenFunc)( T1_Hints hints ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T1_Hints_SetStemFunc */ - /* */ - /* @description: */ - /* A method of the @T1_Hints class used to record a new horizontal or */ - /* vertical stem. This corresponds to the Type 1 "hstem" and "vstem" */ - /* operators. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 1 hints recorder. */ - /* */ - /* dimension :: 0 for horizontal stems (hstem), 1 for vertical ones */ - /* (vstem). */ - /* */ - /* coords :: Array of 2 integers, used as (position,length) stem */ - /* descriptor. */ - /* */ - /* @note: */ - /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */ - /* horizontal coordinates (x) for vertical stems (dim=1). */ - /* */ - /* "coords[0]" is the absolute stem position (lowest coordinate); */ - /* "coords[1]" is the length. */ - /* */ - /* The length can be negative, in which case it must be either -20 or */ - /* -21. It will be interpreted as a "ghost" stem, according to */ - /* Type 1 specification. */ - /* */ - /* If the length is -21 (corresponding to a bottom ghost stem), then */ - /* the real stem position is "coords[0]+coords[1]". */ - /* */ + /************************************************************************* + * + * @functype: + * T1_Hints_SetStemFunc + * + * @description: + * A method of the @T1_Hints class used to record a new horizontal or + * vertical stem. This corresponds to the Type 1 `hstem' and `vstem' + * operators. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * dimension :: + * 0 for horizontal stems (hstem), 1 for vertical ones (vstem). + * + * coords :: + * Array of 2 integers, used as (position,length) stem descriptor. + * + * @note: + * Use vertical coordinates (y) for horizontal stems (dim=0). Use + * horizontal coordinates (x) for vertical stems (dim=1). + * + * `coords[0]' is the absolute stem position (lowest coordinate); + * `coords[1]' is the length. + * + * The length can be negative, in which case it must be either -20 or + * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * specification. + * + * If the length is -21 (corresponding to a bottom ghost stem), then + * the real stem position is `coords[0]+coords[1]'. + * + */ typedef void (*T1_Hints_SetStemFunc)( T1_Hints hints, FT_UInt dimension, FT_Long* coords ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T1_Hints_SetStem3Func */ - /* */ - /* @description: */ - /* A method of the @T1_Hints class used to record three */ - /* counter-controlled horizontal or vertical stems at once. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 1 hints recorder. */ - /* */ - /* dimension :: 0 for horizontal stems, 1 for vertical ones. */ - /* */ - /* coords :: An array of 6 integers, holding 3 (position,length) */ - /* pairs for the counter-controlled stems. */ - /* */ - /* @note: */ - /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */ - /* horizontal coordinates (x) for vertical stems (dim=1). */ - /* */ - /* The lengths cannot be negative (ghost stems are never */ - /* counter-controlled). */ - /* */ + /************************************************************************* + * + * @functype: + * T1_Hints_SetStem3Func + * + * @description: + * A method of the @T1_Hints class used to record three + * counter-controlled horizontal or vertical stems at once. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * dimension :: + * 0 for horizontal stems, 1 for vertical ones. + * + * coords :: + * An array of 6 integers, holding 3 (position,length) pairs for the + * counter-controlled stems. + * + * @note: + * Use vertical coordinates (y) for horizontal stems (dim=0). Use + * horizontal coordinates (x) for vertical stems (dim=1). + * + * The lengths cannot be negative (ghost stems are never + * counter-controlled). + * + */ typedef void (*T1_Hints_SetStem3Func)( T1_Hints hints, FT_UInt dimension, FT_Long* coords ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T1_Hints_ResetFunc */ - /* */ - /* @description: */ - /* A method of the @T1_Hints class used to reset the stems hints in a */ - /* recording session. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 1 hints recorder. */ - /* */ - /* end_point :: The index of the last point in the input glyph in */ - /* which the previously defined hints apply. */ - /* */ + /************************************************************************* + * + * @functype: + * T1_Hints_ResetFunc + * + * @description: + * A method of the @T1_Hints class used to reset the stems hints in a + * recording session. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * end_point :: + * The index of the last point in the input glyph in which the + * previously defined hints apply. + * + */ typedef void (*T1_Hints_ResetFunc)( T1_Hints hints, FT_UInt end_point ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T1_Hints_CloseFunc */ - /* */ - /* @description: */ - /* A method of the @T1_Hints class used to close a hint recording */ - /* session. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 1 hints recorder. */ - /* */ - /* end_point :: The index of the last point in the input glyph. */ - /* */ - /* @return: */ - /* FreeType error code. 0 means success. */ - /* */ - /* @note: */ - /* The error code will be set to indicate that an error occured */ - /* during the recording session. */ - /* */ + /************************************************************************* + * + * @functype: + * T1_Hints_CloseFunc + * + * @description: + * A method of the @T1_Hints class used to close a hint recording + * session. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * end_point :: + * The index of the last point in the input glyph. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The error code is set to indicate that an error occurred during the + * recording session. + * + */ typedef FT_Error (*T1_Hints_CloseFunc)( T1_Hints hints, FT_UInt end_point ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T1_Hints_ApplyFunc */ - /* */ - /* @description: */ - /* A method of the @T1_Hints class used to apply hints to the */ - /* corresponding glyph outline. Must be called once all hints have */ - /* been recorded. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 1 hints recorder. */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* globals :: The hinter globals for this font. */ - /* */ - /* hint_mode :: Hinting information. */ - /* */ - /* @return: */ - /* FreeType error code. 0 means success. */ - /* */ - /* @note: */ - /* On input, all points within the outline are in font coordinates. */ - /* On output, they are in 1/64th of pixels. */ - /* */ - /* The scaling transformation is taken from the "globals" object */ - /* which must correspond to the same font as the glyph. */ - /* */ + /************************************************************************* + * + * @functype: + * T1_Hints_ApplyFunc + * + * @description: + * A method of the @T1_Hints class used to apply hints to the + * corresponding glyph outline. Must be called once all hints have been + * recorded. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * outline :: + * A pointer to the target outline descriptor. + * + * globals :: + * The hinter globals for this font. + * + * hint_mode :: + * Hinting information. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * On input, all points within the outline are in font coordinates. On + * output, they are in 1/64th of pixels. + * + * The scaling transformation is taken from the `globals' object which + * must correspond to the same font as the glyph. + * + */ typedef FT_Error (*T1_Hints_ApplyFunc)( T1_Hints hints, FT_Outline* outline, @@ -286,30 +307,37 @@ FT_BEGIN_HEADER FT_Render_Mode hint_mode ); - /*************************************************************************/ - /* */ - /* @struct: */ - /* T1_Hints_FuncsRec */ - /* */ - /* @description: */ - /* The structure used to provide the API to @T1_Hints objects. */ - /* */ - /* @fields: */ - /* hints :: A handle to the T1 Hints recorder. */ - /* */ - /* open :: The function to open a recording session. */ - /* */ - /* close :: The function to close a recording session. */ - /* */ - /* stem :: The function to set a simple stem. */ - /* */ - /* stem3 :: The function to set counter-controlled stems. */ - /* */ - /* reset :: The function to reset stem hints. */ - /* */ - /* apply :: The function to apply the hints to the corresponding */ - /* glyph outline. */ - /* */ + /************************************************************************* + * + * @struct: + * T1_Hints_FuncsRec + * + * @description: + * The structure used to provide the API to @T1_Hints objects. + * + * @fields: + * hints :: + * A handle to the T1 Hints recorder. + * + * open :: + * The function to open a recording session. + * + * close :: + * The function to close a recording session. + * + * stem :: + * The function to set a simple stem. + * + * stem3 :: + * The function to set counter-controlled stems. + * + * reset :: + * The function to reset stem hints. + * + * apply :: + * The function to apply the hints to the corresponding glyph outline. + * + */ typedef struct T1_Hints_FuncsRec_ { T1_Hints hints; @@ -331,100 +359,108 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @type: */ - /* T2_Hints */ - /* */ - /* @description: */ - /* This is a handle to an opaque structure used to record glyph hints */ - /* from a Type 2 character glyph character string. */ - /* */ - /* The methods used to operate on this object are defined by the */ - /* @T2_Hints_FuncsRec structure. Recording glyph hints is normally */ - /* achieved through the following scheme: */ - /* */ - /* - Open a new hint recording session by calling the "open" method. */ - /* This will rewind the recorder and prepare it for new input. */ - /* */ - /* - For each hint found in the glyph charstring, call the */ - /* corresponding method ("stems", "hintmask", "counters"). Note */ - /* that these functions do not return an error code. */ - /* */ - /* - Close the recording session by calling the "close" method. It */ - /* will return an error code if the hints were invalid or something */ - /* strange happened (e.g. memory shortage). */ - /* */ - /* The hints accumulated in the object can later be used by the */ - /* Postscript hinter. */ - /* */ + /************************************************************************* + * + * @type: + * T2_Hints + * + * @description: + * This is a handle to an opaque structure used to record glyph hints + * from a Type 2 character glyph character string. + * + * The methods used to operate on this object are defined by the + * @T2_Hints_FuncsRec structure. Recording glyph hints is normally + * achieved through the following scheme: + * + * - Open a new hint recording session by calling the `open' method. + * This rewinds the recorder and prepare it for new input. + * + * - For each hint found in the glyph charstring, call the corresponding + * method (`stems', `hintmask', `counters'). Note that these + * functions do not return an error code. + * + * - Close the recording session by calling the `close' method. It + * returns an error code if the hints were invalid or something + * strange happened (e.g., memory shortage). + * + * The hints accumulated in the object can later be used by the + * Postscript hinter. + * + */ typedef struct T2_HintsRec_* T2_Hints; - /*************************************************************************/ - /* */ - /* @type: */ - /* T2_Hints_Funcs */ - /* */ - /* @description: */ - /* A pointer to the @T2_Hints_FuncsRec structure that defines the API */ - /* of a given @T2_Hints object. */ - /* */ + /************************************************************************* + * + * @type: + * T2_Hints_Funcs + * + * @description: + * A pointer to the @T2_Hints_FuncsRec structure that defines the API of + * a given @T2_Hints object. + * + */ typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs; - /*************************************************************************/ - /* */ - /* @functype: */ - /* T2_Hints_OpenFunc */ - /* */ - /* @description: */ - /* A method of the @T2_Hints class used to prepare it for a new */ - /* Type 2 hints recording session. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 2 hints recorder. */ - /* */ - /* @note: */ - /* You should always call the @T2_Hints_CloseFunc method in order to */ - /* close an opened recording session. */ - /* */ + /************************************************************************* + * + * @functype: + * T2_Hints_OpenFunc + * + * @description: + * A method of the @T2_Hints class used to prepare it for a new Type 2 + * hints recording session. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * @note: + * You should always call the @T2_Hints_CloseFunc method in order to + * close an opened recording session. + * + */ typedef void (*T2_Hints_OpenFunc)( T2_Hints hints ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T2_Hints_StemsFunc */ - /* */ - /* @description: */ - /* A method of the @T2_Hints class used to set the table of stems in */ - /* either the vertical or horizontal dimension. Equivalent to the */ - /* "hstem", "vstem", "hstemhm", and "vstemhm" Type 2 operators. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 2 hints recorder. */ - /* */ - /* dimension :: 0 for horizontal stems (hstem), 1 for vertical ones */ - /* (vstem). */ - /* */ - /* count :: The number of stems. */ - /* */ - /* coords :: An array of "count" (position,length) pairs. */ - /* */ - /* @note: */ - /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */ - /* horizontal coordinates (x) for vertical stems (dim=1). */ - /* */ - /* There are "2*count" elements in the "coords" aray. Each even */ - /* element is an absolute position in font units, each odd element is */ - /* a length in font units. */ - /* */ - /* A length can be negative, in which case it must be either -20 or */ - /* -21. It will be interpreted as a "ghost" stem, according to the */ - /* Type 1 specification. */ - /* */ + /************************************************************************* + * + * @functype: + * T2_Hints_StemsFunc + * + * @description: + * A method of the @T2_Hints class used to set the table of stems in + * either the vertical or horizontal dimension. Equivalent to the + * `hstem', `vstem', `hstemhm', and `vstemhm' Type 2 operators. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * dimension :: + * 0 for horizontal stems (hstem), 1 for vertical ones (vstem). + * + * count :: + * The number of stems. + * + * coords :: + * An array of `count' (position,length) pairs. + * + * @note: + * Use vertical coordinates (y) for horizontal stems (dim=0). Use + * horizontal coordinates (x) for vertical stems (dim=1). + * + * There are `2*count' elements in the `coords' aray. Each even element + * is an absolute position in font units, each odd element is a length + * in font units. + * + * A length can be negative, in which case it must be either -20 or + * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * specification. + * + */ typedef void (*T2_Hints_StemsFunc)( T2_Hints hints, FT_UInt dimension, @@ -432,36 +468,41 @@ FT_BEGIN_HEADER FT_Fixed* coordinates ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T2_Hints_MaskFunc */ - /* */ - /* @description: */ - /* A method of the @T2_Hints class used to set a given hintmask */ - /* (this corresponds to the "hintmask" Type 2 operator). */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 2 hints recorder. */ - /* */ - /* end_point :: The glyph index of the last point to which the */ - /* previously defined/activated hints apply. */ - /* */ - /* bit_count :: The number of bits in the hint mask. */ - /* */ - /* bytes :: An array of bytes modelling the hint mask. */ - /* */ - /* @note: */ - /* If the hintmask starts the charstring (before any glyph point */ - /* definition), the value of "end_point" should be 0. */ - /* */ - /* "bit_count" is the number of meaningful bits in the "bytes" array; */ - /* it must be equal to the total number of hints defined so far */ - /* (i.e. horizontal+verticals). */ - /* */ - /* The "bytes" array can come directly from the Type 2 charstring and */ - /* respects the same format. */ - /* */ + /************************************************************************* + * + * @functype: + * T2_Hints_MaskFunc + * + * @description: + * A method of the @T2_Hints class used to set a given hintmask (this + * corresponds to the `hintmask' Type 2 operator). + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * end_point :: + * The glyph index of the last point to which the previously defined + * or activated hints apply. + * + * bit_count :: + * The number of bits in the hint mask. + * + * bytes :: + * An array of bytes modelling the hint mask. + * + * @note: + * If the hintmask starts the charstring (before any glyph point + * definition), the value of `end_point' should be 0. + * + * `bit_count' is the number of meaningful bits in the `bytes' array; it + * must be equal to the total number of hints defined so far (i.e., + * horizontal+verticals). + * + * The `bytes' array can come directly from the Type 2 charstring and + * respects the same format. + * + */ typedef void (*T2_Hints_MaskFunc)( T2_Hints hints, FT_UInt end_point, @@ -469,97 +510,110 @@ FT_BEGIN_HEADER const FT_Byte* bytes ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T2_Hints_CounterFunc */ - /* */ - /* @description: */ - /* A method of the @T2_Hints class used to set a given counter mask */ - /* (this corresponds to the "hintmask" Type 2 operator). */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 2 hints recorder. */ - /* */ - /* end_point :: A glyph index of the last point to which the */ - /* previously defined/active hints apply. */ - /* */ - /* bit_count :: The number of bits in the hint mask. */ - /* */ - /* bytes :: An array of bytes modelling the hint mask. */ - /* */ - /* @note: */ - /* If the hintmask starts the charstring (before any glyph point */ - /* definition), the value of "end_point" should be 0. */ - /* */ - /* "bit_count" is the number of meaningful bits in the "bytes" array; */ - /* it must be equal to the total number of hints defined so far */ - /* (i.e. horizontal+verticals). */ - /* */ - /* The "bytes" array can come directly from the Type 2 charstring and */ - /* respects the same format. */ - /* */ + /************************************************************************* + * + * @functype: + * T2_Hints_CounterFunc + * + * @description: + * A method of the @T2_Hints class used to set a given counter mask + * (this corresponds to the `hintmask' Type 2 operator). + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * end_point :: + * A glyph index of the last point to which the previously defined or + * active hints apply. + * + * bit_count :: + * The number of bits in the hint mask. + * + * bytes :: + * An array of bytes modelling the hint mask. + * + * @note: + * If the hintmask starts the charstring (before any glyph point + * definition), the value of `end_point' should be 0. + * + * `bit_count' is the number of meaningful bits in the `bytes' array; it + * must be equal to the total number of hints defined so far (i.e., + * horizontal+verticals). + * + * The `bytes' array can come directly from the Type 2 charstring and + * respects the same format. + * + */ typedef void (*T2_Hints_CounterFunc)( T2_Hints hints, FT_UInt bit_count, const FT_Byte* bytes ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T2_Hints_CloseFunc */ - /* */ - /* @description: */ - /* A method of the @T2_Hints class used to close a hint recording */ - /* session. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 2 hints recorder. */ - /* */ - /* end_point :: The index of the last point in the input glyph. */ - /* */ - /* @return: */ - /* FreeType error code. 0 means success. */ - /* */ - /* @note: */ - /* The error code will be set to indicate that an error occured */ - /* during the recording session. */ - /* */ + /************************************************************************* + * + * @functype: + * T2_Hints_CloseFunc + * + * @description: + * A method of the @T2_Hints class used to close a hint recording + * session. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * end_point :: + * The index of the last point in the input glyph. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The error code is set to indicate that an error occurred during the + * recording session. + * + */ typedef FT_Error (*T2_Hints_CloseFunc)( T2_Hints hints, FT_UInt end_point ); - /*************************************************************************/ - /* */ - /* @functype: */ - /* T2_Hints_ApplyFunc */ - /* */ - /* @description: */ - /* A method of the @T2_Hints class used to apply hints to the */ - /* corresponding glyph outline. Must be called after the "close" */ - /* method. */ - /* */ - /* @input: */ - /* hints :: A handle to the Type 2 hints recorder. */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* globals :: The hinter globals for this font. */ - /* */ - /* hint_mode :: Hinting information. */ - /* */ - /* @return: */ - /* FreeType error code. 0 means success. */ - /* */ - /* @note: */ - /* On input, all points within the outline are in font coordinates. */ - /* On output, they are in 1/64th of pixels. */ - /* */ - /* The scaling transformation is taken from the "globals" object */ - /* which must correspond to the same font than the glyph. */ - /* */ + /************************************************************************* + * + * @functype: + * T2_Hints_ApplyFunc + * + * @description: + * A method of the @T2_Hints class used to apply hints to the + * corresponding glyph outline. Must be called after the `close' + * method. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * outline :: + * A pointer to the target outline descriptor. + * + * globals :: + * The hinter globals for this font. + * + * hint_mode :: + * Hinting information. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * On input, all points within the outline are in font coordinates. On + * output, they are in 1/64th of pixels. + * + * The scaling transformation is taken from the `globals' object which + * must correspond to the same font than the glyph. + * + */ typedef FT_Error (*T2_Hints_ApplyFunc)( T2_Hints hints, FT_Outline* outline, @@ -567,30 +621,37 @@ FT_BEGIN_HEADER FT_Render_Mode hint_mode ); - /*************************************************************************/ - /* */ - /* @struct: */ - /* T2_Hints_FuncsRec */ - /* */ - /* @description: */ - /* The structure used to provide the API to @T2_Hints objects. */ - /* */ - /* @fields: */ - /* hints :: A handle to the T2 hints recorder object. */ - /* */ - /* open :: The function to open a recording session. */ - /* */ - /* close :: The function to close a recording session. */ - /* */ - /* stems :: The function to set the dimension's stems table. */ - /* */ - /* hintmask :: The function to set hint masks. */ - /* */ - /* counter :: The function to set counter masks. */ - /* */ - /* apply :: The function to apply the hints on the corresponding */ - /* glyph outline. */ - /* */ + /************************************************************************* + * + * @struct: + * T2_Hints_FuncsRec + * + * @description: + * The structure used to provide the API to @T2_Hints objects. + * + * @fields: + * hints :: + * A handle to the T2 hints recorder object. + * + * open :: + * The function to open a recording session. + * + * close :: + * The function to close a recording session. + * + * stems :: + * The function to set the dimension's stems table. + * + * hintmask :: + * The function to set hint masks. + * + * counter :: + * The function to set counter masks. + * + * apply :: + * The function to apply the hints on the corresponding glyph outline. + * + */ typedef struct T2_Hints_FuncsRec_ { T2_Hints hints; diff --git a/headers/libs/freetype2/freetype/internal/services/svgxval.h b/headers/libs/freetype2/freetype/internal/services/svgxval.h new file mode 100644 index 0000000000..2cdab50655 --- /dev/null +++ b/headers/libs/freetype2/freetype/internal/services/svgxval.h @@ -0,0 +1,72 @@ +/***************************************************************************/ +/* */ +/* svgxval.h */ +/* */ +/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ +/* */ +/* Copyright 2004, 2005 by */ +/* Masatake YAMATO, Red Hat K.K., */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* gxvalid is derived from both gxlayout module and otvalid module. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ +/***************************************************************************/ + + +#ifndef __SVGXVAL_H__ +#define __SVGXVAL_H__ + +#include FT_GX_VALIDATE_H +#include FT_INTERNAL_VALIDATE_H + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_GX_VALIDATE "truetypegx-validate" +#define FT_SERVICE_ID_CLASSICKERN_VALIDATE "classickern-validate" + + typedef FT_Error + (*gxv_validate_func)( FT_Face face, + FT_UInt gx_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ); + + + typedef FT_Error + (*ckern_validate_func)( FT_Face face, + FT_UInt ckern_flags, + FT_Bytes *ckern_table ); + + + FT_DEFINE_SERVICE( GXvalidate ) + { + gxv_validate_func validate; + }; + + FT_DEFINE_SERVICE( CKERNvalidate ) + { + ckern_validate_func validate; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* __SVGXVAL_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/autohint/aherrors.h b/headers/libs/freetype2/freetype/internal/services/svkern.h similarity index 55% rename from src/libs/freetype2/autohint/aherrors.h rename to headers/libs/freetype2/freetype/internal/services/svkern.h index bce6107d39..169b36dded 100644 --- a/src/libs/freetype2/autohint/aherrors.h +++ b/headers/libs/freetype2/freetype/internal/services/svkern.h @@ -1,10 +1,10 @@ /***************************************************************************/ /* */ -/* aherrors.h */ +/* svkern.h */ /* */ -/* Autohinter error codes (specification only). */ +/* The FreeType Kerning service (specification). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -16,25 +16,36 @@ /***************************************************************************/ - /*************************************************************************/ - /* */ - /* This file is used to define the Autohinter error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +#ifndef __SVKERN_H__ +#define __SVKERN_H__ -#ifndef __AHERRORS_H__ -#define __AHERRORS_H__ +#include FT_INTERNAL_SERVICE_H +#include FT_TRUETYPE_TABLES_H -#include FT_MODULE_ERRORS_H -#undef __FTERRORS_H__ +FT_BEGIN_HEADER -#define FT_ERR_PREFIX AH_Err_ -#define FT_ERR_BASE FT_Mod_Err_Autohint +#define FT_SERVICE_ID_KERNING "kerning" -#include FT_ERRORS_H -#endif /* __AHERRORS_H__ */ + typedef FT_Error + (*FT_Kerning_TrackGetFunc)( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ); + + FT_DEFINE_SERVICE( Kerning ) + { + FT_Kerning_TrackGetFunc get_track; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* __SVKERN_H__ */ + /* END */ diff --git a/headers/libs/freetype2/freetype/internal/services/svotval.h b/headers/libs/freetype2/freetype/internal/services/svotval.h index fbe45d0ddf..88da778871 100644 --- a/headers/libs/freetype2/freetype/internal/services/svotval.h +++ b/headers/libs/freetype2/freetype/internal/services/svotval.h @@ -4,7 +4,7 @@ /* */ /* The FreeType OpenType validation service (specification). */ /* */ -/* Copyright 2004 by */ +/* Copyright 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,6 +19,8 @@ #ifndef __SVOTVAL_H__ #define __SVOTVAL_H__ +#include FT_OPENTYPE_VALIDATE_H +#include FT_INTERNAL_VALIDATE_H FT_BEGIN_HEADER diff --git a/headers/libs/freetype2/freetype/internal/services/svpfr.h b/headers/libs/freetype2/freetype/internal/services/svpfr.h index b61050543e..462786f9ce 100644 --- a/headers/libs/freetype2/freetype/internal/services/svpfr.h +++ b/headers/libs/freetype2/freetype/internal/services/svpfr.h @@ -4,7 +4,7 @@ /* */ /* Internal PFR service functions (specification). */ /* */ -/* Copyright 2003 by */ +/* Copyright 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,6 +19,7 @@ #ifndef __SVPFR_H__ #define __SVPFR_H__ +#include FT_PFR_H #include FT_INTERNAL_SERVICE_H diff --git a/headers/libs/freetype2/freetype/internal/services/svpscmap.h b/headers/libs/freetype2/freetype/internal/services/svpscmap.h index ade96ef8f1..8f418a83a1 100644 --- a/headers/libs/freetype2/freetype/internal/services/svpscmap.h +++ b/headers/libs/freetype2/freetype/internal/services/svpscmap.h @@ -4,7 +4,7 @@ /* */ /* The FreeType PostScript charmap service (specification). */ /* */ -/* Copyright 2003 by */ +/* Copyright 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,6 +19,8 @@ #ifndef __SVPSCMAP_H__ #define __SVPSCMAP_H__ +#include FT_INTERNAL_OBJECTS_H + FT_BEGIN_HEADER @@ -27,30 +29,23 @@ FT_BEGIN_HEADER /* - * Adobe glyph name to unicode value + * Adobe glyph name to unicode value. */ typedef FT_UInt32 (*PS_Unicode_ValueFunc)( const char* glyph_name ); - /* - * Unicode value to Adobe glyph name index. 0xFFFF if not found. - */ - typedef FT_UInt - (*PS_Unicode_Index_Func)( FT_UInt num_glyphs, - const char** glyph_names, - FT_ULong unicode ); - /* * Macintosh name id to glyph name. NULL if invalid index. */ typedef const char* - (*PS_Macintosh_Name_Func)( FT_UInt name_index ); + (*PS_Macintosh_NameFunc)( FT_UInt name_index ); /* * Adobe standard string ID to glyph name. NULL if invalid index. */ typedef const char* - (*PS_Adobe_Std_Strings_Func)( FT_UInt string_index ); + (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index ); + /* * Simple unicode -> glyph index charmap built from font glyph names @@ -58,33 +53,45 @@ FT_BEGIN_HEADER */ typedef struct PS_UniMap_ { - FT_UInt unicode; - FT_UInt glyph_index; + FT_UInt32 unicode; /* bit 31 set: is glyph variant */ + FT_UInt glyph_index; } PS_UniMap; - typedef struct PS_Unicodes_ + typedef struct PS_UnicodesRec_* PS_Unicodes; + + typedef struct PS_UnicodesRec_ { + FT_CMapRec cmap; FT_UInt num_maps; PS_UniMap* maps; - } PS_Unicodes; + } PS_UnicodesRec; + /* + * A function which returns a glyph name for a given index. Returns + * NULL if invalid index. + */ + typedef const char* + (*PS_Glyph_NameFunc)( FT_Pointer data, + FT_UInt string_index ); + typedef FT_Error - (*PS_Unicodes_InitFunc)( FT_Memory memory, - FT_UInt num_glyphs, - const char** glyph_names, - PS_Unicodes* unicodes ); + (*PS_Unicodes_InitFunc)( FT_Memory memory, + PS_Unicodes unicodes, + FT_UInt num_glyphs, + PS_Glyph_NameFunc get_glyph_name, + FT_Pointer glyph_data ); typedef FT_UInt - (*PS_Unicodes_CharIndexFunc)( PS_Unicodes* unicodes, - FT_UInt unicode ); + (*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes, + FT_UInt32 unicode ); typedef FT_ULong - (*PS_Unicodes_CharNextFunc)( PS_Unicodes* unicodes, - FT_ULong unicode ); + (*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes, + FT_UInt32 *unicode ); FT_DEFINE_SERVICE( PsCMaps ) @@ -95,8 +102,8 @@ FT_BEGIN_HEADER PS_Unicodes_CharIndexFunc unicodes_char_index; PS_Unicodes_CharNextFunc unicodes_char_next; - PS_Macintosh_Name_Func macintosh_name; - PS_Adobe_Std_Strings_Func adobe_std_strings; + PS_Macintosh_NameFunc macintosh_name; + PS_Adobe_Std_StringsFunc adobe_std_strings; const unsigned short* adobe_std_encoding; const unsigned short* adobe_expert_encoding; }; diff --git a/headers/libs/freetype2/freetype/internal/services/svsfnt.h b/headers/libs/freetype2/freetype/internal/services/svsfnt.h index 87346c6d00..b4a85d97ec 100644 --- a/headers/libs/freetype2/freetype/internal/services/svsfnt.h +++ b/headers/libs/freetype2/freetype/internal/services/svsfnt.h @@ -70,7 +70,7 @@ FT_BEGIN_HEADER /* */ - + FT_END_HEADER diff --git a/headers/libs/freetype2/freetype/internal/services/svtteng.h b/headers/libs/freetype2/freetype/internal/services/svtteng.h new file mode 100644 index 0000000000..58e02a6f9d --- /dev/null +++ b/headers/libs/freetype2/freetype/internal/services/svtteng.h @@ -0,0 +1,53 @@ +/***************************************************************************/ +/* */ +/* svtteng.h */ +/* */ +/* The FreeType TrueType engine query service (specification). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __SVTTENG_H__ +#define __SVTTENG_H__ + +#include FT_INTERNAL_SERVICE_H +#include FT_MODULE_H + + +FT_BEGIN_HEADER + + + /* + * SFNT table loading service. + */ + +#define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" + + /* + * Used to implement FT_Get_TrueType_Engine_Type + */ + + FT_DEFINE_SERVICE( TrueTypeEngine ) + { + FT_TrueTypeEngineType engine_type; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* __SVTTENG_H__ */ + + +/* END */ diff --git a/headers/libs/freetype2/freetype/internal/sfnt.h b/headers/libs/freetype2/freetype/internal/sfnt.h index 7b582630b7..b88607a08d 100644 --- a/headers/libs/freetype2/freetype/internal/sfnt.h +++ b/headers/libs/freetype2/freetype/internal/sfnt.h @@ -4,7 +4,7 @@ /* */ /* High-level `sfnt' driver interface (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -34,7 +34,7 @@ FT_BEGIN_HEADER /* TT_Init_Face_Func */ /* */ /* <Description> */ - /* First part of the SFNT face object initialization. This will find */ + /* First part of the SFNT face object initialization. This finds */ /* the face in a SFNT file or collection, and load its format tag in */ /* face->format_tag. */ /* */ @@ -77,9 +77,9 @@ FT_BEGIN_HEADER /* TT_Load_Face_Func */ /* */ /* <Description> */ - /* Second part of the SFNT face object initialization. This will */ - /* load the common SFNT tables (head, OS/2, maxp, metrics, etc.) in */ - /* the face object. */ + /* Second part of the SFNT face object initialization. This loads */ + /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */ + /* face object. */ /* */ /* <Input> */ /* stream :: The input stream. */ @@ -125,6 +125,8 @@ FT_BEGIN_HEADER (*TT_Done_Face_Func)( TT_Face face ); +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + /*************************************************************************/ /* */ /* <FuncType> */ @@ -172,11 +174,11 @@ FT_BEGIN_HEADER /* Loads the table directory into a face object. */ /* */ /* <Input> */ - /* face :: A handle to the target face object. */ + /* face :: A handle to the target face object. */ /* */ - /* stream :: The input stream. */ + /* stream :: The input stream. */ /* */ - /* sfnt :: The SFNT header. */ + /* sfnt :: The SFNT header. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ @@ -191,6 +193,8 @@ FT_BEGIN_HEADER FT_Stream stream, SFNT_Header sfnt ); +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + /*************************************************************************/ /* */ @@ -198,7 +202,7 @@ FT_BEGIN_HEADER /* TT_Load_Any_Func */ /* */ /* <Description> */ - /* Loads any font table into client memory. */ + /* Load any font table into client memory. */ /* */ /* <Input> */ /* face :: The face object to look for. */ @@ -246,7 +250,7 @@ FT_BEGIN_HEADER /* TT_Find_SBit_Image_Func */ /* */ /* <Description> */ - /* Checks whether an embedded bitmap (an `sbit') exists for a given */ + /* Check whether an embedded bitmap (an `sbit') exists for a given */ /* glyph, at a given strike. */ /* */ /* <Input> */ @@ -283,7 +287,7 @@ FT_BEGIN_HEADER /* TT_Load_SBit_Metrics_Func */ /* */ /* <Description> */ - /* Gets the big metrics for a given embedded bitmap. */ + /* Get the big metrics for a given embedded bitmap. */ /* */ /* <Input> */ /* stream :: The input stream. */ @@ -316,7 +320,7 @@ FT_BEGIN_HEADER /* TT_Load_SBit_Image_Func */ /* */ /* <Description> */ - /* Loads a given glyph sbit image from the font resource. This also */ + /* Load a given glyph sbit image from the font resource. This also */ /* returns its metrics. */ /* */ /* <Input> */ @@ -359,21 +363,20 @@ FT_BEGIN_HEADER TT_SBit_MetricsRec *ametrics ); +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + /*************************************************************************/ /* */ /* <FuncType> */ - /* TT_Set_SBit_Strike_Func */ + /* TT_Set_SBit_Strike_OldFunc */ /* */ /* <Description> */ - /* Selects an sbit strike for given horizontal and vertical ppem */ - /* values. */ + /* Select an sbit strike for a given size request. */ /* */ /* <Input> */ /* face :: The target face object. */ /* */ - /* x_ppem :: The horizontal resolution in points per EM. */ - /* */ - /* y_ppem :: The vertical resolution in points per EM. */ + /* req :: The size request. */ /* */ /* <Output> */ /* astrike_index :: The index of the sbit strike. */ @@ -383,10 +386,115 @@ FT_BEGIN_HEADER /* sbit strike exists for the selected ppem values. */ /* */ typedef FT_Error - (*TT_Set_SBit_Strike_Func)( TT_Face face, - FT_UInt x_ppem, - FT_UInt y_ppem, - FT_ULong *astrike_index ); + (*TT_Set_SBit_Strike_OldFunc)( TT_Face face, + FT_UInt x_ppem, + FT_UInt y_ppem, + FT_ULong* astrike_index ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_CharMap_Load_Func */ + /* */ + /* <Description> */ + /* Loads a given TrueType character map into memory. */ + /* */ + /* <Input> */ + /* face :: A handle to the parent face object. */ + /* */ + /* stream :: A handle to the current stream object. */ + /* */ + /* <InOut> */ + /* cmap :: A pointer to a cmap object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* The function assumes that the stream is already in use (i.e., */ + /* opened). In case of error, all partially allocated tables are */ + /* released. */ + /* */ + typedef FT_Error + (*TT_CharMap_Load_Func)( TT_Face face, + void* cmap, + FT_Stream input ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_CharMap_Free_Func */ + /* */ + /* <Description> */ + /* Destroys a character mapping table. */ + /* */ + /* <Input> */ + /* face :: A handle to the parent face object. */ + /* */ + /* cmap :: A handle to a cmap object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_CharMap_Free_Func)( TT_Face face, + void* cmap ); + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Set_SBit_Strike_Func */ + /* */ + /* <Description> */ + /* Select an sbit strike for a given size request. */ + /* */ + /* <Input> */ + /* face :: The target face object. */ + /* */ + /* req :: The size request. */ + /* */ + /* <Output> */ + /* astrike_index :: The index of the sbit strike. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. Returns an error if no */ + /* sbit strike exists for the selected ppem values. */ + /* */ + typedef FT_Error + (*TT_Set_SBit_Strike_Func)( TT_Face face, + FT_Size_Request req, + FT_ULong* astrike_index ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_Strike_Metrics_Func */ + /* */ + /* <Description> */ + /* Load the metrics of a given strike. */ + /* */ + /* <Input> */ + /* face :: The target face object. */ + /* */ + /* strike_index :: The strike index. */ + /* */ + /* <Output> */ + /* metrics :: the metrics of the strike. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. Returns an error if no */ + /* such sbit strike exists. */ + /* */ + typedef FT_Error + (*TT_Load_Strike_Metrics_Func)( TT_Face face, + FT_ULong strike_index, + FT_Size_Metrics* metrics ); /*************************************************************************/ @@ -395,7 +503,7 @@ FT_BEGIN_HEADER /* TT_Get_PS_Name_Func */ /* */ /* <Description> */ - /* Gets the PostScript glyph name of a glyph. */ + /* Get the PostScript glyph name of a glyph. */ /* */ /* <Input> */ /* idx :: The glyph index. */ @@ -420,14 +528,15 @@ FT_BEGIN_HEADER /* TT_Load_Metrics_Func */ /* */ /* <Description> */ - /* Loads the horizontal or vertical header in a face object. */ + /* Load a metrics table, which is a table with a horizontal and a */ + /* vertical version. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* */ /* stream :: The input stream. */ /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ + /* vertical :: A boolean flag. If set, load the vertical one. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ @@ -438,13 +547,39 @@ FT_BEGIN_HEADER FT_Bool vertical ); + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Get_Metrics_Func */ + /* */ + /* <Description> */ + /* Load the horizontal or vertical header in a face object. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* stream :: The input stream. */ + /* */ + /* vertical :: A boolean flag. If set, load vertical metrics. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_Get_Metrics_Func)( TT_Face face, + FT_Bool vertical, + FT_UInt gindex, + FT_Short* abearing, + FT_UShort* aadvance ); + + /*************************************************************************/ /* */ /* <FuncType> */ /* TT_Load_Table_Func */ /* */ /* <Description> */ - /* Loads a given TrueType table. */ + /* Load a given TrueType table. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ @@ -455,8 +590,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* The function will use `face->goto_table' to seek the stream to */ - /* the start of the table. */ + /* The function uses `face->goto_table' to seek the stream to the */ + /* start of the table, except while loading the font directory. */ /* */ typedef FT_Error (*TT_Load_Table_Func)( TT_Face face, @@ -469,7 +604,7 @@ FT_BEGIN_HEADER /* TT_Free_Table_Func */ /* */ /* <Description> */ - /* Frees a given TrueType table. */ + /* Free a given TrueType table. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ @@ -521,47 +656,97 @@ FT_BEGIN_HEADER FT_Module_Requester get_interface; TT_Load_Any_Func load_any; + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS TT_Load_SFNT_HeaderRec_Func load_sfnt_header; TT_Load_Directory_Func load_directory; +#endif /* these functions are called by `load_face' but they can also */ /* be called from external modules, if there is a need to do so */ - TT_Load_Table_Func load_header; - TT_Load_Metrics_Func load_metrics; - TT_Load_Table_Func load_charmaps; - TT_Load_Table_Func load_max_profile; + TT_Load_Table_Func load_head; + TT_Load_Metrics_Func load_hhea; + TT_Load_Table_Func load_cmap; + TT_Load_Table_Func load_maxp; TT_Load_Table_Func load_os2; - TT_Load_Table_Func load_psnames; + TT_Load_Table_Func load_post; - TT_Load_Table_Func load_names; - TT_Free_Table_Func free_names; + TT_Load_Table_Func load_name; + TT_Free_Table_Func free_name; /* optional tables */ - TT_Load_Table_Func load_hdmx; - TT_Free_Table_Func free_hdmx; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + TT_Load_Table_Func load_hdmx_stub; + TT_Free_Table_Func free_hdmx_stub; +#endif + + /* this field was called `load_kerning' up to version 2.1.10 */ + TT_Load_Table_Func load_kern; - TT_Load_Table_Func load_kerning; TT_Load_Table_Func load_gasp; TT_Load_Table_Func load_pclt; - /* see `ttload.h' */ - TT_Load_Table_Func load_bitmap_header; + /* see `ttload.h'; this field was called `load_bitmap_header' up to */ + /* version 2.1.10 */ + TT_Load_Table_Func load_bhed; + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS /* see `ttsbit.h' */ - TT_Set_SBit_Strike_Func set_sbit_strike; - TT_Load_Table_Func load_sbits; + TT_Set_SBit_Strike_OldFunc set_sbit_strike_stub; + TT_Load_Table_Func load_sbits_stub; + + /* + * The following two fields appeared in version 2.1.8, and were placed + * between `load_sbits' and `load_sbit_image'. We support them as a + * special exception since they are used by Xfont library within the + * X.Org xserver, and because the probability that other rogue clients + * use the other version 2.1.7 fields below is _extremely_ low. + * + * Note that this forces us to disable an interesting memory-saving + * optimization though... + */ + TT_Find_SBit_Image_Func find_sbit_image; TT_Load_SBit_Metrics_Func load_sbit_metrics; - TT_Load_SBit_Image_Func load_sbit_image; - TT_Free_Table_Func free_sbits; - /* see `ttkern.h' */ - TT_Face_GetKerningFunc get_kerning; - +#endif + + TT_Load_SBit_Image_Func load_sbit_image; + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + TT_Free_Table_Func free_sbits_stub; +#endif + /* see `ttpost.h' */ TT_Get_PS_Name_Func get_psname; TT_Free_Table_Func free_psnames; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + TT_CharMap_Load_Func load_charmap_stub; + TT_CharMap_Free_Func free_charmap_stub; +#endif + + /* starting here, the structure differs from version 2.1.7 */ + + /* this field was introduced in version 2.1.8, named `get_psname' */ + TT_Face_GetKerningFunc get_kerning; + + /* new elements introduced after version 2.1.10 */ + + /* load the font directory, i.e., the offset table and */ + /* the table directory */ + TT_Load_Table_Func load_font_dir; + TT_Load_Metrics_Func load_hmtx; + + TT_Load_Table_Func load_eblc; + TT_Free_Table_Func free_eblc; + + TT_Set_SBit_Strike_Func set_sbit_strike; + TT_Load_Strike_Metrics_Func load_strike_metrics; + + TT_Get_Metrics_Func get_metrics; + } SFNT_Interface; diff --git a/headers/libs/freetype2/freetype/internal/t1types.h b/headers/libs/freetype2/freetype/internal/t1types.h index 702bb1e4c6..65d9ca92e8 100644 --- a/headers/libs/freetype2/freetype/internal/t1types.h +++ b/headers/libs/freetype2/freetype/internal/t1types.h @@ -5,7 +5,7 @@ /* Basic Type1/Type2 type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -129,6 +129,51 @@ FT_BEGIN_HEADER } CID_SubrsRec, *CID_Subrs; + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** AFM FONT INFORMATION STRUCTURES ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct AFM_TrackKernRec_ + { + FT_Int degree; + FT_Fixed min_ptsize; + FT_Fixed min_kern; + FT_Fixed max_ptsize; + FT_Fixed max_kern; + + } AFM_TrackKernRec, *AFM_TrackKern; + + typedef struct AFM_KernPairRec_ + { + FT_Int index1; + FT_Int index2; + FT_Int x; + FT_Int y; + + } AFM_KernPairRec, *AFM_KernPair; + + typedef struct AFM_FontInfoRec_ + { + FT_Bool IsCIDFont; + FT_BBox FontBBox; + FT_Fixed Ascender; + FT_Fixed Descender; + AFM_TrackKern TrackKerns; /* free if non-NULL */ + FT_Int NumTrackKern; + AFM_KernPair KernPairs; /* free if non-NULL */ + FT_Int NumKernPair; + + } AFM_FontInfoRec, *AFM_FontInfo; + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -148,20 +193,23 @@ FT_BEGIN_HEADER typedef struct T1_FaceRec_ { - FT_FaceRec root; - T1_FontRec type1; - const void* psnames; - const void* psaux; - const void* afm_data; - FT_CharMapRec charmaprecs[2]; - FT_CharMap charmaps[2]; - PS_Unicodes unicode_map; + FT_FaceRec root; + T1_FontRec type1; + const void* psnames; + const void* psaux; + const void* afm_data; + FT_CharMapRec charmaprecs[2]; + FT_CharMap charmaps[2]; + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + PS_Unicodes unicode_map; +#endif /* support for Multiple Masters fonts */ - PS_Blend blend; + PS_Blend blend; - /* since FT 2.1 - interface to PostScript hinter */ - const void* pshinter; + /* since version 2.1 - interface to PostScript hinter */ + const void* pshinter; } T1_FaceRec; @@ -173,13 +221,15 @@ FT_BEGIN_HEADER void* psaux; CID_FaceInfoRec cid; void* afm_data; - FT_Byte* binary_data; /* used if hex data has been converted */ - FT_Stream cid_stream; CID_Subrs subrs; - /* since FT 2.1 - interface to PostScript hinter */ + /* since version 2.1 - interface to PostScript hinter */ void* pshinter; + /* since version 2.1.8, but was originally positioned after `afm_data' */ + FT_Byte* binary_data; /* used if hex data has been converted */ + FT_Stream cid_stream; + } CID_FaceRec; diff --git a/headers/libs/freetype2/freetype/internal/tttypes.h b/headers/libs/freetype2/freetype/internal/tttypes.h index 7f8335f829..5235cc0d20 100644 --- a/headers/libs/freetype2/freetype/internal/tttypes.h +++ b/headers/libs/freetype2/freetype/internal/tttypes.h @@ -5,7 +5,7 @@ /* Basic SFNT/TrueType type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -311,7 +311,7 @@ FT_BEGIN_HEADER } TT_GaspRec; -#ifndef FT_OPTIMIZE_MEMORY +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS /*************************************************************************/ /* */ @@ -389,7 +389,7 @@ FT_BEGIN_HEADER } TT_Kern0_PairRec, *TT_Kern0_Pair; -#endif /* !OPTIMIZE_MEMORY */ +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ /*************************************************************************/ @@ -843,6 +843,72 @@ FT_BEGIN_HEADER typedef struct GX_BlendRec_ *GX_Blend; #endif + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /* + * These types are used to support a `BDF ' table that isn't part of the + * official TrueType specification. It is mainly used in SFNT-based + * bitmap fonts that were generated from a set of BDF fonts. + * + * The format of the table is as follows. + * + * USHORT version `BDF ' table version number, should be 0x0001. + * USHORT strikeCount Number of strikes (bitmap sizes) in this table. + * ULONG stringTable Offset (froms start of BDF table) to string + * table. + * + * This is followed by an array of `strikeCount' descriptors, having the + * following format. + * + * USHORT ppem Vertical pixels per EM for this strike. + * USHORT numItems Number of items for this strike (properties and + * atoms). Maximum is 255. + * + * This array in turn is followed by `strikeCount' value sets. Each + * `value set' is an array of `numItems' items with the following format. + * + * ULONG item_name Offset in string table to item name. + * USHORT item_type The item type. Possible values are + * 0 => string (e.g., COMMENT) + * 1 => atom (e.g., FONT or even SIZE) + * 2 => int32 + * 3 => uint32 + * 0x10 => A flag to indicate a properties. This + * is ORed with the above values. + * ULONG item_value For strings => Offset into string table without + * the corresponding double quotes. + * For atoms => Offset into string table. + * For integers => Direct value. + * + * All strings in the string table consist of bytes and are + * zero-terminated. + * + */ + +#ifdef TT_CONFIG_OPTION_BDF + + typedef struct TT_BDFRec_ + { + FT_Byte* table; + FT_Byte* table_end; + FT_Byte* strings; + FT_UInt32 strings_size; + FT_UInt num_strikes; + FT_Bool loaded; + + } TT_BDFRec, *TT_BDF; + +#endif /* TT_CONFIG_OPTION_BDF */ /*************************************************************************/ /*************************************************************************/ @@ -1036,10 +1102,6 @@ FT_BEGIN_HEADER /* table. We thus define additional fields */ /* below to hold the computed maxima. */ /* */ - /* max_components :: The maximum number of glyph components */ - /* required to load any composite glyph from */ - /* this font. Used to size the load stack. */ - /* */ /* vertical_info :: A boolean which is set when the font file */ /* contains vertical metrics. If not, the */ /* value of the `vertical' field is */ @@ -1205,20 +1267,14 @@ FT_BEGIN_HEADER TT_Header header; /* TrueType header table */ TT_HoriHeader horizontal; /* TrueType horizontal header */ -#ifdef FT_OPTIMIZE_MEMORY - FT_Byte* horz_metrics; - FT_ULong horz_metrics_size; -#endif TT_MaxProfile max_profile; - FT_ULong max_components; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_ULong max_components; /* stubbed to 0 */ +#endif FT_Bool vertical_info; TT_VertHeader vertical; /* TT Vertical header, if present */ -#ifdef FT_OPTIMIZE_MEMORY - FT_Byte* vert_metrics; - FT_ULong vert_metrics_size; -#endif FT_UShort num_names; /* number of name records */ TT_NameTableRec name_table; /* name table */ @@ -1226,7 +1282,7 @@ FT_BEGIN_HEADER TT_OS2 os2; /* TrueType OS/2 table */ TT_Postscript postscript; /* TrueType Postscript table */ - FT_Byte* cmap_table; /* extracted 'cmap' table */ + FT_Byte* cmap_table; /* extracted `cmap' table */ FT_ULong cmap_size; TT_Loader_GotoTableFunc goto_table; @@ -1253,13 +1309,7 @@ FT_BEGIN_HEADER /***********************************************************************/ /* horizontal device metrics */ -#ifdef FT_OPTIMIZE_MEMORY - FT_Byte* hdmx_table; - FT_ULong hdmx_table_size; - FT_UInt hdmx_record_count; - FT_ULong hdmx_record_size; - FT_Byte* hdmx_record_sizes; -#else +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS TT_HdmxRec hdmx; #endif @@ -1270,11 +1320,7 @@ FT_BEGIN_HEADER TT_PCLT pclt; /* embedded bitmaps support */ -#ifdef FT_OPTIMIZE_MEMORY - FT_Byte* sbit_table; - FT_ULong sbit_table_size; - FT_UInt sbit_num_strikes; -#else +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS FT_ULong num_sbit_strikes; TT_SBit_Strike sbit_strikes; #endif @@ -1293,16 +1339,11 @@ FT_BEGIN_HEADER /***********************************************************************/ /* the glyph locations */ -#ifdef FT_OPTIMIZE_MEMORY - FT_UInt num_locations; - FT_Byte* glyph_locations; -#else - FT_UShort num_locations; - FT_Long* glyph_locations; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_UShort num_locations_stub; + FT_Long* glyph_locations_stub; #endif - FT_ULong glyf_len; - /* the font program, if any */ FT_ULong font_program_size; FT_Byte* font_program; @@ -1315,13 +1356,7 @@ FT_BEGIN_HEADER FT_ULong cvt_size; FT_Short* cvt; -#ifdef FT_OPTIMIZE_MEMORY - FT_Byte* kern_table; - FT_ULong kern_table_size; - FT_UInt num_kern_tables; - FT_UInt32 kern_avail_bits; - FT_UInt32 kern_order_bits; -#else +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS /* the format 0 kerning table, if any */ FT_Int num_kern_pairs; FT_Int kern_table_index; @@ -1337,11 +1372,6 @@ FT_BEGIN_HEADER FT_Bool unpatented_hinting; #endif -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Bool doblend; - GX_Blend blend; -#endif - /***********************************************************************/ /* */ /* Other tables or fields. This is used by derivative formats like */ @@ -1353,6 +1383,49 @@ FT_BEGIN_HEADER const char* postscript_name; + /* since version 2.1.8, but was originally placed after */ + /* `glyph_locations_stub' */ + FT_ULong glyf_len; + + /* since version 2.1.8, but was originally placed before `extra' */ +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Bool doblend; + GX_Blend blend; +#endif + + /* since version 2.2 */ + +#ifdef FT_OPTIMIZE_MEMORY + FT_Byte* horz_metrics; + FT_ULong horz_metrics_size; + + FT_Byte* vert_metrics; + FT_ULong vert_metrics_size; + + FT_UInt num_locations; + FT_Byte* glyph_locations; + + FT_Byte* hdmx_table; + FT_ULong hdmx_table_size; + FT_UInt hdmx_record_count; + FT_ULong hdmx_record_size; + FT_Byte* hdmx_record_sizes; + + FT_Byte* sbit_table; + FT_ULong sbit_table_size; + FT_UInt sbit_num_strikes; + + FT_Byte* kern_table; + FT_ULong kern_table_size; + FT_UInt num_kern_tables; + FT_UInt32 kern_avail_bits; + FT_UInt32 kern_order_bits; +#endif + +#ifdef TT_CONFIG_OPTION_BDF + TT_BDFRec bdf; +#endif /* TT_CONFIG_OPTION_BDF */ + } TT_FaceRec; @@ -1423,15 +1496,11 @@ FT_BEGIN_HEADER FT_BBox bbox; FT_Int left_bearing; FT_Int advance; - FT_Int top_bearing; - FT_Int vadvance; FT_Int linear; FT_Bool linear_def; FT_Bool preserve_pps; FT_Vector pp1; FT_Vector pp2; - FT_Vector pp3; - FT_Vector pp4; FT_ULong glyf_offset; @@ -1446,6 +1515,12 @@ FT_BEGIN_HEADER /* for possible extensibility in other formats */ void* other; + /* since version 2.1.8 */ + FT_Int top_bearing; + FT_Int vadvance; + FT_Vector pp3; + FT_Vector pp4; + } TT_LoaderRec; diff --git a/headers/libs/freetype2/freetype/t1tables.h b/headers/libs/freetype2/freetype/t1tables.h index 5ae12b8268..1815250a4f 100644 --- a/headers/libs/freetype2/freetype/t1tables.h +++ b/headers/libs/freetype2/freetype/t1tables.h @@ -64,7 +64,7 @@ FT_BEGIN_HEADER /* <Description> */ /* A structure used to model a Type1/Type2 FontInfo dictionary. Note */ /* that for Multiple Master fonts, each instance has its own */ - /* FontInfo. */ + /* FontInfo dictionary. */ /* */ typedef struct PS_FontInfoRec { @@ -193,6 +193,8 @@ FT_BEGIN_HEADER } T1_Blend_Flags; + /* */ + /*# backwards compatible definitions */ #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION @@ -286,6 +288,14 @@ FT_BEGIN_HEADER typedef CID_FaceDictRec CID_FontDict; + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceInfoRec */ + /* */ + /* <Description> */ + /* A structure used to represent CID Face information. */ + /* */ typedef struct CID_FaceInfoRec_ { FT_String* cid_font_name; @@ -322,7 +332,7 @@ FT_BEGIN_HEADER /* CID_Info */ /* */ /* <Description> */ - /* This type is equivalent to CID_FaceInfoRec. It is deprecated but */ + /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ /* kept to maintain source compatibility between various versions of */ /* FreeType. */ /* */ @@ -381,7 +391,7 @@ FT_BEGIN_HEADER * the face and don't need to be freed by the caller. * * If the font's format is not Postscript-based, this function will - * return the FT_Err_Invalid_Argument error code. + * return the `FT_Err_Invalid_Argument' error code. */ FT_EXPORT( FT_Error ) FT_Get_PS_Font_Info( FT_Face face, @@ -413,7 +423,7 @@ FT_BEGIN_HEADER * the face and don't need to be freed by the caller. * * If the font's format is not Postscript-based, this function will - * return the FT_Err_Invalid_Argument error code. + * return the `FT_Err_Invalid_Argument' error code. */ FT_EXPORT( FT_Error ) FT_Get_PS_Font_Private( FT_Face face, diff --git a/headers/libs/freetype2/freetype/ttnameid.h b/headers/libs/freetype2/freetype/ttnameid.h index 2e7f110855..b9ac880de4 100644 --- a/headers/libs/freetype2/freetype/ttnameid.h +++ b/headers/libs/freetype2/freetype/ttnameid.h @@ -4,7 +4,7 @@ /* */ /* TrueType name ID definitions (specification only). */ /* */ -/* Copyright 1996-2002, 2003, 2004 by */ +/* Copyright 1996-2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -65,7 +65,7 @@ FT_BEGIN_HEADER * Used by Microsoft to indicate Windows-specific charmaps. See * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. * Note that most fonts contain a Unicode charmap using - * (@TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). + * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). * * TT_PLATFORM_CUSTOM :: * Used to indicate application-specific charmaps. @@ -96,14 +96,18 @@ FT_BEGIN_HEADER * @values: * TT_APPLE_ID_DEFAULT :: * Unicode version 1.0. + * * TT_APPLE_ID_UNICODE_1_1 :: * Unicode 1.1; specifies Hangul characters starting at U+34xx. + * * TT_APPLE_ID_ISO_10646 :: - * Deprecated (identical to preceding.) + * Deprecated (identical to preceding). + * * TT_APPLE_ID_UNICODE_2_0 :: - * Unicode 2.0 and beyond (UTF-16 BMP only.) + * Unicode 2.0 and beyond (UTF-16 BMP only). + * * TT_APPLE_ID_UNICODE_32 :: - * Unicode 3.1 and beyond, using UTF-32 + * Unicode 3.1 and beyond, using UTF-32. */ #define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ @@ -491,7 +495,7 @@ FT_BEGIN_HEADER #define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG #endif -#if 0 /* used only with .NET "cultures"; commented out */ +#if 0 /* used only with .NET `cultures'; commented out */ #define TT_MS_LANGID_CHINESE_TRADITIONAL 0x7C04 #endif diff --git a/headers/libs/freetype2/freetype/tttables.h b/headers/libs/freetype2/freetype/tttables.h index 051c1eaf6f..251d67717b 100644 --- a/headers/libs/freetype2/freetype/tttables.h +++ b/headers/libs/freetype2/freetype/tttables.h @@ -5,7 +5,7 @@ /* Basic SFNT/TrueType tables definitions and interface */ /* (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -407,9 +407,9 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* A structure used to model a TrueType Postscript table. All fields */ - /* comply to the TrueType table. This structure does not reference */ - /* the Postscript glyph names, which can be nevertheless accessed */ - /* with the `ttpost' module. */ + /* comply to the TrueType specification. This structure does not */ + /* reference the Postscript glyph names, which can be nevertheless */ + /* accessed with the `ttpost' module. */ /* */ typedef struct TT_Postscript_ { @@ -436,7 +436,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* A structure used to model a TrueType PCLT table. All fields */ - /* comply to the TrueType table. */ + /* comply to the TrueType specification. */ /* */ typedef struct TT_PCLT_ { @@ -594,8 +594,8 @@ FT_BEGIN_HEADER /* The table is owned by the face object and disappears with it. */ /* */ /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt/truetype/opentype drivers. See @FT_Sfnt_Tag for a */ - /* list. */ + /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ + /* a list. */ /* */ FT_EXPORT( void* ) FT_Get_Sfnt_Table( FT_Face face, @@ -604,56 +604,61 @@ FT_BEGIN_HEADER /************************************************************************** * - * <Function> - * FT_Load_Sfnt_Table + * @function: + * FT_Load_Sfnt_Table * - * <Description> + * @description: * Loads any font table into client memory. * - * <Input> - * face :: A handle to the source face. + * @input: + * face :: + * A handle to the source face. * - * tag :: The 4-byte tag of the table to load. Use the value 0 if - * you want to access the whole font file. Otherwise, you can - * use one of the definitions found in the @FT_TRUETYPE_TAGS_H - * file, or forge a new one with @FT_MAKE_TAG. + * tag :: + * The four-byte tag of the table to load. Use the value 0 if you want + * to access the whole font file. Otherwise, you can use one of the + * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new + * one with @FT_MAKE_TAG. * - * offset :: The starting offset in the table (or file if tag == 0). + * offset :: + * The starting offset in the table (or file if tag == 0). * - * <Output> - * buffer :: The target buffer address. The client must ensure that - * the memory array is big enough to hold the data. + * @output: + * buffer :: + * The target buffer address. The client must ensure that the memory + * array is big enough to hold the data. * - * <InOut> - * length :: If the `length' parameter is NULL, then try to load the whole - * table. Return an error code if it fails. + * @inout: + * length :: + * If the `length' parameter is NULL, then try to load the whole table. + * Return an error code if it fails. * - * Else, if `*length' is 0, exit immediately while returning - * the table's (or file) full size in it. + * Else, if `*length' is 0, exit immediately while returning the + * table's (or file) full size in it. * - * Else the number of bytes to read from the table or file, - * from the starting offset. + * Else the number of bytes to read from the table or file, from the + * starting offset. * - * <Return> + * @return: * FreeType error code. 0 means success. * - * <Note> + * @note: * If you need to determine the table's length you should first call this * function with `*length' set to 0, as in the following example: * - * { - * FT_ULong length = 0; + * { + * FT_ULong length = 0; * * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } - * } + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * } */ FT_EXPORT( FT_Error ) FT_Load_Sfnt_Table( FT_Face face, @@ -665,13 +670,13 @@ FT_BEGIN_HEADER /************************************************************************** * - * <Function> - * FT_Sfnt_Table_Info + * @function: + * FT_Sfnt_Table_Info * - * <Description> + * @description: * Returns information on an SFNT table. * - * <Input> + * @input: * face :: * A handle to the source face. * @@ -679,17 +684,17 @@ FT_BEGIN_HEADER * The index of an SFNT table. The function returns * FT_Err_Table_Missing for an invalid value. * - * <Output> + * @output: * tag :: * The name tag of the SFNT table. * * length :: * The length of the SFNT table. * - * <Return> + * @return: * FreeType error code. 0 means success. * - * <Note> + * @note: * SFNT tables with length zero are treated as missing by Windows. * */ @@ -707,7 +712,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Return TrueType/sfnt specific cmap language ID. Definitions of */ - /* language ID values are in freetype/ttnameid.h. */ + /* language ID values are in `freetype/ttnameid.h'. */ /* */ /* <Input> */ /* charmap :: */ diff --git a/headers/libs/freetype2/freetype/tttags.h b/headers/libs/freetype2/freetype/tttags.h index 9fee71bf81..e10244ca7c 100644 --- a/headers/libs/freetype2/freetype/tttags.h +++ b/headers/libs/freetype2/freetype/tttags.h @@ -4,7 +4,7 @@ /* */ /* Tags for TrueType and OpenType tables (specification only). */ /* */ -/* Copyright 1996-2001, 2004 by */ +/* Copyright 1996-2001, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -36,8 +36,10 @@ FT_BEGIN_HEADER #define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) #define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) #define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) #define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) #define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) #define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) @@ -46,6 +48,7 @@ FT_BEGIN_HEADER #define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) #define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) #define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) #define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) #define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) #define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) @@ -59,18 +62,27 @@ FT_BEGIN_HEADER #define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) #define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) #define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) #define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) #define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) #define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) #define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) #define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) #define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) +#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) +#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) #define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) #define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) #define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) #define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) #define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) #define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) +#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) +#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) #define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) #define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) #define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) diff --git a/headers/libs/freetype2/freetype/ttunpat.h b/headers/libs/freetype2/freetype/ttunpat.h index 0bc0a6fe09..a0162759b7 100644 --- a/headers/libs/freetype2/freetype/ttunpat.h +++ b/headers/libs/freetype2/freetype/ttunpat.h @@ -4,7 +4,7 @@ /* */ /* Definitions for the unpatented TrueType hinting system */ /* */ -/* Copyright 2003 by */ +/* Copyright 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* Written by Graham Asher <graham.asher@btinternet.com> */ @@ -43,7 +43,7 @@ FT_BEGIN_HEADER * @description: * A constant used as the tag of an @FT_Parameter structure to indicate * that unpatented methods only should be used by the TrueType bytecode - * interpreter for a typeface opened by FT_Open_Face. + * interpreter for a typeface opened by @FT_Open_Face. * */ #define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) diff --git a/headers/libs/freetype2/ft2build.h b/headers/libs/freetype2/ft2build.h index 2ecfdeab10..923d887df6 100644 --- a/headers/libs/freetype2/ft2build.h +++ b/headers/libs/freetype2/ft2build.h @@ -5,7 +5,7 @@ /* FreeType 2 build and setup macros. */ /* (Generic version) */ /* */ -/* Copyright 1996-2001 by */ +/* Copyright 1996-2001, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,8 +19,8 @@ /*************************************************************************/ /* */ - /* This file corresponds to the default "ft2build.h" file for */ - /* FreeType 2. It uses the "freetype" include root. */ + /* This file corresponds to the default `ft2build.h' file for */ + /* FreeType 2. It uses the `freetype' include root. */ /* */ /* Note that specific platforms might use a different configuration. */ /* See builds/unix/ft2unix.h for an example. */ diff --git a/src/libs/freetype2/Jamfile b/src/libs/freetype2/Jamfile index 1881be7789..4deb710fa3 100644 --- a/src/libs/freetype2/Jamfile +++ b/src/libs/freetype2/Jamfile @@ -1,5 +1,13 @@ -# FreeType 2 src Jamfile (c) 2001, 2002 David Turner +# FreeType 2 src Jamfile # +# Copyright 2001, 2002 by +# David Turner, Robert Wilhelm, and Werner Lemberg. +# +# This file is part of the FreeType project, and may only be used, modified, +# and distributed under the terms of the FreeType project license, +# LICENSE.TXT. By continuing to use, modify, or distribute this file you +# indicate that you have read the license and understand and accept it +# fully. SubDir HAIKU_TOP src libs freetype2 ; diff --git a/src/libs/freetype2/autofit/Jamfile b/src/libs/freetype2/autofit/Jamfile index 8213e4bb37..331dd12625 100644 --- a/src/libs/freetype2/autofit/Jamfile +++ b/src/libs/freetype2/autofit/Jamfile @@ -1,5 +1,13 @@ -# FreeType 2 src/autofit Jamfile (c) 2001 David Turner +# FreeType 2 src/autofit Jamfile # +# Copyright 2003, 2004, 2005, 2006 by +# David Turner, Robert Wilhelm, and Werner Lemberg. +# +# This file is part of the FreeType project, and may only be used, modified, +# and distributed under the terms of the FreeType project license, +# LICENSE.TXT. By continuing to use, modify, or distribute this file you +# indicate that you have read the license and understand and accept it +# fully. SubDir HAIKU_TOP src libs freetype2 autofit ; @@ -13,7 +21,7 @@ UseFreeTypeHeaders ; if $(FT2_MULTI) { - _sources = afangles afglobal afhints aflatin afloader afmodule afdummy ; + _sources = afangles afglobal afhints aflatin afloader afmodule afdummy afwarp ; } else { @@ -24,4 +32,3 @@ UseFreeTypeHeaders ; } # end of src/autofit Jamfile - diff --git a/src/libs/freetype2/autofit/afangles.c b/src/libs/freetype2/autofit/afangles.c index 7411be72f3..94a84862b7 100644 --- a/src/libs/freetype2/autofit/afangles.c +++ b/src/libs/freetype2/autofit/afangles.c @@ -20,6 +20,112 @@ #include "aftypes.h" +#if 1 + + /* the following table has been automatically generated with */ + /* the `mather.py' Python script */ + +#define AF_ATAN_BITS 8 + + static const FT_Byte af_arctan[1L << AF_ATAN_BITS] = + { + 0, 0, 1, 1, 1, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 5, + 5, 5, 6, 6, 6, 7, 7, 7, + 8, 8, 8, 9, 9, 9, 10, 10, + 10, 10, 11, 11, 11, 12, 12, 12, + 13, 13, 13, 14, 14, 14, 14, 15, + 15, 15, 16, 16, 16, 17, 17, 17, + 18, 18, 18, 18, 19, 19, 19, 20, + 20, 20, 21, 21, 21, 21, 22, 22, + 22, 23, 23, 23, 24, 24, 24, 24, + 25, 25, 25, 26, 26, 26, 26, 27, + 27, 27, 28, 28, 28, 28, 29, 29, + 29, 30, 30, 30, 30, 31, 31, 31, + 31, 32, 32, 32, 33, 33, 33, 33, + 34, 34, 34, 34, 35, 35, 35, 35, + 36, 36, 36, 36, 37, 37, 37, 38, + 38, 38, 38, 39, 39, 39, 39, 40, + 40, 40, 40, 41, 41, 41, 41, 42, + 42, 42, 42, 42, 43, 43, 43, 43, + 44, 44, 44, 44, 45, 45, 45, 45, + 46, 46, 46, 46, 46, 47, 47, 47, + 47, 48, 48, 48, 48, 48, 49, 49, + 49, 49, 50, 50, 50, 50, 50, 51, + 51, 51, 51, 51, 52, 52, 52, 52, + 52, 53, 53, 53, 53, 53, 54, 54, + 54, 54, 54, 55, 55, 55, 55, 55, + 56, 56, 56, 56, 56, 57, 57, 57, + 57, 57, 57, 58, 58, 58, 58, 58, + 59, 59, 59, 59, 59, 59, 60, 60, + 60, 60, 60, 61, 61, 61, 61, 61, + 61, 62, 62, 62, 62, 62, 62, 63, + 63, 63, 63, 63, 63, 64, 64, 64 + }; + + + FT_LOCAL_DEF( AF_Angle ) + af_angle_atan( FT_Fixed dx, + FT_Fixed dy ) + { + AF_Angle angle; + + + /* check trivial cases */ + if ( dy == 0 ) + { + angle = 0; + if ( dx < 0 ) + angle = AF_ANGLE_PI; + return angle; + } + else if ( dx == 0 ) + { + angle = AF_ANGLE_PI2; + if ( dy < 0 ) + angle = -AF_ANGLE_PI2; + return angle; + } + + angle = 0; + if ( dx < 0 ) + { + dx = -dx; + dy = -dy; + angle = AF_ANGLE_PI; + } + + if ( dy < 0 ) + { + FT_Pos tmp; + + + tmp = dx; + dx = -dy; + dy = tmp; + angle -= AF_ANGLE_PI2; + } + + if ( dx == 0 && dy == 0 ) + return 0; + + if ( dx == dy ) + angle += AF_ANGLE_PI4; + else if ( dx > dy ) + angle += af_arctan[FT_DivFix( dy, dx ) >> ( 16 - AF_ATAN_BITS )]; + else + angle += AF_ANGLE_PI2 - + af_arctan[FT_DivFix( dx, dy ) >> ( 16 - AF_ATAN_BITS )]; + + if ( angle > AF_ANGLE_PI ) + angle -= AF_ANGLE_2PI; + + return angle; + } + + +#else /* 0 */ + /* * a python script used to generate the following table * @@ -234,6 +340,8 @@ for n in r: return delta; } +#endif /* 0 */ + FT_LOCAL_DEF( void ) af_sort_pos( FT_UInt count, diff --git a/src/libs/freetype2/autofit/afcjk.c b/src/libs/freetype2/autofit/afcjk.c new file mode 100644 index 0000000000..6a020e3f4a --- /dev/null +++ b/src/libs/freetype2/autofit/afcjk.c @@ -0,0 +1,1508 @@ +/***************************************************************************/ +/* */ +/* afcjk.c */ +/* */ +/* Auto-fitter hinting routines for CJK script (body). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /* + * The algorithm is based on akito's autohint patch, available here: + * + * http://www.kde.gr.jp/~akito/patch/freetype2/ + * + */ + +#include "aftypes.h" +#include "aflatin.h" + + +#ifdef AF_CONFIG_OPTION_CJK + +#include "afcjk.h" +#include "aferrors.h" + + +#ifdef AF_USE_WARPER +#include "afwarp.h" +#endif + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** C J K G L O B A L M E T R I C S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + static FT_Error + af_cjk_metrics_init( AF_LatinMetrics metrics, + FT_Face face ) + { + FT_CharMap oldmap = face->charmap; + + + metrics->units_per_em = face->units_per_EM; + + /* TODO are there blues? */ + + if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) ) + face->charmap = NULL; + + /* latin's version would suffice */ + af_latin_metrics_init_widths( metrics, face, 0x7530 ); + + FT_Set_Charmap( face, oldmap ); + + return AF_Err_Ok; + } + + + static void + af_cjk_metrics_scale_dim( AF_LatinMetrics metrics, + AF_Scaler scaler, + AF_Dimension dim ) + { + AF_LatinAxis axis; + + + axis = &metrics->axis[dim]; + + if ( dim == AF_DIMENSION_HORZ ) + { + axis->scale = scaler->x_scale; + axis->delta = scaler->x_delta; + } + else + { + axis->scale = scaler->y_scale; + axis->delta = scaler->y_delta; + } + } + + + static void + af_cjk_metrics_scale( AF_LatinMetrics metrics, + AF_Scaler scaler ) + { + metrics->root.scaler = *scaler; + + af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ ); + af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT ); + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** C J K G L Y P H A N A L Y S I S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + static FT_Error + af_cjk_hints_compute_segments( AF_GlyphHints hints, + AF_Dimension dim ) + { + AF_AxisHints axis = &hints->axis[dim]; + AF_Segment segments = axis->segments; + AF_Segment segment_limit = segments + axis->num_segments; + FT_Error error; + AF_Segment seg; + + + error = af_latin_hints_compute_segments( hints, dim ); + if ( error ) + return error; + + /* a segment is round if it doesn't have successive */ + /* on-curve points. */ + for ( seg = segments; seg < segment_limit; seg++ ) + { + AF_Point pt = seg->first; + AF_Point last = seg->last; + AF_Flags f0 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL); + AF_Flags f1; + + + seg->flags &= ~AF_EDGE_ROUND; + + for ( ; pt != last; f0 = f1 ) + { + pt = pt->next; + f1 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL); + + if ( !f0 && !f1 ) + break; + + if ( pt == last ) + seg->flags |= AF_EDGE_ROUND; + } + } + + return AF_Err_Ok; + } + + + static void + af_cjk_hints_link_segments( AF_GlyphHints hints, + AF_Dimension dim ) + { + AF_AxisHints axis = &hints->axis[dim]; + AF_Segment segments = axis->segments; + AF_Segment segment_limit = segments + axis->num_segments; + AF_Direction major_dir = axis->major_dir; + AF_Segment seg1, seg2; + FT_Pos len_threshold; + FT_Pos dist_threshold; + + + len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 ); + + dist_threshold = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale + : hints->y_scale; + dist_threshold = FT_DivFix( 64 * 3, dist_threshold ); + + /* now compare each segment to the others */ + for ( seg1 = segments; seg1 < segment_limit; seg1++ ) + { + /* the fake segments are for metrics hinting only */ + if ( seg1->first == seg1->last ) + continue; + + if ( seg1->dir != major_dir ) + continue; + + for ( seg2 = segments; seg2 < segment_limit; seg2++ ) + if ( seg2 != seg1 && seg1->dir + seg2->dir == 0 ) + { + FT_Pos dist = seg2->pos - seg1->pos; + + + if ( dist < 0 ) + continue; + + { + FT_Pos min = seg1->min_coord; + FT_Pos max = seg1->max_coord; + FT_Pos len; + + + if ( min < seg2->min_coord ) + min = seg2->min_coord; + + if ( max > seg2->max_coord ) + max = seg2->max_coord; + + len = max - min; + if ( len >= len_threshold ) + { + if ( dist * 8 < seg1->score * 9 && + ( dist * 8 < seg1->score * 7 || seg1->len < len ) ) + { + seg1->score = dist; + seg1->len = len; + seg1->link = seg2; + } + + if ( dist * 8 < seg2->score * 9 && + ( dist * 8 < seg2->score * 7 || seg2->len < len ) ) + { + seg2->score = dist; + seg2->len = len; + seg2->link = seg1; + } + } + } + } + } + + /* + * now compute the `serif' segments + * + * In Hanzi, some strokes are wider on one or both of the ends. + * We either identify the stems on the ends as serifs or remove + * the linkage, depending on the length of the stems. + * + */ + + { + AF_Segment link1, link2; + + + for ( seg1 = segments; seg1 < segment_limit; seg1++ ) + { + link1 = seg1->link; + if ( !link1 || link1->link != seg1 || link1->pos <= seg1->pos ) + continue; + + if ( seg1->score >= dist_threshold ) + continue; + + for ( seg2 = segments; seg2 < segment_limit; seg2++ ) + { + if ( seg2->pos > seg1->pos || seg1 == seg2 ) + continue; + + link2 = seg2->link; + if ( !link2 || link2->link != seg2 || link2->pos < link1->pos ) + continue; + + if ( seg1->pos == seg2->pos && link1->pos == link2->pos ) + continue; + + if ( seg2->score <= seg1->score || seg1->score * 4 <= seg2->score ) + continue; + + /* seg2 < seg1 < link1 < link2 */ + + if ( seg1->len >= seg2->len * 3 ) + { + AF_Segment seg; + + + for ( seg = segments; seg < segment_limit; seg++ ) + { + AF_Segment link = seg->link; + + + if ( link == seg2 ) + { + seg->link = 0; + seg->serif = link1; + } + else if ( link == link2 ) + { + seg->link = 0; + seg->serif = seg1; + } + } + } + else + { + seg1->link = link1->link = 0; + + break; + } + } + } + } + + for ( seg1 = segments; seg1 < segment_limit; seg1++ ) + { + seg2 = seg1->link; + + if ( seg2 ) + { + seg2->num_linked++; + if ( seg2->link != seg1 ) + { + seg1->link = 0; + + if ( seg2->score < dist_threshold || seg1->score < seg2->score * 4 ) + seg1->serif = seg2->link; + else + seg2->num_linked--; + } + } + } + } + + + static FT_Error + af_cjk_hints_compute_edges( AF_GlyphHints hints, + AF_Dimension dim ) + { + AF_AxisHints axis = &hints->axis[dim]; + FT_Error error = AF_Err_Ok; + FT_Memory memory = hints->memory; + AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim]; + + AF_Segment segments = axis->segments; + AF_Segment segment_limit = segments + axis->num_segments; + AF_Segment seg; + + AF_Direction up_dir; + FT_Fixed scale; + FT_Pos edge_distance_threshold; + + + axis->num_edges = 0; + + scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale + : hints->y_scale; + + up_dir = ( dim == AF_DIMENSION_HORZ ) ? AF_DIR_UP + : AF_DIR_RIGHT; + + /*********************************************************************/ + /* */ + /* We begin by generating a sorted table of edges for the current */ + /* direction. To do so, we simply scan each segment and try to find */ + /* an edge in our table that corresponds to its position. */ + /* */ + /* If no edge is found, we create and insert a new edge in the */ + /* sorted table. Otherwise, we simply add the segment to the edge's */ + /* list which is then processed in the second step to compute the */ + /* edge's properties. */ + /* */ + /* Note that the edges table is sorted along the segment/edge */ + /* position. */ + /* */ + /*********************************************************************/ + + edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold, + scale ); + if ( edge_distance_threshold > 64 / 4 ) + edge_distance_threshold = FT_DivFix( 64 / 4, scale ); + else + edge_distance_threshold = laxis->edge_distance_threshold; + + for ( seg = segments; seg < segment_limit; seg++ ) + { + AF_Edge found = 0; + FT_Pos best = 0xFFFFU; + FT_Int ee; + + + /* look for an edge corresponding to the segment */ + for ( ee = 0; ee < axis->num_edges; ee++ ) + { + AF_Edge edge = axis->edges + ee; + FT_Pos dist; + + + if ( edge->dir != seg->dir ) + continue; + + dist = seg->pos - edge->fpos; + if ( dist < 0 ) + dist = -dist; + + if ( dist < edge_distance_threshold && dist < best ) + { + AF_Segment link = seg->link; + + + /* check whether all linked segments of the candidate edge */ + /* can make a single edge. */ + if ( link ) + { + AF_Segment seg1 = edge->first; + AF_Segment link1; + FT_Pos dist2 = 0; + + + do + { + link1 = seg1->link; + if ( link1 ) + { + dist2 = AF_SEGMENT_DIST( link, link1 ); + if ( dist2 >= edge_distance_threshold ) + break; + } + + } while ( ( seg1 = seg1->edge_next ) != edge->first ); + + if ( dist2 >= edge_distance_threshold ) + continue; + } + + best = dist; + found = edge; + } + } + + if ( !found ) + { + AF_Edge edge; + + + /* insert a new edge in the list and */ + /* sort according to the position */ + error = af_axis_hints_new_edge( axis, seg->pos, memory, &edge ); + if ( error ) + goto Exit; + + /* add the segment to the new edge's list */ + FT_ZERO( edge ); + + edge->first = seg; + edge->last = seg; + edge->fpos = seg->pos; + edge->opos = edge->pos = FT_MulFix( seg->pos, scale ); + seg->edge_next = seg; + edge->dir = seg->dir; + } + else + { + /* if an edge was found, simply add the segment to the edge's */ + /* list */ + seg->edge_next = found->first; + found->last->edge_next = seg; + found->last = seg; + } + } + + /*********************************************************************/ + /* */ + /* Good, we now compute each edge's properties according to segments */ + /* found on its position. Basically, these are as follows. */ + /* */ + /* - edge's main direction */ + /* - stem edge, serif edge or both (which defaults to stem then) */ + /* - rounded edge, straight or both (which defaults to straight) */ + /* - link for edge */ + /* */ + /*********************************************************************/ + + /* first of all, set the `edge' field in each segment -- this is */ + /* required in order to compute edge links */ + /* */ + /* Note that removing this loop and setting the `edge' field of each */ + /* segment directly in the code above slows down execution speed for */ + /* some reasons on platforms like the Sun. */ + + { + AF_Edge edges = axis->edges; + AF_Edge edge_limit = edges + axis->num_edges; + AF_Edge edge; + + + for ( edge = edges; edge < edge_limit; edge++ ) + { + seg = edge->first; + if ( seg ) + do + { + seg->edge = edge; + seg = seg->edge_next; + + } while ( seg != edge->first ); + } + + /* now compute each edge properties */ + for ( edge = edges; edge < edge_limit; edge++ ) + { + FT_Int is_round = 0; /* does it contain round segments? */ + FT_Int is_straight = 0; /* does it contain straight segments? */ + + + seg = edge->first; + + do + { + FT_Bool is_serif; + + + /* check for roundness of segment */ + if ( seg->flags & AF_EDGE_ROUND ) + is_round++; + else + is_straight++; + + /* check for links -- if seg->serif is set, then seg->link must */ + /* be ignored */ + is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge ); + + if ( seg->link || is_serif ) + { + AF_Edge edge2; + AF_Segment seg2; + + + edge2 = edge->link; + seg2 = seg->link; + + if ( is_serif ) + { + seg2 = seg->serif; + edge2 = edge->serif; + } + + if ( edge2 ) + { + FT_Pos edge_delta; + FT_Pos seg_delta; + + + edge_delta = edge->fpos - edge2->fpos; + if ( edge_delta < 0 ) + edge_delta = -edge_delta; + + seg_delta = AF_SEGMENT_DIST( seg, seg2 ); + + if ( seg_delta < edge_delta ) + edge2 = seg2->edge; + } + else + edge2 = seg2->edge; + + if ( is_serif ) + { + edge->serif = edge2; + edge2->flags |= AF_EDGE_SERIF; + } + else + edge->link = edge2; + } + + seg = seg->edge_next; + + } while ( seg != edge->first ); + + /* set the round/straight flags */ + edge->flags = AF_EDGE_NORMAL; + + if ( is_round > 0 && is_round >= is_straight ) + edge->flags |= AF_EDGE_ROUND; + + /* get rid of serifs if link is set */ + /* XXX: This gets rid of many unpleasant artefacts! */ + /* Example: the `c' in cour.pfa at size 13 */ + + if ( edge->serif && edge->link ) + edge->serif = 0; + } + } + + Exit: + return error; + } + + + static FT_Error + af_cjk_hints_detect_features( AF_GlyphHints hints, + AF_Dimension dim ) + { + FT_Error error; + + + error = af_cjk_hints_compute_segments( hints, dim ); + if ( !error ) + { + af_cjk_hints_link_segments( hints, dim ); + + error = af_cjk_hints_compute_edges( hints, dim ); + } + return error; + } + + + static FT_Error + af_cjk_hints_init( AF_GlyphHints hints, + AF_LatinMetrics metrics ) + { + FT_Render_Mode mode; + FT_UInt32 scaler_flags, other_flags; + + + af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics ); + + /* + * correct x_scale and y_scale when needed, since they may have + * been modified af_cjk_scale_dim above + */ + hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale; + hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta; + hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale; + hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta; + + /* compute flags depending on render mode, etc. */ + mode = metrics->root.scaler.render_mode; + +#ifdef AF_USE_WARPER + if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V ) + metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL; +#endif + + scaler_flags = hints->scaler_flags; + other_flags = 0; + + /* + * We snap the width of vertical stems for the monochrome and + * horizontal LCD rendering targets only. + */ + if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) + other_flags |= AF_LATIN_HINTS_HORZ_SNAP; + + /* + * We snap the width of horizontal stems for the monochrome and + * vertical LCD rendering targets only. + */ + if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) + other_flags |= AF_LATIN_HINTS_VERT_SNAP; + + /* + * We adjust stems to full pixels only if we don't use the `light' mode. + */ + if ( mode != FT_RENDER_MODE_LIGHT ) + other_flags |= AF_LATIN_HINTS_STEM_ADJUST; + + if ( mode == FT_RENDER_MODE_MONO ) + other_flags |= AF_LATIN_HINTS_MONO; + + scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE; + + hints->scaler_flags = scaler_flags; + hints->other_flags = other_flags; + + return 0; + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** C J K G L Y P H G R I D - F I T T I N G *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /* snap a given width in scaled coordinates to one of the */ + /* current standard widths */ + + static FT_Pos + af_cjk_snap_width( AF_Width widths, + FT_Int count, + FT_Pos width ) + { + int n; + FT_Pos best = 64 + 32 + 2; + FT_Pos reference = width; + FT_Pos scaled; + + + for ( n = 0; n < count; n++ ) + { + FT_Pos w; + FT_Pos dist; + + + w = widths[n].cur; + dist = width - w; + if ( dist < 0 ) + dist = -dist; + if ( dist < best ) + { + best = dist; + reference = w; + } + } + + scaled = FT_PIX_ROUND( reference ); + + if ( width >= reference ) + { + if ( width < scaled + 48 ) + width = reference; + } + else + { + if ( width > scaled - 48 ) + width = reference; + } + + return width; + } + + + /* compute the snapped width of a given stem */ + + static FT_Pos + af_cjk_compute_stem_width( AF_GlyphHints hints, + AF_Dimension dim, + FT_Pos width, + AF_Edge_Flags base_flags, + AF_Edge_Flags stem_flags ) + { + AF_LatinMetrics metrics = (AF_LatinMetrics) hints->metrics; + AF_LatinAxis axis = & metrics->axis[dim]; + FT_Pos dist = width; + FT_Int sign = 0; + FT_Int vertical = ( dim == AF_DIMENSION_VERT ); + + FT_UNUSED( base_flags ); + FT_UNUSED( stem_flags ); + + + if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ) + return width; + + if ( dist < 0 ) + { + dist = -width; + sign = 1; + } + + if ( ( vertical && !AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) || + ( !vertical && !AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) ) + { + /* smooth hinting process: very lightly quantize the stem width */ + + if ( axis->width_count > 0 ) + { + if ( FT_ABS( dist - axis->widths[0].cur ) < 40 ) + { + dist = axis->widths[0].cur; + if ( dist < 48 ) + dist = 48; + + goto Done_Width; + } + } + + if ( dist < 54 ) + dist += ( 54 - dist ) / 2 ; + else if ( dist < 3 * 64 ) + { + FT_Pos delta; + + + delta = dist & 63; + dist &= -64; + + if ( delta < 10 ) + dist += delta; + else if ( delta < 22 ) + dist += 10; + else if ( delta < 42 ) + dist += delta; + else if ( delta < 54 ) + dist += 54; + else + dist += delta; + } + } + else + { + /* strong hinting process: snap the stem width to integer pixels */ + + dist = af_cjk_snap_width( axis->widths, axis->width_count, dist ); + + if ( vertical ) + { + /* in the case of vertical hinting, always round */ + /* the stem heights to integer pixels */ + + if ( dist >= 64 ) + dist = ( dist + 16 ) & ~63; + else + dist = 64; + } + else + { + if ( AF_LATIN_HINTS_DO_MONO( hints ) ) + { + /* monochrome horizontal hinting: snap widths to integer pixels */ + /* with a different threshold */ + + if ( dist < 64 ) + dist = 64; + else + dist = ( dist + 32 ) & ~63; + } + else + { + /* for horizontal anti-aliased hinting, we adopt a more subtle */ + /* approach: we strengthen small stems, round stems whose size */ + /* is between 1 and 2 pixels to an integer, otherwise nothing */ + + if ( dist < 48 ) + dist = ( dist + 64 ) >> 1; + + else if ( dist < 128 ) + dist = ( dist + 22 ) & ~63; + else + /* round otherwise to prevent color fringes in LCD mode */ + dist = ( dist + 32 ) & ~63; + } + } + } + + Done_Width: + if ( sign ) + dist = -dist; + + return dist; + } + + + /* align one stem edge relative to the previous stem edge */ + + static void + af_cjk_align_linked_edge( AF_GlyphHints hints, + AF_Dimension dim, + AF_Edge base_edge, + AF_Edge stem_edge ) + { + FT_Pos dist = stem_edge->opos - base_edge->opos; + + FT_Pos fitted_width = af_cjk_compute_stem_width( + hints, dim, dist, + (AF_Edge_Flags)base_edge->flags, + (AF_Edge_Flags)stem_edge->flags ); + + + stem_edge->pos = base_edge->pos + fitted_width; + } + + + static void + af_cjk_align_serif_edge( AF_GlyphHints hints, + AF_Edge base, + AF_Edge serif ) + { + FT_UNUSED( hints ); + + serif->pos = base->pos + ( serif->opos - base->opos ); + } + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** E D G E H I N T I N G ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + +#define AF_LIGHT_MODE_MAX_HORZ_GAP 9 +#define AF_LIGHT_MODE_MAX_VERT_GAP 15 +#define AF_LIGHT_MODE_MAX_DELTA_ABS 14 + + + static FT_Pos + af_hint_normal_stem( AF_GlyphHints hints, + AF_Edge edge, + AF_Edge edge2, + FT_Pos anchor, + AF_Dimension dim ) + { + FT_Pos org_len, cur_len, org_center; + FT_Pos cur_pos1, cur_pos2; + FT_Pos d_off1, u_off1, d_off2, u_off2, delta; + FT_Pos offset; + FT_Pos threshold = 64; + + + if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ) + { + if ( ( edge->flags & AF_EDGE_ROUND ) && + ( edge2->flags & AF_EDGE_ROUND ) ) + { + if ( dim == AF_DIMENSION_VERT ) + threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP; + else + threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP; + } + else + { + if ( dim == AF_DIMENSION_VERT ) + threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP / 3; + else + threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP / 3; + } + } + + org_len = edge2->opos - edge->opos; + cur_len = af_cjk_compute_stem_width( hints, dim, org_len, + (AF_Edge_Flags)edge->flags, + (AF_Edge_Flags)edge2->flags ); + + org_center = ( edge->opos + edge2->opos ) / 2 + anchor; + cur_pos1 = org_center - cur_len / 2; + cur_pos2 = cur_pos1 + cur_len; + d_off1 = cur_pos1 - FT_PIX_FLOOR( cur_pos1 ); + d_off2 = cur_pos2 - FT_PIX_FLOOR( cur_pos2 ); + u_off1 = 64 - d_off1; + u_off2 = 64 - d_off2; + delta = 0; + + + if ( d_off1 == 0 || d_off2 == 0 ) + goto Exit; + + if ( cur_len <= threshold ) + { + if ( d_off2 < cur_len ) + { + if ( u_off1 <= d_off2 ) + delta = u_off1; + else + delta = -d_off2; + } + + goto Exit; + } + + if ( threshold < 64 ) + { + if ( d_off1 >= threshold || u_off1 >= threshold || + d_off2 >= threshold || u_off2 >= threshold ) + goto Exit; + } + + offset = cur_len % 64; + + if ( offset < 32 ) + { + if ( u_off1 <= offset || d_off2 <= offset ) + goto Exit; + } + else + offset = 64 - threshold; + + d_off1 = threshold - u_off1; + u_off1 = u_off1 - offset; + u_off2 = threshold - d_off2; + d_off2 = d_off2 - offset; + + if ( d_off1 <= u_off1 ) + u_off1 = -d_off1; + + if ( d_off2 <= u_off2 ) + u_off2 = -d_off2; + + if ( FT_ABS( u_off1 ) <= FT_ABS( u_off2 ) ) + delta = u_off1; + else + delta = u_off2; + + Exit: + +#if 1 + if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ) + { + if ( delta > AF_LIGHT_MODE_MAX_DELTA_ABS ) + delta = AF_LIGHT_MODE_MAX_DELTA_ABS; + else if ( delta < -AF_LIGHT_MODE_MAX_DELTA_ABS ) + delta = -AF_LIGHT_MODE_MAX_DELTA_ABS; + } +#endif + + cur_pos1 += delta; + + if ( edge->opos < edge2->opos ) + { + edge->pos = cur_pos1; + edge2->pos = cur_pos1 + cur_len; + } + else + { + edge->pos = cur_pos1 + cur_len; + edge2->pos = cur_pos1; + } + + return delta; + } + + + static void + af_cjk_hint_edges( AF_GlyphHints hints, + AF_Dimension dim ) + { + AF_AxisHints axis = &hints->axis[dim]; + AF_Edge edges = axis->edges; + AF_Edge edge_limit = edges + axis->num_edges; + FT_Int n_edges; + AF_Edge edge; + AF_Edge anchor = 0; + FT_Pos delta = 0; + FT_Int skipped = 0; + + + /* now we align all stem edges. */ + for ( edge = edges; edge < edge_limit; edge++ ) + { + AF_Edge edge2; + + + if ( edge->flags & AF_EDGE_DONE ) + continue; + + /* skip all non-stem edges */ + edge2 = edge->link; + if ( !edge2 ) + { + skipped++; + continue; + } + + /* now align the stem */ + + if ( edge2 < edge ) + { + af_cjk_align_linked_edge( hints, dim, edge2, edge ); + edge->flags |= AF_EDGE_DONE; + continue; + } + + if ( dim != AF_DIMENSION_VERT && !anchor ) + { + +#if 0 + if ( fixedpitch ) + { + AF_Edge left = edge; + AF_Edge right = edge_limit - 1; + AF_EdgeRec left1, left2, right1, right2; + FT_Pos target, center1, center2; + FT_Pos delta1, delta2, d1, d2; + + + while ( right > left && !right->link ) + right--; + + left1 = *left; + left2 = *left->link; + right1 = *right->link; + right2 = *right; + + delta = ( ( ( hinter->pp2.x + 32 ) & -64 ) - hinter->pp2.x ) / 2; + target = left->opos + ( right->opos - left->opos ) / 2 + delta - 16; + + delta1 = delta; + delta1 += af_hint_normal_stem( hints, left, left->link, + delta1, 0 ); + + if ( left->link != right ) + af_hint_normal_stem( hints, right->link, right, delta1, 0 ); + + center1 = left->pos + ( right->pos - left->pos ) / 2; + + if ( center1 >= target ) + delta2 = delta - 32; + else + delta2 = delta + 32; + + delta2 += af_hint_normal_stem( hints, &left1, &left2, delta2, 0 ); + + if ( delta1 != delta2 ) + { + if ( left->link != right ) + af_hint_normal_stem( hints, &right1, &right2, delta2, 0 ); + + center2 = left1.pos + ( right2.pos - left1.pos ) / 2; + + d1 = center1 - target; + d2 = center2 - target; + + if ( FT_ABS( d2 ) < FT_ABS( d1 ) ) + { + left->pos = left1.pos; + left->link->pos = left2.pos; + + if ( left->link != right ) + { + right->link->pos = right1.pos; + right->pos = right2.pos; + } + + delta1 = delta2; + } + } + + delta = delta1; + right->link->flags |= AF_EDGE_DONE; + right->flags |= AF_EDGE_DONE; + } + else + +#endif /* 0 */ + + delta = af_hint_normal_stem( hints, edge, edge2, 0, + AF_DIMENSION_HORZ ); + } + else + af_hint_normal_stem( hints, edge, edge2, delta, dim ); + +#if 0 + printf( "stem (%d,%d) adjusted (%.1f,%.1f)\n", + edge - edges, edge2 - edges, + ( edge->pos - edge->opos ) / 64.0, + ( edge2->pos - edge2->opos ) / 64.0 ); +#endif + + anchor = edge; + edge->flags |= AF_EDGE_DONE; + edge2->flags |= AF_EDGE_DONE; + } + + /* make sure that lowercase m's maintain their symmetry */ + + /* In general, lowercase m's have six vertical edges if they are sans */ + /* serif, or twelve if they are with serifs. This implementation is */ + /* based on that assumption, and seems to work very well with most */ + /* faces. However, if for a certain face this assumption is not */ + /* true, the m is just rendered like before. In addition, any stem */ + /* correction will only be applied to symmetrical glyphs (even if the */ + /* glyph is not an m), so the potential for unwanted distortion is */ + /* relatively low. */ + + /* We don't handle horizontal edges since we can't easily assure that */ + /* the third (lowest) stem aligns with the base line; it might end up */ + /* one pixel higher or lower. */ + + n_edges = edge_limit - edges; + if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) ) + { + AF_Edge edge1, edge2, edge3; + FT_Pos dist1, dist2, span; + + + if ( n_edges == 6 ) + { + edge1 = edges; + edge2 = edges + 2; + edge3 = edges + 4; + } + else + { + edge1 = edges + 1; + edge2 = edges + 5; + edge3 = edges + 9; + } + + dist1 = edge2->opos - edge1->opos; + dist2 = edge3->opos - edge2->opos; + + span = dist1 - dist2; + if ( span < 0 ) + span = -span; + + if ( edge1->link == edge1 + 1 && + edge2->link == edge2 + 1 && + edge3->link == edge3 + 1 && span < 8 ) + { + delta = edge3->pos - ( 2 * edge2->pos - edge1->pos ); + edge3->pos -= delta; + if ( edge3->link ) + edge3->link->pos -= delta; + + /* move the serifs along with the stem */ + if ( n_edges == 12 ) + { + ( edges + 8 )->pos -= delta; + ( edges + 11 )->pos -= delta; + } + + edge3->flags |= AF_EDGE_DONE; + if ( edge3->link ) + edge3->link->flags |= AF_EDGE_DONE; + } + } + + if ( !skipped ) + return; + + /* + * now hint the remaining edges (serifs and single) in order + * to complete our processing + */ + for ( edge = edges; edge < edge_limit; edge++ ) + { + if ( edge->flags & AF_EDGE_DONE ) + continue; + + if ( edge->serif ) + { + af_cjk_align_serif_edge( hints, edge->serif, edge ); + edge->flags |= AF_EDGE_DONE; + skipped--; + } + } + + if ( !skipped ) + return; + + for ( edge = edges; edge < edge_limit; edge++ ) + { + AF_Edge before, after; + + + if ( edge->flags & AF_EDGE_DONE ) + continue; + + before = after = edge; + + while ( --before >= edges ) + if ( before->flags & AF_EDGE_DONE ) + break; + + while ( ++after < edge_limit ) + if ( after->flags & AF_EDGE_DONE ) + break; + + if ( before >= edges || after < edge_limit ) + { + if ( before < edges ) + af_cjk_align_serif_edge( hints, after, edge ); + else if ( after >= edge_limit ) + af_cjk_align_serif_edge( hints, before, edge ); + else + edge->pos = before->pos + + FT_MulDiv( edge->fpos - before->fpos, + after->pos - before->pos, + after->fpos - before->fpos ); + } + } + } + + + static void + af_cjk_align_edge_points( AF_GlyphHints hints, + AF_Dimension dim ) + { + AF_AxisHints axis = & hints->axis[dim]; + AF_Edge edges = axis->edges; + AF_Edge edge_limit = edges + axis->num_edges; + AF_Edge edge; + FT_Bool snapping; + + + snapping = FT_BOOL( ( dim == AF_DIMENSION_HORZ && + AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) || + ( dim == AF_DIMENSION_VERT && + AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) ); + + for ( edge = edges; edge < edge_limit; edge++ ) + { + /* move the points of each segment */ + /* in each edge to the edge's position */ + AF_Segment seg = edge->first; + + + if ( snapping ) + { + do + { + AF_Point point = seg->first; + + + for (;;) + { + if ( dim == AF_DIMENSION_HORZ ) + { + point->x = edge->pos; + point->flags |= AF_FLAG_TOUCH_X; + } + else + { + point->y = edge->pos; + point->flags |= AF_FLAG_TOUCH_Y; + } + + if ( point == seg->last ) + break; + + point = point->next; + } + + seg = seg->edge_next; + + } while ( seg != edge->first ); + } + else + { + FT_Pos delta = edge->pos - edge->opos; + + + do + { + AF_Point point = seg->first; + + + for (;;) + { + if ( dim == AF_DIMENSION_HORZ ) + { + point->x += delta; + point->flags |= AF_FLAG_TOUCH_X; + } + else + { + point->y += delta; + point->flags |= AF_FLAG_TOUCH_Y; + } + + if ( point == seg->last ) + break; + + point = point->next; + } + + seg = seg->edge_next; + + } while ( seg != edge->first ); + } + } + } + + + static FT_Error + af_cjk_hints_apply( AF_GlyphHints hints, + FT_Outline* outline, + AF_LatinMetrics metrics ) + { + FT_Error error; + int dim; + + FT_UNUSED( metrics ); + + + error = af_glyph_hints_reload( hints, outline ); + if ( error ) + goto Exit; + + /* analyze glyph outline */ + if ( AF_HINTS_DO_HORIZONTAL( hints ) ) + { + error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ ); + if ( error ) + goto Exit; + } + + if ( AF_HINTS_DO_VERTICAL( hints ) ) + { + error = af_cjk_hints_detect_features( hints, AF_DIMENSION_VERT ); + if ( error ) + goto Exit; + } + + /* grid-fit the outline */ + for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) + { + if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) || + ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) ) + { + +#ifdef AF_USE_WARPER + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL ) + { + AF_WarperRec warper; + FT_Fixed scale; + FT_Pos delta; + + + af_warper_compute( &warper, hints, dim, &scale, &delta ); + af_glyph_hints_scale_dim( hints, dim, scale, delta ); + continue; + } +#endif /* AF_USE_WARPER */ + + af_cjk_hint_edges( hints, (AF_Dimension)dim ); + af_cjk_align_edge_points( hints, (AF_Dimension)dim ); + af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim ); + af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim ); + } + } + +#if 0 + af_glyph_hints_dump_points( hints ); + af_glyph_hints_dump_segments( hints ); + af_glyph_hints_dump_edges( hints ); +#endif + + af_glyph_hints_save( hints, outline ); + + Exit: + return error; + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** C J K S C R I P T C L A S S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + + static const AF_Script_UniRangeRec af_cjk_uniranges[] = + { + { 0x0100, 0xFFFF }, + { 0x2E80, 0x2EFF }, /* CJK Radicals Supplement */ + { 0x2F00, 0x2FDF }, /* Kangxi Radicals */ + { 0x3000, 0x303F }, /* CJK Symbols and Punctuation */ + { 0x3040, 0x309F }, /* Hiragana */ + { 0x30A0, 0x30FF }, /* Katakana */ + { 0x3100, 0x312F }, /* Bopomofo */ + { 0x3130, 0x318F }, /* Hangul Compatibility Jamo */ + { 0x31A0, 0x31BF }, /* Bopomofo Extended */ + { 0x31C0, 0x31EF }, /* CJK Strokes */ + { 0x31F0, 0x31FF }, /* Katakana Phonetic Extensions */ + { 0x3200, 0x32FF }, /* Enclosed CJK Letters and Months */ + { 0x3300, 0x33FF }, /* CJK Compatibility */ + { 0x3400, 0x4DBF }, /* CJK Unified Ideographs Extension A */ + { 0x4DC0, 0x4DFF }, /* Yijing Hexagram Symbols */ + { 0x4E00, 0x9FFF }, /* CJK Unified Ideographs */ + { 0xF900, 0xFAFF }, /* CJK Compatibility Ideographs */ + { 0xFE30, 0xFE4F }, /* CJK Compatibility Forms */ + { 0xFF00, 0xFFEF }, /* Halfwidth and Fullwidth Forms */ + { 0x20000, 0x2A6DF }, /* CJK Unified Ideographs Extension B */ + { 0x2F800, 0x2FA1F }, /* CJK Compatibility Ideographs Supplement */ + { 0, 0 } + }; + + + FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec + af_cjk_script_class = + { + AF_SCRIPT_CJK, + af_cjk_uniranges, + + sizeof( AF_LatinMetricsRec ), + + (AF_Script_InitMetricsFunc) af_cjk_metrics_init, + (AF_Script_ScaleMetricsFunc)af_cjk_metrics_scale, + (AF_Script_DoneMetricsFunc) NULL, + + (AF_Script_InitHintsFunc) af_cjk_hints_init, + (AF_Script_ApplyHintsFunc) af_cjk_hints_apply + }; + +#else /* !AF_CONFIG_OPTION_CJK */ + + static const AF_Script_UniRangeRec af_cjk_uniranges[] = + { + { 0, 0 } + }; + + + FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec + af_cjk_script_class = + { + AF_SCRIPT_CJK, + af_cjk_uniranges, + + sizeof( AF_LatinMetricsRec ), + + (AF_Script_InitMetricsFunc) NULL, + (AF_Script_ScaleMetricsFunc)NULL, + (AF_Script_DoneMetricsFunc) NULL, + + (AF_Script_InitHintsFunc) NULL, + (AF_Script_ApplyHintsFunc) NULL + }; + +#endif /* !AF_CONFIG_OPTION_CJK */ + + +/* END */ diff --git a/src/libs/freetype2/autofit/afcjk.h b/src/libs/freetype2/autofit/afcjk.h new file mode 100644 index 0000000000..0de4a5ab72 --- /dev/null +++ b/src/libs/freetype2/autofit/afcjk.h @@ -0,0 +1,41 @@ +/***************************************************************************/ +/* */ +/* afcjk.h */ +/* */ +/* Auto-fitter hinting routines for CJK script (specification). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __AFCJK_H__ +#define __AFCJK_H__ + +#include "afhints.h" + + +FT_BEGIN_HEADER + + + /* the CJK-specific script class */ + + FT_CALLBACK_TABLE const AF_ScriptClassRec + af_cjk_script_class; + + +/* */ + +FT_END_HEADER + +#endif /* __AFCJK_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/autofit/afglobal.c b/src/libs/freetype2/autofit/afglobal.c index e28673bb73..62669eac43 100644 --- a/src/libs/freetype2/autofit/afglobal.c +++ b/src/libs/freetype2/autofit/afglobal.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter routines to compute global hinting values (body). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,6 +19,7 @@ #include "afglobal.h" #include "afdummy.h" #include "aflatin.h" +#include "afcjk.h" #include "aferrors.h" @@ -27,6 +28,7 @@ { &af_dummy_script_class, &af_latin_script_class, + &af_cjk_script_class, NULL /* do not remove */ }; diff --git a/src/libs/freetype2/autofit/afhints.c b/src/libs/freetype2/autofit/afhints.c index a3095ee216..b011c15b07 100644 --- a/src/libs/freetype2/autofit/afhints.c +++ b/src/libs/freetype2/autofit/afhints.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines (body). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -265,11 +265,61 @@ #endif /* AF_DEBUG */ + /* compute the direction value of a given vector */ FT_LOCAL_DEF( AF_Direction ) af_direction_compute( FT_Pos dx, FT_Pos dy ) { +#if 1 + AF_Direction dir = AF_DIR_NONE; + + + /* atan(1/12) == 4.7 degrees */ + + if ( dx < 0 ) + { + if ( dy < 0 ) + { + if ( -dx * 12 < -dy ) + dir = AF_DIR_DOWN; + + else if ( -dy * 12 < -dx ) + dir = AF_DIR_LEFT; + } + else /* dy >= 0 */ + { + if ( -dx * 12 < dy ) + dir = AF_DIR_UP; + + else if ( dy * 12 < -dx ) + dir = AF_DIR_LEFT; + } + } + else /* dx >= 0 */ + { + if ( dy < 0 ) + { + if ( dx * 12 < -dy ) + dir = AF_DIR_DOWN; + + else if ( -dy * 12 < dx ) + dir = AF_DIR_RIGHT; + } + else /* dy >= 0 */ + { + if ( dx * 12 < dy ) + dir = AF_DIR_UP; + + else if ( dy * 12 < dx ) + dir = AF_DIR_RIGHT; + } + } + + return dir; + +#else /* 0 */ + AF_Direction dir; FT_Pos ax = FT_ABS( dx ); FT_Pos ay = FT_ABS( dy ); @@ -291,6 +341,9 @@ } return dir; + +#endif /* 0 */ + } @@ -349,8 +402,9 @@ } while ( angle_in == angle_seg ); - first = start; - diff_in = af_angle_diff( angle_in, angle_seg ); + first = start; + + AF_ANGLE_DIFF( diff_in, angle_in, angle_seg ); /* now, process all segments in the contour */ do @@ -373,7 +427,7 @@ } while ( angle_out == angle_seg ); - diff_out = af_angle_diff( angle_seg, angle_out ); + AF_ANGLE_DIFF( diff_out, angle_seg, angle_out ); if ( ( diff_in ^ diff_out ) < 0 ) { @@ -455,7 +509,8 @@ af_glyph_hints_rescale( AF_GlyphHints hints, AF_ScriptMetrics metrics ) { - hints->metrics = metrics; + hints->metrics = metrics; + hints->scaler_flags = metrics->scaler.flags; } @@ -466,7 +521,6 @@ FT_Error error = AF_Err_Ok; AF_Point points; FT_UInt old_max, new_max; - AF_Scaler scaler = &hints->metrics->scaler; FT_Fixed x_scale = hints->x_scale; FT_Fixed y_scale = hints->y_scale; FT_Pos x_delta = hints->x_delta; @@ -474,7 +528,6 @@ FT_Memory memory = hints->memory; - hints->scaler_flags = scaler->flags; hints->num_points = 0; hints->num_contours = 0; @@ -657,7 +710,8 @@ angle_in = af_angle_atan( in_x, in_y ); angle_out = af_angle_atan( out_x, out_y ); - delta = af_angle_diff( angle_in, angle_out ); + + AF_ANGLE_DIFF( delta, angle_in, angle_out ); if ( delta < 2 && delta > -2 ) goto Is_Weak_Point; @@ -1087,4 +1141,31 @@ } +#ifdef AF_USE_WARPER + + FT_LOCAL_DEF( void ) + af_glyph_hints_scale_dim( AF_GlyphHints hints, + AF_Dimension dim, + FT_Fixed scale, + FT_Pos delta ) + { + AF_Point points = hints->points; + AF_Point points_limit = points + hints->num_points; + AF_Point point; + + + if ( dim == AF_DIMENSION_HORZ ) + { + for ( point = points; point < points_limit; point++ ) + point->x = FT_MulFix( point->fx, scale ) + delta; + } + else + { + for ( point = points; point < points_limit; point++ ) + point->y = FT_MulFix( point->fy, scale ) + delta; + } + } + +#endif /* AF_USE_WARPER */ + /* END */ diff --git a/src/libs/freetype2/autofit/afhints.h b/src/libs/freetype2/autofit/afhints.h index 6f1a8a59a9..cb27b8f974 100644 --- a/src/libs/freetype2/autofit/afhints.h +++ b/src/libs/freetype2/autofit/afhints.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines (specification). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -133,6 +133,7 @@ FT_BEGIN_HEADER AF_Segment serif; /* primary segment for serifs */ FT_Pos num_linked; /* number of linked segments */ FT_Pos score; /* used during stem matching */ + FT_Pos len; /* used during stem matching */ AF_Point first; /* first point in edge segment */ AF_Point last; /* last point in edge segment */ @@ -272,11 +273,25 @@ FT_BEGIN_HEADER af_glyph_hints_align_weak_points( AF_GlyphHints hints, AF_Dimension dim ); +#ifdef AF_USE_WARPER + FT_LOCAL( void ) + af_glyph_hints_scale_dim( AF_GlyphHints hints, + AF_Dimension dim, + FT_Fixed scale, + FT_Pos delta ); +#endif + FT_LOCAL( void ) af_glyph_hints_done( AF_GlyphHints hints ); /* */ +#define AF_SEGMENT_LEN( seg ) ( (seg)->max_coord - (seg)->min_coord ) + +#define AF_SEGMENT_DIST( seg1, seg2 ) ( ( (seg1)->pos > (seg2)->pos ) \ + ? (seg1)->pos - (seg2)->pos \ + : (seg2)->pos - (seg1)->pos ) + FT_END_HEADER diff --git a/src/libs/freetype2/autofit/aflatin.c b/src/libs/freetype2/autofit/aflatin.c index 35dfe2932d..2351f23f12 100644 --- a/src/libs/freetype2/autofit/aflatin.c +++ b/src/libs/freetype2/autofit/aflatin.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for latin script (body). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,6 +20,11 @@ #include "aferrors.h" +#ifdef AF_USE_WARPER +#include "afwarp.h" +#endif + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -28,9 +33,10 @@ /*************************************************************************/ /*************************************************************************/ - static void + FT_LOCAL_DEF( void ) af_latin_metrics_init_widths( AF_LatinMetrics metrics, - FT_Face face ) + FT_Face face, + FT_ULong charcode ) { /* scan the array of segments in each direction */ AF_GlyphHintsRec hints[1]; @@ -41,16 +47,15 @@ metrics->axis[AF_DIMENSION_HORZ].width_count = 0; metrics->axis[AF_DIMENSION_VERT].width_count = 0; - /* For now, compute the standard width and height from the `o'. */ { FT_Error error; FT_UInt glyph_index; int dim; - AF_ScriptMetricsRec dummy[1]; - AF_Scaler scaler = &dummy->scaler; + AF_LatinMetricsRec dummy[1]; + AF_Scaler scaler = &dummy->root.scaler; - glyph_index = FT_Get_Char_Index( face, 'o' ); + glyph_index = FT_Get_Char_Index( face, charcode ); if ( glyph_index == 0 ) goto Exit; @@ -60,13 +65,14 @@ FT_ZERO( dummy ); + dummy->units_per_em = metrics->units_per_em; scaler->x_scale = scaler->y_scale = 0x10000L; scaler->x_delta = scaler->y_delta = 0; scaler->face = face; scaler->render_mode = FT_RENDER_MODE_NORMAL; scaler->flags = 0; - af_glyph_hints_rescale( hints, dummy ); + af_glyph_hints_rescale( hints, (AF_ScriptMetrics)dummy ); error = af_glyph_hints_reload( hints, &face->glyph->outline ); if ( error ) @@ -77,9 +83,7 @@ AF_LatinAxis axis = &metrics->axis[dim]; AF_AxisHints axhints = &hints->axis[dim]; AF_Segment seg, limit, link; - - FT_UInt num_widths = 0; - FT_Pos edge_distance_threshold = 32000; + FT_UInt num_widths = 0; error = af_latin_hints_compute_segments( hints, @@ -114,22 +118,24 @@ af_sort_widths( num_widths, axis->widths ); axis->width_count = num_widths; + } - /* we will now try to find the smallest width */ - if ( num_widths > 0 && axis->widths[0].org < edge_distance_threshold ) - edge_distance_threshold = axis->widths[0].org; + Exit: + for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) + { + AF_LatinAxis axis = &metrics->axis[dim]; + FT_Pos stdw; - /* Now, compute the edge distance threshold as a fraction of the */ - /* smallest width in the font. Set it in `hinter->glyph' too! */ - if ( edge_distance_threshold == 32000 ) - edge_distance_threshold = 50; - /* let's try 20% */ - axis->edge_distance_threshold = edge_distance_threshold / 5; + stdw = ( axis->width_count > 0 ) + ? axis->widths[0].org + : AF_LATIN_CONSTANT( metrics, 50 ); + + /* let's try 20% of the smallest width */ + axis->edge_distance_threshold = stdw / 5; } } - Exit: af_glyph_hints_done( hints ); } @@ -404,7 +410,8 @@ if ( !error ) { - af_latin_metrics_init_widths( metrics, face ); + /* For now, compute the standard width and height from the `o'. */ + af_latin_metrics_init_widths( metrics, face, 'o' ); af_latin_metrics_init_blues( metrics, face ); } @@ -559,6 +566,9 @@ af_latin_metrics_scale( AF_LatinMetrics metrics, AF_Scaler scaler ) { + metrics->root.scaler.render_mode = scaler->render_mode; + metrics->root.scaler.face = scaler->face; + af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ ); af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT ); } @@ -739,6 +749,7 @@ segment->last = point; segment->contour = contour; segment->score = 32000; + segment->len = 0; segment->link = NULL; on_edge = 1; @@ -805,6 +816,7 @@ segment->last = min_point; segment->pos = min_pos; segment->score = 32000; + segment->len = 0; segment->link = NULL; segment = NULL; @@ -824,6 +836,7 @@ segment->last = max_point; segment->pos = max_pos; segment->score = 32000; + segment->len = 0; segment->link = NULL; segment = NULL; @@ -844,9 +857,16 @@ AF_Segment segments = axis->segments; AF_Segment segment_limit = segments + axis->num_segments; AF_Direction major_dir = axis->major_dir; + FT_Pos len_threshold, len_score; AF_Segment seg1, seg2; - + + len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 ); + if ( len_threshold == 0 ) + len_threshold = 1; + + len_score = AF_LATIN_CONSTANT( hints->metrics, 3000 ); + /* now compare each segment to the others */ for ( seg1 = segments; seg1 < segment_limit; seg1++ ) { @@ -879,9 +899,9 @@ max = seg2->max_coord; len = max - min; - if ( len >= 8 ) + if ( len >= len_threshold ) { - score = dist + 3000 / len; + score = dist + len_score / len; if ( score < seg1->score ) { @@ -1292,6 +1312,8 @@ AF_LatinMetrics metrics ) { FT_Render_Mode mode; + FT_UInt32 scaler_flags, other_flags; + FT_Face face = metrics->root.scaler.face; af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics ); @@ -1305,32 +1327,52 @@ hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale; hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta; - /* compute flags depending on render mode, etc... */ - + /* compute flags depending on render mode, etc. */ mode = metrics->root.scaler.render_mode; +#ifdef AF_USE_WARPER + if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V ) + { + metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL; + } +#endif + + scaler_flags = hints->scaler_flags; + other_flags = 0; + /* * We snap the width of vertical stems for the monochrome and * horizontal LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) - hints->other_flags |= AF_LATIN_HINTS_HORZ_SNAP; + other_flags |= AF_LATIN_HINTS_HORZ_SNAP; /* * We snap the width of horizontal stems for the monochrome and * vertical LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) - hints->other_flags |= AF_LATIN_HINTS_VERT_SNAP; + other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* * We adjust stems to full pixels only if we don't use the `light' mode. */ if ( mode != FT_RENDER_MODE_LIGHT ) - hints->other_flags |= AF_LATIN_HINTS_STEM_ADJUST; + other_flags |= AF_LATIN_HINTS_STEM_ADJUST; if ( mode == FT_RENDER_MODE_MONO ) - hints->other_flags |= AF_LATIN_HINTS_MONO; + other_flags |= AF_LATIN_HINTS_MONO; + + /* + * In `light' hinting mode we disable horizontal hinting completely. + * We also do it if the face is italic. + */ + if ( mode == FT_RENDER_MODE_LIGHT || + (face->style_flags & FT_STYLE_FLAG_ITALIC) != 0 ) + scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL; + + hints->scaler_flags = scaler_flags; + hints->other_flags = other_flags; return 0; } @@ -1405,7 +1447,7 @@ AF_LatinAxis axis = & metrics->axis[dim]; FT_Pos dist = width; FT_Int sign = 0; - FT_Int vertical = AF_HINTS_DO_VERTICAL( hints ); + FT_Int vertical = ( dim == AF_DIMENSION_VERT ); if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ) @@ -1926,6 +1968,20 @@ if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) || ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) ) { +#ifdef AF_USE_WARPER + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL ) + { + AF_WarperRec warper; + FT_Fixed scale; + FT_Pos delta; + + + af_warper_compute( &warper, hints, dim, &scale, &delta ); + af_glyph_hints_scale_dim( hints, dim, scale, delta ); + continue; + } +#endif af_latin_hint_edges( hints, (AF_Dimension)dim ); af_glyph_hints_align_edge_points( hints, (AF_Dimension)dim ); af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim ); diff --git a/src/libs/freetype2/autofit/aflatin.h b/src/libs/freetype2/autofit/aflatin.h index bc63c02118..e73c44ad14 100644 --- a/src/libs/freetype2/autofit/aflatin.h +++ b/src/libs/freetype2/autofit/aflatin.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for latin script (specification). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,6 +31,11 @@ FT_BEGIN_HEADER af_latin_script_class; +/* constants are given with units_per_em == 2048 in mind */ +#define AF_LATIN_CONSTANT( metrics, c ) \ + ( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 ) + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -126,6 +131,10 @@ FT_BEGIN_HEADER af_latin_metrics_scale( AF_LatinMetrics metrics, AF_Scaler scaler ); + FT_LOCAL( void ) + af_latin_metrics_init_widths( AF_LatinMetrics metrics, + FT_Face face, + FT_ULong charcode ); /*************************************************************************/ diff --git a/src/libs/freetype2/autofit/afloader.c b/src/libs/freetype2/autofit/afloader.c index c3f3b2c37b..01b4f57305 100644 --- a/src/libs/freetype2/autofit/afloader.c +++ b/src/libs/freetype2/autofit/afloader.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (body). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,24 +27,11 @@ af_loader_init( AF_Loader loader, FT_Memory memory ) { - FT_Error error; - - FT_ZERO( loader ); af_glyph_hints_init( &loader->hints, memory ); - error = FT_GlyphLoader_New( memory, &loader->gloader ); - if ( !error ) - { - error = FT_GlyphLoader_CreateExtra( loader->gloader ); - if ( error ) - { - FT_GlyphLoader_Done( loader->gloader ); - loader->gloader = NULL; - } - } - return error; + return FT_GlyphLoader_New( memory, &loader->gloader ); } @@ -138,9 +125,9 @@ /* copy the outline points in the loader's current */ /* extra points which is used to keep original glyph coordinates */ - error = FT_GlyphLoader_CheckPoints( gloader, - slot->outline.n_points + 4, - slot->outline.n_contours ); + error = FT_GLYPHLOADER_CHECK_POINTS( gloader, + slot->outline.n_points + 4, + slot->outline.n_contours ); if ( error ) goto Exit; @@ -148,10 +135,6 @@ slot->outline.points, slot->outline.n_points ); - FT_ARRAY_COPY( gloader->current.extra_points, - slot->outline.points, - slot->outline.n_points ); - FT_ARRAY_COPY( gloader->current.outline.contours, slot->outline.contours, slot->outline.n_contours ); @@ -184,6 +167,7 @@ /* we now need to hint the metrics according to the change in */ /* width/positioning that occured during the hinting process */ { +#ifndef AF_USE_WARPER FT_Pos old_advance, old_rsb, old_lsb, new_lsb; FT_Pos pp1x_uh, pp2x_uh; AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ]; @@ -192,7 +176,7 @@ axis->num_edges - 1; /* rightmost edge */ - if ( axis->num_edges > 1 ) + if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) ) { old_advance = loader->pp2.x; old_rsb = old_advance - edge2->opos; @@ -219,18 +203,18 @@ slot->lsb_delta = loader->pp1.x - pp1x_uh; slot->rsb_delta = loader->pp2.x - pp2x_uh; - -#if 0 - /* try to fix certain bad advance computations */ - if ( loader->pp2.x + loader->pp1.x == edge2->pos && old_rsb > 4 ) - loader->pp2.x += 64; -#endif - } else +#endif /* !AF_USE_WARPER */ { + FT_Pos pp1x = loader->pp1.x; + FT_Pos pp2x = loader->pp2.x; + loader->pp1.x = FT_PIX_ROUND( loader->pp1.x ); loader->pp2.x = FT_PIX_ROUND( loader->pp2.x ); + + slot->lsb_delta = loader->pp1.x - pp1x; + slot->rsb_delta = loader->pp2.x - pp2x; } } @@ -307,16 +291,11 @@ { FT_Vector* cur = gloader->base.outline.points + num_base_points; - FT_Vector* org = gloader->base.extra_points + - num_base_points; FT_Vector* limit = cur + num_new_points; - for ( ; cur < limit; cur++, org++ ) - { + for ( ; cur < limit; cur++ ) FT_Vector_Transform( cur, &subglyph->transform ); - FT_Vector_Transform( org, &subglyph->transform ); - } } /* apply offset */ @@ -376,12 +355,21 @@ Hint_Metrics: if ( depth == 0 ) { - FT_BBox bbox; + FT_BBox bbox; + FT_Vector vvector; + vvector.x = slot->metrics.vertBearingX - slot->metrics.horiBearingX; + vvector.y = slot->metrics.vertBearingY - slot->metrics.horiBearingY; + vvector.x = FT_MulFix( vvector.x, metrics->scaler.x_scale ); + vvector.y = FT_MulFix( vvector.y, metrics->scaler.y_scale ); + /* transform the hinted outline if needed */ if ( loader->transformed ) + { FT_Outline_Transform( &gloader->base.outline, &loader->trans_matrix ); + FT_Vector_Transform( &vvector, &loader->trans_matrix ); + } /* we must translate our final outline by -pp1.x and compute */ /* the new metrics */ @@ -400,6 +388,9 @@ slot->metrics.horiBearingX = bbox.xMin; slot->metrics.horiBearingY = bbox.yMax; + slot->metrics.vertBearingX = FT_PIX_FLOOR( bbox.xMin + vvector.x ); + slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y ); + /* for mono-width fonts (like Andale, Courier, etc.) we need */ /* to keep the original rounded advance width */ #if 0 @@ -416,7 +407,11 @@ metrics->scaler.x_scale ); #endif + slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance, + metrics->scaler.y_scale ); + slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance ); + slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance ); /* now copy outline into glyph slot */ FT_GlyphLoader_Rewind( internal->loader ); diff --git a/src/libs/freetype2/autofit/aftypes.h b/src/libs/freetype2/autofit/aftypes.h index c9323e74ce..f6e94e1ce4 100644 --- a/src/libs/freetype2/autofit/aftypes.h +++ b/src/libs/freetype2/autofit/aftypes.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter types (specification only). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -16,20 +16,20 @@ /***************************************************************************/ -/*************************************************************************** - * - * The auto-fitter is a complete rewrite of the old auto-hinter. - * Its main feature is the ability to differentiate between different - * scripts in order to apply language-specific rules. - * - * The code has also been compartimentized into several entities that - * should make algorithmic experimentation easier than with the old - * code. - * - * Finally, we get rid of the Catharon license, since this code is - * released under the FreeType one. - * - ***************************************************************************/ + /************************************************************************* + * + * The auto-fitter is a complete rewrite of the old auto-hinter. + * Its main feature is the ability to differentiate between different + * scripts in order to apply language-specific rules. + * + * The code has also been compartimentized into several entities that + * should make algorithmic experimentation easier than with the old + * code. + * + * Finally, we get rid of the Catharon license, since this code is + * released under the FreeType one. + * + *************************************************************************/ #ifndef __AFTYPES_H__ @@ -53,6 +53,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ +#define xxAF_USE_WARPER /* only define to use warp hinting */ #define xxAF_DEBUG #ifdef AF_DEBUG @@ -125,6 +126,7 @@ FT_BEGIN_HEADER FT_Pos dy ); +#if 0 /* * compute `angle2 - angle1'; the result is always within * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1] @@ -132,6 +134,23 @@ FT_BEGIN_HEADER FT_LOCAL( AF_Angle ) af_angle_diff( AF_Angle angle1, AF_Angle angle2 ); +#endif /* 0 */ + + +#define AF_ANGLE_DIFF( result, angle1, angle2 ) \ + FT_BEGIN_STMNT \ + AF_Angle _delta = (angle2) - (angle1); \ + \ + \ + _delta %= AF_ANGLE_2PI; \ + if ( _delta < 0 ) \ + _delta += AF_ANGLE_2PI; \ + \ + if ( _delta > AF_ANGLE_PI ) \ + _delta -= AF_ANGLE_2PI; \ + \ + result = _delta; \ + FT_END_STMNT /*************************************************************************/ @@ -240,6 +259,7 @@ FT_BEGIN_HEADER { AF_SCRIPT_NONE = 0, AF_SCRIPT_LATIN = 1, + AF_SCRIPT_CJK = 2, /* add new scripts here. Don't forget to update the list in */ /* `afglobal.c'. */ diff --git a/src/libs/freetype2/autofit/afwarp.c b/src/libs/freetype2/autofit/afwarp.c new file mode 100644 index 0000000000..c8f86c7158 --- /dev/null +++ b/src/libs/freetype2/autofit/afwarp.c @@ -0,0 +1,313 @@ +/***************************************************************************/ +/* */ +/* afwarp.c */ +/* */ +/* Auto-fitter warping algorithm (body). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include "afwarp.h" + +#ifdef AF_USE_WARPER + +#if 1 + static const AF_WarpScore + af_warper_weights[64] = + { + 35, 20, 20, 20, 15, 12, 10, 5, 2, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, -2, -5, -8,-10,-10,-20,-20,-30,-30, + + -30,-30,-20,-20,-10,-10, -8, -5, -2, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 10, 12, 15, 20, 20, 20, + }; +#else + static const AF_WarpScore + af_warper_weights[64] = + { + 30, 20, 10, 5, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, -5, -5,-10,-10,-15,-20, + + -20,-15,-15,-10,-10, -5, -5, -2, -2, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 5, 10, 20, + }; +#endif + + + static void + af_warper_compute_line_best( AF_Warper warper, + FT_Fixed scale, + FT_Pos delta, + FT_Pos xx1, + FT_Pos xx2, + AF_WarpScore base_distort, + AF_Segment segments, + FT_UInt num_segments ) + { + FT_Int idx_min, idx_max, idx0; + FT_UInt nn; + AF_WarpScore scores[64]; + + + for ( nn = 0; nn < 64; nn++ ) + scores[nn] = 0; + + idx0 = xx1 - warper->t1; + + /* compute minimum and maximum indices */ + { + FT_Pos xx1min = warper->x1min; + FT_Pos xx1max = warper->x1max; + FT_Pos w = xx2 - xx1; + + + if ( xx1min + w < warper->x2min ) + xx1min = warper->x2min - ( xx2 - xx1 ); + + xx1max = warper->x1max; + if ( xx1max + w > warper->x2max ) + xx1max = warper->x2max - ( xx2 - xx1 ); + + idx_min = xx1min - warper->t1; + idx_max = xx1max - warper->t1; + + if ( idx_min > idx_max ) + { + AF_LOG(( "invalid indices:\n" + " min=%d max=%d, xx1=%ld xx2=%ld,\n" + " x1min=%ld x1max=%ld, x2min=%ld x2max=%ld\n", + idx_min, idx_max, xx1, xx2, + warper->x1min, warper->x1max, + warper->x2min, warper->x2max )); + return; + } + } + + for ( nn = 0; nn < num_segments; nn++ ) + { + FT_Pos len = segments[nn].max_coord - segments[nn].min_coord; + FT_Pos y0 = FT_MulFix( segments[nn].pos, scale ) + delta; + FT_Pos y = y0 + ( idx_min - idx0 ); + + FT_Int idx; + + + for ( idx = idx_min; idx <= idx_max; idx++, y++ ) + scores[idx] += af_warper_weights[y & 63] * len; + } + + /* find best score */ + { + FT_Int idx; + + + for ( idx = idx_min; idx <= idx_max; idx++ ) + { + AF_WarpScore score = scores[idx]; + AF_WarpScore distort = base_distort + ( idx - idx0 ); + + + if ( score > warper->best_score || + ( score == warper->best_score && + distort < warper->best_distort ) ) + { + warper->best_score = score; + warper->best_distort = distort; + warper->best_scale = scale; + warper->best_delta = delta + ( idx - idx0 ); + } + } + } + } + + + FT_LOCAL_DEF( void ) + af_warper_compute( AF_Warper warper, + AF_GlyphHints hints, + AF_Dimension dim, + FT_Fixed *a_scale, + FT_Pos *a_delta ) + { + AF_AxisHints axis; + AF_Point points; + + FT_Fixed org_scale; + FT_Pos org_delta; + + FT_UInt nn, num_points, num_segments; + FT_Int X1, X2; + FT_Int w; + + AF_WarpScore base_distort; + AF_Segment segments; + + + /* get original scaling transformation */ + if ( dim == AF_DIMENSION_VERT ) + { + org_scale = hints->y_scale; + org_delta = hints->y_delta; + } + else + { + org_scale = hints->x_scale; + org_delta = hints->x_delta; + } + + warper->best_scale = org_scale; + warper->best_delta = org_delta; + warper->best_score = 0; + warper->best_distort = 0; + + axis = &hints->axis[dim]; + segments = axis->segments; + num_segments = axis->num_segments; + points = hints->points; + num_points = hints->num_points; + + *a_scale = org_scale; + *a_delta = org_delta; + + /* get X1 and X2, minimum and maximum in original coordinates */ + if ( axis->num_segments < 1 ) + return; + +#if 1 + X1 = X2 = points[0].fx; + for ( nn = 1; nn < num_points; nn++ ) + { + FT_Int X = points[nn].fx; + + + if ( X < X1 ) + X1 = X; + if ( X > X2 ) + X2 = X; + } +#else + X1 = X2 = segments[0].pos; + for ( nn = 1; nn < num_segments; nn++ ) + { + FT_Int X = segments[nn].pos; + + + if ( X < X1 ) + X1 = X; + if ( X > X2 ) + X2 = X; + } +#endif + + if ( X1 >= X2 ) + return; + + warper->x1 = FT_MulFix( X1, org_scale ) + org_delta; + warper->x2 = FT_MulFix( X2, org_scale ) + org_delta; + + warper->t1 = AF_WARPER_FLOOR( warper->x1 ); + warper->t2 = AF_WARPER_CEIL( warper->x2 ); + + warper->x1min = warper->x1 & ~31; + warper->x1max = warper->x1min + 32; + warper->x2min = warper->x2 & ~31; + warper->x2max = warper->x2min + 32; + + if ( warper->x1max > warper->x2 ) + warper->x1max = warper->x2; + + if ( warper->x2min < warper->x1 ) + warper->x2min = warper->x1; + + warper->w0 = warper->x2 - warper->x1; + + if ( warper->w0 <= 64 ) + { + warper->x1max = warper->x1; + warper->x2min = warper->x2; + } + + warper->wmin = warper->x2min - warper->x1max; + warper->wmax = warper->x2max - warper->x1min; + + if ( warper->wmin < warper->w0 - 32 ) + warper->wmin = warper->w0 - 32; + + if ( warper->wmax > warper->w0 + 32 ) + warper->wmax = warper->w0 + 32; + + if ( warper->wmin < warper->w0 * 3 / 4 ) + warper->wmin = warper->w0 * 3 / 4; + + if ( warper->wmax > warper->w0 * 5 / 4 ) + warper->wmax = warper->w0 * 5 / 4; + + /* warper->wmin = warper->wmax = warper->w0; */ + + for ( w = warper->wmin; w <= warper->wmax; w++ ) + { + FT_Fixed new_scale; + FT_Pos new_delta; + FT_Pos xx1, xx2; + + + xx1 = warper->x1; + xx2 = warper->x2; + if ( w >= warper->w0 ) + { + xx1 -= w - warper->w0; + if ( xx1 < warper->x1min ) + { + xx2 += warper->x1min - xx1; + xx1 = warper->x1min; + } + } + else + { + xx1 -= w - warper->w0; + if ( xx1 > warper->x1max ) + { + xx2 -= xx1 - warper->x1max; + xx1 = warper->x1max; + } + } + + if ( xx1 < warper->x1 ) + base_distort = warper->x1 - xx1; + else + base_distort = xx1 - warper->x1; + + if ( xx2 < warper->x2 ) + base_distort += warper->x2 - xx2; + else + base_distort += xx2 - warper->x2; + + base_distort *= 10; + + new_scale = org_scale + FT_DivFix( w - warper->w0, X2 - X1 ); + new_delta = xx1 - FT_MulFix( X1, new_scale ); + + af_warper_compute_line_best( warper, new_scale, new_delta, xx1, xx2, + base_distort, + segments, num_segments ); + } + + *a_scale = warper->best_scale; + *a_delta = warper->best_delta; + } + +#else /* !AF_USE_WARPER */ + +char af_warper_dummy = 0; /* make compiler happy */ + +#endif /* !AF_USE_WARPER */ + +/* END */ diff --git a/src/libs/freetype2/autofit/afwarp.h b/src/libs/freetype2/autofit/afwarp.h new file mode 100644 index 0000000000..6ca1ce7ba2 --- /dev/null +++ b/src/libs/freetype2/autofit/afwarp.h @@ -0,0 +1,65 @@ +/***************************************************************************/ +/* */ +/* afwarp.h */ +/* */ +/* Auto-fitter warping algorithm (specification). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __AFWARP_H__ +#define __AFWARP_H__ + +#include "afhints.h" + +FT_BEGIN_HEADER + +#define AF_WARPER_SCALE + +#define AF_WARPER_FLOOR( x ) ( (x) & ~63 ) +#define AF_WARPER_CEIL( x ) AF_WARPER_FLOOR( (x) + 63 ) + + + typedef FT_Int32 AF_WarpScore; + + typedef struct AF_WarperRec_ + { + FT_Int X1, X2; + FT_Pos x1, x2; + FT_Pos t1, t2; + FT_Pos x1min, x1max; + FT_Pos x2min, x2max; + FT_Pos w0, wmin, wmax; + + FT_Fixed best_scale; + FT_Pos best_delta; + AF_WarpScore best_score; + AF_WarpScore best_distort; + + } AF_WarperRec, *AF_Warper; + + + FT_LOCAL( void ) + af_warper_compute( AF_Warper warper, + AF_GlyphHints hints, + AF_Dimension dim, + FT_Fixed *a_scale, + FT_Fixed *a_delta ); + + +FT_END_HEADER + + +#endif /* __AFWARP_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/autofit/autofit.c b/src/libs/freetype2/autofit/autofit.c index 2d58682ce8..b4b304068e 100644 --- a/src/libs/freetype2/autofit/autofit.c +++ b/src/libs/freetype2/autofit/autofit.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module (body). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,8 +23,12 @@ #include "afhints.c" #include "afdummy.c" #include "aflatin.c" +#include "afcjk.c" #include "afloader.c" #include "afmodule.c" +#ifdef AF_USE_WARPER +#include "afwarp.c" +#endif /* END */ diff --git a/src/libs/freetype2/autofit/module.mk b/src/libs/freetype2/autofit/module.mk index aa19380fbb..4a386ce66c 100644 --- a/src/libs/freetype2/autofit/module.mk +++ b/src/libs/freetype2/autofit/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2003, 2004, 2005 by +# Copyright 2003, 2004, 2005, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_autofit_module +FTMODULE_H_COMMANDS += AUTOFIT_MODULE -add_autofit_module: - $(OPEN_DRIVER)autofit_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)autofit $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE) +define AUTOFIT_MODULE +$(OPEN_DRIVER)autofit_module_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)autofit $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/autofit/rules.mk b/src/libs/freetype2/autofit/rules.mk index 7f7ff99759..8d6f668f52 100644 --- a/src/libs/freetype2/autofit/rules.mk +++ b/src/libs/freetype2/autofit/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2003, 2004, 2005 by +# Copyright 2003, 2004, 2005, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -30,8 +30,10 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \ $(AUTOF_DIR)/afglobal.c \ $(AUTOF_DIR)/afhints.c \ $(AUTOF_DIR)/aflatin.c \ + $(AUTOF_DIR)/afcjk.c \ $(AUTOF_DIR)/afloader.c \ - $(AUTOF_DIR)/afmodule.c + $(AUTOF_DIR)/afmodule.c \ + $(AUTOF_DIR)/afwarp.c # AUTOF driver headers # diff --git a/src/libs/freetype2/autohint/CatharonLicense.txt b/src/libs/freetype2/autohint/CatharonLicense.txt deleted file mode 100644 index 789c8c9fec..0000000000 --- a/src/libs/freetype2/autohint/CatharonLicense.txt +++ /dev/null @@ -1,123 +0,0 @@ - The Catharon Open Source LICENSE - ---------------------------- - - 2000-Jul-04 - - Copyright (C) 2000 by Catharon Productions, Inc. - - - -Introduction -============ - - This license applies to source files distributed by Catharon - Productions, Inc. in several archive packages. This license - applies to all files found in such packages which do not fall - under their own explicit license. - - This license was inspired by the BSD, Artistic, and IJG - (Independent JPEG Group) licenses, which all encourage inclusion - and use of free software in commercial and freeware products - alike. As a consequence, its main points are that: - - o We don't promise that this software works. However, we are - interested in any kind of bug reports. (`as is' distribution) - - o You can use this software for whatever you want, in parts or - full form, without having to pay us. (`royalty-free' usage) - - o You may not pretend that you wrote this software. If you use - it, or only parts of it, in a program, you must acknowledge - somewhere in your documentation that you have used the - Catharon Code. (`credits') - - We specifically permit and encourage the inclusion of this - software, with or without modifications, in commercial products. - We disclaim all warranties covering the packages distributed by - Catharon Productions, Inc. and assume no liability related to - their use. - - -Legal Terms -=========== - -0. Definitions --------------- - - Throughout this license, the terms `Catharon Package', `package', - and `Catharon Code' refer to the set of files originally - distributed by Catharon Productions, Inc. - - `You' refers to the licensee, or person using the project, where - `using' is a generic term including compiling the project's source - code as well as linking it to form a `program' or `executable'. - This program is referred to as `a program using one of the - Catharon Packages'. - - This license applies to all files distributed in the original - Catharon Package(s), including all source code, binaries and - documentation, unless otherwise stated in the file in its - original, unmodified form as distributed in the original archive. - If you are unsure whether or not a particular file is covered by - this license, you must contact us to verify this. - - The Catharon Packages are copyright (C) 2000 by Catharon - Productions, Inc. All rights reserved except as specified below. - -1. No Warranty --------------- - - THE CATHARON PACKAGES ARE PROVIDED `AS IS' WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OF OR THE INABILITY TO - USE THE CATHARON PACKAGE. - -2. Redistribution ------------------ - - This license grants a worldwide, royalty-free, perpetual and - irrevocable right and license to use, execute, perform, compile, - display, copy, create derivative works of, distribute and - sublicense the Catharon Packages (in both source and object code - forms) and derivative works thereof for any purpose; and to - authorize others to exercise some or all of the rights granted - herein, subject to the following conditions: - - o Redistribution of source code must retain this license file - (`license.txt') unaltered; any additions, deletions or changes - to the original files must be clearly indicated in - accompanying documentation. The copyright notices of the - unaltered, original files must be preserved in all copies of - source files. - - o Redistribution in binary form must provide a disclaimer that - states that the software is based in part on the work of - Catharon Productions, Inc. in the distribution documentation. - - These conditions apply to any software derived from or based on - the Catharon Packages, not just the unmodified files. If you use - our work, you must acknowledge us. However, no fee need be paid - to us. - -3. Advertising --------------- - - Neither Catharon Productions, Inc. and contributors nor you shall - use the name of the other for commercial, advertising, or - promotional purposes without specific prior written permission. - - We suggest, but do not require, that you use the following phrase - to refer to this software in your documentation: 'this software is - based in part on the Catharon Typography Project'. - - As you have not signed this license, you are not required to - accept it. However, as the Catharon Packages are copyrighted - material, only this license, or another one contracted with the - authors, grants you the right to use, distribute, and modify it. - Therefore, by using, distributing, or modifying the Catharon - Packages, you indicate that you understand and accept all the - terms of this license. - ---- end of license.txt --- diff --git a/src/libs/freetype2/autohint/Jamfile b/src/libs/freetype2/autohint/Jamfile deleted file mode 100644 index f53df8cbf0..0000000000 --- a/src/libs/freetype2/autohint/Jamfile +++ /dev/null @@ -1,27 +0,0 @@ -# FreeType 2 src/autohint Jamfile (c) 2001 David Turner -# - -SubDir HAIKU_TOP src libs freetype2 autohint ; - -SetSubDirSupportedPlatformsBeOSCompatible ; -AddSubDirSupportedPlatforms libbe_test ; - -UseFreeTypeHeaders ; - -{ - local _sources ; - - if $(FT2_MULTI) - { - _sources = ahangles ahglobal ahglyph ahhint ahmodule ; - } - else - { - _sources = autohint ; - } - - FT2_Library $(FT2_LIB) : $(_sources).c ; -} - -# end of src/autohint Jamfile - diff --git a/src/libs/freetype2/autohint/ahangles.c b/src/libs/freetype2/autohint/ahangles.c deleted file mode 100644 index ef5a88ee66..0000000000 --- a/src/libs/freetype2/autohint/ahangles.c +++ /dev/null @@ -1,147 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahangles.h */ -/* */ -/* A routine used to compute vector angles with limited accuracy */ -/* and very high speed (body). */ -/* */ -/* Copyright 2000-2001, 2002 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include "ahangles.h" - - - /* the following table has been automatically generated with */ - /* the `mather.py' Python script */ - - const AH_Angle ah_arctan[1L << AH_ATAN_BITS] = - { - 0, 0, 1, 1, 1, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 5, - 5, 5, 6, 6, 6, 7, 7, 7, - 8, 8, 8, 9, 9, 9, 10, 10, - 10, 10, 11, 11, 11, 12, 12, 12, - 13, 13, 13, 14, 14, 14, 14, 15, - 15, 15, 16, 16, 16, 17, 17, 17, - 18, 18, 18, 18, 19, 19, 19, 20, - 20, 20, 21, 21, 21, 21, 22, 22, - 22, 23, 23, 23, 24, 24, 24, 24, - 25, 25, 25, 26, 26, 26, 26, 27, - 27, 27, 28, 28, 28, 28, 29, 29, - 29, 30, 30, 30, 30, 31, 31, 31, - 31, 32, 32, 32, 33, 33, 33, 33, - 34, 34, 34, 34, 35, 35, 35, 35, - 36, 36, 36, 36, 37, 37, 37, 38, - 38, 38, 38, 39, 39, 39, 39, 40, - 40, 40, 40, 41, 41, 41, 41, 42, - 42, 42, 42, 42, 43, 43, 43, 43, - 44, 44, 44, 44, 45, 45, 45, 45, - 46, 46, 46, 46, 46, 47, 47, 47, - 47, 48, 48, 48, 48, 48, 49, 49, - 49, 49, 50, 50, 50, 50, 50, 51, - 51, 51, 51, 51, 52, 52, 52, 52, - 52, 53, 53, 53, 53, 53, 54, 54, - 54, 54, 54, 55, 55, 55, 55, 55, - 56, 56, 56, 56, 56, 57, 57, 57, - 57, 57, 57, 58, 58, 58, 58, 58, - 59, 59, 59, 59, 59, 59, 60, 60, - 60, 60, 60, 61, 61, 61, 61, 61, - 61, 62, 62, 62, 62, 62, 62, 63, - 63, 63, 63, 63, 63, 64, 64, 64 - }; - - - FT_LOCAL_DEF( AH_Angle ) - ah_angle( FT_Vector* v ) - { - FT_Pos dx, dy; - AH_Angle angle; - - - dx = v->x; - dy = v->y; - - /* check trivial cases */ - if ( dy == 0 ) - { - angle = 0; - if ( dx < 0 ) - angle = AH_PI; - return angle; - } - else if ( dx == 0 ) - { - angle = AH_HALF_PI; - if ( dy < 0 ) - angle = -AH_HALF_PI; - return angle; - } - - angle = 0; - if ( dx < 0 ) - { - dx = -v->x; - dy = -v->y; - angle = AH_PI; - } - - if ( dy < 0 ) - { - FT_Pos tmp; - - - tmp = dx; - dx = -dy; - dy = tmp; - angle -= AH_HALF_PI; - } - - if ( dx == 0 && dy == 0 ) - return 0; - - if ( dx == dy ) - angle += AH_PI / 4; - else if ( dx > dy ) - angle += ah_arctan[FT_DivFix( dy, dx ) >> ( 16 - AH_ATAN_BITS )]; - else - angle += AH_HALF_PI - - ah_arctan[FT_DivFix( dx, dy ) >> ( 16 - AH_ATAN_BITS )]; - - if ( angle > AH_PI ) - angle -= AH_2PI; - - return angle; - } - - - FT_LOCAL_DEF( AH_Angle ) - ah_angle_diff( AH_Angle angle1, - AH_Angle angle2 ) - { - AH_Angle delta; - - - delta = ( angle2 - angle1 ); - if ( delta < 0 ) - delta += AH_2PI; - - if ( delta > AH_PI ) - delta -= AH_2PI; - - return delta; - } - -/* END */ diff --git a/src/libs/freetype2/autohint/ahangles.h b/src/libs/freetype2/autohint/ahangles.h deleted file mode 100644 index f46bfaad78..0000000000 --- a/src/libs/freetype2/autohint/ahangles.h +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahangles.h */ -/* */ -/* A routine used to compute vector angles with limited accuracy */ -/* and very high speed (specification). */ -/* */ -/* Copyright 2000-2001, 2002 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#ifndef __AHANGLES_H__ -#define __AHANGLES_H__ - - -#include <ft2build.h> -#include FT_INTERNAL_OBJECTS_H -#include "ahtypes.h" - - -FT_BEGIN_HEADER - - - /* PI expressed in ah_angles -- we don't really need an important */ - /* precision, so 256 should be enough */ -#define AH_PI 256 -#define AH_2PI ( AH_PI * 2 ) -#define AH_HALF_PI ( AH_PI / 2 ) -#define AH_2PIMASK ( AH_2PI - 1 ) - - /* the number of bits used to express an arc tangent; */ - /* see the structure of the lookup table */ -#define AH_ATAN_BITS 8 - - extern - const AH_Angle ah_arctan[1L << AH_ATAN_BITS]; - - - FT_LOCAL( AH_Angle ) - ah_angle( FT_Vector* v ); - - - FT_LOCAL( AH_Angle ) - ah_angle_diff( AH_Angle angle1, - AH_Angle angle2 ); - - -FT_END_HEADER - -#endif /* __AHANGLES_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahglobal.c b/src/libs/freetype2/autohint/ahglobal.c deleted file mode 100644 index e157014b57..0000000000 --- a/src/libs/freetype2/autohint/ahglobal.c +++ /dev/null @@ -1,402 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahglobal.c */ -/* */ -/* Routines used to compute global metrics automatically (body). */ -/* */ -/* Copyright 2000-2001, 2002, 2003, 2004 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_INTERNAL_DEBUG_H -#include "ahglobal.h" -#include "ahglyph.h" - - -#define MAX_TEST_CHARACTERS 12 - - /* cf. AH_BLUE_XXX constants in ahtypes.h */ - - static - const char* const blue_chars[AH_BLUE_MAX] = - { - "THEZOCQS", - "HEZLOCUS", -#ifdef FT_CONFIG_CHESTER_SMALL_F - "fijkdbh", -#endif - "xzroesc", - "xzroesc", - "pqgjy" - }; - - - /* simple insertion sort */ - static void - sort_values( FT_Int count, - FT_Pos* table ) - { - FT_Int i, j; - FT_Pos swap; - - - for ( i = 1; i < count; i++ ) - { - for ( j = i; j > 0; j-- ) - { - if ( table[j] > table[j - 1] ) - break; - - swap = table[j]; - table[j] = table[j - 1]; - table[j - 1] = swap; - } - } - } - - - static FT_Error - ah_hinter_compute_blues( AH_Hinter hinter ) - { - AH_Blue blue; - AH_Globals globals = &hinter->globals->design; - FT_Pos flats [MAX_TEST_CHARACTERS]; - FT_Pos rounds[MAX_TEST_CHARACTERS]; - FT_Int num_flats; - FT_Int num_rounds; - - FT_Face face; - FT_GlyphSlot glyph; - FT_Error error; - FT_CharMap charmap; - - - face = hinter->face; - glyph = face->glyph; - - /* save current charmap */ - charmap = face->charmap; - - /* do we have a Unicode charmap in there? */ - error = FT_Select_Charmap( face, FT_ENCODING_UNICODE ); - if ( error ) - goto Exit; - - /* we compute the blues simply by loading each character from the */ - /* `blue_chars[blues]' string, then compute its top-most or */ - /* bottom-most points (depending on `AH_IS_TOP_BLUE') */ - - AH_LOG(( "blue zones computation\n" )); - AH_LOG(( "------------------------------------------------\n" )); - - for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ ) - { - const char* p = blue_chars[blue]; - const char* limit = p + MAX_TEST_CHARACTERS; - - FT_Pos *blue_ref, *blue_shoot; - - - AH_LOG(( "blue %3d: ", blue )); - - num_flats = 0; - num_rounds = 0; - - for ( ; p < limit; p++ ) - { - FT_UInt glyph_index; - FT_Vector* extremum; - FT_Vector* points; - FT_Vector* point_limit; - FT_Vector* point; - FT_Bool round; - - - /* exit if we reach the end of the string */ - if ( !*p ) - break; - - AH_LOG(( "`%c'", *p )); - - /* load the character in the face -- skip unknown or empty ones */ - glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p ); - if ( glyph_index == 0 ) - continue; - - error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE ); - if ( error || glyph->outline.n_points <= 0 ) - continue; - - /* now compute min or max point indices and coordinates */ - points = glyph->outline.points; - point_limit = points + glyph->outline.n_points; - point = points; - extremum = point; - point++; - - if ( AH_IS_TOP_BLUE( blue ) ) - { - for ( ; point < point_limit; point++ ) - if ( point->y > extremum->y ) - extremum = point; - } - else - { - for ( ; point < point_limit; point++ ) - if ( point->y < extremum->y ) - extremum = point; - } - - AH_LOG(( "%5d", (int)extremum->y )); - - /* now, check whether the point belongs to a straight or round */ - /* segment; we first need to find in which contour the extremum */ - /* lies, then see its previous and next points */ - { - FT_Int idx = (FT_Int)( extremum - points ); - FT_Int n; - FT_Int first, last, prev, next, end; - FT_Pos dist; - - - last = -1; - first = 0; - - for ( n = 0; n < glyph->outline.n_contours; n++ ) - { - end = glyph->outline.contours[n]; - if ( end >= idx ) - { - last = end; - break; - } - first = end + 1; - } - - /* XXX: should never happen! */ - if ( last < 0 ) - continue; - - /* now look for the previous and next points that are not on the */ - /* same Y coordinate. Threshold the `closeness'... */ - - prev = idx; - next = prev; - - do - { - if ( prev > first ) - prev--; - else - prev = last; - - dist = points[prev].y - extremum->y; - if ( dist < -5 || dist > 5 ) - break; - - } while ( prev != idx ); - - do - { - if ( next < last ) - next++; - else - next = first; - - dist = points[next].y - extremum->y; - if ( dist < -5 || dist > 5 ) - break; - - } while ( next != idx ); - - /* now, set the `round' flag depending on the segment's kind */ - round = FT_BOOL( - FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_CURVE_TAG_ON || - FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_CURVE_TAG_ON ); - - AH_LOG(( "%c ", round ? 'r' : 'f' )); - } - - if ( round ) - rounds[num_rounds++] = extremum->y; - else - flats[num_flats++] = extremum->y; - } - - AH_LOG(( "\n" )); - - /* we have computed the contents of the `rounds' and `flats' tables, */ - /* now determine the reference and overshoot position of the blue -- */ - /* we simply take the median value after a simple sort */ - sort_values( num_rounds, rounds ); - sort_values( num_flats, flats ); - - blue_ref = globals->blue_refs + blue; - blue_shoot = globals->blue_shoots + blue; - if ( num_flats == 0 && num_rounds == 0 ) - { - *blue_ref = -10000; - *blue_shoot = -10000; - } - else if ( num_flats == 0 ) - { - *blue_ref = - *blue_shoot = rounds[num_rounds / 2]; - } - else if ( num_rounds == 0 ) - { - *blue_ref = - *blue_shoot = flats[num_flats / 2]; - } - else - { - *blue_ref = flats[num_flats / 2]; - *blue_shoot = rounds[num_rounds / 2]; - } - - /* there are sometimes problems: if the overshoot position of top */ - /* zones is under its reference position, or the opposite for bottom */ - /* zones. We must thus check everything there and correct the errors */ - if ( *blue_shoot != *blue_ref ) - { - FT_Pos ref = *blue_ref; - FT_Pos shoot = *blue_shoot; - FT_Bool over_ref = FT_BOOL( shoot > ref ); - - - if ( AH_IS_TOP_BLUE( blue ) ^ over_ref ) - *blue_shoot = *blue_ref = ( shoot + ref ) / 2; - } - - AH_LOG(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot )); - } - - /* reset original face charmap */ - FT_Set_Charmap( face, charmap ); - error = 0; - - Exit: - return error; - } - - - static FT_Error - ah_hinter_compute_widths( AH_Hinter hinter ) - { - /* scan the array of segments in each direction */ - AH_Outline outline = hinter->glyph; - AH_Segment segments; - AH_Segment limit; - AH_Globals globals = &hinter->globals->design; - FT_Pos* widths; - FT_Int dimension; - FT_Int* p_num_widths; - FT_Error error = 0; - FT_Pos edge_distance_threshold = 32000; - - - globals->num_widths = 0; - globals->num_heights = 0; - - /* For now, compute the standard width and height from the `o' */ - /* character. I started computing the stem width of the `i' and the */ - /* stem height of the "-", but it wasn't too good. Moreover, we now */ - /* have a single character that gives us standard width and height. */ - { - FT_UInt glyph_index; - - - glyph_index = FT_Get_Char_Index( hinter->face, 'o' ); - if ( glyph_index == 0 ) - return 0; - - error = FT_Load_Glyph( hinter->face, glyph_index, FT_LOAD_NO_SCALE ); - if ( error ) - goto Exit; - - error = ah_outline_load( hinter->glyph, 0x10000L, 0x10000L, - hinter->face ); - if ( error ) - goto Exit; - - ah_outline_compute_segments( hinter->glyph ); - ah_outline_link_segments( hinter->glyph ); - } - - segments = outline->horz_segments; - limit = segments + outline->num_hsegments; - widths = globals->heights; - p_num_widths = &globals->num_heights; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Segment seg = segments; - AH_Segment link; - FT_Int num_widths = 0; - - - for ( ; seg < limit; seg++ ) - { - link = seg->link; - /* we only consider stem segments there! */ - if ( link && link->link == seg && link > seg ) - { - FT_Pos dist; - - - dist = seg->pos - link->pos; - if ( dist < 0 ) - dist = -dist; - - if ( num_widths < AH_MAX_WIDTHS ) - widths[num_widths++] = dist; - } - } - - sort_values( num_widths, widths ); - *p_num_widths = num_widths; - - /* we will now try to find the smallest width */ - if ( num_widths > 0 && widths[0] < edge_distance_threshold ) - edge_distance_threshold = widths[0]; - - segments = outline->vert_segments; - limit = segments + outline->num_vsegments; - widths = globals->widths; - p_num_widths = &globals->num_widths; - } - - /* Now, compute the edge distance threshold as a fraction of the */ - /* smallest width in the font. Set it in `hinter->glyph' too! */ - if ( edge_distance_threshold == 32000 ) - edge_distance_threshold = 50; - - /* let's try 20% */ - hinter->glyph->edge_distance_threshold = edge_distance_threshold / 5; - - Exit: - return error; - } - - - FT_LOCAL_DEF( FT_Error ) - ah_hinter_compute_globals( AH_Hinter hinter ) - { - return ah_hinter_compute_widths( hinter ) || - ah_hinter_compute_blues ( hinter ); - } - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahglobal.h b/src/libs/freetype2/autohint/ahglobal.h deleted file mode 100644 index 5a9bcf8352..0000000000 --- a/src/libs/freetype2/autohint/ahglobal.h +++ /dev/null @@ -1,59 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahglobal.h */ -/* */ -/* Routines used to compute global metrics automatically */ -/* (specification). */ -/* */ -/* Copyright 2000-2001, 2002, 2003 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#ifndef __AHGLOBAL_H__ -#define __AHGLOBAL_H__ - - -#include <ft2build.h> -#include "ahtypes.h" -#include FT_INTERNAL_OBJECTS_H - - -FT_BEGIN_HEADER - - -#ifdef FT_CONFIG_CHESTER_SMALL_F - -#define AH_IS_TOP_BLUE( b ) ( (b) == AH_BLUE_CAPITAL_TOP || \ - (b) == AH_BLUE_SMALL_F_TOP || \ - (b) == AH_BLUE_SMALL_TOP ) - -#else /* !FT_CONFIG_CHESTER_SMALL_F */ - -#define AH_IS_TOP_BLUE( b ) ( (b) == AH_BLUE_CAPITAL_TOP || \ - (b) == AH_BLUE_SMALL_TOP ) - -#endif /* !FT_CONFIG_CHESTER_SMALL_F */ - - - /* compute global metrics automatically */ - FT_LOCAL( FT_Error ) - ah_hinter_compute_globals( AH_Hinter hinter ); - - -FT_END_HEADER - -#endif /* __AHGLOBAL_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahglyph.c b/src/libs/freetype2/autohint/ahglyph.c deleted file mode 100644 index 2a0390be44..0000000000 --- a/src/libs/freetype2/autohint/ahglyph.c +++ /dev/null @@ -1,1699 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahglyph.c */ -/* */ -/* Routines used to load and analyze a given glyph before hinting */ -/* (body). */ -/* */ -/* Copyright 2000-2001, 2002, 2003, 2004 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include "ahglyph.h" -#include "ahangles.h" -#include "ahglobal.h" -#include "aherrors.h" - - -#ifdef AH_DEBUG - -#include <stdio.h> - - void - ah_dump_edges( AH_Outline outline ) - { - AH_Edge edges; - AH_Edge edge_limit; - AH_Segment segments; - FT_Int dimension; - - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - segments = outline->horz_segments; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge edge; - - - printf ( "Table of %s edges:\n", - !dimension ? "vertical" : "horizontal" ); - printf ( " [ index | pos | dir | link |" - " serif | blue | opos | pos ]\n" ); - - for ( edge = edges; edge < edge_limit; edge++ ) - { - printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n", - edge - edges, - (int)edge->fpos, - edge->dir == AH_DIR_UP - ? "up" - : ( edge->dir == AH_DIR_DOWN - ? "down" - : ( edge->dir == AH_DIR_LEFT - ? "left" - : ( edge->dir == AH_DIR_RIGHT - ? "right" - : "none" ) ) ), - edge->link ? ( edge->link - edges ) : -1, - edge->serif ? ( edge->serif - edges ) : -1, - edge->blue_edge ? 'y' : 'n', - edge->opos / 64.0, - edge->pos / 64.0 ); - } - - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - segments = outline->vert_segments; - } - } - - - /* A function used to dump the array of linked segments */ - void - ah_dump_segments( AH_Outline outline ) - { - AH_Segment segments; - AH_Segment segment_limit; - AH_Point points; - FT_Int dimension; - - - points = outline->points; - segments = outline->horz_segments; - segment_limit = segments + outline->num_hsegments; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Segment seg; - - - printf ( "Table of %s segments:\n", - !dimension ? "vertical" : "horizontal" ); - printf ( " [ index | pos | dir | link | serif |" - " numl | first | start ]\n" ); - - for ( seg = segments; seg < segment_limit; seg++ ) - { - printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n", - seg - segments, - (int)seg->pos, - seg->dir == AH_DIR_UP - ? "up" - : ( seg->dir == AH_DIR_DOWN - ? "down" - : ( seg->dir == AH_DIR_LEFT - ? "left" - : ( seg->dir == AH_DIR_RIGHT - ? "right" - : "none" ) ) ), - seg->link ? ( seg->link - segments ) : -1, - seg->serif ? ( seg->serif - segments ) : -1, - (int)seg->num_linked, - seg->first - points, - seg->last - points ); - } - - segments = outline->vert_segments; - segment_limit = segments + outline->num_vsegments; - } - } - -#endif /* AH_DEBUG */ - - - /* compute the direction value of a given vector */ - static AH_Direction - ah_compute_direction( FT_Pos dx, - FT_Pos dy ) - { - AH_Direction dir; - FT_Pos ax = FT_ABS( dx ); - FT_Pos ay = FT_ABS( dy ); - - - dir = AH_DIR_NONE; - - /* atan(1/12) == 4.7 degrees */ - - /* test for vertical direction */ - if ( ax * 12 < ay ) - { - dir = dy > 0 ? AH_DIR_UP : AH_DIR_DOWN; - } - /* test for horizontal direction */ - else if ( ay * 12 < ax ) - { - dir = dx > 0 ? AH_DIR_RIGHT : AH_DIR_LEFT; - } - - return dir; - } - - - /* this function is used by ah_get_orientation (see below) to test */ - /* the fill direction of given bbox extremum */ - static FT_Int - ah_test_extremum( FT_Outline* outline, - FT_Int n ) - { - FT_Vector *prev, *cur, *next; - FT_Pos product; - FT_Int first, last, c; - FT_Int retval; - - - /* we need to compute the `previous' and `next' point */ - /* for this extremum; we check whether the extremum */ - /* is start or end of a contour and providing */ - /* appropriate values if so */ - cur = outline->points + n; - prev = cur - 1; - next = cur + 1; - - first = 0; - for ( c = 0; c < outline->n_contours; c++ ) - { - last = outline->contours[c]; - - if ( n == first ) - prev = outline->points + last; - - if ( n == last ) - next = outline->points + first; - - first = last + 1; - } - - /* compute the vectorial product -- since we know that the angle */ - /* is <= 180 degrees (otherwise it wouldn't be an extremum) we */ - /* can determine the filling orientation if the product is */ - /* either positive or negative */ - product = FT_MulDiv( cur->x - prev->x, /* in.x */ - next->y - cur->y, /* out.y */ - 0x40 ) - - - FT_MulDiv( cur->y - prev->y, /* in.y */ - next->x - cur->x, /* out.x */ - 0x40 ); - - retval = 0; - if ( product ) - retval = product > 0 ? 2 : 1; - - return retval; - } - - - /* Compute the orientation of path filling. It differs between TrueType */ - /* and Type1 formats. We could use the `FT_OUTLINE_REVERSE_FILL' flag, */ - /* but it is better to re-compute it directly (it seems that this flag */ - /* isn't correctly set for some weird composite glyphs currently). */ - /* */ - /* We do this by computing bounding box points, and computing their */ - /* curvature. */ - /* */ - /* The function returns either 1 or 2. */ - /* */ - static FT_Int - ah_get_orientation( FT_Outline* outline ) - { - FT_BBox box; - FT_Int indices_xMin, indices_yMin, indices_xMax, indices_yMax; - FT_Int n, last; - - - indices_xMin = -1; - indices_yMin = -1; - indices_xMax = -1; - indices_yMax = -1; - - box.xMin = box.yMin = 32767L; - box.xMax = box.yMax = -32768L; - - /* is it empty? */ - if ( outline->n_contours < 1 ) - return 1; - - last = outline->contours[outline->n_contours - 1]; - - for ( n = 0; n <= last; n++ ) - { - FT_Pos x, y; - - - x = outline->points[n].x; - if ( x < box.xMin ) - { - box.xMin = x; - indices_xMin = n; - } - if ( x > box.xMax ) - { - box.xMax = x; - indices_xMax = n; - } - - y = outline->points[n].y; - if ( y < box.yMin ) - { - box.yMin = y; - indices_yMin = n; - } - if ( y > box.yMax ) - { - box.yMax = y; - indices_yMax = n; - } - } - - /* test orientation of the extrema */ - n = ah_test_extremum( outline, indices_xMin ); - if ( n ) - goto Exit; - - n = ah_test_extremum( outline, indices_yMin ); - if ( n ) - goto Exit; - - n = ah_test_extremum( outline, indices_xMax ); - if ( n ) - goto Exit; - - n = ah_test_extremum( outline, indices_yMax ); - if ( !n ) - n = 1; - - Exit: - return n; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_new */ - /* */ - /* <Description> */ - /* Creates a new and empty AH_OutlineRec object. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - ah_outline_new( FT_Memory memory, - AH_Outline* aoutline ) - { - FT_Error error; - AH_Outline outline; - - - if ( !FT_NEW( outline ) ) - { - outline->memory = memory; - *aoutline = outline; - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_done */ - /* */ - /* <Description> */ - /* Destroys a given AH_OutlineRec object. */ - /* */ - FT_LOCAL_DEF( void ) - ah_outline_done( AH_Outline outline ) - { - FT_Memory memory = outline->memory; - - - FT_FREE( outline->horz_edges ); - FT_FREE( outline->horz_segments ); - FT_FREE( outline->contours ); - FT_FREE( outline->points ); - - FT_FREE( outline ); - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_save */ - /* */ - /* <Description> */ - /* Saves the contents of a given AH_OutlineRec object into a face's */ - /* glyph slot. */ - /* */ - FT_LOCAL_DEF( void ) - ah_outline_save( AH_Outline outline, - AH_Loader gloader ) - { - AH_Point point = outline->points; - AH_Point point_limit = point + outline->num_points; - FT_Vector* vec = gloader->current.outline.points; - char* tag = gloader->current.outline.tags; - - - /* we assume that the glyph loader has already been checked for storage */ - for ( ; point < point_limit; point++, vec++, tag++ ) - { - vec->x = point->x; - vec->y = point->y; - - if ( point->flags & AH_FLAG_CONIC ) - tag[0] = FT_CURVE_TAG_CONIC; - else if ( point->flags & AH_FLAG_CUBIC ) - tag[0] = FT_CURVE_TAG_CUBIC; - else - tag[0] = FT_CURVE_TAG_ON; - } - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_load */ - /* */ - /* <Description> */ - /* Loads an unscaled outline from a glyph slot into an AH_OutlineRec */ - /* object. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - ah_outline_load( AH_Outline outline, - FT_Fixed x_scale, - FT_Fixed y_scale, - FT_Face face ) - { - FT_Memory memory = outline->memory; - FT_Error error = AH_Err_Ok; - FT_Outline* source = &face->glyph->outline; - FT_Int num_points = source->n_points; - FT_Int num_contours = source->n_contours; - AH_Point points; - - - /* check arguments */ - if ( !face || - !face->size || - face->glyph->format != FT_GLYPH_FORMAT_OUTLINE ) - return AH_Err_Invalid_Argument; - - /* first of all, reallocate the contours array if necessary */ - if ( num_contours > outline->max_contours ) - { - FT_Int new_contours = FT_PAD_CEIL( num_contours, 4 ); - - - if ( FT_RENEW_ARRAY( outline->contours, - outline->max_contours, - new_contours ) ) - goto Exit; - - outline->max_contours = new_contours; - } - - /* then, reallocate the points, segments & edges arrays if needed -- */ - /* note that we reserved two additional point positions, used to */ - /* hint metrics appropriately */ - /* */ - if ( num_points + 2 > outline->max_points ) - { - FT_Int news = FT_PAD_CEIL( num_points + 2, 8 ); - FT_Int max = outline->max_points; - - - if ( FT_RENEW_ARRAY( outline->points, max, news ) || - FT_RENEW_ARRAY( outline->horz_edges, max * 2, news * 2 ) || - FT_RENEW_ARRAY( outline->horz_segments, max * 2, news * 2 ) ) - goto Exit; - - /* readjust some pointers */ - outline->vert_edges = outline->horz_edges + news; - outline->vert_segments = outline->horz_segments + news; - outline->max_points = news; - } - - outline->num_points = num_points; - outline->num_contours = num_contours; - - outline->num_hedges = 0; - outline->num_vedges = 0; - outline->num_hsegments = 0; - outline->num_vsegments = 0; - - /* We can't rely on the value of `FT_Outline.flags' to know the fill */ - /* direction used for a glyph, given that some fonts are broken (e.g. */ - /* the Arphic ones). We thus recompute it each time we need to. */ - /* */ - outline->vert_major_dir = AH_DIR_UP; - outline->horz_major_dir = AH_DIR_LEFT; - - if ( ah_get_orientation( source ) > 1 ) - { - outline->vert_major_dir = AH_DIR_DOWN; - outline->horz_major_dir = AH_DIR_RIGHT; - } - - outline->x_scale = x_scale; - outline->y_scale = y_scale; - - points = outline->points; - if ( outline->num_points == 0 ) - goto Exit; - - { - /* do one thing at a time -- it is easier to understand, and */ - /* the code is clearer */ - AH_Point point; - AH_Point point_limit = points + outline->num_points; - - - /* compute coordinates */ - { - FT_Vector* vec = source->points; - - - for ( point = points; point < point_limit; vec++, point++ ) - { - point->fx = vec->x; - point->fy = vec->y; - point->ox = point->x = FT_MulFix( vec->x, x_scale ); - point->oy = point->y = FT_MulFix( vec->y, y_scale ); - - point->flags = 0; - } - } - - /* compute Bezier flags */ - { - char* tag = source->tags; - - - for ( point = points; point < point_limit; point++, tag++ ) - { - switch ( FT_CURVE_TAG( *tag ) ) - { - case FT_CURVE_TAG_CONIC: - point->flags = AH_FLAG_CONIC; - break; - case FT_CURVE_TAG_CUBIC: - point->flags = AH_FLAG_CUBIC; - break; - default: - ; - } - } - } - - /* compute `next' and `prev' */ - { - FT_Int contour_index; - AH_Point prev; - AH_Point first; - AH_Point end; - - - contour_index = 0; - - first = points; - end = points + source->contours[0]; - prev = end; - - for ( point = points; point < point_limit; point++ ) - { - point->prev = prev; - if ( point < end ) - { - point->next = point + 1; - prev = point; - } - else - { - point->next = first; - contour_index++; - if ( point + 1 < point_limit ) - { - end = points + source->contours[contour_index]; - first = point + 1; - prev = end; - } - } - } - } - - /* set-up the contours array */ - { - AH_Point* contour = outline->contours; - AH_Point* contour_limit = contour + outline->num_contours; - short* end = source->contours; - short idx = 0; - - - for ( ; contour < contour_limit; contour++, end++ ) - { - contour[0] = points + idx; - idx = (short)( end[0] + 1 ); - } - } - - /* compute directions of in & out vectors */ - { - for ( point = points; point < point_limit; point++ ) - { - AH_Point prev; - AH_Point next; - FT_Vector ivec, ovec; - - - prev = point->prev; - ivec.x = point->fx - prev->fx; - ivec.y = point->fy - prev->fy; - - point->in_dir = ah_compute_direction( ivec.x, ivec.y ); - - next = point->next; - ovec.x = next->fx - point->fx; - ovec.y = next->fy - point->fy; - - point->out_dir = ah_compute_direction( ovec.x, ovec.y ); - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - if ( point->flags & ( AH_FLAG_CONIC | AH_FLAG_CUBIC ) ) - { - Is_Weak_Point: - point->flags |= AH_FLAG_WEAK_INTERPOLATION; - } - else if ( point->out_dir == point->in_dir ) - { - AH_Angle angle_in, angle_out, delta; - - - if ( point->out_dir != AH_DIR_NONE ) - goto Is_Weak_Point; - - angle_in = ah_angle( &ivec ); - angle_out = ah_angle( &ovec ); - delta = angle_in - angle_out; - - if ( delta > AH_PI ) - delta = AH_2PI - delta; - - if ( delta < 0 ) - delta = -delta; - - if ( delta < 2 ) - goto Is_Weak_Point; - } - else if ( point->in_dir == -point->out_dir ) - goto Is_Weak_Point; -#endif - } - } - } - - Exit: - return error; - } - - - FT_LOCAL_DEF( void ) - ah_setup_uv( AH_Outline outline, - AH_UV source ) - { - AH_Point point = outline->points; - AH_Point point_limit = point + outline->num_points; - - - switch ( source ) - { - case AH_UV_FXY: - for ( ; point < point_limit; point++ ) - { - point->u = point->fx; - point->v = point->fy; - } - break; - - case AH_UV_FYX: - for ( ; point < point_limit; point++ ) - { - point->u = point->fy; - point->v = point->fx; - } - break; - - case AH_UV_OXY: - for ( ; point < point_limit; point++ ) - { - point->u = point->ox; - point->v = point->oy; - } - break; - - case AH_UV_OYX: - for ( ; point < point_limit; point++ ) - { - point->u = point->oy; - point->v = point->ox; - } - break; - - case AH_UV_YX: - for ( ; point < point_limit; point++ ) - { - point->u = point->y; - point->v = point->x; - } - break; - - case AH_UV_OX: - for ( ; point < point_limit; point++ ) - { - point->u = point->x; - point->v = point->ox; - } - break; - - case AH_UV_OY: - for ( ; point < point_limit; point++ ) - { - point->u = point->y; - point->v = point->oy; - } - break; - - default: - for ( ; point < point_limit; point++ ) - { - point->u = point->x; - point->v = point->y; - } - } - } - - - /* compute all inflex points in a given glyph */ - static void - ah_outline_compute_inflections( AH_Outline outline ) - { - AH_Point* contour = outline->contours; - AH_Point* contour_limit = contour + outline->num_contours; - - - /* load original coordinates in (u,v) */ - ah_setup_uv( outline, AH_UV_FXY ); - - /* do each contour separately */ - for ( ; contour < contour_limit; contour++ ) - { - FT_Vector vec; - AH_Point point = contour[0]; - AH_Point first = point; - AH_Point start = point; - AH_Point end = point; - AH_Point before; - AH_Point after; - AH_Angle angle_in, angle_seg, angle_out; - AH_Angle diff_in, diff_out; - FT_Int finished = 0; - - - /* compute first segment in contour */ - first = point; - - start = end = first; - do - { - end = end->next; - if ( end == first ) - goto Skip; - - } while ( end->u == first->u && end->v == first->v ); - - vec.x = end->u - start->u; - vec.y = end->v - start->v; - angle_seg = ah_angle( &vec ); - - /* extend the segment start whenever possible */ - before = start; - do - { - do - { - start = before; - before = before->prev; - if ( before == first ) - goto Skip; - - } while ( before->u == start->u && before->v == start->v ); - - vec.x = start->u - before->u; - vec.y = start->v - before->v; - angle_in = ah_angle( &vec ); - - } while ( angle_in == angle_seg ); - - first = start; - diff_in = ah_angle_diff( angle_in, angle_seg ); - - /* now, process all segments in the contour */ - do - { - /* first, extend current segment's end whenever possible */ - after = end; - do - { - do - { - end = after; - after = after->next; - if ( after == first ) - finished = 1; - - } while ( end->u == after->u && end->v == after->v ); - - vec.x = after->u - end->u; - vec.y = after->v - end->v; - angle_out = ah_angle( &vec ); - - } while ( angle_out == angle_seg ); - - diff_out = ah_angle_diff( angle_seg, angle_out ); - - if ( ( diff_in ^ diff_out ) < 0 ) - { - /* diff_in and diff_out have different signs, we have */ - /* inflection points here... */ - do - { - start->flags |= AH_FLAG_INFLECTION; - start = start->next; - - } while ( start != end ); - - start->flags |= AH_FLAG_INFLECTION; - } - - start = end; - end = after; - angle_seg = angle_out; - diff_in = diff_out; - - } while ( !finished ); - - Skip: - ; - } - } - - - FT_LOCAL_DEF( void ) - ah_outline_compute_segments( AH_Outline outline ) - { - int dimension; - AH_Segment segments; - FT_Int* p_num_segments; - AH_Direction segment_dir; - AH_Direction major_dir; - - - segments = outline->horz_segments; - p_num_segments = &outline->num_hsegments; - major_dir = AH_DIR_RIGHT; /* This value must be positive! */ - segment_dir = major_dir; - - /* set up (u,v) in each point */ - ah_setup_uv( outline, AH_UV_FYX ); - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Point* contour = outline->contours; - AH_Point* contour_limit = contour + outline->num_contours; - AH_Segment segment = segments; - FT_Int num_segments = 0; - -#ifdef AH_HINT_METRICS - AH_Point min_point = 0; - AH_Point max_point = 0; - FT_Pos min_coord = 32000; - FT_Pos max_coord = -32000; -#endif - - - /* do each contour separately */ - for ( ; contour < contour_limit; contour++ ) - { - AH_Point point = contour[0]; - AH_Point last = point->prev; - int on_edge = 0; - FT_Pos min_pos = 32000; /* minimum segment pos != min_coord */ - FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */ - FT_Bool passed; - - -#ifdef AH_HINT_METRICS - if ( point->u < min_coord ) - { - min_coord = point->u; - min_point = point; - } - if ( point->u > max_coord ) - { - max_coord = point->u; - max_point = point; - } -#endif - - if ( point == last ) /* skip singletons -- just in case */ - continue; - - if ( FT_ABS( last->out_dir ) == major_dir && - FT_ABS( point->out_dir ) == major_dir ) - { - /* we are already on an edge, try to locate its start */ - last = point; - - for (;;) - { - point = point->prev; - if ( FT_ABS( point->out_dir ) != major_dir ) - { - point = point->next; - break; - } - if ( point == last ) - break; - } - } - - last = point; - passed = 0; - - for (;;) - { - FT_Pos u, v; - - - if ( on_edge ) - { - u = point->u; - if ( u < min_pos ) - min_pos = u; - if ( u > max_pos ) - max_pos = u; - - if ( point->out_dir != segment_dir || point == last ) - { - /* we are just leaving an edge; record a new segment! */ - segment->last = point; - segment->pos = ( min_pos + max_pos ) >> 1; - - /* a segment is round if either its first or last point */ - /* is a control point */ - if ( ( segment->first->flags | point->flags ) & - AH_FLAG_CONTROL ) - segment->flags |= AH_EDGE_ROUND; - - /* compute segment size */ - min_pos = max_pos = point->v; - - v = segment->first->v; - if ( v < min_pos ) - min_pos = v; - if ( v > max_pos ) - max_pos = v; - - segment->min_coord = min_pos; - segment->max_coord = max_pos; - - on_edge = 0; - num_segments++; - segment++; - /* fallthrough */ - } - } - - /* now exit if we are at the start/end point */ - if ( point == last ) - { - if ( passed ) - break; - passed = 1; - } - - if ( !on_edge && FT_ABS( point->out_dir ) == major_dir ) - { - /* this is the start of a new segment! */ - segment_dir = point->out_dir; - - /* clear all segment fields */ - FT_ZERO( segment ); - - segment->dir = segment_dir; - segment->flags = AH_EDGE_NORMAL; - min_pos = max_pos = point->u; - segment->first = point; - segment->last = point; - segment->contour = contour; - segment->score = 32000; - segment->link = NULL; - on_edge = 1; - -#ifdef AH_HINT_METRICS - if ( point == max_point ) - max_point = 0; - - if ( point == min_point ) - min_point = 0; -#endif - } - - point = point->next; - } - - } /* contours */ - -#ifdef AH_HINT_METRICS - /* we need to ensure that there are edges on the left-most and */ - /* right-most points of the glyph in order to hint the metrics; */ - /* we do this by inserting fake segments when needed */ - if ( dimension == 0 ) - { - AH_Point point = outline->points; - AH_Point point_limit = point + outline->num_points; - - FT_Pos min_pos = 32000; - FT_Pos max_pos = -32000; - - - min_point = 0; - max_point = 0; - - /* compute minimum and maximum points */ - for ( ; point < point_limit; point++ ) - { - FT_Pos x = point->fx; - - - if ( x < min_pos ) - { - min_pos = x; - min_point = point; - } - if ( x > max_pos ) - { - max_pos = x; - max_point = point; - } - } - - /* insert minimum segment */ - if ( min_point ) - { - /* clear all segment fields */ - FT_ZERO( segment ); - - segment->dir = segment_dir; - segment->flags = AH_EDGE_NORMAL; - segment->first = min_point; - segment->last = min_point; - segment->pos = min_pos; - segment->score = 32000; - segment->link = NULL; - - num_segments++; - segment++; - } - - /* insert maximum segment */ - if ( max_point ) - { - /* clear all segment fields */ - FT_ZERO( segment ); - - segment->dir = segment_dir; - segment->flags = AH_EDGE_NORMAL; - segment->first = max_point; - segment->last = max_point; - segment->pos = max_pos; - segment->score = 32000; - segment->link = NULL; - - num_segments++; - segment++; - } - } -#endif /* AH_HINT_METRICS */ - - *p_num_segments = num_segments; - - segments = outline->vert_segments; - major_dir = AH_DIR_UP; - p_num_segments = &outline->num_vsegments; - - ah_setup_uv( outline, AH_UV_FXY ); - } - } - - - FT_LOCAL_DEF( void ) - ah_outline_link_segments( AH_Outline outline ) - { - AH_Segment segments; - AH_Segment segment_limit; - AH_Direction major_dir; - int dimension; - - - segments = outline->horz_segments; - segment_limit = segments + outline->num_hsegments; - major_dir = outline->horz_major_dir; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Segment seg1; - AH_Segment seg2; - -#if 0 - /* now compare each segment to the others */ - for ( seg1 = segments; seg1 < segment_limit; seg1++ ) - { - FT_Pos best_score; - AH_Segment best_segment; - - - /* the fake segments are introduced to hint the metrics -- */ - /* we must never link them to anything */ - if ( seg1->first == seg1->last ) - continue; - - best_segment = seg1->link; - if ( best_segment ) - best_score = seg1->score; - else - best_score = +32000; - - for ( seg2 = segments; seg2 < segment_limit; seg2++ ) - if ( seg1 != seg2 && seg1->dir + seg2->dir == 0 ) - { - FT_Pos pos1 = seg1->pos; - FT_Pos pos2 = seg2->pos; - FT_Bool is_dir; - FT_Bool is_pos; - - - /* check that the segments are correctly oriented and */ - /* positioned to form a black distance */ - - is_dir = (FT_Bool)( seg1->dir == outline->horz_major_dir || - seg1->dir == outline->vert_major_dir ); - is_pos = (FT_Bool)( pos1 > pos2 ); - - if ( pos1 == pos2 || !(is_dir ^ is_pos) ) - continue; - - { - FT_Pos min = seg1->min_coord; - FT_Pos max = seg1->max_coord; - FT_Pos len, dist, score; - - - if ( min < seg2->min_coord ) - min = seg2->min_coord; - - if ( max > seg2->max_coord ) - max = seg2->max_coord; - - len = max - min; - if ( len >= 8 ) - { - dist = seg2->pos - seg1->pos; - if ( dist < 0 ) - dist = -dist; - - score = dist + 3000 / len; - - if ( score < best_score ) - { - best_score = score; - best_segment = seg2; - } - } - } - } - - if ( best_segment ) - { - seg1->link = best_segment; - seg1->score = best_score; - best_segment->num_linked++; - } - } -#endif /* 0 */ - -#if 1 - /* the following code does the same, but much faster! */ - - /* now compare each segment to the others */ - for ( seg1 = segments; seg1 < segment_limit; seg1++ ) - { - /* the fake segments are introduced to hint the metrics -- */ - /* we must never link them to anything */ - if ( seg1->first == seg1->last || seg1->dir != major_dir ) - continue; - - for ( seg2 = segments; seg2 < segment_limit; seg2++ ) - if ( seg2 != seg1 && seg1->dir + seg2->dir == 0 ) - { - FT_Pos pos1 = seg1->pos; - FT_Pos pos2 = seg2->pos; - FT_Pos dist = pos2 - pos1; - - - if ( dist < 0 ) - continue; - - { - FT_Pos min = seg1->min_coord; - FT_Pos max = seg1->max_coord; - FT_Pos len, score; - - - if ( min < seg2->min_coord ) - min = seg2->min_coord; - - if ( max > seg2->max_coord ) - max = seg2->max_coord; - - len = max - min; - if ( len >= 8 ) - { - score = dist + 3000 / len; - - if ( score < seg1->score ) - { - seg1->score = score; - seg1->link = seg2; - } - - if ( score < seg2->score ) - { - seg2->score = score; - seg2->link = seg1; - } - } - } - } - } -#endif /* 1 */ - - /* now, compute the `serif' segments */ - for ( seg1 = segments; seg1 < segment_limit; seg1++ ) - { - seg2 = seg1->link; - - if ( seg2 ) - { - seg2->num_linked++; - if ( seg2->link != seg1 ) - { - seg1->link = 0; - seg1->serif = seg2->link; - } - } - } - - segments = outline->vert_segments; - segment_limit = segments + outline->num_vsegments; - major_dir = outline->vert_major_dir; - } - } - - - static void - ah_outline_compute_edges( AH_Outline outline ) - { - AH_Edge edges; - AH_Segment segments; - AH_Segment segment_limit; - AH_Direction up_dir; - FT_Int* p_num_edges; - FT_Int dimension; - FT_Fixed scale; - FT_Pos edge_distance_threshold; - - - edges = outline->horz_edges; - segments = outline->horz_segments; - segment_limit = segments + outline->num_hsegments; - p_num_edges = &outline->num_hedges; - up_dir = AH_DIR_RIGHT; - scale = outline->y_scale; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge edge; - AH_Edge edge_limit; /* really == edge + num_edges */ - AH_Segment seg; - - - /*********************************************************************/ - /* */ - /* We will begin by generating a sorted table of edges for the */ - /* current direction. To do so, we simply scan each segment and try */ - /* to find an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which will be processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the edges table is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ - - edge_distance_threshold = FT_MulFix( outline->edge_distance_threshold, - scale ); - if ( edge_distance_threshold > 64 / 4 ) - edge_distance_threshold = 64 / 4; - - edge_distance_threshold = FT_DivFix( edge_distance_threshold, - scale ); - - edge_limit = edges; - for ( seg = segments; seg < segment_limit; seg++ ) - { - AH_Edge found = 0; - - - /* look for an edge corresponding to the segment */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - FT_Pos dist; - - - dist = seg->pos - edge->fpos; - if ( dist < 0 ) - dist = -dist; - - if ( dist < edge_distance_threshold ) - { - found = edge; - break; - } - } - - if ( !found ) - { - /* insert a new edge in the list and */ - /* sort according to the position */ - while ( edge > edges && edge[-1].fpos > seg->pos ) - { - edge[0] = edge[-1]; - edge--; - } - edge_limit++; - - /* clear all edge fields */ - FT_MEM_ZERO( edge, sizeof ( *edge ) ); - - /* add the segment to the new edge's list */ - edge->first = seg; - edge->last = seg; - edge->fpos = seg->pos; - edge->opos = edge->pos = FT_MulFix( seg->pos, scale ); - seg->edge_next = seg; - } - else - { - /* if an edge was found, simply add the segment to the edge's */ - /* list */ - seg->edge_next = edge->first; - edge->last->edge_next = seg; - edge->last = seg; - } - } - *p_num_edges = (FT_Int)( edge_limit - edges ); - - - /*********************************************************************/ - /* */ - /* Good, we will now compute each edge's properties according to */ - /* segments found on its position. Basically, these are: */ - /* */ - /* - edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straight or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /*********************************************************************/ - - /* first of all, set the `edge' field in each segment -- this is */ - /* required in order to compute edge links */ - - /* Note that I've tried to remove this loop, setting - * the "edge" field of each segment directly in the - * code above. For some reason, it slows down execution - * speed -- on a Sun. - */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - seg = edge->first; - if ( seg ) - do - { - seg->edge = edge; - seg = seg->edge_next; - } - while ( seg != edge->first ); - } - - /* now, compute each edge properties */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - FT_Int is_round = 0; /* does it contain round segments? */ - FT_Int is_straight = 0; /* does it contain straight segments? */ - FT_Pos ups = 0; /* number of upwards segments */ - FT_Pos downs = 0; /* number of downwards segments */ - - - seg = edge->first; - - do - { - FT_Bool is_serif; - - - /* check for roundness of segment */ - if ( seg->flags & AH_EDGE_ROUND ) - is_round++; - else - is_straight++; - - /* check for segment direction */ - if ( seg->dir == up_dir ) - ups += seg->max_coord-seg->min_coord; - else - downs += seg->max_coord-seg->min_coord; - - /* check for links -- if seg->serif is set, then seg->link must */ - /* be ignored */ - is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge ); - - if ( seg->link || is_serif ) - { - AH_Edge edge2; - AH_Segment seg2; - - - edge2 = edge->link; - seg2 = seg->link; - - if ( is_serif ) - { - seg2 = seg->serif; - edge2 = edge->serif; - } - - if ( edge2 ) - { - FT_Pos edge_delta; - FT_Pos seg_delta; - - - edge_delta = edge->fpos - edge2->fpos; - if ( edge_delta < 0 ) - edge_delta = -edge_delta; - - seg_delta = seg->pos - seg2->pos; - if ( seg_delta < 0 ) - seg_delta = -seg_delta; - - if ( seg_delta < edge_delta ) - edge2 = seg2->edge; - } - else - edge2 = seg2->edge; - -#ifdef FT_CONFIG_CHESTER_SERIF - if ( is_serif ) - { - edge->serif = edge2; - edge2->flags |= AH_EDGE_SERIF; - } - else - edge->link = edge2; -#else /* !FT_CONFIG_CHESTER_SERIF */ - if ( is_serif ) - edge->serif = edge2; - else - edge->link = edge2; -#endif /* !FT_CONFIG_CHESTER_SERIF */ - } - - seg = seg->edge_next; - - } while ( seg != edge->first ); - - /* set the round/straight flags */ - edge->flags = AH_EDGE_NORMAL; - - if ( is_round > 0 && is_round >= is_straight ) - edge->flags |= AH_EDGE_ROUND; - - /* set the edge's main direction */ - edge->dir = AH_DIR_NONE; - - if ( ups > downs ) - edge->dir = up_dir; - - else if ( ups < downs ) - edge->dir = -up_dir; - - else if ( ups == downs ) - edge->dir = 0; /* both up and down! */ - - /* gets rid of serifs if link is set */ - /* XXX: This gets rid of many unpleasant artefacts! */ - /* Example: the `c' in cour.pfa at size 13 */ - - if ( edge->serif && edge->link ) - edge->serif = 0; - } - - edges = outline->vert_edges; - segments = outline->vert_segments; - segment_limit = segments + outline->num_vsegments; - p_num_edges = &outline->num_vedges; - up_dir = AH_DIR_UP; - scale = outline->x_scale; - } - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_detect_features */ - /* */ - /* <Description> */ - /* Performs feature detection on a given AH_OutlineRec object. */ - /* */ - FT_LOCAL_DEF( void ) - ah_outline_detect_features( AH_Outline outline ) - { - ah_outline_compute_segments ( outline ); - ah_outline_link_segments ( outline ); - ah_outline_compute_edges ( outline ); - ah_outline_compute_inflections( outline ); - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_compute_blue_edges */ - /* */ - /* <Description> */ - /* Computes the `blue edges' in a given outline (i.e. those that must */ - /* be snapped to a blue zone edge (top or bottom). */ - /* */ - FT_LOCAL_DEF( void ) - ah_outline_compute_blue_edges( AH_Outline outline, - AH_Face_Globals face_globals ) - { - AH_Edge edge = outline->horz_edges; - AH_Edge edge_limit = edge + outline->num_hedges; - AH_Globals globals = &face_globals->design; - FT_Fixed y_scale = outline->y_scale; - - FT_Bool blue_active[AH_BLUE_MAX]; - - - /* compute which blue zones are active, i.e. have their scaled */ - /* size < 3/4 pixels */ - { - AH_Blue blue; - FT_Bool check = 0; - - - for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ ) - { - FT_Pos ref, shoot, dist; - - - ref = globals->blue_refs[blue]; - shoot = globals->blue_shoots[blue]; - dist = ref - shoot; - if ( dist < 0 ) - dist = -dist; - - blue_active[blue] = 0; - - if ( FT_MulFix( dist, y_scale ) < 48 ) - { - blue_active[blue] = 1; - check = 1; - } - } - - /* return immediately if no blue zone is active */ - if ( !check ) - return; - } - - /* for each horizontal edge search the blue zone which is closest */ - for ( ; edge < edge_limit; edge++ ) - { - AH_Blue blue; - FT_Pos* best_blue = 0; - FT_Pos best_dist; /* initial threshold */ - - - /* compute the initial threshold as a fraction of the EM size */ - best_dist = FT_MulFix( face_globals->face->units_per_EM / 40, y_scale ); - -#ifdef FT_CONFIG_CHESTER_SMALL_F - if ( best_dist > 64 / 2 ) - best_dist = 64 / 2; -#else - if ( best_dist > 64 / 4 ) - best_dist = 64 / 4; -#endif - - for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ ) - { - /* if it is a top zone, check for right edges -- if it is a bottom */ - /* zone, check for left edges */ - /* */ - /* of course, that's for TrueType XXX */ - FT_Bool is_top_blue = - FT_BOOL( AH_IS_TOP_BLUE( blue ) ); - FT_Bool is_major_dir = - FT_BOOL( edge->dir == outline->horz_major_dir ); - - - if ( !blue_active[blue] ) - continue; - - /* if it is a top zone, the edge must be against the major */ - /* direction; if it is a bottom zone, it must be in the major */ - /* direction */ - if ( is_top_blue ^ is_major_dir ) - { - FT_Pos dist; - FT_Pos* blue_pos = globals->blue_refs + blue; - - - /* first of all, compare it to the reference position */ - dist = edge->fpos - *blue_pos; - if ( dist < 0 ) - dist = -dist; - - dist = FT_MulFix( dist, y_scale ); - if ( dist < best_dist ) - { - best_dist = dist; - best_blue = blue_pos; - } - - /* now, compare it to the overshoot position if the edge is */ - /* rounded, and if the edge is over the reference position of a */ - /* top zone, or under the reference position of a bottom zone */ - if ( edge->flags & AH_EDGE_ROUND && dist != 0 ) - { - FT_Bool is_under_ref = FT_BOOL( edge->fpos < *blue_pos ); - - - if ( is_top_blue ^ is_under_ref ) - { - blue_pos = globals->blue_shoots + blue; - dist = edge->fpos - *blue_pos; - if ( dist < 0 ) - dist = -dist; - - dist = FT_MulFix( dist, y_scale ); - if ( dist < best_dist ) - { - best_dist = dist; - best_blue = blue_pos; - } - } - } - } - } - - if ( best_blue ) - edge->blue_edge = best_blue; - } - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ah_outline_scale_blue_edges */ - /* */ - /* <Description> */ - /* This function must be called before hinting in order to re-adjust */ - /* the contents of the detected edges (basically change the `blue */ - /* edge' pointer from `design units' to `scaled ones'). */ - /* */ - FT_LOCAL_DEF( void ) - ah_outline_scale_blue_edges( AH_Outline outline, - AH_Face_Globals globals ) - { - AH_Edge edge = outline->horz_edges; - AH_Edge edge_limit = edge + outline->num_hedges; - FT_Pos delta; - - - delta = globals->scaled.blue_refs - globals->design.blue_refs; - - for ( ; edge < edge_limit; edge++ ) - { - if ( edge->blue_edge ) - edge->blue_edge += delta; - } - } - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahglyph.h b/src/libs/freetype2/autohint/ahglyph.h deleted file mode 100644 index b346cbe8b6..0000000000 --- a/src/libs/freetype2/autohint/ahglyph.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahglyph.h */ -/* */ -/* Routines used to load and analyze a given glyph before hinting */ -/* (specification). */ -/* */ -/* Copyright 2000-2001, 2002 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#ifndef __AHGLYPH_H__ -#define __AHGLYPH_H__ - - -#include <ft2build.h> -#include "ahtypes.h" - - -FT_BEGIN_HEADER - - - typedef enum AH_UV_ - { - AH_UV_FXY, - AH_UV_FYX, - AH_UV_OXY, - AH_UV_OYX, - AH_UV_OX, - AH_UV_OY, - AH_UV_YX, - AH_UV_XY /* should always be last! */ - - } AH_UV; - - - FT_LOCAL( void ) - ah_setup_uv( AH_Outline outline, - AH_UV source ); - - - /* AH_OutlineRec functions - they should be typically called in this order */ - - FT_LOCAL( FT_Error ) - ah_outline_new( FT_Memory memory, - AH_Outline* aoutline ); - - FT_LOCAL( FT_Error ) - ah_outline_load( AH_Outline outline, - FT_Fixed x_scale, - FT_Fixed y_scale, - FT_Face face ); - - FT_LOCAL( void ) - ah_outline_compute_segments( AH_Outline outline ); - - FT_LOCAL( void ) - ah_outline_link_segments( AH_Outline outline ); - - FT_LOCAL( void ) - ah_outline_detect_features( AH_Outline outline ); - - FT_LOCAL( void ) - ah_outline_compute_blue_edges( AH_Outline outline, - AH_Face_Globals globals ); - - FT_LOCAL( void ) - ah_outline_scale_blue_edges( AH_Outline outline, - AH_Face_Globals globals ); - - FT_LOCAL( void ) - ah_outline_save( AH_Outline outline, - AH_Loader loader ); - - FT_LOCAL( void ) - ah_outline_done( AH_Outline outline ); - - -FT_END_HEADER - -#endif /* __AHGLYPH_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahhint.c b/src/libs/freetype2/autohint/ahhint.c deleted file mode 100644 index 69ac954705..0000000000 --- a/src/libs/freetype2/autohint/ahhint.c +++ /dev/null @@ -1,1921 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahhint.c */ -/* */ -/* Glyph hinter (body). */ -/* */ -/* Copyright 2000-2001, 2002, 2003, 2004 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include "ahhint.h" -#include "ahglyph.h" -#include "ahangles.h" -#include "aherrors.h" -#include FT_OUTLINE_H - - -#define FACE_GLOBALS( face ) ( (AH_Face_Globals)(face)->autohint.data ) - -#define AH_USE_IUP -#define OPTIM_STEM_SNAP - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** Hinting routines ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - /* snap a given width in scaled coordinates to one of the */ - /* current standard widths */ - static FT_Pos - ah_snap_width( FT_Pos* widths, - FT_Int count, - FT_Pos width ) - { - int n; - FT_Pos best = 64 + 32 + 2; - FT_Pos reference = width; - FT_Pos scaled; - - - for ( n = 0; n < count; n++ ) - { - FT_Pos w; - FT_Pos dist; - - - w = widths[n]; - dist = width - w; - if ( dist < 0 ) - dist = -dist; - if ( dist < best ) - { - best = dist; - reference = w; - } - } - - scaled = FT_PIX_ROUND( reference ); - - if ( width >= reference ) - { - if ( width < scaled + 48 ) - width = reference; - } - else - { - if ( width > scaled - 48 ) - width = reference; - } - - return width; - } - - - /* compute the snapped width of a given stem */ - -#ifdef FT_CONFIG_CHESTER_SERIF - - static FT_Pos - ah_compute_stem_width( AH_Hinter hinter, - int vertical, - FT_Pos width, - AH_Edge_Flags base_flags, - AH_Edge_Flags stem_flags ) - { - AH_Globals globals = &hinter->globals->scaled; - FT_Pos dist = width; - FT_Int sign = 0; - - - if ( dist < 0 ) - { - dist = -width; - sign = 1; - } - - if ( !hinter->do_stem_adjust ) - { - /* leave stem widths unchanged */ - } - else if ( ( vertical && !hinter->do_vert_snapping ) || - ( !vertical && !hinter->do_horz_snapping ) ) - { - /* smooth hinting process: very lightly quantize the stem width */ - /* */ - - /* leave the widths of serifs alone */ - - if ( ( stem_flags & AH_EDGE_SERIF ) && vertical && ( dist < 3 * 64 ) ) - goto Done_Width; - - else if ( ( base_flags & AH_EDGE_ROUND ) ) - { - if ( dist < 80 ) - dist = 64; - } - else if ( dist < 56 ) - dist = 56; - - { - FT_Pos delta = dist - globals->stds[vertical]; - - - if ( delta < 0 ) - delta = -delta; - - if ( delta < 40 ) - { - dist = globals->stds[vertical]; - if ( dist < 48 ) - dist = 48; - - goto Done_Width; - } - - if ( dist < 3 * 64 ) - { - delta = dist & 63; - dist &= -64; - - if ( delta < 10 ) - dist += delta; - - else if ( delta < 32 ) - dist += 10; - - else if ( delta < 54 ) - dist += 54; - - else - dist += delta; - } - else - dist = ( dist + 32 ) & ~63; - } - } - else - { - /* strong hinting process: snap the stem width to integer pixels */ - /* */ - if ( vertical ) - { - dist = ah_snap_width( globals->heights, globals->num_heights, dist ); - - /* in the case of vertical hinting, always round */ - /* the stem heights to integer pixels */ - if ( dist >= 64 ) - dist = ( dist + 16 ) & ~63; - else - dist = 64; - } - else - { - dist = ah_snap_width( globals->widths, globals->num_widths, dist ); - - if ( hinter->flags & AH_HINTER_MONOCHROME ) - { - /* monochrome horizontal hinting: snap widths to integer pixels */ - /* with a different threshold */ - if ( dist < 64 ) - dist = 64; - else - dist = ( dist + 32 ) & ~63; - } - else - { - /* for horizontal anti-aliased hinting, we adopt a more subtle */ - /* approach: we strengthen small stems, round stems whose size */ - /* is between 1 and 2 pixels to an integer, otherwise nothing */ - if ( dist < 48 ) - dist = ( dist + 64 ) >> 1; - - else if ( dist < 128 ) - dist = ( dist + 22 ) & ~63; - else - /* XXX: round otherwise to prevent color fringes in LCD mode */ - dist = ( dist + 32 ) & ~63; - } - } - } - - Done_Width: - if ( sign ) - dist = -dist; - - return dist; - } - -#else /* !FT_CONFIG_CHESTER_SERIF */ - - static FT_Pos - ah_compute_stem_width( AH_Hinter hinter, - int vertical, - FT_Pos width ) - { - AH_Globals globals = &hinter->globals->scaled; - FT_Pos dist = width; - FT_Int sign = 0; - - - if ( dist < 0 ) - { - dist = -width; - sign = 1; - } - - if ( !hinter->do_stem_adjust ) - { - /* leave stem widths unchanged */ - } - else if ( ( vertical && !hinter->do_vert_snapping ) || - ( !vertical && !hinter->do_horz_snapping ) ) - { - /* smooth hinting process: very lightly quantize the stem width */ - /* */ - if ( dist < 64 ) - dist = 64; - - { - FT_Pos delta = dist - globals->stds[vertical]; - - - if ( delta < 0 ) - delta = -delta; - - if ( delta < 40 ) - { - dist = globals->stds[vertical]; - if ( dist < 48 ) - dist = 48; - } - - if ( dist < 3 * 64 ) - { - delta = dist & 63; - dist &= -64; - - if ( delta < 10 ) - dist += delta; - - else if ( delta < 32 ) - dist += 10; - - else if ( delta < 54 ) - dist += 54; - - else - dist += delta; - } - else - dist = ( dist + 32 ) & ~63; - } - } - else - { - /* strong hinting process: snap the stem width to integer pixels */ - /* */ - if ( vertical ) - { - dist = ah_snap_width( globals->heights, globals->num_heights, dist ); - - /* in the case of vertical hinting, always round */ - /* the stem heights to integer pixels */ - if ( dist >= 64 ) - dist = ( dist + 16 ) & ~63; - else - dist = 64; - } - else - { - dist = ah_snap_width( globals->widths, globals->num_widths, dist ); - - if ( hinter->flags & AH_HINTER_MONOCHROME ) - { - /* monochrome horizontal hinting: snap widths to integer pixels */ - /* with a different threshold */ - if ( dist < 64 ) - dist = 64; - else - dist = ( dist + 32 ) & ~63; - } - else - { - /* for horizontal anti-aliased hinting, we adopt a more subtle */ - /* approach: we strengthen small stems, round stems whose size */ - /* is between 1 and 2 pixels to an integer, otherwise nothing */ - if ( dist < 48 ) - dist = ( dist + 64 ) >> 1; - - else if ( dist < 128 ) - dist = ( dist + 22 ) & ~63; - else - /* XXX: round otherwise to prevent color fringes in LCD mode */ - dist = ( dist + 32 ) & ~63; - } - } - } - - if ( sign ) - dist = -dist; - - return dist; - } - -#endif /* !FT_CONFIG_CHESTER_SERIF */ - - - /* align one stem edge relative to the previous stem edge */ - static void - ah_align_linked_edge( AH_Hinter hinter, - AH_Edge base_edge, - AH_Edge stem_edge, - int vertical ) - { - FT_Pos dist = stem_edge->opos - base_edge->opos; - -#ifdef FT_CONFIG_CHESTER_SERIF - - FT_Pos fitted_width = ah_compute_stem_width( hinter, - vertical, - dist, - base_edge->flags, - stem_edge->flags ); - - - stem_edge->pos = base_edge->pos + fitted_width; - -#else - - stem_edge->pos = base_edge->pos + - ah_compute_stem_width( hinter, vertical, dist ); - -#endif - - } - - - static void - ah_align_serif_edge( AH_Hinter hinter, - AH_Edge base, - AH_Edge serif, - int vertical ) - { - FT_Pos dist; - FT_Pos sign = 1; - - FT_UNUSED( hinter ); - FT_UNUSED( vertical ); - - - dist = serif->opos - base->opos; - if ( dist < 0 ) - { - dist = -dist; - sign = -1; - } - -#if 0 - /* do not touch serifs widths! */ - if ( base->flags & AH_EDGE_DONE ) - { - if ( dist >= 64 ) - dist = ( dist + 8 ) & ~63; - - else if ( dist <= 32 && !vertical ) - dist = ( dist + 33 ) >> 1; - - else - dist = 0; - } -#endif - - serif->pos = base->pos + sign * dist; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** E D G E H I N T I N G ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - FT_LOCAL_DEF( void ) - ah_hinter_hint_edges( AH_Hinter hinter ) - { - AH_Edge edges; - AH_Edge edge_limit; - AH_Outline outline = hinter->glyph; - FT_Int dimension; - FT_Int n_edges; - - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge edge; - AH_Edge anchor = 0; - int has_serifs = 0; - - - if ( !hinter->do_horz_hints && !dimension ) - goto Next_Dimension; - - if ( !hinter->do_vert_hints && dimension ) - goto Next_Dimension; - - /* we begin by aligning all stems relative to the blue zone */ - /* if needed -- that's only for horizontal edges */ - if ( dimension ) - { - for ( edge = edges; edge < edge_limit; edge++ ) - { - FT_Pos* blue; - AH_EdgeRec *edge1, *edge2; - - - if ( edge->flags & AH_EDGE_DONE ) - continue; - - blue = edge->blue_edge; - edge1 = 0; - edge2 = edge->link; - - if ( blue ) - { - edge1 = edge; - } - else if ( edge2 && edge2->blue_edge ) - { - blue = edge2->blue_edge; - edge1 = edge2; - edge2 = edge; - } - - if ( !edge1 ) - continue; - - edge1->pos = blue[0]; - edge1->flags |= AH_EDGE_DONE; - - if ( edge2 && !edge2->blue_edge ) - { - ah_align_linked_edge( hinter, edge1, edge2, dimension ); - edge2->flags |= AH_EDGE_DONE; - } - - if ( !anchor ) - anchor = edge; - } - } - - /* now we will align all stem edges, trying to maintain the */ - /* relative order of stems in the glyph */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - AH_EdgeRec* edge2; - - - if ( edge->flags & AH_EDGE_DONE ) - continue; - - /* skip all non-stem edges */ - edge2 = edge->link; - if ( !edge2 ) - { - has_serifs++; - continue; - } - - /* now align the stem */ - - /* this should not happen, but it's better to be safe */ - if ( edge2->blue_edge || edge2 < edge ) - { - ah_align_linked_edge( hinter, edge2, edge, dimension ); - edge->flags |= AH_EDGE_DONE; - continue; - } - - if ( !anchor ) - { - -#ifdef FT_CONFIG_CHESTER_STEM - - FT_Pos org_len, org_center, cur_len; - FT_Pos cur_pos1, error1, error2, u_off, d_off; - - - org_len = edge2->opos - edge->opos; - cur_len = ah_compute_stem_width( hinter, dimension, org_len, - edge->flags, edge2->flags ); - - if ( cur_len <= 64 ) - u_off = d_off = 32; - else - { - u_off = 38; - d_off = 26; - } - - if ( cur_len < 96 ) - { - org_center = edge->opos + ( org_len >> 1 ); - - cur_pos1 = FT_PIX_ROUND( org_center ); - - error1 = org_center - ( cur_pos1 - u_off ); - if ( error1 < 0 ) - error1 = -error1; - - error2 = org_center - ( cur_pos1 + d_off ); - if ( error2 < 0 ) - error2 = -error2; - - if ( error1 < error2 ) - cur_pos1 -= u_off; - else - cur_pos1 += d_off; - - edge->pos = cur_pos1 - cur_len / 2; - edge2->pos = cur_pos1 + cur_len / 2; - - } - else - edge->pos = FT_PIX_ROUND( edge->opos ); - - anchor = edge; - - edge->flags |= AH_EDGE_DONE; - - ah_align_linked_edge( hinter, edge, edge2, dimension ); - -#else /* !FT_CONFIG_CHESTER_STEM */ - - edge->pos = FT_PIX_ROUND( edge->opos ); - anchor = edge; - - edge->flags |= AH_EDGE_DONE; - - ah_align_linked_edge( hinter, edge, edge2, dimension ); - -#endif /* !FT_CONFIG_CHESTER_STEM */ - - } - else - { - FT_Pos org_pos, org_len, org_center, cur_len; - FT_Pos cur_pos1, cur_pos2, delta1, delta2; - - - org_pos = anchor->pos + ( edge->opos - anchor->opos ); - org_len = edge2->opos - edge->opos; - org_center = org_pos + ( org_len >> 1 ); - -#ifdef FT_CONFIG_CHESTER_SERIF - - cur_len = ah_compute_stem_width( hinter, dimension, org_len, - edge->flags, edge2->flags ); - - -#else /* !FT_CONFIG_CHESTER_SERIF */ - - cur_len = ah_compute_stem_width( hinter, dimension, org_len ); - -#endif /* !FT_CONFIG_CHESTER_SERIF */ - -#ifdef FT_CONFIG_CHESTER_STEM - - if ( cur_len < 96 ) - { - FT_Pos u_off, d_off; - - - cur_pos1 = FT_PIX_ROUND( org_center ); - - if (cur_len <= 64 ) - u_off = d_off = 32; - else - { - u_off = 38; - d_off = 26; - } - - delta1 = org_center - ( cur_pos1 - u_off ); - if ( delta1 < 0 ) - delta1 = -delta1; - - delta2 = org_center - ( cur_pos1 + d_off ); - if ( delta2 < 0 ) - delta2 = -delta2; - - if ( delta1 < delta2 ) - cur_pos1 -= u_off; - else - cur_pos1 += d_off; - - edge->pos = cur_pos1 - cur_len / 2; - edge2->pos = cur_pos1 + cur_len / 2; - } - else - { - org_pos = anchor->pos + ( edge->opos - anchor->opos ); - org_len = edge2->opos - edge->opos; - org_center = org_pos + ( org_len >> 1 ); - - cur_len = ah_compute_stem_width( hinter, dimension, org_len, - edge->flags, edge2->flags ); - - cur_pos1 = FT_PIX_ROUND( org_pos ); - delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center ); - if ( delta1 < 0 ) - delta1 = -delta1; - - cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len; - delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center ); - if ( delta2 < 0 ) - delta2 = -delta2; - - edge->pos = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2; - edge2->pos = edge->pos + cur_len; - } - -#else /* !FT_CONFIG_CHESTER_STEM */ - - cur_pos1 = FT_PIX_ROUND( org_pos ); - delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center ); - if ( delta1 < 0 ) - delta1 = -delta1; - - cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len; - delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center ); - if ( delta2 < 0 ) - delta2 = -delta2; - - edge->pos = ( delta1 <= delta2 ) ? cur_pos1 : cur_pos2; - edge2->pos = edge->pos + cur_len; - -#endif /* !FT_CONFIG_CHESTER_STEM */ - - edge->flags |= AH_EDGE_DONE; - edge2->flags |= AH_EDGE_DONE; - - if ( edge > edges && edge->pos < edge[-1].pos ) - edge->pos = edge[-1].pos; - } - } - - /* make sure that lowercase m's maintain their symmetry */ - - /* In general, lowercase m's have six vertical edges if they are sans */ - /* serif, or twelve if they are avec serif. This implementation is */ - /* based on that assumption, and seems to work very well with most */ - /* faces. However, if for a certain face this assumption is not */ - /* true, the m is just rendered like before. In addition, any stem */ - /* correction will only be applied to symmetrical glyphs (even if the */ - /* glyph is not an m), so the potential for unwanted distortion is */ - /* relatively low. */ - - /* We don't handle horizontal edges since we can't easily assure that */ - /* the third (lowest) stem aligns with the base line; it might end up */ - /* one pixel higher or lower. */ - - n_edges = (FT_Int)( edge_limit - edges ); - if ( !dimension && ( n_edges == 6 || n_edges == 12 ) ) - { - AH_EdgeRec *edge1, *edge2, *edge3; - FT_Pos dist1, dist2, span, delta; - - - if ( n_edges == 6 ) - { - edge1 = edges; - edge2 = edges + 2; - edge3 = edges + 4; - } - else - { - edge1 = edges + 1; - edge2 = edges + 5; - edge3 = edges + 9; - } - - dist1 = edge2->opos - edge1->opos; - dist2 = edge3->opos - edge2->opos; - - span = dist1 - dist2; - if ( span < 0 ) - span = -span; - - if ( span < 8 ) - { - delta = edge3->pos - ( 2 * edge2->pos - edge1->pos ); - edge3->pos -= delta; - if ( edge3->link ) - edge3->link->pos -= delta; - - /* move the serifs along with the stem */ - if ( n_edges == 12 ) - { - ( edges + 8 )->pos -= delta; - ( edges + 11 )->pos -= delta; - } - - edge3->flags |= AH_EDGE_DONE; - if ( edge3->link ) - edge3->link->flags |= AH_EDGE_DONE; - } - } - - if ( !has_serifs ) - goto Next_Dimension; - - /* now hint the remaining edges (serifs and single) in order */ - /* to complete our processing */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - if ( edge->flags & AH_EDGE_DONE ) - continue; - - if ( edge->serif ) - ah_align_serif_edge( hinter, edge->serif, edge, dimension ); - else if ( !anchor ) - { - edge->pos = FT_PIX_ROUND( edge->opos ); - anchor = edge; - } - else - edge->pos = anchor->pos + - FT_PIX_ROUND( edge->opos - anchor->opos ); - - edge->flags |= AH_EDGE_DONE; - - if ( edge > edges && edge->pos < edge[-1].pos ) - edge->pos = edge[-1].pos; - - if ( edge + 1 < edge_limit && - edge[1].flags & AH_EDGE_DONE && - edge->pos > edge[1].pos ) - edge->pos = edge[1].pos; - } - - Next_Dimension: - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - } - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** P O I N T H I N T I N G ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - static void - ah_hinter_align_edge_points( AH_Hinter hinter ) - { - AH_Outline outline = hinter->glyph; - AH_Edge edges; - AH_Edge edge_limit; - FT_Int dimension; - - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge edge; - - - edge = edges; - for ( ; edge < edge_limit; edge++ ) - { - /* move the points of each segment */ - /* in each edge to the edge's position */ - AH_Segment seg = edge->first; - - - do - { - AH_Point point = seg->first; - - - for (;;) - { - if ( dimension ) - { - point->y = edge->pos; - point->flags |= AH_FLAG_TOUCH_Y; - } - else - { - point->x = edge->pos; - point->flags |= AH_FLAG_TOUCH_X; - } - - if ( point == seg->last ) - break; - - point = point->next; - } - - seg = seg->edge_next; - - } while ( seg != edge->first ); - } - - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - } - } - - - /* hint the strong points -- this is equivalent to the TrueType `IP' */ - /* hinting instruction */ - static void - ah_hinter_align_strong_points( AH_Hinter hinter ) - { - AH_Outline outline = hinter->glyph; - FT_Int dimension; - AH_Edge edges; - AH_Edge edge_limit; - AH_Point points; - AH_Point point_limit; - AH_Flags touch_flag; - - - points = outline->points; - point_limit = points + outline->num_points; - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - touch_flag = AH_FLAG_TOUCH_Y; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Point point; - AH_Edge edge; - - - if ( edges < edge_limit ) - for ( point = points; point < point_limit; point++ ) - { - FT_Pos u, ou, fu; /* point position */ - FT_Pos delta; - - - if ( point->flags & touch_flag ) - continue; - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - /* if this point is candidate to weak interpolation, we will */ - /* interpolate it after all strong points have been processed */ - if ( ( point->flags & AH_FLAG_WEAK_INTERPOLATION ) && - !( point->flags & AH_FLAG_INFLECTION ) ) - continue; -#endif - - if ( dimension ) - { - u = point->fy; - ou = point->oy; - } - else - { - u = point->fx; - ou = point->ox; - } - - fu = u; - - /* is the point before the first edge? */ - edge = edges; - delta = edge->fpos - u; - if ( delta >= 0 ) - { - u = edge->pos - ( edge->opos - ou ); - goto Store_Point; - } - - /* is the point after the last edge? */ - edge = edge_limit - 1; - delta = u - edge->fpos; - if ( delta >= 0 ) - { - u = edge->pos + ( ou - edge->opos ); - goto Store_Point; - } - -#if 1 - { - FT_UInt min, max, mid; - FT_Pos fpos; - - - /* find enclosing edges */ - min = 0; - max = (FT_UInt)( edge_limit - edges ); - - while ( min < max ) - { - mid = ( max + min ) >> 1; - edge = edges + mid; - fpos = edge->fpos; - - if ( u < fpos ) - max = mid; - else if ( u > fpos ) - min = mid + 1; - else - { - /* we are on the edge */ - u = edge->pos; - goto Store_Point; - } - } - - { - AH_Edge before = edges + min - 1; - AH_Edge after = edges + min + 0; - - - /* assert( before && after && before != after ) */ - if ( before->scale == 0 ) - before->scale = FT_DivFix( after->pos - before->pos, - after->fpos - before->fpos ); - - u = before->pos + FT_MulFix( fu - before->fpos, - before->scale ); - } - } - -#else /* !0 */ - - /* otherwise, interpolate the point in between */ - { - AH_Edge before = 0; - AH_Edge after = 0; - - - for ( edge = edges; edge < edge_limit; edge++ ) - { - if ( u == edge->fpos ) - { - u = edge->pos; - goto Store_Point; - } - if ( u < edge->fpos ) - break; - before = edge; - } - - for ( edge = edge_limit - 1; edge >= edges; edge-- ) - { - if ( u == edge->fpos ) - { - u = edge->pos; - goto Store_Point; - } - if ( u > edge->fpos ) - break; - after = edge; - } - - if ( before->scale == 0 ) - before->scale = FT_DivFix( after->pos - before->pos, - after->fpos - before->fpos ); - - u = before->pos + FT_MulFix( fu - before->fpos, - before->scale ); - } - -#endif /* !0 */ - - Store_Point: - - /* save the point position */ - if ( dimension ) - point->y = u; - else - point->x = u; - - point->flags |= touch_flag; - } - - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - touch_flag = AH_FLAG_TOUCH_X; - } - } - - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - - static void - ah_iup_shift( AH_Point p1, - AH_Point p2, - AH_Point ref ) - { - AH_Point p; - FT_Pos delta = ref->u - ref->v; - - - for ( p = p1; p < ref; p++ ) - p->u = p->v + delta; - - for ( p = ref + 1; p <= p2; p++ ) - p->u = p->v + delta; - } - - - static void - ah_iup_interp( AH_Point p1, - AH_Point p2, - AH_Point ref1, - AH_Point ref2 ) - { - AH_Point p; - FT_Pos u; - FT_Pos v1 = ref1->v; - FT_Pos v2 = ref2->v; - FT_Pos d1 = ref1->u - v1; - FT_Pos d2 = ref2->u - v2; - - - if ( p1 > p2 ) - return; - - if ( v1 == v2 ) - { - for ( p = p1; p <= p2; p++ ) - { - u = p->v; - - if ( u <= v1 ) - u += d1; - else - u += d2; - - p->u = u; - } - return; - } - - if ( v1 < v2 ) - { - for ( p = p1; p <= p2; p++ ) - { - u = p->v; - - if ( u <= v1 ) - u += d1; - else if ( u >= v2 ) - u += d2; - else - u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 ); - - p->u = u; - } - } - else - { - for ( p = p1; p <= p2; p++ ) - { - u = p->v; - - if ( u <= v2 ) - u += d2; - else if ( u >= v1 ) - u += d1; - else - u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 ); - - p->u = u; - } - } - } - - - /* interpolate weak points -- this is equivalent to the TrueType `IUP' */ - /* hinting instruction */ - static void - ah_hinter_align_weak_points( AH_Hinter hinter ) - { - AH_Outline outline = hinter->glyph; - FT_Int dimension; - AH_Point points; - AH_Point point_limit; - AH_Point* contour_limit; - AH_Flags touch_flag; - - - points = outline->points; - point_limit = points + outline->num_points; - - /* PASS 1: Move segment points to edge positions */ - - touch_flag = AH_FLAG_TOUCH_Y; - - contour_limit = outline->contours + outline->num_contours; - - ah_setup_uv( outline, AH_UV_OY ); - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Point point; - AH_Point end_point; - AH_Point first_point; - AH_Point* contour; - - - point = points; - contour = outline->contours; - - for ( ; contour < contour_limit; contour++ ) - { - point = *contour; - end_point = point->prev; - first_point = point; - - while ( point <= end_point && !( point->flags & touch_flag ) ) - point++; - - if ( point <= end_point ) - { - AH_Point first_touched = point; - AH_Point cur_touched = point; - - - point++; - while ( point <= end_point ) - { - if ( point->flags & touch_flag ) - { - /* we found two successive touched points; we interpolate */ - /* all contour points between them */ - ah_iup_interp( cur_touched + 1, point - 1, - cur_touched, point ); - cur_touched = point; - } - point++; - } - - if ( cur_touched == first_touched ) - { - /* this is a special case: only one point was touched in the */ - /* contour; we thus simply shift the whole contour */ - ah_iup_shift( first_point, end_point, cur_touched ); - } - else - { - /* now interpolate after the last touched point to the end */ - /* of the contour */ - ah_iup_interp( cur_touched + 1, end_point, - cur_touched, first_touched ); - - /* if the first contour point isn't touched, interpolate */ - /* from the contour start to the first touched point */ - if ( first_touched > points ) - ah_iup_interp( first_point, first_touched - 1, - cur_touched, first_touched ); - } - } - } - - /* now save the interpolated values back to x/y */ - if ( dimension ) - { - for ( point = points; point < point_limit; point++ ) - point->y = point->u; - - touch_flag = AH_FLAG_TOUCH_X; - ah_setup_uv( outline, AH_UV_OX ); - } - else - { - for ( point = points; point < point_limit; point++ ) - point->x = point->u; - - break; /* exit loop */ - } - } - } - -#endif /* !AH_OPTION_NO_WEAK_INTERPOLATION */ - - - FT_LOCAL_DEF( void ) - ah_hinter_align_points( AH_Hinter hinter ) - { - ah_hinter_align_edge_points( hinter ); - -#ifndef AH_OPTION_NO_STRONG_INTERPOLATION - ah_hinter_align_strong_points( hinter ); -#endif - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - ah_hinter_align_weak_points( hinter ); -#endif - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** H I N T E R O B J E C T M E T H O D S ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* scale and fit the global metrics */ - static void - ah_hinter_scale_globals( AH_Hinter hinter, - FT_Fixed x_scale, - FT_Fixed y_scale ) - { - FT_Int n; - AH_Face_Globals globals = hinter->globals; - AH_Globals design = &globals->design; - AH_Globals scaled = &globals->scaled; - - - /* copy content */ - *scaled = *design; - - /* scale the standard widths & heights */ - for ( n = 0; n < design->num_widths; n++ ) - scaled->widths[n] = FT_MulFix( design->widths[n], x_scale ); - - for ( n = 0; n < design->num_heights; n++ ) - scaled->heights[n] = FT_MulFix( design->heights[n], y_scale ); - - scaled->stds[0] = ( design->num_widths > 0 ) ? scaled->widths[0] : 32000; - scaled->stds[1] = ( design->num_heights > 0 ) ? scaled->heights[0] : 32000; - - /* scale the blue zones */ - for ( n = 0; n < AH_BLUE_MAX; n++ ) - { - FT_Pos delta, delta2; - - - delta = design->blue_shoots[n] - design->blue_refs[n]; - delta2 = delta; - if ( delta < 0 ) - delta2 = -delta2; - delta2 = FT_MulFix( delta2, y_scale ); - - if ( delta2 < 32 ) - delta2 = 0; - else if ( delta2 < 64 ) - delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 ); - else - delta2 = FT_PIX_ROUND( delta2 ); - - if ( delta < 0 ) - delta2 = -delta2; - - scaled->blue_refs[n] = - FT_PIX_ROUND( FT_MulFix( design->blue_refs[n], y_scale ) ); - - scaled->blue_shoots[n] = scaled->blue_refs[n] + delta2; - } - - globals->x_scale = x_scale; - globals->y_scale = y_scale; - } - - - static void - ah_hinter_align( AH_Hinter hinter ) - { - ah_hinter_align_edge_points( hinter ); - ah_hinter_align_points( hinter ); - } - - - /* finalize a hinter object */ - FT_LOCAL_DEF( void ) - ah_hinter_done( AH_Hinter hinter ) - { - if ( hinter ) - { - FT_Memory memory = hinter->memory; - - - ah_loader_done( hinter->loader ); - ah_outline_done( hinter->glyph ); - - /* note: the `globals' pointer is _not_ owned by the hinter */ - /* but by the current face object; we don't need to */ - /* release it */ - hinter->globals = 0; - hinter->face = 0; - - FT_FREE( hinter ); - } - } - - - /* create a new empty hinter object */ - FT_LOCAL_DEF( FT_Error ) - ah_hinter_new( FT_Library library, - AH_Hinter *ahinter ) - { - AH_Hinter hinter = 0; - FT_Memory memory = library->memory; - FT_Error error; - - - *ahinter = 0; - - /* allocate object */ - if ( FT_NEW( hinter ) ) - goto Exit; - - hinter->memory = memory; - hinter->flags = 0; - - /* allocate outline and loader */ - error = ah_outline_new( memory, &hinter->glyph ) || - ah_loader_new ( memory, &hinter->loader ) || - ah_loader_create_extra( hinter->loader ); - if ( error ) - goto Exit; - - *ahinter = hinter; - - Exit: - if ( error ) - ah_hinter_done( hinter ); - - return error; - } - - - /* create a face's autohint globals */ - FT_LOCAL_DEF( FT_Error ) - ah_hinter_new_face_globals( AH_Hinter hinter, - FT_Face face, - AH_Globals globals ) - { - FT_Error error; - FT_Memory memory = hinter->memory; - AH_Face_Globals face_globals; - - - if ( FT_NEW( face_globals ) ) - goto Exit; - - hinter->face = face; - hinter->globals = face_globals; - - if ( globals ) - face_globals->design = *globals; - else - ah_hinter_compute_globals( hinter ); - - face->autohint.data = face_globals; - face->autohint.finalizer = (FT_Generic_Finalizer) - ah_hinter_done_face_globals; - face_globals->face = face; - - Exit: - return error; - } - - - /* discard a face's autohint globals */ - FT_LOCAL_DEF( void ) - ah_hinter_done_face_globals( AH_Face_Globals globals ) - { - FT_Face face = globals->face; - FT_Memory memory = face->memory; - - - FT_FREE( globals ); - } - - - static FT_Error - ah_hinter_load( AH_Hinter hinter, - FT_UInt glyph_index, - FT_Int32 load_flags, - FT_UInt depth ) - { - FT_Face face = hinter->face; - FT_GlyphSlot slot = face->glyph; - FT_Slot_Internal internal = slot->internal; - FT_Fixed x_scale = hinter->globals->x_scale; - FT_Fixed y_scale = hinter->globals->y_scale; - FT_Error error; - AH_Outline outline = hinter->glyph; - AH_Loader gloader = hinter->loader; - - - /* load the glyph */ - error = FT_Load_Glyph( face, glyph_index, load_flags ); - if ( error ) - goto Exit; - - /* Set `hinter->transformed' after loading with FT_LOAD_NO_RECURSE. */ - hinter->transformed = internal->glyph_transformed; - - if ( hinter->transformed ) - { - FT_Matrix imatrix; - - - imatrix = internal->glyph_matrix; - hinter->trans_delta = internal->glyph_delta; - hinter->trans_matrix = imatrix; - - FT_Matrix_Invert( &imatrix ); - FT_Vector_Transform( &hinter->trans_delta, &imatrix ); - } - - /* set linear horizontal metrics */ - slot->linearHoriAdvance = slot->metrics.horiAdvance; - slot->linearVertAdvance = slot->metrics.vertAdvance; - - switch ( slot->format ) - { - case FT_GLYPH_FORMAT_OUTLINE: - - /* translate glyph outline if we need to */ - if ( hinter->transformed ) - { - FT_UInt n = slot->outline.n_points; - FT_Vector* point = slot->outline.points; - - - for ( ; n > 0; point++, n-- ) - { - point->x += hinter->trans_delta.x; - point->y += hinter->trans_delta.y; - } - } - - /* copy the outline points in the loader's current */ - /* extra points which is used to keep original glyph coordinates */ - error = ah_loader_check_points( gloader, slot->outline.n_points + 4, - slot->outline.n_contours ); - if ( error ) - goto Exit; - - FT_ARRAY_COPY( gloader->current.extra_points, slot->outline.points, - slot->outline.n_points ); - - FT_ARRAY_COPY( gloader->current.outline.contours, slot->outline.contours, - slot->outline.n_contours ); - - FT_ARRAY_COPY( gloader->current.outline.tags, slot->outline.tags, - slot->outline.n_points ); - - gloader->current.outline.n_points = slot->outline.n_points; - gloader->current.outline.n_contours = slot->outline.n_contours; - - /* compute original horizontal phantom points, ignoring vertical ones */ - hinter->pp1.x = 0; - hinter->pp1.y = 0; - hinter->pp2.x = FT_MulFix( slot->metrics.horiAdvance, x_scale ); - hinter->pp2.y = 0; - - /* be sure to check for spacing glyphs */ - if ( slot->outline.n_points == 0 ) - goto Hint_Metrics; - - /* now load the slot image into the auto-outline and run the */ - /* automatic hinting process */ - error = ah_outline_load( outline, x_scale, y_scale, face ); - if ( error ) - goto Exit; - - /* perform feature detection */ - ah_outline_detect_features( outline ); - - if ( hinter->do_vert_hints ) - { - ah_outline_compute_blue_edges( outline, hinter->globals ); - ah_outline_scale_blue_edges( outline, hinter->globals ); - } - - /* perform alignment control */ - ah_hinter_hint_edges( hinter ); - ah_hinter_align( hinter ); - - /* now save the current outline into the loader's current table */ - ah_outline_save( outline, gloader ); - - /* we now need to hint the metrics according to the change in */ - /* width/positioning that occured during the hinting process */ - if ( outline->num_vedges > 0 ) - { - FT_Pos old_advance, old_rsb, old_lsb, new_lsb; - AH_Edge edge1 = outline->vert_edges; /* leftmost edge */ - AH_Edge edge2 = edge1 + - outline->num_vedges - 1; /* rightmost edge */ - - - old_advance = hinter->pp2.x; - old_rsb = old_advance - edge2->opos; - old_lsb = edge1->opos; - new_lsb = edge1->pos; - - hinter->pp1.x = FT_PIX_ROUND( new_lsb - old_lsb ); - hinter->pp2.x = FT_PIX_ROUND( edge2->pos + old_rsb ); - -#if 0 - /* try to fix certain bad advance computations */ - if ( hinter->pp2.x + hinter->pp1.x == edge2->pos && old_rsb > 4 ) - hinter->pp2.x += 64; -#endif - } - - else - { - hinter->pp1.x = ( hinter->pp1.x + 32 ) & -64; - hinter->pp2.x = ( hinter->pp2.x + 32 ) & -64; - } - - /* good, we simply add the glyph to our loader's base */ - ah_loader_add( gloader ); - break; - - case FT_GLYPH_FORMAT_COMPOSITE: - { - FT_UInt nn, num_subglyphs = slot->num_subglyphs; - FT_UInt num_base_subgs, start_point; - FT_SubGlyph subglyph; - - - start_point = gloader->base.outline.n_points; - - /* first of all, copy the subglyph descriptors in the glyph loader */ - error = ah_loader_check_subglyphs( gloader, num_subglyphs ); - if ( error ) - goto Exit; - - FT_ARRAY_COPY( gloader->current.subglyphs, slot->subglyphs, - num_subglyphs ); - - gloader->current.num_subglyphs = num_subglyphs; - num_base_subgs = gloader->base.num_subglyphs; - - /* now, read each subglyph independently */ - for ( nn = 0; nn < num_subglyphs; nn++ ) - { - FT_Vector pp1, pp2; - FT_Pos x, y; - FT_UInt num_points, num_new_points, num_base_points; - - - /* gloader.current.subglyphs can change during glyph loading due */ - /* to re-allocation -- we must recompute the current subglyph on */ - /* each iteration */ - subglyph = gloader->base.subglyphs + num_base_subgs + nn; - - pp1 = hinter->pp1; - pp2 = hinter->pp2; - - num_base_points = gloader->base.outline.n_points; - - error = ah_hinter_load( hinter, subglyph->index, - load_flags, depth + 1 ); - if ( error ) - goto Exit; - - /* recompute subglyph pointer */ - subglyph = gloader->base.subglyphs + num_base_subgs + nn; - - if ( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ) - { - pp1 = hinter->pp1; - pp2 = hinter->pp2; - } - else - { - hinter->pp1 = pp1; - hinter->pp2 = pp2; - } - - num_points = gloader->base.outline.n_points; - num_new_points = num_points - num_base_points; - - /* now perform the transform required for this subglyph */ - - if ( subglyph->flags & ( FT_SUBGLYPH_FLAG_SCALE | - FT_SUBGLYPH_FLAG_XY_SCALE | - FT_SUBGLYPH_FLAG_2X2 ) ) - { - FT_Vector* cur = gloader->base.outline.points + - num_base_points; - FT_Vector* org = gloader->base.extra_points + - num_base_points; - FT_Vector* limit = cur + num_new_points; - - - for ( ; cur < limit; cur++, org++ ) - { - FT_Vector_Transform( cur, &subglyph->transform ); - FT_Vector_Transform( org, &subglyph->transform ); - } - } - - /* apply offset */ - - if ( !( subglyph->flags & FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ) ) - { - FT_Int k = subglyph->arg1; - FT_UInt l = subglyph->arg2; - FT_Vector* p1; - FT_Vector* p2; - - - if ( start_point + k >= num_base_points || - l >= (FT_UInt)num_new_points ) - { - error = AH_Err_Invalid_Composite; - goto Exit; - } - - l += num_base_points; - - /* for now, only use the current point coordinates; */ - /* we may consider another approach in the near future */ - p1 = gloader->base.outline.points + start_point + k; - p2 = gloader->base.outline.points + start_point + l; - - x = p1->x - p2->x; - y = p1->y - p2->y; - } - else - { - x = FT_MulFix( subglyph->arg1, x_scale ); - y = FT_MulFix( subglyph->arg2, y_scale ); - - x = FT_PIX_ROUND(x); - y = FT_PIX_ROUND(y); - } - - { - FT_Outline dummy = gloader->base.outline; - - - dummy.points += num_base_points; - dummy.n_points = (short)num_new_points; - - FT_Outline_Translate( &dummy, x, y ); - } - } - } - break; - - default: - /* we don't support other formats (yet?) */ - error = AH_Err_Unimplemented_Feature; - } - - Hint_Metrics: - if ( depth == 0 ) - { - FT_BBox bbox; - - - /* transform the hinted outline if needed */ - if ( hinter->transformed ) - FT_Outline_Transform( &gloader->base.outline, &hinter->trans_matrix ); - - /* we must translate our final outline by -pp1.x and compute */ - /* the new metrics */ - if ( hinter->pp1.x ) - FT_Outline_Translate( &gloader->base.outline, -hinter->pp1.x, 0 ); - - FT_Outline_Get_CBox( &gloader->base.outline, &bbox ); - bbox.xMin = FT_PIX_FLOOR( bbox.xMin ); - bbox.yMin = FT_PIX_FLOOR( bbox.yMin ); - bbox.xMax = FT_PIX_CEIL( bbox.xMax ); - bbox.yMax = FT_PIX_CEIL( bbox.yMax ); - - slot->metrics.width = bbox.xMax - bbox.xMin; - slot->metrics.height = bbox.yMax - bbox.yMin; - slot->metrics.horiBearingX = bbox.xMin; - slot->metrics.horiBearingY = bbox.yMax; - - /* for mono-width fonts (like Andale, Courier, etc.) we need */ - /* to keep the original rounded advance width */ - if ( !FT_IS_FIXED_WIDTH( slot->face ) ) - slot->metrics.horiAdvance = hinter->pp2.x - hinter->pp1.x; - else - slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, - x_scale ); - - slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance ); - - /* now copy outline into glyph slot */ - ah_loader_rewind( slot->internal->loader ); - error = ah_loader_copy_points( slot->internal->loader, gloader ); - if ( error ) - goto Exit; - - slot->outline = slot->internal->loader->base.outline; - slot->format = FT_GLYPH_FORMAT_OUTLINE; - } - -#ifdef DEBUG_HINTER - ah_debug_hinter = hinter; -#endif - - Exit: - return error; - } - - - /* load and hint a given glyph */ - FT_LOCAL_DEF( FT_Error ) - ah_hinter_load_glyph( AH_Hinter hinter, - FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int32 load_flags ) - { - FT_Face face = slot->face; - FT_Error error; - FT_Fixed x_scale = size->metrics.x_scale; - FT_Fixed y_scale = size->metrics.y_scale; - AH_Face_Globals face_globals = FACE_GLOBALS( face ); - FT_Render_Mode hint_mode = FT_LOAD_TARGET_MODE( load_flags ); - - - /* first of all, we need to check that we're using the correct face and */ - /* global hints to load the glyph */ - if ( hinter->face != face || hinter->globals != face_globals ) - { - hinter->face = face; - if ( !face_globals ) - { - error = ah_hinter_new_face_globals( hinter, face, 0 ); - if ( error ) - goto Exit; - - } - hinter->globals = FACE_GLOBALS( face ); - face_globals = FACE_GLOBALS( face ); - - } - -#ifdef FT_CONFIG_CHESTER_BLUE_SCALE - - /* try to optimize the y_scale so that the top of non-capital letters - * is aligned on a pixel boundary whenever possible - */ - { - AH_Globals design = &face_globals->design; - FT_Pos shoot = design->blue_shoots[AH_BLUE_SMALL_TOP]; - - - /* the value of 'shoot' will be -1000 if the font doesn't have */ - /* small latin letters; we simply check the sign here... */ - if ( shoot > 0 ) - { - FT_Pos scaled = FT_MulFix( shoot, y_scale ); - FT_Pos fitted = FT_PIX_ROUND( scaled ); - - - if ( scaled != fitted ) - { - /* adjust y_scale - */ - y_scale = FT_MulDiv( y_scale, fitted, scaled ); - - /* adust x_scale - */ - if ( fitted < scaled ) - x_scale -= x_scale / 50; /* x_scale*0.98 with integers */ - } - } - } - -#endif /* FT_CONFIG_CHESTER_BLUE_SCALE */ - - /* now, we must check the current character pixel size to see if we */ - /* need to rescale the global metrics */ - if ( face_globals->x_scale != x_scale || - face_globals->y_scale != y_scale ) - ah_hinter_scale_globals( hinter, x_scale, y_scale ); - - ah_loader_rewind( hinter->loader ); - - /* reset hinting flags according to load flags and current render target */ - hinter->do_horz_hints = FT_BOOL( !(load_flags & FT_LOAD_NO_AUTOHINT) ); - hinter->do_vert_hints = FT_BOOL( !(load_flags & FT_LOAD_NO_AUTOHINT) ); - -#ifdef DEBUG_HINTER - hinter->do_horz_hints = !ah_debug_disable_vert; /* not a bug, the meaning */ - hinter->do_vert_hints = !ah_debug_disable_horz; /* of h/v is inverted! */ -#endif - - /* we snap the width of vertical stems for the monochrome and */ - /* horizontal LCD rendering targets only. Corresponds to X snapping. */ - hinter->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO || - hint_mode == FT_RENDER_MODE_LCD ); - - /* we snap the width of horizontal stems for the monochrome and */ - /* vertical LCD rendering targets only. Corresponds to Y snapping. */ - hinter->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO || - hint_mode == FT_RENDER_MODE_LCD_V ); - - hinter->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT ); - - load_flags |= FT_LOAD_NO_SCALE - | FT_LOAD_IGNORE_TRANSFORM; - load_flags &= ~FT_LOAD_RENDER; - - error = ah_hinter_load( hinter, glyph_index, load_flags, 0 ); - - Exit: - return error; - } - - - /* retrieve a face's autohint globals for client applications */ - FT_LOCAL_DEF( void ) - ah_hinter_get_global_hints( AH_Hinter hinter, - FT_Face face, - void** global_hints, - long* global_len ) - { - AH_Globals globals = 0; - FT_Memory memory = hinter->memory; - FT_Error error; - - - /* allocate new master globals */ - if ( FT_NEW( globals ) ) - goto Fail; - - /* compute face globals if needed */ - if ( !FACE_GLOBALS( face ) ) - { - error = ah_hinter_new_face_globals( hinter, face, 0 ); - if ( error ) - goto Fail; - } - - *globals = FACE_GLOBALS( face )->design; - *global_hints = globals; - *global_len = sizeof( *globals ); - - return; - - Fail: - FT_FREE( globals ); - - *global_hints = 0; - *global_len = 0; - } - - - FT_LOCAL_DEF( void ) - ah_hinter_done_global_hints( AH_Hinter hinter, - void* global_hints ) - { - FT_Memory memory = hinter->memory; - - - FT_FREE( global_hints ); - } - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahhint.h b/src/libs/freetype2/autohint/ahhint.h deleted file mode 100644 index 2c352d0c99..0000000000 --- a/src/libs/freetype2/autohint/ahhint.h +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahhint.h */ -/* */ -/* Glyph hinter (declaration). */ -/* */ -/* Copyright 2000-2001, 2002 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#ifndef __AHHINT_H__ -#define __AHHINT_H__ - - -#include <ft2build.h> -#include "ahglobal.h" - - -FT_BEGIN_HEADER - - -#define AH_HINT_DEFAULT 0 -#define AH_HINT_NO_ALIGNMENT 1 -#define AH_HINT_NO_HORZ_EDGES 0x200000L /* temporary hack */ -#define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */ - - - /* create a new empty hinter object */ - FT_LOCAL( FT_Error ) - ah_hinter_new( FT_Library library, - AH_Hinter* ahinter ); - - /* Load a hinted glyph in the hinter */ - FT_LOCAL( FT_Error ) - ah_hinter_load_glyph( AH_Hinter hinter, - FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int32 load_flags ); - - /* finalize a hinter object */ - FT_LOCAL( void ) - ah_hinter_done( AH_Hinter hinter ); - - FT_LOCAL( void ) - ah_hinter_done_face_globals( AH_Face_Globals globals ); - - FT_LOCAL( void ) - ah_hinter_get_global_hints( AH_Hinter hinter, - FT_Face face, - void** global_hints, - long* global_len ); - - FT_LOCAL( void ) - ah_hinter_done_global_hints( AH_Hinter hinter, - void* global_hints ); - - -FT_END_HEADER - -#endif /* __AHHINT_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahloader.h b/src/libs/freetype2/autohint/ahloader.h deleted file mode 100644 index c8e42ef225..0000000000 --- a/src/libs/freetype2/autohint/ahloader.h +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahloader.h */ -/* */ -/* Glyph loader for the auto-hinting module (declaration only). */ -/* */ -/* Copyright 2000-2001, 2002 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This defines the AH_GlyphLoader type; it is simply a typedef to */ - /* FT_GlyphLoader. */ - /* */ - /*************************************************************************/ - - -#ifndef __AHLOADER_H__ -#define __AHLOADER_H__ - - -#include <ft2build.h> - - -FT_BEGIN_HEADER - -#include FT_INTERNAL_GLYPH_LOADER_H - - #define AH_Load FT_GlyphLoad - #define AH_Loader FT_GlyphLoader - - #define ah_loader_new FT_GlyphLoader_New - #define ah_loader_done FT_GlyphLoader_Done - #define ah_loader_reset FT_GlyphLoader_Reset - #define ah_loader_rewind FT_GlyphLoader_Rewind - #define ah_loader_create_extra FT_GlyphLoader_CreateExtra - #define ah_loader_check_points FT_GlyphLoader_CheckPoints - #define ah_loader_check_subglyphs FT_GlyphLoader_CheckSubGlyphs - #define ah_loader_prepare FT_GlyphLoader_Prepare - #define ah_loader_add FT_GlyphLoader_Add - #define ah_loader_copy_points FT_GlyphLoader_CopyPoints - - -FT_END_HEADER - -#endif /* __AHLOADER_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahmodule.c b/src/libs/freetype2/autohint/ahmodule.c deleted file mode 100644 index 8fce31d618..0000000000 --- a/src/libs/freetype2/autohint/ahmodule.c +++ /dev/null @@ -1,137 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahmodule.c */ -/* */ -/* Auto-hinting module implementation (declaration). */ -/* */ -/* Copyright 2000-2001, 2002, 2003 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_MODULE_H -#include "ahhint.h" - - -#ifdef DEBUG_HINTER - AH_Hinter ah_debug_hinter = NULL; - FT_Bool ah_debug_disable_horz = 0; - FT_Bool ah_debug_disable_vert = 0; -#endif - - typedef struct FT_AutoHinterRec_ - { - FT_ModuleRec root; - AH_Hinter hinter; - - } FT_AutoHinterRec; - - - FT_CALLBACK_DEF( FT_Error ) - ft_autohinter_init( FT_AutoHinter module ) - { - FT_Error error; - - - error = ah_hinter_new( module->root.library, &module->hinter ); -#ifdef DEBUG_HINTER - if ( !error ) - ah_debug_hinter = module->hinter; -#endif - return error; - } - - - FT_CALLBACK_DEF( void ) - ft_autohinter_done( FT_AutoHinter module ) - { - ah_hinter_done( module->hinter ); - -#ifdef DEBUG_HINTER - ah_debug_hinter = NULL; -#endif - } - - - FT_CALLBACK_DEF( FT_Error ) - ft_autohinter_load_glyph( FT_AutoHinter module, - FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int32 load_flags ) - { - return ah_hinter_load_glyph( module->hinter, - slot, size, glyph_index, load_flags ); - } - - - FT_CALLBACK_DEF( void ) - ft_autohinter_reset_globals( FT_AutoHinter module, - FT_Face face ) - { - FT_UNUSED( module ); - - if ( face->autohint.data ) - ah_hinter_done_face_globals( (AH_Face_Globals)(face->autohint.data) ); - } - - - FT_CALLBACK_DEF( void ) - ft_autohinter_get_globals( FT_AutoHinter module, - FT_Face face, - void** global_hints, - long* global_len ) - { - ah_hinter_get_global_hints( module->hinter, face, - global_hints, global_len ); - } - - - FT_CALLBACK_DEF( void ) - ft_autohinter_done_globals( FT_AutoHinter module, - void* global_hints ) - { - ah_hinter_done_global_hints( module->hinter, global_hints ); - } - - - FT_CALLBACK_TABLE_DEF - const FT_AutoHinter_ServiceRec ft_autohinter_service = - { - ft_autohinter_reset_globals, - ft_autohinter_get_globals, - ft_autohinter_done_globals, - ft_autohinter_load_glyph - }; - - - FT_CALLBACK_TABLE_DEF - const FT_Module_Class autohint_module_class = - { - FT_MODULE_HINTER, - sizeof ( FT_AutoHinterRec ), - - "autohinter", - 0x10000L, /* version 1.0 of the autohinter */ - 0x20000L, /* requires FreeType 2.0 or above */ - - (const void*) &ft_autohinter_service, - - (FT_Module_Constructor)ft_autohinter_init, - (FT_Module_Destructor) ft_autohinter_done, - (FT_Module_Requester) 0 - }; - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahmodule.h b/src/libs/freetype2/autohint/ahmodule.h deleted file mode 100644 index 43b1dbe983..0000000000 --- a/src/libs/freetype2/autohint/ahmodule.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahmodule.h */ -/* */ -/* Auto-hinting module (declaration). */ -/* */ -/* Copyright 2000-2001 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#ifndef __AHMODULE_H__ -#define __AHMODULE_H__ - - -#include <ft2build.h> -#include FT_MODULE_H - - -FT_BEGIN_HEADER - - - FT_CALLBACK_TABLE - const FT_Module_Class autohint_module_class; - - -FT_END_HEADER - -#endif /* __AHMODULE_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/ahtypes.h b/src/libs/freetype2/autohint/ahtypes.h deleted file mode 100644 index f2cedd2887..0000000000 --- a/src/libs/freetype2/autohint/ahtypes.h +++ /dev/null @@ -1,527 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahtypes.h */ -/* */ -/* General types and definitions for the auto-hint module */ -/* (specification only). */ -/* */ -/* Copyright 2000-2001, 2002, 2003, 2004 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#ifndef __AHTYPES_H__ -#define __AHTYPES_H__ - - -#include <ft2build.h> -#include FT_INTERNAL_OBJECTS_H - -#ifdef DEBUG_HINTER -#include <../src/autohint/ahloader.h> -#else -#include "ahloader.h" -#endif - - -#define xxAH_DEBUG - - -#ifdef AH_DEBUG - -#include <stdio.h> -#define AH_LOG( x ) printf ## x - -#else - -#define AH_LOG( x ) do ; while ( 0 ) /* nothing */ - -#endif /* AH_DEBUG */ - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** COMPILE-TIME BUILD OPTIONS ****/ - /**** ****/ - /**** Toggle these configuration macros to experiment with `features' ****/ - /**** of the auto-hinter. ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* If this option is defined, only strong interpolation will be used to */ - /* place the points between edges. Otherwise, `smooth' points are */ - /* detected and later hinted through weak interpolation to correct some */ - /* unpleasant artefacts. */ - /* */ -#undef AH_OPTION_NO_WEAK_INTERPOLATION - - - /*************************************************************************/ - /* */ - /* Undefine this macro if you don't want to hint the metrics. There is */ - /* no reason to do this (at least for non-CJK scripts), except for */ - /* experimentation. */ - /* */ -#undef AH_HINT_METRICS - - - /*************************************************************************/ - /* */ - /* Define this macro if you do not want to insert extra edges at a */ - /* glyph's x and y extremum (if there isn't one already available). */ - /* This helps to reduce a number of artefacts and allows hinting of */ - /* metrics. */ - /* */ -#undef AH_OPTION_NO_EXTREMUM_EDGES - - - /* don't touch for now */ -#define AH_MAX_WIDTHS 12 -#define AH_MAX_HEIGHTS 12 - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** TYPE DEFINITIONS ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* see ahangles.h */ - typedef FT_Int AH_Angle; - - - /* hint flags */ -#define AH_FLAG_NONE 0 - - /* bezier control points flags */ -#define AH_FLAG_CONIC 1 -#define AH_FLAG_CUBIC 2 -#define AH_FLAG_CONTROL ( AH_FLAG_CONIC | AH_FLAG_CUBIC ) - - /* extrema flags */ -#define AH_FLAG_EXTREMA_X 4 -#define AH_FLAG_EXTREMA_Y 8 - - /* roundness */ -#define AH_FLAG_ROUND_X 16 -#define AH_FLAG_ROUND_Y 32 - - /* touched */ -#define AH_FLAG_TOUCH_X 64 -#define AH_FLAG_TOUCH_Y 128 - - /* weak interpolation */ -#define AH_FLAG_WEAK_INTERPOLATION 256 -#define AH_FLAG_INFLECTION 512 - - typedef FT_Int AH_Flags; - - - /* edge hint flags */ -#define AH_EDGE_NORMAL 0 -#define AH_EDGE_ROUND 1 -#define AH_EDGE_SERIF 2 -#define AH_EDGE_DONE 4 - - typedef FT_Int AH_Edge_Flags; - - - /* hint directions -- the values are computed so that two vectors are */ - /* in opposite directions iff `dir1+dir2 == 0' */ -#define AH_DIR_NONE 4 -#define AH_DIR_RIGHT 1 -#define AH_DIR_LEFT -1 -#define AH_DIR_UP 2 -#define AH_DIR_DOWN -2 - - typedef FT_Int AH_Direction; - - - typedef struct AH_PointRec_* AH_Point; - typedef struct AH_SegmentRec_* AH_Segment; - typedef struct AH_EdgeRec_* AH_Edge; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AH_PointRec */ - /* */ - /* <Description> */ - /* A structure used to model an outline point to the AH_OutlineRec */ - /* type. */ - /* */ - /* <Fields> */ - /* flags :: The current point hint flags. */ - /* */ - /* ox, oy :: The current original scaled coordinates. */ - /* */ - /* fx, fy :: The current coordinates in font units. */ - /* */ - /* x, y :: The current hinted coordinates. */ - /* */ - /* u, v :: Point coordinates -- meaning varies with context. */ - /* */ - /* in_dir :: The direction of the inwards vector (prev->point). */ - /* */ - /* out_dir :: The direction of the outwards vector (point->next). */ - /* */ - /* next :: The next point in same contour. */ - /* */ - /* prev :: The previous point in same contour. */ - /* */ - typedef struct AH_PointRec_ - { - AH_Flags flags; /* point flags used by hinter */ - FT_Pos ox, oy; - FT_Pos fx, fy; - FT_Pos x, y; - FT_Pos u, v; - - AH_Direction in_dir; /* direction of inwards vector */ - AH_Direction out_dir; /* direction of outwards vector */ - - AH_Point next; /* next point in contour */ - AH_Point prev; /* previous point in contour */ - - } AH_PointRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AH_SegmentRec */ - /* */ - /* <Description> */ - /* A structure used to describe an edge segment to the auto-hinter. */ - /* A segment is simply a sequence of successive points located on the */ - /* same horizontal or vertical `position', in a given direction. */ - /* */ - /* <Fields> */ - /* flags :: The segment edge flags (straight, rounded, etc.). */ - /* */ - /* dir :: The segment direction. */ - /* */ - /* min_coord :: The minimum coordinate of the segment. */ - /* */ - /* max_coord :: The maximum coordinate of the segment. */ - /* */ - /* edge :: The edge of the current segment. */ - /* */ - /* edge_next :: The next segment on the same edge. */ - /* */ - /* link :: The pairing segment for this edge. */ - /* */ - /* serif :: The primary segment for serifs. */ - /* */ - /* num_linked :: The number of other segments that link to this one. */ - /* */ - /* score :: Used to score the segment when selecting them. */ - /* */ - /* first :: The first point in the segment. */ - /* */ - /* last :: The last point in the segment. */ - /* */ - /* contour :: A pointer to the first point of the segment's */ - /* contour. */ - /* */ - typedef struct AH_SegmentRec_ - { - AH_Edge_Flags flags; - AH_Direction dir; - FT_Pos pos; /* position of segment */ - FT_Pos min_coord; /* minimum coordinate of segment */ - FT_Pos max_coord; /* maximum coordinate of segment */ - - AH_Edge edge; - AH_Segment edge_next; - - AH_Segment link; /* link segment */ - AH_Segment serif; /* primary segment for serifs */ - FT_Pos num_linked; /* number of linked segments */ - FT_Pos score; - - AH_Point first; /* first point in edge segment */ - AH_Point last; /* last point in edge segment */ - AH_Point* contour; /* ptr to first point of segment's contour */ - - } AH_SegmentRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AH_EdgeRec */ - /* */ - /* <Description> */ - /* A structure used to describe an edge, which really is a horizontal */ - /* or vertical coordinate to be hinted depending on the segments */ - /* located on it. */ - /* */ - /* <Fields> */ - /* fpos :: The original edge position in font units. */ - /* */ - /* opos :: The original scaled edge position. */ - /* */ - /* pos :: The hinted edge position. */ - /* */ - /* flags :: The segment edge flags (straight, rounded, etc.). */ - /* */ - /* dir :: The main segment direction on this edge. */ - /* */ - /* scale :: Scaling factor between original and hinted edge */ - /* positions. */ - /* */ - /* blue_edge :: Indicate the blue zone edge this edge is related to. */ - /* Only set for some of the horizontal edges in a latin */ - /* font. */ - /* */ - /* link :: The linked edge. */ - /* */ - /* serif :: The serif edge. */ - /* */ - /* num_linked :: The number of other edges that pair to this one. */ - /* */ - /* score :: Used to score the edge when selecting them. */ - /* */ - /* first :: The first edge segment. */ - /* */ - /* last :: The last edge segment. */ - /* */ - typedef struct AH_EdgeRec_ - { - FT_Pos fpos; - FT_Pos opos; - FT_Pos pos; - - AH_Edge_Flags flags; - AH_Direction dir; - FT_Fixed scale; - FT_Pos* blue_edge; - - AH_Edge link; - AH_Edge serif; - FT_Int num_linked; - - FT_Int score; - - AH_Segment first; - AH_Segment last; - - - } AH_EdgeRec; - - - /* an outline as seen by the hinter */ - typedef struct AH_OutlineRec_ - { - FT_Memory memory; - - AH_Direction vert_major_dir; /* vertical major direction */ - AH_Direction horz_major_dir; /* horizontal major direction */ - - FT_Fixed x_scale; - FT_Fixed y_scale; - FT_Pos edge_distance_threshold; - - FT_Int max_points; - FT_Int num_points; - AH_Point points; - - FT_Int max_contours; - FT_Int num_contours; - AH_Point* contours; - - FT_Int num_hedges; - AH_Edge horz_edges; - - FT_Int num_vedges; - AH_Edge vert_edges; - - FT_Int num_hsegments; - AH_Segment horz_segments; - - FT_Int num_vsegments; - AH_Segment vert_segments; - - } AH_OutlineRec, *AH_Outline; - - -#ifdef FT_CONFIG_CHESTER_SMALL_F - -#define AH_BLUE_CAPITAL_TOP 0 /* THEZOCQS */ -#define AH_BLUE_CAPITAL_BOTTOM ( AH_BLUE_CAPITAL_TOP + 1 ) /* HEZLOCUS */ -#define AH_BLUE_SMALL_F_TOP ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* fijkdbh */ -#define AH_BLUE_SMALL_TOP ( AH_BLUE_SMALL_F_TOP + 1 ) /* xzroesc */ -#define AH_BLUE_SMALL_BOTTOM ( AH_BLUE_SMALL_TOP + 1 ) /* xzroesc */ -#define AH_BLUE_SMALL_MINOR ( AH_BLUE_SMALL_BOTTOM + 1 ) /* pqgjy */ -#define AH_BLUE_MAX ( AH_BLUE_SMALL_MINOR + 1 ) - -#else /* !FT_CONFIG_CHESTER_SMALL_F */ - -#define AH_BLUE_CAPITAL_TOP 0 /* THEZOCQS */ -#define AH_BLUE_CAPITAL_BOTTOM ( AH_BLUE_CAPITAL_TOP + 1 ) /* HEZLOCUS */ -#define AH_BLUE_SMALL_TOP ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* xzroesc */ -#define AH_BLUE_SMALL_BOTTOM ( AH_BLUE_SMALL_TOP + 1 ) /* xzroesc */ -#define AH_BLUE_SMALL_MINOR ( AH_BLUE_SMALL_BOTTOM + 1 ) /* pqgjy */ -#define AH_BLUE_MAX ( AH_BLUE_SMALL_MINOR + 1 ) - -#endif /* !FT_CONFIG_CHESTER_SMALL_F */ - - typedef FT_Int AH_Blue; - - -#define AH_HINTER_MONOCHROME 1 -#define AH_HINTER_OPTIMIZE 2 - - typedef FT_Int AH_Hinter_Flags; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AH_GlobalsRec */ - /* */ - /* <Description> */ - /* Holds the global metrics for a given font face (be it in design */ - /* units or scaled pixel values). */ - /* */ - /* <Fields> */ - /* num_widths :: The number of widths. */ - /* */ - /* num_heights :: The number of heights. */ - /* */ - /* stds :: A two-element array giving the default stem width */ - /* and height. */ - /* */ - /* widths :: Snap widths, including standard one. */ - /* */ - /* heights :: Snap height, including standard one. */ - /* */ - /* blue_refs :: The reference positions of blue zones. */ - /* */ - /* blue_shoots :: The overshoot positions of blue zones. */ - /* */ - typedef struct AH_GlobalsRec_ - { - FT_Int num_widths; - FT_Int num_heights; - - FT_Pos stds[2]; - - FT_Pos widths [AH_MAX_WIDTHS]; - FT_Pos heights[AH_MAX_HEIGHTS]; - - FT_Pos blue_refs [AH_BLUE_MAX]; - FT_Pos blue_shoots[AH_BLUE_MAX]; - - } AH_GlobalsRec, *AH_Globals; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AH_Face_GlobalsRec */ - /* */ - /* <Description> */ - /* Holds the complete global metrics for a given font face (i.e., the */ - /* design units version + a scaled version + the current scales */ - /* used). */ - /* */ - /* <Fields> */ - /* face :: A handle to the source face object */ - /* */ - /* design :: The globals in font design units. */ - /* */ - /* scaled :: Scaled globals in sub-pixel values. */ - /* */ - /* x_scale :: The current horizontal scale. */ - /* */ - /* y_scale :: The current vertical scale. */ - /* */ - /* control_overshoot :: */ - /* Currently unused. */ - /* */ - typedef struct AH_Face_GlobalsRec_ - { - FT_Face face; - AH_GlobalsRec design; - AH_GlobalsRec scaled; - FT_Fixed x_scale; - FT_Fixed y_scale; - FT_Bool control_overshoot; - - } AH_Face_GlobalsRec, *AH_Face_Globals; - - - typedef struct AH_HinterRec_ - { - FT_Memory memory; - AH_Hinter_Flags flags; - - FT_Int algorithm; - FT_Face face; - - AH_Face_Globals globals; - - AH_Outline glyph; - - AH_Loader loader; - FT_Vector pp1; /* horizontal phantom points */ - FT_Vector pp2; - /* we ignore vertical phantom points */ - - FT_Bool transformed; - FT_Vector trans_delta; - FT_Matrix trans_matrix; - - FT_Bool do_horz_hints; /* disable X hinting */ - FT_Bool do_vert_hints; /* disable Y hinting */ - FT_Bool do_horz_snapping; /* disable X stem size snapping */ - FT_Bool do_vert_snapping; /* disable Y stem size snapping */ - FT_Bool do_stem_adjust; /* disable light stem snapping */ - - } AH_HinterRec, *AH_Hinter; - - -#ifdef DEBUG_HINTER - extern AH_Hinter ah_debug_hinter; - extern FT_Bool ah_debug_disable_horz; - extern FT_Bool ah_debug_disable_vert; -#else -#define ah_debug_disable_horz 0 -#define ah_debug_disable_vert 0 -#endif /* DEBUG_HINTER */ - - -FT_END_HEADER - -#endif /* __AHTYPES_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/autohint/autohint.c b/src/libs/freetype2/autohint/autohint.c deleted file mode 100644 index 3783a82d96..0000000000 --- a/src/libs/freetype2/autohint/autohint.c +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************/ -/* */ -/* autohint.c */ -/* */ -/* Automatic Hinting wrapper (body only). */ -/* */ -/* Copyright 2000-2001 Catharon Productions Inc. */ -/* Author: David Turner */ -/* */ -/* This file is part of the Catharon Typography Project and shall only */ -/* be used, modified, and distributed under the terms of the Catharon */ -/* Open Source License that should come with this file under the name */ -/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* Note that this license is compatible with the FreeType license. */ -/* */ -/***************************************************************************/ - - -#define FT_MAKE_OPTION_SINGLE_OBJECT - -#include <ft2build.h> -#include "ahangles.c" -#include "ahglyph.c" -#include "ahglobal.c" -#include "ahhint.c" -#include "ahmodule.c" - - -/* END */ diff --git a/src/libs/freetype2/autohint/descrip.mms b/src/libs/freetype2/autohint/descrip.mms deleted file mode 100644 index e528a898b0..0000000000 --- a/src/libs/freetype2/autohint/descrip.mms +++ /dev/null @@ -1,25 +0,0 @@ -# -# FreeType 2 auto-hinter module compilation rules for VMS -# - - -# Copyright 2001, 2002 Catharon Productions Inc. -# -# This file is part of the Catharon Typography Project and shall only -# be used, modified, and distributed under the terms of the Catharon -# Open Source License that should come with this file under the name -# `CatharonLicense.txt'. By continuing to use, modify, or distribute -# this file you indicate that you have read the license and -# understand and accept it fully. -# -# Note that this license is compatible with the FreeType license. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/incl=([--.include],[--.src.autohint]) - -OBJS=autohint.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/autohint/mather.py b/src/libs/freetype2/autohint/mather.py deleted file mode 100644 index 8ad8b55359..0000000000 --- a/src/libs/freetype2/autohint/mather.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -# - -# -# autohint math table builder -# - - -# Copyright 1996-2000 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -import math - -ag_pi = 256 - -def print_arctan( atan_bits ): - atan_base = 1 << atan_bits - - print " static AH_Angle ag_arctan[1L << AG_ATAN_BITS] =" - print " {" - - count = 0 - line = " " - - for n in range( atan_base ): - comma = "," - if ( n == atan_base - 1 ): - comma = "" - - angle = math.atan( n * 1.0 / atan_base ) / math.pi * ag_pi - line = line + " " + repr( int( angle + 0.5 ) ) + comma - count = count + 1; - if ( count == 8 ): - count = 0 - print line - line = " " - - if ( count > 0 ): - print line - print " };" - - -# This routine is not used currently. -# -def print_sines(): - print " static FT_Fixed ah_sines[AG_HALF_PI + 1] =" - print " {" - - count = 0 - line = " " - - for n in range( ag_pi / 2 ): - sinus = math.sin( n * math.pi / ag_pi ) - line = line + " " + repr( int( 65536.0 * sinus ) ) + "," - count = count + 1 - if ( count == 8 ): - count = 0 - print line - line = " " - - if ( count > 0 ): - print line - print " 65536" - print " };" - - -print_arctan( 8 ) -print - - -# END diff --git a/src/libs/freetype2/autohint/module.mk b/src/libs/freetype2/autohint/module.mk deleted file mode 100644 index edc9f4e1af..0000000000 --- a/src/libs/freetype2/autohint/module.mk +++ /dev/null @@ -1,25 +0,0 @@ -# -# FreeType 2 auto-hinter module definition -# - - -# Copyright 2000 Catharon Productions Inc. -# Author: David Turner -# -# This file is part of the Catharon Typography Project and shall only -# be used, modified, and distributed under the terms of the Catharon -# Open Source License that should come with this file under the name -# `CatharonLicense.txt'. By continuing to use, modify, or distribute -# this file you indicate that you have read the license and -# understand and accept it fully. -# -# Note that this license is compatible with the FreeType license. - - -make_module_list: add_autohint_module - -add_autohint_module: - $(OPEN_DRIVER)autohint_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)autohint $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE) - -# EOF diff --git a/src/libs/freetype2/autohint/rules.mk b/src/libs/freetype2/autohint/rules.mk deleted file mode 100644 index ee264e8622..0000000000 --- a/src/libs/freetype2/autohint/rules.mk +++ /dev/null @@ -1,77 +0,0 @@ -# -# FreeType 2 auto-hinter module configuration rules -# - - -# Copyright 2000, 2001, 2002, 2003 Catharon Productions Inc. -# Author: David Turner -# -# This file is part of the Catharon Typography Project and shall only -# be used, modified, and distributed under the terms of the Catharon -# Open Source License that should come with this file under the name -# `CatharonLicense.txt'. By continuing to use, modify, or distribute -# this file you indicate that you have read the license and -# understand and accept it fully. -# -# Note that this license is compatible with the FreeType license. - - -# AUTO driver directory -# -AUTO_DIR := $(SRC_DIR)/autohint - - -# compilation flags for the driver -# -AUTO_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(AUTO_DIR)) - - -# AUTO driver sources (i.e., C files) -# -AUTO_DRV_SRC := $(AUTO_DIR)/ahangles.c \ - $(AUTO_DIR)/ahglobal.c \ - $(AUTO_DIR)/ahglyph.c \ - $(AUTO_DIR)/ahhint.c \ - $(AUTO_DIR)/ahmodule.c - -# AUTO driver headers -# -AUTO_DRV_H := $(AUTO_DRV_SRC:%c=%h) \ - $(AUTO_DIR)/ahloader.h \ - $(AUTO_DIR)/ahtypes.h \ - $(AUTO_DIR)/aherrors.h - - -# AUTO driver object(s) -# -# AUTO_DRV_OBJ_M is used during `multi' builds. -# AUTO_DRV_OBJ_S is used during `single' builds. -# -AUTO_DRV_OBJ_M := $(AUTO_DRV_SRC:$(AUTO_DIR)/%.c=$(OBJ_DIR)/%.$O) -AUTO_DRV_OBJ_S := $(OBJ_DIR)/autohint.$O - -# AUTO driver source file for single build -# -AUTO_DRV_SRC_S := $(AUTO_DIR)/autohint.c - - -# AUTO driver - single object -# -$(AUTO_DRV_OBJ_S): $(AUTO_DRV_SRC_S) $(AUTO_DRV_SRC) \ - $(FREETYPE_H) $(AUTO_DRV_H) - $(AUTO_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(AUTO_DRV_SRC_S)) - - -# AUTO driver - multiple objects -# -$(OBJ_DIR)/%.$O: $(AUTO_DIR)/%.c $(FREETYPE_H) $(AUTO_DRV_H) - $(AUTO_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) - - -# update main driver object lists -# -DRV_OBJS_S += $(AUTO_DRV_OBJ_S) -DRV_OBJS_M += $(AUTO_DRV_OBJ_M) - - -# EOF diff --git a/src/libs/freetype2/base/Jamfile b/src/libs/freetype2/base/Jamfile index 758006d798..9e1c18f340 100644 --- a/src/libs/freetype2/base/Jamfile +++ b/src/libs/freetype2/base/Jamfile @@ -1,5 +1,13 @@ -# FreeType 2 src/base Jamfile (c) 2001, 2002 David Turner +# FreeType 2 src/base Jamfile # +# Copyright 2001, 2002, 2003, 2004, 2005 by +# David Turner, Robert Wilhelm, and Werner Lemberg. +# +# This file is part of the FreeType project, and may only be used, modified, +# and distributed under the terms of the FreeType project license, +# LICENSE.TXT. By continuing to use, modify, or distribute this file you +# indicate that you have read the license and understand and accept it +# fully. SubDir HAIKU_TOP src libs freetype2 base ; @@ -14,7 +22,7 @@ UseFreeTypeHeaders ; if $(FT2_MULTI) { _sources = ftutil ftdbgmem ftstream ftcalc fttrigon ftgloadr ftoutln - ftobjs ftnames ftrfork ; + ftobjs ftnames ftrfork ; } else { @@ -26,9 +34,15 @@ UseFreeTypeHeaders ; # Add the optional/replaceable files. # -FT2_Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c - ftbbox.c ftdebug.c ftxf86.c fttype1.c ftpfr.c - ftstroke.c ftwinfnt.c ftotval.c ftbitmap.c ; +{ + local _sources = system init glyph mm bdf + bbox debug xf86 type1 pfr + stroke winfnt otval bitmap synth + gxval + ; + + FT2_Library $(FT2_LIB) : ft$(_sources).c ; +} # Add Macintosh-specific file to the library when necessary. # @@ -38,4 +52,3 @@ if $(MAC) } # end of src/base Jamfile - diff --git a/src/libs/freetype2/base/descrip.mms b/src/libs/freetype2/base/descrip.mms deleted file mode 100644 index 73bad4d738..0000000000 --- a/src/libs/freetype2/base/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 base layer compilation rules for VMS -# - - -# Copyright 2001, 2003, 2004 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base]) - -OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj,ftpfr.obj,ftstroke.obj,ftwinfnt.obj,ftbbox.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/base/ftbdf.c b/src/libs/freetype2/base/ftbdf.c index fec27e2db6..d29adf09dd 100644 --- a/src/libs/freetype2/base/ftbdf.c +++ b/src/libs/freetype2/base/ftbdf.c @@ -58,7 +58,7 @@ /* documentation is in ftbdf.h */ - FT_EXPORT( FT_Error ) + FT_EXPORT_DEF( FT_Error ) FT_Get_BDF_Property( FT_Face face, const char* prop_name, BDF_PropertyRec *aproperty ) diff --git a/src/libs/freetype2/base/ftbitmap.c b/src/libs/freetype2/base/ftbitmap.c index 7c95af7fa9..d4709a440f 100644 --- a/src/libs/freetype2/base/ftbitmap.c +++ b/src/libs/freetype2/base/ftbitmap.c @@ -5,7 +5,7 @@ /* FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */ /* bitmaps into 8bpp format (body). */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -73,10 +73,10 @@ target_size = (FT_ULong)( target_pitch * target->rows ); if ( target_size != size ) - FT_QREALLOC( target->buffer, target_size, size ); + (void)FT_QREALLOC( target->buffer, target_size, size ); } else - FT_QALLOC( target->buffer, size ); + (void)FT_QALLOC( target->buffer, size ); if ( !error ) { @@ -165,7 +165,7 @@ new_pitch = ( bitmap->width + xpixels + ppb - 1 ) / ppb; - if ( FT_ALLOC( buffer, new_pitch * ( bitmap->rows + ypixels ) ) ) + if ( FT_QALLOC_MULT( buffer, new_pitch, bitmap->rows + ypixels ) ) return error; if ( bitmap->pitch > 0 ) @@ -277,7 +277,7 @@ /* for each row */ for ( y = 0; y < bitmap->rows ; y++ ) { - /* + /* * Horizontally: * * From the last pixel on, make each pixel or'ed with the @@ -310,12 +310,12 @@ { if ( p[x] + p[x - i] > bitmap->num_grays - 1 ) { - p[x] = bitmap->num_grays - 1; + p[x] = (unsigned char)(bitmap->num_grays - 1); break; } else { - p[x] += p[x - i]; + p[x] = (unsigned char)(p[x] + p[x-i]); if ( p[x] == bitmap->num_grays - 1 ) break; } @@ -326,7 +326,7 @@ } } - /* + /* * Vertically: * * Make the above `ystr' rows or'ed with it. diff --git a/src/libs/freetype2/base/ftcalc.c b/src/libs/freetype2/base/ftcalc.c index 6e19e55f34..ba3d089355 100644 --- a/src/libs/freetype2/base/ftcalc.c +++ b/src/libs/freetype2/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -99,6 +99,8 @@ } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + /* documentation is in ftcalc.h */ FT_EXPORT_DEF( FT_Int32 ) @@ -128,6 +130,8 @@ return root; } +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + #ifdef FT_LONG64 @@ -293,9 +297,7 @@ } - /* documentation is in ftcalc.h */ - - FT_EXPORT_DEF( void ) + static void FT_Add64( FT_Int64* x, FT_Int64* y, FT_Int64 *z ) @@ -394,6 +396,42 @@ FT_MulFix( FT_Long a, FT_Long b ) { +#if 1 + FT_Long sa, sb; + FT_ULong ua, ub; + + + if ( a == 0 || b == 0x10000L ) + return a; + + sa = ( a >> ( sizeof ( a ) * 8 - 1 ) ); + a = ( a ^ sa ) - sa; + sb = ( b >> ( sizeof ( b ) * 8 - 1 ) ); + b = ( b ^ sb ) - sb; + + ua = (FT_ULong)a; + ub = (FT_ULong)b; + + if ( ua <= 2048 && ub <= 1048576L ) + { + ua = ( ua * ub + 0x8000 ) >> 16; + } + else + { + FT_ULong al = ua & 0xFFFF; + + + ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) + + ( ( al * ( ub & 0xFFFF ) + 0x8000 ) >> 16 ); + } + + sa ^= sb, + ua = (FT_ULong)(( ua ^ sa ) - sa); + + return (FT_Long)ua; + +#else /* 0 */ + FT_Long s; FT_ULong ua, ub; @@ -421,6 +459,9 @@ } return ( s < 0 ? -(FT_Long)ua : (FT_Long)ua ); + +#endif /* 0 */ + } @@ -464,6 +505,8 @@ } +#if 0 + /* documentation is in ftcalc.h */ FT_EXPORT_DEF( void ) @@ -487,10 +530,8 @@ } - /* documentation is in ftcalc.h */ - /* apparently, the second version of this code is not compiled correctly */ - /* on Mac machines with the MPW C compiler.. tsss, tsss, tss... */ + /* on Mac machines with the MPW C compiler.. tsk, tsk, tsk... */ #if 1 @@ -582,13 +623,15 @@ #endif /* 0 */ +#endif /* 0 */ + #endif /* FT_LONG64 */ /* documentation is in ftcalc.h */ - FT_EXPORT_DEF( FT_Int32 ) + FT_BASE_DEF( FT_Int32 ) FT_SqrtFixed( FT_Int32 x ) { FT_UInt32 root, rem_hi, rem_lo, test_div; diff --git a/src/libs/freetype2/base/ftdbgmem.c b/src/libs/freetype2/base/ftdbgmem.c index 2442a41c48..7ebb141242 100644 --- a/src/libs/freetype2/base/ftdbgmem.c +++ b/src/libs/freetype2/base/ftdbgmem.c @@ -4,7 +4,7 @@ /* */ /* Memory debugger (body). */ /* */ -/* Copyright 2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -36,6 +36,8 @@ #include <stdio.h> #include <stdlib.h> + FT_BASE_DEF( const char* ) _ft_debug_file = 0; + FT_BASE_DEF( long ) _ft_debug_lineno = 0; extern void FT_DumpMemory( FT_Memory memory ); @@ -48,8 +50,12 @@ #define FT_MEM_VAL( addr ) ((FT_ULong)(FT_Pointer)( addr )) - - typedef struct FT_MemSourceRec_ + /* + * This structure holds statistics for a single allocation/release + * site. This is useful to know where memory operations happen the + * most. + */ + typedef struct FT_MemSourceRec_ { const char* file_name; long line_no; @@ -70,13 +76,19 @@ } FT_MemSourceRec; -/* - * We don't need a resizable array for the memory sources, because - * their number is pretty limited within FreeType. - */ + /* + * We don't need a resizable array for the memory sources, because + * their number is pretty limited within FreeType. + */ #define FT_MEM_SOURCE_BUCKETS 128 - + /* + * This structure holds information related to a single allocated + * memory block. If KEEPALIVE is defined, blocks that are freed by + * FreeType are never released to the system. Instead, their `size' + * field is set to -size. This is mainly useful to detect double frees, + * at the price of large memory footprint during execution. + */ typedef struct FT_MemNodeRec_ { FT_Byte* address; @@ -94,6 +106,10 @@ } FT_MemNodeRec; + /* + * The global structure, containing compound statistics and all hash + * tables. + */ typedef struct FT_MemTableRec_ { FT_ULong size; @@ -113,9 +129,6 @@ FT_MemSource sources[FT_MEM_SOURCE_BUCKETS]; - const char* file_name; - FT_Long line_no; - FT_Bool keep_alive; FT_Memory memory; @@ -133,10 +146,10 @@ #define FT_FILENAME( x ) ((x) ? (x) : "unknown file") - /* - * Prime numbers are ugly to handle. It would be better to implement - * L-Hashing, which is 10% faster and doesn't require divisions. - */ + /* + * Prime numbers are ugly to handle. It would be better to implement + * L-Hashing, which is 10% faster and doesn't require divisions. + */ static const FT_UInt ft_mem_primes[] = { 7, @@ -222,7 +235,7 @@ block = table->alloc( memory, size ); memory->user = table; - return block; + return block; } @@ -338,8 +351,9 @@ if ( table ) { - FT_Long leak_count = 0; - FT_ULong leaks = 0; + FT_Long leak_count = 0; + FT_ULong leaks = 0; + /* remove all blocks from the table, revealing leaked ones */ for ( i = 0; i < table->size; i++ ) @@ -378,8 +392,8 @@ ft_mem_table_free( table, table->buckets ); table->buckets = NULL; - table->size = 0; - table->nodes = 0; + table->size = 0; + table->nodes = 0; /* remove all sources */ for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ ) @@ -446,8 +460,8 @@ FT_MemSource node, *pnode; - hash = (FT_UInt32)(void*)table->file_name + - (FT_UInt32)( 5 * table->line_no ); + hash = (FT_UInt32)(void*)_ft_debug_file + + (FT_UInt32)( 5 * _ft_debug_lineno ); pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS]; for ( ;; ) @@ -456,8 +470,8 @@ if ( node == NULL ) break; - if ( node->file_name == table->file_name && - node->line_no == table->line_no ) + if ( node->file_name == _ft_debug_file && + node->line_no == _ft_debug_lineno ) goto Exit; pnode = &node->link; @@ -468,8 +482,8 @@ ft_mem_debug_panic( "not enough memory to perform memory debugging\n" ); - node->file_name = table->file_name; - node->line_no = table->line_no; + node->file_name = _ft_debug_file; + node->line_no = _ft_debug_lineno; node->cur_blocks = 0; node->max_blocks = 0; @@ -493,7 +507,8 @@ static void ft_mem_table_set( FT_MemTable table, FT_Byte* address, - FT_ULong size ) + FT_ULong size, + FT_Long delta ) { FT_MemNode *pnode, node; @@ -525,7 +540,7 @@ "org=%s:%d new=%s:%d\n", node->address, node->size, FT_FILENAME( node->source->file_name ), node->source->line_no, - FT_FILENAME( table->file_name ), table->line_no ); + FT_FILENAME( _ft_debug_file ), _ft_debug_lineno ); } } @@ -536,19 +551,35 @@ node->address = address; node->size = size; + node->source = source = ft_mem_table_get_source( table ); - node->source = source = ft_mem_table_get_source( table ); - - source->all_blocks++; - source->cur_blocks++; - if ( source->cur_blocks > source->max_blocks ) - source->max_blocks = source->cur_blocks; + if ( delta == 0 ) + { + /* this is an allocation */ + source->all_blocks++; + source->cur_blocks++; + if ( source->cur_blocks > source->max_blocks ) + source->max_blocks = source->cur_blocks; + } if ( size > (FT_ULong)source->cur_max ) source->cur_max = size; + if ( delta != 0 ) + { + /* we are growing or shrinking a reallocated block */ + source->cur_size += delta; + table->alloc_current += delta; + } + else + { + /* we are allocating a new block */ + source->cur_size += size; + table->alloc_current += size; + } + source->all_size += size; - source->cur_size += size; + if ( source->cur_size > source->max_size ) source->max_size = source->cur_size; @@ -560,8 +591,8 @@ pnode[0] = node; table->nodes++; - table->alloc_total += size; - table->alloc_current += size; + table->alloc_total += size; + if ( table->alloc_current > table->alloc_max ) table->alloc_max = table->alloc_current; @@ -574,7 +605,8 @@ static void ft_mem_table_remove( FT_MemTable table, - FT_Byte* address ) + FT_Byte* address, + FT_Long delta ) { if ( table ) { @@ -593,26 +625,30 @@ "freeing memory block at %p more than once at (%s:%ld)\n" "block allocated at (%s:%ld) and released at (%s:%ld)", address, - FT_FILENAME( table->file_name ), table->line_no, + FT_FILENAME( _ft_debug_file ), _ft_debug_lineno, FT_FILENAME( node->source->file_name ), node->source->line_no, FT_FILENAME( node->free_file_name ), node->free_line_no ); /* scramble the node's content for additional safety */ FT_MEM_SET( address, 0xF3, node->size ); - table->alloc_current -= node->size; - source = node->source; + if ( delta == 0 ) + { + source = node->source; - source->cur_blocks--; - source->cur_size -= node->size; + source->cur_blocks--; + source->cur_size -= node->size; + + table->alloc_current -= node->size; + } if ( table->keep_alive ) { /* we simply invert the node's size to indicate that the node */ /* was freed. */ node->size = -node->size; - node->free_file_name = table->file_name; - node->free_line_no = table->line_no; + node->free_file_name = _ft_debug_file; + node->free_line_no = _ft_debug_lineno; } else { @@ -634,7 +670,7 @@ ft_mem_debug_panic( "trying to free unknown block at %p in (%s:%ld)\n", address, - FT_FILENAME( table->file_name ), table->line_no ); + FT_FILENAME( _ft_debug_file ), _ft_debug_lineno ); } } @@ -657,17 +693,19 @@ /* return NULL if this allocation would overflow the maximum heap size */ if ( table->bound_total && - table->alloc_current + (FT_ULong)size > table->alloc_total_max ) + table->alloc_total_max - table->alloc_current > (FT_ULong)size ) return NULL; block = (FT_Byte *)ft_mem_table_alloc( table, size ); if ( block ) - ft_mem_table_set( table, block, (FT_ULong)size ); + { + ft_mem_table_set( table, block, (FT_ULong)size, 0 ); - table->alloc_count++; + table->alloc_count++; + } - table->file_name = NULL; - table->line_no = 0; + _ft_debug_file = "<unknown>"; + _ft_debug_lineno = 0; return (FT_Pointer)block; } @@ -682,18 +720,18 @@ if ( block == NULL ) ft_mem_debug_panic( "trying to free NULL in (%s:%ld)", - FT_FILENAME( table->file_name ), - table->line_no ); + FT_FILENAME( _ft_debug_file ), + _ft_debug_lineno ); - ft_mem_table_remove( table, (FT_Byte*)block ); + ft_mem_table_remove( table, (FT_Byte*)block, 0 ); if ( !table->keep_alive ) ft_mem_table_free( table, block ); table->alloc_count--; - table->file_name = NULL; - table->line_no = 0; + _ft_debug_file = "<unknown>"; + _ft_debug_lineno = 0; } @@ -706,11 +744,16 @@ FT_MemTable table = (FT_MemTable)memory->user; FT_MemNode node, *pnode; FT_Pointer new_block; + FT_Long delta; - const char* file_name = FT_FILENAME( table->file_name ); - FT_Long line_no = table->line_no; + const char* file_name = FT_FILENAME( _ft_debug_file ); + FT_Long line_no = _ft_debug_lineno; + /* unlikely, but possible */ + if ( new_size == cur_size ) + return block; + /* the following is valid according to ANSI C */ #if 0 if ( block == NULL || cur_size == 0 ) @@ -743,16 +786,34 @@ "%ld instead of %ld in (%s:%ld)", block, cur_size, node->size, file_name, line_no ); - new_block = ft_mem_debug_alloc( memory, new_size ); + /* return NULL if the maximum number of allocations was reached */ + if ( table->bound_count && + table->alloc_count >= table->alloc_count_max ) + return NULL; + + delta = (FT_Long)( new_size - cur_size ); + + /* return NULL if this allocation would overflow the maximum heap size */ + if ( delta > 0 && + table->bound_total && + table->alloc_current + (FT_ULong)delta > table->alloc_total_max ) + return NULL; + + new_block = (FT_Byte *)ft_mem_table_alloc( table, new_size ); if ( new_block == NULL ) return NULL; + ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta ); + ft_memcpy( new_block, block, cur_size < new_size ? cur_size : new_size ); - table->file_name = file_name; - table->line_no = line_no; + ft_mem_table_remove( table, (FT_Byte*)block, delta ); - ft_mem_debug_free( memory, (FT_Byte*)block ); + _ft_debug_file = "<unknown>"; + _ft_debug_lineno = 0; + + if ( !table->keep_alive ) + ft_mem_table_free( table, block ); return new_block; } @@ -839,106 +900,6 @@ } - FT_BASE_DEF( FT_Error ) - FT_Alloc_Debug( FT_Memory memory, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ) - { - FT_MemTable table = (FT_MemTable)memory->user; - - - if ( table ) - { - table->file_name = file_name; - table->line_no = line_no; - } - - return FT_Alloc( memory, size, P ); - } - - - FT_BASE_DEF( FT_Error ) - FT_Realloc_Debug( FT_Memory memory, - FT_Long current, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ) - { - FT_MemTable table = (FT_MemTable)memory->user; - - - if ( table ) - { - table->file_name = file_name; - table->line_no = line_no; - } - - return FT_Realloc( memory, current, size, P ); - } - - - FT_BASE_DEF( FT_Error ) - FT_QAlloc_Debug( FT_Memory memory, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ) - { - FT_MemTable table = (FT_MemTable)memory->user; - - - if ( table ) - { - table->file_name = file_name; - table->line_no = line_no; - } - - return FT_QAlloc( memory, size, P ); - } - - - FT_BASE_DEF( FT_Error ) - FT_QRealloc_Debug( FT_Memory memory, - FT_Long current, - FT_Long size, - void* *P, - const char* file_name, - FT_Long line_no ) - { - FT_MemTable table = (FT_MemTable)memory->user; - - - if ( table ) - { - table->file_name = file_name; - table->line_no = line_no; - } - - return FT_QRealloc( memory, current, size, P ); - } - - - FT_BASE_DEF( void ) - FT_Free_Debug( FT_Memory memory, - FT_Pointer block, - const char* file_name, - FT_Long line_no ) - { - FT_MemTable table = (FT_MemTable)memory->user; - - - if ( table ) - { - table->file_name = file_name; - table->line_no = line_no; - } - - FT_Free( memory, (void **)block ); - } - static int ft_mem_source_compare( const void* p1, diff --git a/src/libs/freetype2/base/ftdebug.c b/src/libs/freetype2/base/ftdebug.c index 160f20bfa5..c55d3c8114 100644 --- a/src/libs/freetype2/base/ftdebug.c +++ b/src/libs/freetype2/base/ftdebug.c @@ -50,7 +50,7 @@ /* documentation is in ftdebug.h */ - FT_EXPORT_DEF( void ) + FT_BASE_DEF( void ) FT_Message( const char* fmt, ... ) { va_list ap; @@ -64,7 +64,7 @@ /* documentation is in ftdebug.h */ - FT_EXPORT_DEF( void ) + FT_BASE_DEF( void ) FT_Panic( const char* fmt, ... ) { va_list ap; @@ -101,7 +101,7 @@ /* documentation is in ftdebug.h */ - FT_EXPORT_DEF( FT_Int ) + FT_BASE_DEF( FT_Int ) FT_Trace_Get_Count( void ) { return trace_count; @@ -110,7 +110,7 @@ /* documentation is in ftdebug.h */ - FT_EXPORT_DEF( const char * ) + FT_BASE_DEF( const char * ) FT_Trace_Get_Name( FT_Int idx ) { int max = FT_Trace_Get_Count(); @@ -224,14 +224,14 @@ } - FT_EXPORT_DEF( FT_Int ) + FT_BASE_DEF( FT_Int ) FT_Trace_Get_Count( void ) { return 0; } - FT_EXPORT_DEF( const char * ) + FT_BASE_DEF( const char * ) FT_Trace_Get_Name( FT_Int idx ) { FT_UNUSED( idx ); diff --git a/src/libs/freetype2/base/ftexcept.c b/src/libs/freetype2/base/ftexcept.c deleted file mode 100644 index 1b93a99705..0000000000 --- a/src/libs/freetype2/base/ftexcept.c +++ /dev/null @@ -1,197 +0,0 @@ -#include <ft2build.h> -#include FT_EXCEPT_H - - - FT_BASE_DEF( void ) - ft_cleanup_stack_init( FT_CleanupStack stack, - FT_Memory memory ) - { - stack->chunk = &stack->chunk_0; - stack->top = stack->chunk->items; - stack->limit = stack->top + FT_CLEANUP_CHUNK_SIZE; - stack->chunk_0.link = NULL; - - stack->memory = memory; - } - - - - FT_BASE_DEF( void ) - ft_cleanup_stack_done( FT_CleanupStack stack ) - { - FT_Memory memory = stack->memory; - FT_CleanupChunk chunk, next; - - for (;;) - { - chunk = stack->chunk; - if ( chunk == &stack->chunk_0 ) - break; - - stack->chunk = chunk->link; - - FT_Free( chunk, memory ); - } - - stack->memory = NULL; - } - - - - FT_BASE_DEF( void ) - ft_cleanup_stack_push( FT_CleanupStack stack, - FT_Pointer item, - FT_CleanupFunc item_func, - FT_Pointer item_data ) - { - FT_CleanupItem top; - - - FT_ASSERT( stack && stack->chunk && stack->top ); - FT_ASSERT( item && item_func ); - - top = stack->top; - - top->item = item; - top->item_func = item_func; - top->item_data = item_data; - - top ++; - - if ( top == stack->limit ) - { - FT_CleanupChunk chunk; - - chunk = FT_QAlloc( sizeof(*chunk), stack->memory ); - - chunk->link = stack->chunk; - stack->chunk = chunk; - stack->limit = chunk->items + FT_CLEANUP_CHUNK_SIZE; - top = chunk->items; - } - - stack->top = top; - } - - - - FT_BASE_DEF( void ) - ft_cleanup_stack_pop( FT_CleanupStack stack, - FT_Int destroy ) - { - FT_CleanupItem top; - - - FT_ASSERT( stack && stack->chunk && stack->top ); - top = stack->top; - - if ( top == stack->chunk->items ) - { - FT_CleanupChunk chunk; - - chunk = stack->chunk; - - if ( chunk == &stack->chunk_0 ) - { - FT_ERROR(( "cleanup.pop: empty cleanup stack !!\n" )); - ft_cleanup_throw( stack, FT_Err_EmptyCleanupStack ); - } - - chunk = chunk->link; - FT_QFree( stack->chunk, stack->memory ); - - stack->chunk = chunk; - stack->limit = chunk->items + FT_CLEANUP_CHUNK_SIZE; - top = stack->limit; - } - - top --; - - if ( destroy ) - top->item_func( top->item, top->item_data ); - - top->item = NULL; - top->item_func = NULL; - top->item_data = NULL; - - stack->top = top; - } - - - - FT_BASE_DEF( FT_CleanupItem ) - ft_cleanup_stack_peek( FT_CleanupStack stack ) - { - FT_CleanupItem top; - FT_CleanupChunk chunk; - - - FT_ASSERT( stack && stack->chunk && stack->top ); - - top = stack->top; - chunk = stack->chunk; - - if ( top > chunk->items ) - top--; - else - { - chunk = chunk->link; - top = NULL; - if ( chunk != NULL ) - top = chunk->items + FT_CLEANUP_CHUNK_SIZE - 1; - } - return top; - } - - - - FT_BASE_DEF( void ) - ft_xhandler_enter( FT_XHandler xhandler, - FT_Memory memory ) - { - FT_CleanupStack stack = FT_MEMORY__CLEANUP(memory); - - xhandler->previous = stack->xhandler; - xhandler->cleanup = stack->top; - xhandler->error = 0; - stack->xhandler = xhandler; - } - - - - FT_BASE_DEF( void ) - ft_xhandler_exit( FT_XHandler xhandler ) - { - FT_CleanupStack stack = FT_MEMORY__CLEANUP(memory); - - stack->xhandler = xhandler->previous; - xhandler->previous = NULL; - xhandler->error = error; - xhandler->cleanup = NULL; - } - - - - FT_BASE_DEF( void ) - ft_cleanup_throw( FT_CleanupStack stack, - FT_Error error ) - { - FT_XHandler xhandler = stack->xhandler; - - if ( xhandler == NULL ) - { - /* no exception handler was registered. this */ - /* means that we have an un-handled exception */ - /* the only thing we can do is _PANIC_ and */ - /* halt the current program.. */ - /* */ - FT_ERROR(( "FREETYPE PANIC: An un-handled exception occured. Program aborted" )); - ft_exit(1); - } - - /* cleanup the stack until we reach the handler's */ - /* starting stack location.. */ - - xhandler->error = error; - longmp( xhandler->jump_buffer, 1 ); - } \ No newline at end of file diff --git a/src/libs/freetype2/base/ftgloadr.c b/src/libs/freetype2/base/ftgloadr.c index 94a0706733..81ecd8e373 100644 --- a/src/libs/freetype2/base/ftgloadr.c +++ b/src/libs/freetype2/base/ftgloadr.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph loader (body). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -195,7 +195,7 @@ FT_Error error = FT_Err_Ok; FT_Outline* base = &loader->base.outline; FT_Outline* current = &loader->current.outline; - FT_Bool adjust = 1; + FT_Bool adjust = 0; FT_UInt new_max, old_max; @@ -296,14 +296,23 @@ FT_BASE_DEF( void ) FT_GlyphLoader_Add( FT_GlyphLoader loader ) { - FT_GlyphLoad base = &loader->base; - FT_GlyphLoad current = &loader->current; + FT_GlyphLoad base; + FT_GlyphLoad current; - FT_UInt n_curr_contours = current->outline.n_contours; - FT_UInt n_base_points = base->outline.n_points; + FT_UInt n_curr_contours; + FT_UInt n_base_points; FT_UInt n; + if ( !loader ) + return; + + base = &loader->base; + current = &loader->current; + + n_curr_contours = current->outline.n_contours; + n_base_points = base->outline.n_points; + base->outline.n_points = (short)( base->outline.n_points + current->outline.n_points ); base->outline.n_contours = diff --git a/src/libs/freetype2/base/ftgxval.c b/src/libs/freetype2/base/ftgxval.c new file mode 100644 index 0000000000..615e5ed6f5 --- /dev/null +++ b/src/libs/freetype2/base/ftgxval.c @@ -0,0 +1,129 @@ +/***************************************************************************/ +/* */ +/* ftgxval.c */ +/* */ +/* FreeType API for validating TrueTyepGX/AAT tables (body). */ +/* */ +/* Copyright 2004, 2005 by */ +/* Masatake YAMATO, Redhat K.K, */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* gxvalid is derived from both gxlayout module and otvalid module. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_INTERNAL_OBJECTS_H +#include FT_SERVICE_GX_VALIDATE_H + + + /* documentation is in ftgxval.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_TrueTypeGX_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ) + { + FT_Service_GXvalidate service; + FT_Error error; + + + if ( !face ) + { + error = FT_Err_Invalid_Face_Handle; + goto Exit; + } + + if ( tables == NULL ) + { + error = FT_Err_Invalid_Argument; + goto Exit; + } + + FT_FACE_FIND_GLOBAL_SERVICE( face, service, GX_VALIDATE ); + + if ( service ) + error = service->validate( face, + validation_flags, + tables, + table_length ); + else + error = FT_Err_Invalid_Argument; + + Exit: + return error; + } + + + FT_EXPORT_DEF( void ) + FT_TrueTypeGX_Free( FT_Face face, + FT_Bytes table ) + { + FT_Memory memory = FT_FACE_MEMORY( face ); + + + FT_FREE( table ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_ClassicKern_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *ckern_table ) + { + FT_Service_CKERNvalidate service; + FT_Error error; + + + if ( !face ) + { + error = FT_Err_Invalid_Face_Handle; + goto Exit; + } + + if ( ckern_table == NULL ) + { + error = FT_Err_Invalid_Argument; + goto Exit; + } + + FT_FACE_FIND_GLOBAL_SERVICE( face, service, CLASSICKERN_VALIDATE ); + + if ( service ) + error = service->validate( face, + validation_flags, + ckern_table ); + else + error = FT_Err_Invalid_Argument; + + Exit: + return error; + } + + + FT_EXPORT_DEF( void ) + FT_ClassicKern_Free( FT_Face face, + FT_Bytes table ) + { + FT_Memory memory = FT_FACE_MEMORY( face ); + + + FT_FREE( table ); + } + + +/* END */ diff --git a/src/libs/freetype2/base/fthash.c b/src/libs/freetype2/base/fthash.c deleted file mode 100644 index c42b1dcf4b..0000000000 --- a/src/libs/freetype2/base/fthash.c +++ /dev/null @@ -1,246 +0,0 @@ -#include <ft2build.h> -#include FT_TYPES_H -#include FT_INTERNAL_HASH_H -#include FT_INTERNAL_MEMORY_H -#include FT_INTERNAL_DEBUG_H - -#define FT_HASH_MAX_LOAD 2 -#define FT_HASH_MIN_LOAD 1 -#define FT_HASH_SUB_LOAD (FT_HASH_MAX_LOAD-FT_HASH_MIN_LOAD) - -/* this one _must_ be a power of 2 !! */ -#define FT_HASH_INITIAL_SIZE 8 - - - FT_BASE_DEF( void ) - ft_hash_done( FT_Hash table, - FT_Hash_ForeachFunc node_func, - const FT_Pointer node_data ) - { - if ( table ) - { - FT_Memory memory = table->memory; - - if ( node_func ) - ft_hash_foreach( table, node_func, node_data ); - - FT_FREE( table->buckets ); - table->p = 0; - table->mask = 0; - table->slack = 0; - - table->node_equal = NULL; - } - } - - - FT_BASE_DEF( FT_UInt ) - ft_hash_get_size( FT_Hash table ) - { - FT_UInt result = 0; - - if ( table ) - result = (table->p + table->mask + 1)*FT_HASH_MAX_LOAD - table->slack; - - return result; - } - - - - FT_BASE_DEF( FT_Error ) - ft_hash_init( FT_Hash table, - FT_Hash_EqualFunc equal, - FT_Memory memory ) - { - FT_Error error; - - table->memory = memory; - table->p = 0; - table->mask = FT_HASH_INITIAL_SIZE-1; - table->slack = FT_HASH_INITIAL_SIZE*FT_HASH_MAX_LOAD; - table->node_equal = equal; - - (void)FT_NEW_ARRAY( table->buckets, FT_HASH_INITIAL_SIZE*2 ); - - return error; - } - - - - FT_BASE_DEF( void ) - ft_hash_foreach( FT_Hash table, - FT_Hash_ForeachFunc foreach_func, - const FT_Pointer foreach_data ) - { - FT_UInt count = table->p + table->mask + 1; - FT_HashNode* pnode = table->buckets; - FT_HashNode node, next; - - for ( ; count > 0; count--, pnode++ ) - { - node = *pnode; - while ( node ) - { - next = node->link; - foreach_func( node, foreach_data ); - node = next; - } - } - } - - - - FT_BASE_DEF( FT_HashLookup ) - ft_hash_lookup( FT_Hash table, - FT_HashNode keynode ) - { - FT_UInt index; - FT_UInt32 hash = keynode->hash; - FT_HashNode node, *pnode; - - index = (FT_UInt)(hash & table->mask); - if ( index < table->p ) - index = (FT_UInt)(hash & (2*table->mask+1)); - - pnode = &table->buckets[index]; - for (;;) - { - node = *pnode; - if ( node == NULL ) - break; - - if ( node->hash == hash && table->node_equal( node, keynode ) ) - break; - - pnode = &node->link; - } - - return pnode; - } - - - - - FT_BASE_DEF( FT_Error ) - ft_hash_add( FT_Hash table, - FT_HashLookup lookup, - FT_HashNode new_node ) - { - FT_Error error = 0; - - /* add it to the hash table */ - new_node->link = *lookup; - *lookup = new_node; - - if ( --table->slack < 0 ) - { - FT_UInt p = table->p; - FT_UInt mask = table->mask; - FT_HashNode new_list, node, *pnode; - - /* split a single bucket */ - new_list = NULL; - pnode = table->buckets + p; - for (;;) - { - node = *pnode; - if ( node == NULL ) - break; - - if ( node->hash & mask ) - { - *pnode = node->link; - node->link = new_list; - new_list = node; - } - else - pnode = &node->link; - } - - table->buckets[ p + mask + 1 ] = new_list; - - table->slack += FT_HASH_MAX_LOAD; - - if ( p >= mask ) - { - FT_Memory memory = table->memory; - - - if (FT_RENEW_ARRAY( table->buckets, (mask+1)*2, (mask+1)*4 )) - goto Exit; - - table->mask = 2*mask + 1; - table->p = 0; - } - else - table->p = p + 1; - } - Exit: - return error; - } - - - - FT_BASE_DEF( FT_Error ) - ft_hash_remove( FT_Hash table, - FT_HashLookup lookup ) - { - FT_HashNode node; - FT_UInt num_buckets; - FT_Error error = 0; - - FT_ASSERT( pnode != NULL && node != NULL ); - - node = *lookup; - *lookup = node->link; - node->link = NULL; - - num_buckets = ( table->p + table->mask + 1) ; - - if ( ++ table->slack > (FT_Long)num_buckets*FT_HASH_SUB_LOAD ) - { - FT_UInt p = table->p; - FT_UInt mask = table->mask; - FT_UInt old_index = p + mask; - FT_HashNode* pnode; - FT_HashNode* pold; - - if ( old_index < FT_HASH_INITIAL_SIZE ) - goto Exit; - - if ( p == 0 ) - { - FT_Memory memory = table->memory; - - table->mask >>= 1; - p = table->mask; - - if ( FT_RENEW_ARRAY( table->buckets, (mask+1)*2, (mask+1) ) ) - { - /* this should never happen normally, but who knows :-) */ - /* we need to re-inject the node in the hash table before */ - /* returning there, since it's safer */ - pnode = table->buckets; - node->link = *pnode; - *pnode = node; - - goto Exit; - } - } - else - p--; - - pnode = table->buckets + p; - while ( *pnode ) - pnode = &(*pnode)->link; - - pold = table->buckets + old_index; - *pnode = *pold; - *pold = NULL; - - table->slack -= FT_HASH_MAX_LOAD; - table->p = p; - } - Exit: - return error; - } diff --git a/src/libs/freetype2/base/ftinit.c b/src/libs/freetype2/base/ftinit.c index ac009b76d0..ef32af5ee8 100644 --- a/src/libs/freetype2/base/ftinit.c +++ b/src/libs/freetype2/base/ftinit.c @@ -75,7 +75,7 @@ }; - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( void ) FT_Add_Default_Modules( FT_Library library ) diff --git a/src/libs/freetype2/base/ftlist.c b/src/libs/freetype2/base/ftlist.c deleted file mode 100644 index 52687b361d..0000000000 --- a/src/libs/freetype2/base/ftlist.c +++ /dev/null @@ -1,217 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlist.c */ -/* */ -/* Generic list support for FreeType (body). */ -/* */ -/* Copyright 1996-2001, 2002 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype/internal/ftlist.h'. */ - /* */ - /*************************************************************************/ - - -#include <ft2build.h> -#include FT_LIST_H -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_OBJECTS_H - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ -#undef FT_COMPONENT -#define FT_COMPONENT trace_list - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( FT_ListNode ) - FT_List_Find( FT_List list, - void* data ) - { - FT_ListNode cur; - - - cur = list->head; - while ( cur ) - { - if ( cur->data == data ) - return cur; - - cur = cur->next; - } - - return (FT_ListNode)0; - } - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( void ) - FT_List_Add( FT_List list, - FT_ListNode node ) - { - FT_ListNode before = list->tail; - - - node->next = 0; - node->prev = before; - - if ( before ) - before->next = node; - else - list->head = node; - - list->tail = node; - } - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( void ) - FT_List_Insert( FT_List list, - FT_ListNode node ) - { - FT_ListNode after = list->head; - - - node->next = after; - node->prev = 0; - - if ( !after ) - list->tail = node; - else - after->prev = node; - - list->head = node; - } - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( void ) - FT_List_Remove( FT_List list, - FT_ListNode node ) - { - FT_ListNode before, after; - - - before = node->prev; - after = node->next; - - if ( before ) - before->next = after; - else - list->head = after; - - if ( after ) - after->prev = before; - else - list->tail = before; - } - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( void ) - FT_List_Up( FT_List list, - FT_ListNode node ) - { - FT_ListNode before, after; - - - before = node->prev; - after = node->next; - - /* check whether we are already on top of the list */ - if ( !before ) - return; - - before->next = after; - - if ( after ) - after->prev = before; - else - list->tail = before; - - node->prev = 0; - node->next = list->head; - list->head->prev = node; - list->head = node; - } - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_List_Iterate( FT_List list, - FT_List_Iterator iterator, - void* user ) - { - FT_ListNode cur = list->head; - FT_Error error = FT_Err_Ok; - - - while ( cur ) - { - FT_ListNode next = cur->next; - - - error = iterator( cur, user ); - if ( error ) - break; - - cur = next; - } - - return error; - } - - - /* documentation is in ftlist.h */ - - FT_EXPORT_DEF( void ) - FT_List_Finalize( FT_List list, - FT_List_Destructor destroy, - FT_Memory memory, - void* user ) - { - FT_ListNode cur; - - - cur = list->head; - while ( cur ) - { - FT_ListNode next = cur->next; - void* data = cur->data; - - - if ( destroy ) - destroy( memory, data, user ); - - FT_FREE( cur ); - cur = next; - } - - list->head = 0; - list->tail = 0; - } - - -/* END */ diff --git a/src/libs/freetype2/base/ftmac.c b/src/libs/freetype2/base/ftmac.c index 0c45372c6f..6e4cbe577b 100644 --- a/src/libs/freetype2/base/ftmac.c +++ b/src/libs/freetype2/base/ftmac.c @@ -3,8 +3,9 @@ /* ftmac.c */ /* */ /* Mac FOND support. Written by just@letterror.com. */ +/* Heavily Fixed by mpsuzuki, George Williams and Sean McBride */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,39 +24,35 @@ support this I use the face_index argument of FT_(Open|New)_Face() functions, and pretend the suitcase file is a collection. - Warning: Although the FOND driver sets face->num_faces field to the - number of available fonts, but the Type 1 driver sets it to 1 anyway. - So this field is currently not reliable, and I don't see a clean way - to resolve that. The face_index argument translates to - - Get1IndResource( 'FOND', face_index + 1 ); - - so clients should figure out the resource index of the FOND. - (I'll try to provide some example code for this at some point.) + Warning: fbit and NFNT bitmap resources are not supported yet. In old + sfnt fonts, bitmap glyph data for each size is stored in each `NFNT' + resources instead of the `bdat' table in the sfnt resource. Therefore, + face->num_fixed_sizes is set to 0, because bitmap data in `NFNT' + resource is unavailable at present. The Mac FOND support works roughly like this: - - Check whether the offered stream points to a Mac suitcase file. - This is done by checking the file type: it has to be 'FFIL' or 'tfil'. - The stream that gets passed to our init_face() routine is a stdio - stream, which isn't usable for us, since the FOND resources live - in the resource fork. So we just grab the stream->pathname field. + - Check whether the offered stream points to a Mac suitcase file. This + is done by checking the file type: it has to be 'FFIL' or 'tfil'. The + stream that gets passed to our init_face() routine is a stdio stream, + which isn't usable for us, since the FOND resources live in the + resource fork. So we just grab the stream->pathname field. - - Read the FOND resource into memory, then check whether there is - a TrueType font and/or(!) a Type 1 font available. + - Read the FOND resource into memory, then check whether there is a + TrueType font and/or(!) a Type 1 font available. - - If there is a Type 1 font available (as a separate 'LWFN' file), - read its data into memory, massage it slightly so it becomes - PFB data, wrap it into a memory stream, load the Type 1 driver - and delegate the rest of the work to it by calling FT_Open_Face(). - (XXX TODO: after this has been done, the kerning data from the FOND - resource should be appended to the face: On the Mac there are usually - no AFM files available. However, this is tricky since we need to map - Mac char codes to ps glyph names to glyph ID's...) + - If there is a Type 1 font available (as a separate `LWFN' file), read + its data into memory, massage it slightly so it becomes PFB data, wrap + it into a memory stream, load the Type 1 driver and delegate the rest + of the work to it by calling FT_Open_Face(). (XXX TODO: after this + has been done, the kerning data from the FOND resource should be + appended to the face: On the Mac there are usually no AFM files + available. However, this is tricky since we need to map Mac char + codes to ps glyph names to glyph ID's...) - - If there is a TrueType font (an 'sfnt' resource), read it into - memory, wrap it into a memory stream, load the TrueType driver - and delegate the rest of the work to it, by calling FT_Open_Face(). + - If there is a TrueType font (an `sfnt' resource), read it into memory, + wrap it into a memory stream, load the TrueType driver and delegate + the rest of the work to it, by calling FT_Open_Face(). */ @@ -67,7 +64,7 @@ /* This is for Mac OS X. Without redefinition, OS_INLINE */ /* expands to `static inline' which doesn't survive the */ /* -ansi compilation flag of GCC. */ -#define OS_INLINE static __inline__ +#define OS_INLINE static __inline__ #include <Carbon/Carbon.h> #else #include <Resources.h> @@ -84,23 +81,224 @@ #include FT_MAC_H + /* FSSpec functions are deprecated since Mac OS X 10.4 */ +#ifndef HAVE_FSSPEC +#if TARGET_API_MAC_OS8 || TARGET_API_MAC_CARBON +#define HAVE_FSSPEC 1 +#else +#define HAVE_FSSPEC 0 +#endif +#endif + + /* most FSRef functions were introduced since Mac OS 9 */ +#ifndef HAVE_FSREF +#if TARGET_API_MAC_OSX +#define HAVE_FSREF 1 +#else +#define HAVE_FSREF 0 +#endif +#endif + +#ifndef HFS_MAXPATHLEN +#define HFS_MAXPATHLEN 1024 +#endif + + + /* QuickDraw is deprecated since Mac OS X 10.4 */ +#ifndef HAVE_QUICKDRAW_CARBON +#if TARGET_API_MAC_OS8 || TARGET_API_MAC_CARBON +#define HAVE_QUICKDRAW_CARBON 1 +#else +#define HAVE_QUICKDRAW_CARBON 0 +#endif +#endif + + /* AppleTypeService is available since Mac OS X */ +#ifndef HAVE_ATS +#if TARGET_API_MAC_OSX +#define HAVE_ATS 1 +#else +#define HAVE_ATS 0 +#endif +#endif + /* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over TrueType in case *both* are available (this is not common, but it *is* possible). */ #ifndef PREFER_LWFN -#define PREFER_LWFN 1 +#define PREFER_LWFN 1 #endif +#if !HAVE_QUICKDRAW_CARBON /* QuickDraw is deprecated since Mac OS X 10.4 */ + + FT_EXPORT_DEF( FT_Error ) + FT_GetFile_From_Mac_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + { + return FT_Err_Unimplemented_Feature; + } + +#else + + FT_EXPORT_DEF( FT_Error ) + FT_GetFile_From_Mac_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + { + OptionBits options = kFMUseGlobalScopeOption; + + FMFontFamilyIterator famIter; + OSStatus status = FMCreateFontFamilyIterator( NULL, NULL, + options, + &famIter ); + FMFont the_font = 0; + FMFontFamily family = 0; + + + *face_index = 0; + while ( status == 0 && !the_font ) + { + status = FMGetNextFontFamily( &famIter, &family ); + if ( status == 0 ) + { + int stat2; + FMFontFamilyInstanceIterator instIter; + Str255 famNameStr; + char famName[256]; + + + /* get the family name */ + FMGetFontFamilyName( family, famNameStr ); + CopyPascalStringToC( famNameStr, famName ); + + /* iterate through the styles */ + FMCreateFontFamilyInstanceIterator( family, &instIter ); + + *face_index = 0; + stat2 = 0; + + while ( stat2 == 0 && !the_font ) + { + FMFontStyle style; + FMFontSize size; + FMFont font; + + + stat2 = FMGetNextFontFamilyInstance( &instIter, &font, + &style, &size ); + if ( stat2 == 0 && size == 0 ) + { + char fullName[256]; + + + /* build up a complete face name */ + ft_strcpy( fullName, famName ); + if ( style & bold ) + ft_strcat( fullName, " Bold" ); + if ( style & italic ) + ft_strcat( fullName, " Italic" ); + + /* compare with the name we are looking for */ + if ( ft_strcmp( fullName, fontName ) == 0 ) + { + /* found it! */ + the_font = font; + } + else + ++(*face_index); + } + } + + FMDisposeFontFamilyInstanceIterator( &instIter ); + } + } + + FMDisposeFontFamilyIterator( &famIter ); + + if ( the_font ) + { + FMGetFontContainer( the_font, pathSpec ); + return FT_Err_Ok; + } + else + return FT_Err_Unknown_File_Format; + } + +#endif /* HAVE_QUICKDRAW_CARBON */ + + +#if !HAVE_ATS + + FT_EXPORT_DEF( FT_Error ) + FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + { + return FT_Err_Unimplemented_Feature; + } + +#else + + FT_EXPORT_DEF( FT_Error ) + FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + { + CFStringRef cf_fontName; + ATSFontRef ats_font_id; + + + *face_index = 0; + + cf_fontName = CFStringCreateWithCString( NULL, fontName, + kCFStringEncodingMacRoman ); + ats_font_id = ATSFontFindFromName( cf_fontName, + kATSOptionFlagsUnRestrictedScope ); + + if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL ) + return FT_Err_Unknown_File_Format; + + if ( 0 != ATSFontGetFileSpecification( ats_font_id, pathSpec ) ) + return FT_Err_Unknown_File_Format; + + /* face_index calculation by searching preceding fontIDs */ + /* with same FSRef */ + { + int i; + FSSpec f; + + + for ( i = 1; i < ats_font_id; i++ ) + { + if ( 0 != ATSFontGetFileSpecification( ats_font_id - i, + &f ) || + f.vRefNum != pathSpec->vRefNum || + f.parID != pathSpec->parID || + f.name[0] != pathSpec->name[0] || + 0 != ft_strncmp( (char *)f.name + 1, + (char *)pathSpec->name + 1, + f.name[0] ) ) + break; + } + *face_index = ( i - 1 ); + } + return FT_Err_Ok; + } + +#endif /* HAVE_ATS */ + + #if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO -#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) +#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer ) FT_CALLBACK_DEF( void ) ft_FSp_stream_close( FT_Stream stream ) { - fclose( STREAM_FILE( stream ) ); + ft_fclose( STREAM_FILE( stream ) ); stream->descriptor.pointer = NULL; stream->size = 0; @@ -114,72 +312,190 @@ unsigned char* buffer, unsigned long count ) { - FILE* file; + FT_FILE* file; file = STREAM_FILE( stream ); - fseek( file, offset, SEEK_SET ); + ft_fseek( file, offset, SEEK_SET ); - return (unsigned long)fread( buffer, 1, count, file ); + return (unsigned long)ft_fread( buffer, 1, count, file ); } #endif /* __MWERKS__ && !TARGET_RT_MAC_MACHO */ - /* Given a pathname, fill in a file spec. */ - static int - file_spec_from_path( const char* pathname, - FSSpec* spec ) +#if HAVE_FSSPEC && !HAVE_FSREF + + static OSErr + FT_FSPathMakeSpec( const UInt8* pathname, + FSSpec* spec_p, + Boolean isDirectory ) { - -#if !TARGET_API_MAC_OS8 && \ - !( defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO ) - - OSErr e; - FSRef ref; + const char *p, *q; + short vRefNum; + long dirID; + Str255 nodeName; + OSErr err; - e = FSPathMakeRef( (UInt8 *)pathname, &ref, false /* not a directory */ ); - if ( e == noErr ) - e = FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL, spec, NULL ); + p = q = (const char *)pathname; + dirID = 0; + vRefNum = 0; - return ( e == noErr ) ? 0 : (-1); + while ( 1 ) + { + q = p + FT_MIN( 255, ft_strlen( p ) ); -#else + if ( q == p ) + return 0; - Str255 p_path; - FT_ULong path_len; + if ( 255 < ft_strlen( (char *)pathname ) ) + { + while ( p < q && *q != ':' ) + q--; + } + if ( p < q ) + *(char *)nodeName = q - p; + else if ( ft_strlen( p ) < 256 ) + *(char *)nodeName = ft_strlen( p ); + else + return errFSNameTooLong; - /* convert path to a pascal string */ - path_len = ft_strlen( pathname ); - if ( path_len > 255 ) - return -1; - p_path[0] = (unsigned char)path_len; - ft_strncpy( (char*)p_path + 1, pathname, path_len ); + ft_strncpy( (char *)nodeName + 1, (char *)p, *(char *)nodeName ); + err = FSMakeFSSpec( vRefNum, dirID, nodeName, spec_p ); + if ( err || '\0' == *q ) + return err; - if ( FSMakeFSSpec( 0, 0, p_path, spec ) != noErr ) - return -1; - else - return 0; - -#endif + vRefNum = spec_p->vRefNum; + dirID = spec_p->parID; + p = q; + } } - /* Return the file type of the file specified by spec. */ - static OSType - get_file_type( const FSSpec* spec ) + static OSErr + FT_FSpMakePath( const FSSpec* spec_p, + UInt8* path, + UInt32 maxPathSize ) { + OSErr err; + FSSpec spec = *spec_p; + short vRefNum; + long dirID; + Str255 parDir_name; + + + FT_MEM_SET( path, 0, maxPathSize ); + while ( 1 ) + { + int child_namelen = ft_strlen( (char *)path ); + unsigned char node_namelen = spec.name[0]; + unsigned char* node_name = spec.name + 1; + + + if ( node_namelen + child_namelen > maxPathSize ) + return errFSNameTooLong; + + FT_MEM_MOVE( path + node_namelen + 1, path, child_namelen ); + FT_MEM_COPY( path, node_name, node_namelen ); + if ( child_namelen > 0 ) + path[node_namelen] = ':'; + + vRefNum = spec.vRefNum; + dirID = spec.parID; + parDir_name[0] = '\0'; + err = FSMakeFSSpec( vRefNum, dirID, parDir_name, &spec ); + if ( noErr != err || dirID == spec.parID ) + break; + } + return noErr; + } + +#endif /* HAVE_FSSPEC && !HAVE_FSREF */ + + + static OSErr + FT_FSPathMakeRes( const UInt8* pathname, + short* res ) + { + +#if HAVE_FSREF + + OSErr err; + FSRef ref; + + + if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) ) + return FT_Err_Cannot_Open_Resource; + + /* at present, no support for dfont format */ + err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res ); + if ( noErr == err ) + return err; + + /* fallback to original resource-fork font */ + *res = FSOpenResFile( &ref, fsRdPerm ); + err = ResError(); + +#else + + OSErr err; + FSSpec spec; + + + if ( noErr != FT_FSPathMakeSpec( pathname, &spec, FALSE ) ) + return FT_Err_Cannot_Open_Resource; + + /* at present, no support for dfont format without FSRef */ + /* (see above), try original resource-fork font */ + *res = FSpOpenResFile( &spec, fsRdPerm ); + err = ResError(); + +#endif /* HAVE_FSREF */ + + return err; + } + + + /* Return the file type for given pathname */ + static OSType + get_file_type_from_path( const UInt8* pathname ) + { + +#if HAVE_FSREF + + FSRef ref; + FSCatalogInfo info; + + + if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) ) + return ( OSType ) 0; + + if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info, + NULL, NULL, NULL ) ) + return ( OSType ) 0; + + return ((FInfo *)(info.finderInfo))->fdType; + +#else + + FSSpec spec; FInfo finfo; - if ( FSpGetFInfo( spec, &finfo ) != noErr ) - return 0; /* file might not exist */ + if ( noErr != FT_FSPathMakeSpec( pathname, &spec, FALSE ) ) + return ( OSType ) 0; + + if ( noErr != FSpGetFInfo( &spec, &finfo ) ) + return ( OSType ) 0; return finfo.fdType; + +#endif /* HAVE_FSREF */ + } @@ -214,66 +530,35 @@ } - /* Given a file reference, answer its location as a vRefNum - and a dirID. */ - static FT_Error - get_file_location( short ref_num, - short* v_ref_num, - long* dir_id, - unsigned char* file_name ) - { - FCBPBRec pb; - OSErr error; - - - pb.ioNamePtr = file_name; - pb.ioVRefNum = 0; - pb.ioRefNum = ref_num; - pb.ioFCBIndx = 0; - - error = PBGetFCBInfoSync( &pb ); - if ( error == noErr ) - { - *v_ref_num = pb.ioFCBVRefNum; - *dir_id = pb.ioFCBParID; - } - return error; - } - - - /* Make a file spec for an LWFN file from a FOND resource and - a file name. */ - static FT_Error - make_lwfn_spec( Handle fond, - const unsigned char* file_name, - FSSpec* spec ) - { - FT_Error error; - short ref_num, v_ref_num; - long dir_id; - Str255 fond_file_name; - - - ref_num = HomeResFile( fond ); - - error = ResError(); - if ( !error ) - error = get_file_location( ref_num, &v_ref_num, - &dir_id, fond_file_name ); - if ( !error ) - error = FSMakeFSSpec( v_ref_num, dir_id, file_name, spec ); - - return error; - } - - static short - count_faces_sfnt( char *fond_data ) + count_faces_sfnt( char* fond_data ) { /* The count is 1 greater than the value in the FOND. */ /* Isn't that cute? :-) */ - return 1 + *( (short *)( fond_data + sizeof ( FamRec ) ) ); + return 1 + *( (short*)( fond_data + sizeof ( FamRec ) ) ); + } + + + static short + count_faces_scalable( char* fond_data ) + { + AsscEntry* assoc; + FamRec* fond; + short i, face, face_all; + + + fond = (FamRec*)fond_data; + face_all = *( (short *)( fond_data + sizeof ( FamRec ) ) ) + 1; + assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 ); + face = 0; + + for ( i = 0; i < face_all; i++ ) + { + if ( 0 == assoc[i].fontSize ) + face++; + } + return face; } @@ -340,10 +625,10 @@ string_count = *(unsigned short*)(p); p += sizeof ( short ); - for ( i = 0 ; i < string_count && i < 64; i++ ) + for ( i = 0; i < string_count && i < 64; i++ ) { names[i] = p; - p += names[i][0]; + p += names[i][0]; p++; } @@ -388,13 +673,106 @@ } - static short - count_faces( Handle fond ) + static FT_Error + lookup_lwfn_by_fond( const UInt8* path_fond, + const StringPtr base_lwfn, + UInt8* path_lwfn, + int path_size ) { - short sfnt_id, have_sfnt, have_lwfn = 0; - Str255 lwfn_file_name; - FSSpec lwfn_spec; +#if HAVE_FSREF + + FSRef ref, par_ref; + int dirname_len; + + + /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */ + /* We should not extract parent directory by string manipulation. */ + + if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) ) + return FT_Err_Invalid_Argument; + + if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, + NULL, NULL, NULL, &par_ref ) ) + return FT_Err_Invalid_Argument; + + if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) ) + return FT_Err_Invalid_Argument; + + if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size ) + return FT_Err_Invalid_Argument; + + /* now we have absolute dirname in lookup_path */ + if ( path_lwfn[0] == '/' ) + ft_strcat( (char *)path_lwfn, "/" ); + else + ft_strcat( (char *)path_lwfn, ":" ); + + dirname_len = ft_strlen( (char *)path_lwfn ); + ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 ); + path_lwfn[dirname_len + base_lwfn[0]] = '\0'; + + if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) ) + return FT_Err_Cannot_Open_Resource; + + if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, + NULL, NULL, NULL, NULL ) ) + return FT_Err_Cannot_Open_Resource; + + return FT_Err_Ok; + +#else + + int i; + FSSpec spec; + + + /* pathname for FSSpec is always HFS format */ + if ( ft_strlen( (char *)path_fond ) > path_size ) + return FT_Err_Invalid_Argument; + + ft_strcpy( (char *)path_lwfn, (char *)path_fond ); + + i = ft_strlen( (char *)path_lwfn ) - 1; + while ( i > 0 && ':' != path_lwfn[i] ) + i--; + + if ( i + 1 + base_lwfn[0] > path_size ) + return FT_Err_Invalid_Argument; + + if ( ':' == path_lwfn[i] ) + { + ft_strcpy( (char *)path_lwfn + i + 1, (char *)base_lwfn + 1 ); + path_lwfn[i + 1 + base_lwfn[0]] = '\0'; + } + else + { + ft_strcpy( (char *)path_lwfn, (char *)base_lwfn + 1 ); + path_lwfn[base_lwfn[0]] = '\0'; + } + + if ( noErr != FT_FSPathMakeSpec( path_lwfn, &spec, FALSE ) ) + return FT_Err_Cannot_Open_Resource; + + return FT_Err_Ok; + +#endif /* HAVE_FSREF */ + + } + + + static short + count_faces( Handle fond, + const UInt8* pathname ) + { + short sfnt_id; + short have_sfnt, have_lwfn; + Str255 lwfn_file_name; + UInt8 buff[HFS_MAXPATHLEN]; + FT_Error err; + + + have_sfnt = have_lwfn = 0; HLock( fond ); parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 ); @@ -402,27 +780,27 @@ if ( lwfn_file_name[0] ) { - if ( make_lwfn_spec( fond, lwfn_file_name, &lwfn_spec ) == FT_Err_Ok ) - have_lwfn = 1; /* yeah, we got one! */ - else - have_lwfn = 0; /* no LWFN file found */ + err = lookup_lwfn_by_fond( pathname, lwfn_file_name, + buff, sizeof ( buff ) ); + if ( FT_Err_Ok == err ) + have_lwfn = 1; } if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) ) return 1; else - return count_faces_sfnt( *fond ); + return count_faces_scalable( *fond ); } /* Read Type 1 data from the POST resources inside the LWFN file, - return a PFB buffer. This is somewhat convoluted because the FT2 + return a PFB buffer. This is somewhat convoluted because the FT2 PFB parser wants the ASCII header as one chunk, and the LWFN - chunks are often not organized that way, so we'll glue chunks + chunks are often not organized that way, so we glue chunks of the same type together. */ static FT_Error read_lwfn( FT_Memory memory, - short res_ref, + short res, FT_Byte** pfb_data, FT_ULong* size ) { @@ -430,12 +808,13 @@ short res_id; unsigned char *buffer, *p, *size_p = NULL; FT_ULong total_size = 0; + FT_ULong old_total_size = 0; FT_ULong post_size, pfb_chunk_size; Handle post_data; char code, last_code; - UseResFile( res_ref ); + UseResFile( res ); /* First pass: load all POST resources, and determine the size of */ /* the output buffer. */ @@ -446,7 +825,7 @@ { post_data = Get1Resource( 'POST', res_id++ ); if ( post_data == NULL ) - break; /* we're done */ + break; /* we are done */ code = (*post_data)[0]; @@ -460,6 +839,15 @@ total_size += GetHandleSize( post_data ) - 2; last_code = code; + + /* detect integer overflows */ + if ( total_size < old_total_size ) + { + error = FT_Err_Array_Too_Large; + goto Error; + } + + old_total_size = total_size; } if ( FT_ALLOC( buffer, (FT_Long)total_size ) ) @@ -476,7 +864,7 @@ { post_data = Get1Resource( 'POST', res_id++ ); if ( post_data == NULL ) - break; /* we're done */ + break; /* we are done */ post_size = (FT_ULong)GetHandleSize( post_data ) - 2; code = (*post_data)[0]; @@ -485,7 +873,7 @@ { if ( last_code != -1 ) { - /* we're done adding a chunk, fill in the size field */ + /* we are done adding a chunk, fill in the size field */ if ( size_p != NULL ) { *size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF ); @@ -521,7 +909,7 @@ *size = total_size; Error: - CloseResFile( res_ref ); + CloseResFile( res ); return error; } @@ -548,7 +936,7 @@ FT_Byte* base, FT_ULong size, FT_Stream_CloseFunc close, - FT_Stream *astream ) + FT_Stream* astream ) { FT_Error error; FT_Memory memory; @@ -584,7 +972,7 @@ FT_ULong size, FT_Long face_index, char* driver_name, - FT_Face *aface ) + FT_Face* aface ) { FT_Open_Args args; FT_Error error; @@ -603,11 +991,11 @@ return error; } - args.flags = FT_OPEN_STREAM; + args.flags = FT_OPEN_STREAM; args.stream = stream; if ( driver_name ) { - args.flags = args.flags | FT_OPEN_DRIVER; + args.flags = args.flags | FT_OPEN_DRIVER; args.driver = FT_Get_Module( library, driver_name ); } @@ -627,59 +1015,26 @@ } - static FT_Error - OpenFileAsResource( const FSSpec* spec, - short *p_res_ref ) - { - FT_Error error; - -#if !TARGET_API_MAC_OS8 - - FSRef hostContainerRef; - - - error = FSpMakeFSRef( spec, &hostContainerRef ); - if ( error == noErr ) - error = FSOpenResourceFile( &hostContainerRef, - 0, NULL, fsRdPerm, p_res_ref ); - - /* If the above fails, then it is probably not a resource file */ - /* However, it has been reported that FSOpenResourceFile() sometimes */ - /* fails on some old resource-fork files, which FSpOpenResFile() can */ - /* open. So, just try again with FSpOpenResFile() and see what */ - /* happens :-) */ - - if ( error != noErr ) - -#endif /* !TARGET_API_MAC_OS8 */ - - { - *p_res_ref = FSpOpenResFile( spec, fsRdPerm ); - error = ResError(); - } - - return error ? FT_Err_Cannot_Open_Resource : FT_Err_Ok; - } - - /* Create a new FT_Face from a file spec to an LWFN file. */ static FT_Error - FT_New_Face_From_LWFN( FT_Library library, - const FSSpec* lwfn_spec, - FT_Long face_index, - FT_Face *aface ) + FT_New_Face_From_LWFN( FT_Library library, + const UInt8* pathname, + FT_Long face_index, + FT_Face* aface ) { FT_Byte* pfb_data; FT_ULong pfb_size; FT_Error error; - short res_ref; + short res; - error = OpenFileAsResource( lwfn_spec, &res_ref ); - if ( error ) - return error; + if ( noErr != FT_FSPathMakeRes( pathname, &res ) ) + return FT_Err_Cannot_Open_Resource; - error = read_lwfn( library->memory, res_ref, &pfb_data, &pfb_size ); + pfb_data = NULL; + pfb_size = 0; + error = read_lwfn( library->memory, res, &pfb_data, &pfb_size ); + CloseResFile( res ); /* PFB is already loaded, useless anymore */ if ( error ) return error; @@ -697,12 +1052,12 @@ FT_New_Face_From_SFNT( FT_Library library, short sfnt_id, FT_Long face_index, - FT_Face *aface ) + FT_Face* aface ) { Handle sfnt = NULL; FT_Byte* sfnt_data; size_t sfnt_size; - FT_Error error = 0; + FT_Error error = FT_Err_Ok; FT_Memory memory = library->memory; int is_cff; @@ -739,41 +1094,43 @@ /* Create a new FT_Face from a file spec to a suitcase file. */ static FT_Error - FT_New_Face_From_Suitcase( FT_Library library, - short res_ref, - FT_Long face_index, - FT_Face *aface ) + FT_New_Face_From_Suitcase( FT_Library library, + const UInt8* pathname, + FT_Long face_index, + FT_Face* aface ) { - FT_Error error = FT_Err_Ok; - short res_index; + FT_Error error = FT_Err_Cannot_Open_Resource; + short res_ref, res_index; Handle fond; - short num_faces; + short num_faces_in_res, num_faces_in_fond; + if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) ) + return FT_Err_Cannot_Open_Resource; + UseResFile( res_ref ); + if ( ResError() ) + return FT_Err_Cannot_Open_Resource; + num_faces_in_res = 0; for ( res_index = 1; ; ++res_index ) { fond = Get1IndResource( 'FOND', res_index ); if ( ResError() ) - { - error = FT_Err_Cannot_Open_Resource; - goto Error; - } - if ( face_index < 0 ) break; - num_faces = count_faces( fond ); - if ( face_index < num_faces ) - break; + num_faces_in_fond = count_faces( fond, pathname ); + num_faces_in_res += num_faces_in_fond; - face_index -= num_faces; + if ( 0 <= face_index && face_index < num_faces_in_fond && error ) + error = FT_New_Face_From_FOND( library, fond, face_index, aface ); + + face_index -= num_faces_in_fond; } - error = FT_New_Face_From_FOND( library, fond, face_index, aface ); - - Error: CloseResFile( res_ref ); + if ( FT_Err_Ok == error && NULL != aface ) + (*aface)->num_faces = num_faces_in_res; return error; } @@ -784,14 +1141,16 @@ FT_New_Face_From_FOND( FT_Library library, Handle fond, FT_Long face_index, - FT_Face *aface ) + FT_Face* aface ) { - short sfnt_id, have_sfnt, have_lwfn = 0; - Str255 lwfn_file_name; - short fond_id; - OSType fond_type; - Str255 fond_name; - FSSpec lwfn_spec; + short sfnt_id, have_sfnt, have_lwfn = 0; + short fond_id; + OSType fond_type; + Str255 fond_name; + Str255 lwfn_file_name; + UInt8 path_lwfn[HFS_MAXPATHLEN]; + OSErr err; + FT_Error error; GetResInfo( fond, &fond_id, &fond_type, fond_name ); @@ -804,18 +1163,83 @@ if ( lwfn_file_name[0] ) { - if ( make_lwfn_spec( fond, lwfn_file_name, &lwfn_spec ) == FT_Err_Ok ) - have_lwfn = 1; /* yeah, we got one! */ - else - have_lwfn = 0; /* no LWFN file found */ + short res; + + + res = HomeResFile( fond ); + if ( noErr != ResError() ) + goto found_no_lwfn_file; + +#if HAVE_FSREF + + { + UInt8 path_fond[HFS_MAXPATHLEN]; + FSRef ref; + + + err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum, + NULL, NULL, NULL, &ref, NULL ); + if ( noErr != err ) + goto found_no_lwfn_file; + + err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) ); + if ( noErr != err ) + goto found_no_lwfn_file; + + error = lookup_lwfn_by_fond( path_fond, lwfn_file_name, + path_lwfn, sizeof ( path_lwfn ) ); + if ( FT_Err_Ok == error ) + have_lwfn = 1; + } + +#elif HAVE_FSSPEC + + { + UInt8 path_fond[HFS_MAXPATHLEN]; + FCBPBRec pb; + Str255 fond_file_name; + FSSpec spec; + + + FT_MEM_SET( &spec, 0, sizeof ( FSSpec ) ); + FT_MEM_SET( &pb, 0, sizeof ( FCBPBRec ) ); + + pb.ioNamePtr = fond_file_name; + pb.ioVRefNum = 0; + pb.ioRefNum = res; + pb.ioFCBIndx = 0; + + err = PBGetFCBInfoSync( &pb ); + if ( noErr != err ) + goto found_no_lwfn_file; + + err = FSMakeFSSpec( pb.ioFCBVRefNum, pb.ioFCBParID, + fond_file_name, &spec ); + if ( noErr != err ) + goto found_no_lwfn_file; + + err = FT_FSpMakePath( &spec, path_fond, sizeof ( path_fond ) ); + if ( noErr != err ) + goto found_no_lwfn_file; + + error = lookup_lwfn_by_fond( path_fond, lwfn_file_name, + path_lwfn, sizeof ( path_lwfn ) ); + if ( FT_Err_Ok == error ) + have_lwfn = 1; + } + +#endif /* HAVE_FSREF, HAVE_FSSPEC */ + } if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) ) return FT_New_Face_From_LWFN( library, - &lwfn_spec, + path_lwfn, face_index, aface ); - else if ( have_sfnt ) + + found_no_lwfn_file: + if ( have_sfnt ) return FT_New_Face_From_SFNT( library, sfnt_id, face_index, @@ -825,126 +1249,29 @@ } - /* documentation is in ftmac.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_GetFile_From_Mac_Name( const char* fontName, - FSSpec* pathSpec, - FT_Long* face_index ) - { - OptionBits options = kFMUseGlobalScopeOption; - - FMFontFamilyIterator famIter; - OSStatus status = FMCreateFontFamilyIterator( NULL, NULL, - options, - &famIter ); - FMFont the_font = NULL; - FMFontFamily family = NULL; - - - *face_index = 0; - while ( status == 0 && !the_font ) - { - status = FMGetNextFontFamily( &famIter, &family ); - if ( status == 0 ) - { - int stat2; - FMFontFamilyInstanceIterator instIter; - Str255 famNameStr; - char famName[256]; - - - /* get the family name */ - FMGetFontFamilyName( family, famNameStr ); - CopyPascalStringToC( famNameStr, famName ); - - /* iterate through the styles */ - FMCreateFontFamilyInstanceIterator( family, &instIter ); - - *face_index = 0; - stat2 = 0; - while ( stat2 == 0 && !the_font ) - { - FMFontStyle style; - FMFontSize size; - FMFont font; - - - stat2 = FMGetNextFontFamilyInstance( &instIter, &font, - &style, &size ); - if ( stat2 == 0 && size == 0 ) - { - char fullName[256]; - - - /* build up a complete face name */ - ft_strcpy( fullName, famName ); - if ( style & bold ) - strcat( fullName, " Bold" ); - if ( style & italic ) - strcat( fullName, " Italic" ); - - /* compare with the name we are looking for */ - if ( ft_strcmp( fullName, fontName ) == 0 ) - { - /* found it! */ - the_font = font; - } - else - ++(*face_index); - } - } - - FMDisposeFontFamilyInstanceIterator( &instIter ); - } - } - - FMDisposeFontFamilyIterator( &famIter ); - - if ( the_font ) - { - FMGetFontContainer( the_font, pathSpec ); - return FT_Err_Ok; - } - else - return FT_Err_Unknown_File_Format; - } - /* Common function to load a new FT_Face from a resource file. */ - static FT_Error - FT_New_Face_From_Resource( FT_Library library, - const FSSpec *spec, - FT_Long face_index, - FT_Face *aface ) + FT_New_Face_From_Resource( FT_Library library, + const UInt8* pathname, + FT_Long face_index, + FT_Face* aface ) { OSType file_type; - short res_ref; FT_Error error; - if ( OpenFileAsResource( spec, &res_ref ) == FT_Err_Ok ) - { - /* LWFN is a (very) specific file format, check for it explicitly */ + /* LWFN is a (very) specific file format, check for it explicitly */ + file_type = get_file_type_from_path( pathname ); + if ( file_type == 'LWFN' ) + return FT_New_Face_From_LWFN( library, pathname, face_index, aface ); - file_type = get_file_type( spec ); - if ( file_type == 'LWFN' ) - return FT_New_Face_From_LWFN( library, spec, face_index, aface ); - - /* Otherwise the file type doesn't matter (there are more than */ - /* `FFIL' and `tfil'). Just try opening it as a font suitcase; */ - /* if it works, fine. */ + /* Otherwise the file type doesn't matter (there are more than */ + /* `FFIL' and `tfil'). Just try opening it as a font suitcase; */ + /* if it works, fine. */ - error = FT_New_Face_From_Suitcase( library, res_ref, - face_index, aface ); - if ( error == 0 ) - return error; - - /* else forget about the resource fork and fall through to */ - /* data fork formats */ - - CloseResFile( res_ref ); - } + error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface ); + if ( error == 0 ) + return error; /* let it fall through to normal loader (.ttf, .otf, etc.); */ /* we signal this by returning no error and no FT_Face */ @@ -968,10 +1295,9 @@ FT_New_Face( FT_Library library, const char* pathname, FT_Long face_index, - FT_Face *aface ) + FT_Face* aface ) { FT_Open_Args args; - FSSpec spec; FT_Error error; @@ -979,10 +1305,12 @@ if ( !pathname ) return FT_Err_Invalid_Argument; - if ( file_spec_from_path( pathname, &spec ) ) - return FT_Err_Invalid_Argument; + error = FT_Err_Ok; + *aface = NULL; - error = FT_New_Face_From_Resource( library, &spec, face_index, aface ); + /* try resourcefork based font: LWFN, FFIL */ + error = FT_New_Face_From_Resource( library, (UInt8 *)pathname, + face_index, aface ); if ( error != 0 || *aface != NULL ) return error; @@ -993,6 +1321,55 @@ } + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FSRef */ + /* */ + /* <Description> */ + /* FT_New_Face_From_FSRef is identical to FT_New_Face except it */ + /* accepts an FSRef instead of a path. */ + /* */ + FT_EXPORT_DEF( FT_Error ) + FT_New_Face_From_FSRef( FT_Library library, + const FSRef* ref, + FT_Long face_index, + FT_Face* aface ) + { + +#if !HAVE_FSREF + + return FT_Err_Unimplemented_Feature; + +#else + + FT_Error error; + FT_Open_Args args; + OSErr err; + UInt8 pathname[HFS_MAXPATHLEN]; + + + if ( !ref ) + return FT_Err_Invalid_Argument; + + err = FSRefMakePath( ref, pathname, sizeof ( pathname ) ); + if ( err ) + error = FT_Err_Cannot_Open_Resource; + + error = FT_New_Face_From_Resource( library, pathname, face_index, aface ); + if ( error != 0 || *aface != NULL ) + return error; + + /* fallback to datafork font */ + args.flags = FT_OPEN_PATHNAME; + args.pathname = (char*)pathname; + return FT_Open_Face( library, &args, face_index, aface ); + +#endif /* HAVE_FSREF */ + + } + + /*************************************************************************/ /* */ /* <Function> */ @@ -1003,87 +1380,52 @@ /* accepts an FSSpec instead of a path. */ /* */ FT_EXPORT_DEF( FT_Error ) - FT_New_Face_From_FSSpec( FT_Library library, - const FSSpec *spec, - FT_Long face_index, - FT_Face *aface ) + FT_New_Face_From_FSSpec( FT_Library library, + const FSSpec* spec, + FT_Long face_index, + FT_Face* aface ) { -#if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO - FT_Open_Args args; - FT_Stream stream; - FILE* file; - FT_Memory memory; -#endif + +#if HAVE_FSREF + + FSRef ref; + + + if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr ) + return FT_Err_Invalid_Argument; + else + return FT_New_Face_From_FSRef( library, &ref, face_index, aface ); + +#elif HAVE_FSSPEC + FT_Error error; + FT_Open_Args args; + OSErr err; + UInt8 pathname[HFS_MAXPATHLEN]; - /* test for valid `library' and `aface' delayed to FT_Open_Face() */ if ( !spec ) return FT_Err_Invalid_Argument; - error = FT_New_Face_From_Resource( library, spec, face_index, aface ); + err = FT_FSpMakePath( spec, pathname, sizeof ( pathname ) ); + if ( err ) + error = FT_Err_Cannot_Open_Resource; + + error = FT_New_Face_From_Resource( library, pathname, face_index, aface ); if ( error != 0 || *aface != NULL ) return error; - /* let it fall through to normal loader (.ttf, .otf, etc.) */ + /* fallback to datafork font */ + args.flags = FT_OPEN_PATHNAME; + args.pathname = (char*)pathname; + return FT_Open_Face( library, &args, face_index, aface ); -#if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO +#else - /* Codewarrior's C library can open a FILE from a FSSpec */ - /* but we must compile with FSp_fopen.c in addition to */ - /* runtime libraries. */ + return FT_Err_Unimplemented_Feature; - memory = library->memory; +#endif /* HAVE_FSREF, HAVE_FSSPEC */ - if ( FT_NEW( stream ) ) - return error; - stream->memory = memory; - - file = FSp_fopen( spec, "rb" ); - if ( !file ) - return FT_Err_Cannot_Open_Resource; - - fseek( file, 0, SEEK_END ); - stream->size = ftell( file ); - fseek( file, 0, SEEK_SET ); - - stream->descriptor.pointer = file; - stream->pathname.pointer = NULL; - stream->pos = 0; - - stream->read = ft_FSp_stream_io; - stream->close = ft_FSp_stream_close; - - args.flags = FT_OPEN_STREAM; - args.stream = stream; - - error = FT_Open_Face( library, &args, face_index, aface ); - if ( error == FT_Err_Ok ) - (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; - -#else /* !(__MWERKS__ && !TARGET_RT_MAC_MACHO) */ - - { - FSRef ref; - UInt8 path[256]; - OSErr err; - - - err = FSpMakeFSRef(spec, &ref); - if ( !err ) - { - err = FSRefMakePath( &ref, path, sizeof ( path ) ); - if ( !err ) - error = FT_New_Face( library, (const char*)path, - face_index, aface ); - } - if ( err ) - error = FT_Err_Cannot_Open_Resource; - } - -#endif /* !(__MWERKS__ && !TARGET_RT_MAC_MACHO) */ - - return error; } diff --git a/src/libs/freetype2/base/ftobject.c b/src/libs/freetype2/base/ftobject.c deleted file mode 100644 index 34e41e943f..0000000000 --- a/src/libs/freetype2/base/ftobject.c +++ /dev/null @@ -1,396 +0,0 @@ -#include <ft2build.h> -#include FT_INTERNAL_OBJECT_H -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_OBJECTS_H - -#define FT_MAGIC_DEATH 0xDEADdead -#define FT_MAGIC_CLASS 0x12345678 - -#define FT_TYPE_HASH(x) (( (FT_UInt32)(x) >> 2 )^( (FT_UInt32)(x) >> 10 )) - -#define FT_OBJECT_CHECK(o) \ - ( FT_OBJECT(o) != NULL && \ - FT_OBJECT(o)->clazz != NULL && \ - FT_OBJECT(o)->ref_count >= 1 && \ - FT_OBJECT(o)->clazz->magic == FT_MAGIC_CLASS ) - -#define FT_CLASS_CHECK(c) \ - ( FT_CLASS(c) != NULL && FT_CLASS(c)->magic == FT_MAGIC_CLASS ) - -#define FT_ASSERT_IS_CLASS(c) FT_ASSERT( FT_CLASS_CHECK(c) ) - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** *****/ - /***** M E T A - C L A S S *****/ - /***** *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - /* forward declaration */ - FT_BASE_DEF( FT_Error ) - ft_metaclass_init( FT_MetaClass meta, - FT_Library library ); - - /* forward declaration */ - FT_BASE_DEF( void ) - ft_metaclass_done( FT_MetaClass meta ); - - - /* class type for the meta-class itself */ - static const FT_TypeRec ft_meta_class_type = - { - "FT2.MetaClass", - NULL, - - sizeof( FT_MetaClassRec ), - (FT_Object_InitFunc) ft_metaclass_init, - (FT_Object_DoneFunc) ft_metaclass_done, - - sizeof( FT_ClassRec ), - (FT_Object_InitFunc) NULL, - (FT_Object_DoneFunc) NULL - }; - - - - - /* destroy a given class */ - static void - ft_class_hnode_destroy( FT_ClassHNode node ) - { - FT_Class clazz = node->clazz; - FT_Memory memory = clazz->memory; - - if ( clazz->class_done ) - clazz->class_done( (FT_Object) clazz ); - - FT_FREE( clazz ); - - node->clazz = NULL; - node->type = NULL; - - FT_FREE( node ); - } - - - static FT_Int - ft_type_equal( FT_Type type1, - FT_Type type2 ) - { - if ( type1 == type2 ) - goto Ok; - - if ( type1 == NULL || type2 == NULL ) - goto Fail; - - /* compare parent types */ - if ( type1->super != type2->super ) - { - if ( type1->super == NULL || - type2->super == NULL || - !ft_type_equal( type1, type2 ) ) - goto Fail; - } - - /* compare type names */ - if ( type1->name != type2->name ) - { - if ( type1->name == NULL || - type2->name == NULL || - ft_strcmp( type1->name, type2->name ) != 0 ) - goto Fail; - } - - /* compare the other type fields */ - if ( type1->class_size != type2->class_size || - type1->class_init != type2->class_init || - type1->class_done != type2->class_done || - type1->obj_size != type2->obj_size || - type1->obj_init != type2->obj_init || - type1->obj_done != type2->obj_done ) - goto Fail; - - Ok: - return 1; - - Fail: - return 0; - } - - - static FT_Int - ft_class_hnode_equal( const FT_ClassHNode node1, - const FT_ClassHNode node2 ) - { - FT_Type type1 = node1->type; - FT_Type type2 = node2->type; - - /* comparing the pointers should work in 99% of cases */ - return ( type1 == type2 ) ? 1 : ft_type_equal( type1, type2 ); - } - - - FT_BASE_DEF( void ) - ft_metaclass_done( FT_MetaClass meta ) - { - /* clear all classes */ - ft_hash_done( &meta->type_to_class, - (FT_Hash_ForeachFunc) ft_class_hnode_destroy, - NULL ); - - meta->clazz.object.clazz = NULL; - meta->clazz.object.ref_count = 0; - meta->clazz.magic = FT_MAGIC_DEATH; - } - - - FT_BASE_DEF( FT_Error ) - ft_metaclass_init( FT_MetaClass meta, - FT_Library library ) - { - FT_ClassRec* clazz = (FT_ClassRec*) &meta->clazz; - - /* the meta-class is its OWN class !! */ - clazz->object.clazz = (FT_Class) clazz; - clazz->object.ref_count = 1; - clazz->magic = FT_MAGIC_CLASS; - clazz->library = library; - clazz->memory = library->memory; - clazz->type = &ft_meta_class_type; - clazz->info = NULL; - - clazz->class_done = (FT_Object_DoneFunc) ft_metaclass_done; - - clazz->obj_size = sizeof( FT_ClassRec ); - clazz->obj_init = NULL; - clazz->obj_done = NULL; - - return ft_hash_init( &meta->type_to_class, - (FT_Hash_EqualFunc) ft_class_hnode_equal, - library->memory ); - } - - - /* find or create the class corresponding to a given type */ - /* note that this function will retunr NULL in case of */ - /* memory overflow */ - /* */ - static FT_Class - ft_metaclass_get_class( FT_MetaClass meta, - FT_Type ctype ) - { - FT_ClassHNodeRec keynode, *node, **pnode; - FT_Memory memory; - FT_ClassRec* clazz; - FT_Class parent; - FT_Error error; - - keynode.hnode.hash = FT_TYPE_HASH( ctype ); - keynode.type = ctype; - - pnode = (FT_ClassHNode*) ft_hash_lookup( &meta->type_to_class, - (FT_HashNode) &keynode ); - node = *pnode; - if ( node != NULL ) - { - clazz = (FT_ClassRec*) node->clazz; - goto Exit; - } - - memory = FT_CLASS__MEMORY(meta); - clazz = NULL; - parent = NULL; - if ( ctype->super != NULL ) - { - FT_ASSERT( ctype->super->class_size <= ctype->class_size ); - FT_ASSERT( ctype->super->obj_size <= ctype->obj_size ); - - parent = ft_metaclass_get_class( meta, ctype->super ); - } - - if ( !FT_NEW( node ) ) - { - if ( !FT_ALLOC( clazz, ctype->class_size ) ) - { - if ( parent ) - FT_MEM_COPY( (FT_ClassRec*)clazz, parent, parent->type->class_size ); - - clazz->object.clazz = (FT_Class) meta; - clazz->object.ref_count = 1; - - clazz->memory = memory; - clazz->library = FT_CLASS__LIBRARY(meta); - clazz->super = parent; - clazz->type = ctype; - clazz->info = NULL; - clazz->magic = FT_MAGIC_CLASS; - - clazz->class_done = ctype->class_done; - clazz->obj_size = ctype->obj_size; - clazz->obj_init = ctype->obj_init; - clazz->obj_done = ctype->obj_done; - - if ( parent ) - { - if ( clazz->class_done == NULL ) - clazz->class_done = parent->class_done; - - if ( clazz->obj_init == NULL ) - clazz->obj_init = parent->obj_init; - - if ( clazz->obj_done == NULL ) - clazz->obj_done = parent->obj_done; - } - - /* find class initializer, if any */ - { - FT_Type ztype = ctype; - FT_Object_InitFunc cinit = NULL; - - do - { - cinit = ztype->class_init; - if ( cinit != NULL ) - break; - - ztype = ztype->super; - } - while ( ztype != NULL ); - - /* then call it when needed */ - if ( cinit != NULL ) - error = cinit( (FT_Object) clazz, NULL ); - } - } - - if (error) - { - if ( clazz ) - { - /* we always call the class destructor when */ - /* an error was detected in the constructor !! */ - if ( clazz->class_done ) - clazz->class_done( (FT_Object) clazz ); - - FT_FREE( clazz ); - } - FT_FREE( node ); - } - } - - Exit: - return (FT_Class) clazz; - } - - - - - - - - - - - - - - - FT_BASE_DEF( FT_Int ) - ft_object_check( FT_Pointer obj ) - { - return FT_OBJECT_CHECK(obj); - } - - - FT_BASE_DEF( FT_Int ) - ft_object_is_a( FT_Pointer obj, - FT_Class clazz ) - { - if ( FT_OBJECT_CHECK(obj) ) - { - FT_Class c = FT_OBJECT__CLASS(obj); - - do - { - if ( c == clazz ) - return 1; - - c = c->super; - } - while ( c == NULL ); - - return (clazz == NULL); - } - return 0; - } - - - FT_BASE_DEF( FT_Error ) - ft_object_create( FT_Object *pobject, - FT_Class clazz, - FT_Pointer init_data ) - { - FT_Memory memory; - FT_Error error; - FT_Object obj; - - FT_ASSERT_IS_CLASS(clazz); - - memory = FT_CLASS__MEMORY(clazz); - if ( !FT_ALLOC( obj, clazz->obj_size ) ) - { - obj->clazz = clazz; - obj->ref_count = 1; - - if ( clazz->obj_init ) - { - error = clazz->obj_init( obj, init_data ); - if ( error ) - { - /* IMPORTANT: call the destructor when an error */ - /* was detected in the constructor !! */ - if ( clazz->obj_done ) - clazz->obj_done( obj ); - - FT_FREE( obj ); - } - } - } - *pobject = obj; - return error; - } - - - FT_BASE_DEF( FT_Class ) - ft_class_find_by_type( FT_Type type, - FT_Library library ) - { - FT_MetaClass meta = &library->meta_class; - - return ft_metaclass_get_class( meta, type ); - } - - - FT_BASE_DEF( FT_Error ) - ft_object_create_from_type( FT_Object *pobject, - FT_Type type, - FT_Pointer init_data, - FT_Library library ) - { - FT_Class clazz; - FT_Error error; - - clazz = ft_class_find_by_type( type, library ); - if ( clazz ) - error = ft_object_create( pobject, clazz, init_data ); - else - { - *pobject = NULL; - error = FT_Err_Out_Of_Memory; - } - - return error; - } diff --git a/src/libs/freetype2/base/ftobjs.c b/src/libs/freetype2/base/ftobjs.c index 1bf813a482..a7d82de768 100644 --- a/src/libs/freetype2/base/ftobjs.c +++ b/src/libs/freetype2/base/ftobjs.c @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -33,7 +33,10 @@ #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_TT_CMAP_H +#include FT_SERVICE_KERNING_H +#include FT_SERVICE_TRUETYPE_ENGINE_H +#define GRID_FIT_METRICS FT_BASE_DEF( FT_Pointer ) ft_service_list_lookup( FT_ServiceDesc service_descriptors, @@ -267,6 +270,7 @@ FT_ULong size ) { FT_Memory memory = FT_FACE_MEMORY( slot->face ); + FT_Error error; if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) @@ -274,7 +278,8 @@ else slot->internal->flags |= FT_GLYPH_OWN_BITMAP; - return FT_MEM_ALLOC( slot->bitmap.buffer, size ); + (void)FT_ALLOC( slot->bitmap.buffer, size ); + return error; } @@ -313,9 +318,9 @@ static void ft_glyphslot_done( FT_GlyphSlot slot ) { - FT_Driver driver = slot->face->driver; - FT_Driver_Class clazz = driver->clazz; - FT_Memory memory = driver->root.memory; + FT_Driver driver = slot->face->driver; + FT_Driver_Class clazz = driver->clazz; + FT_Memory memory = driver->root.memory; if ( clazz->done_slot ) @@ -341,11 +346,11 @@ FT_New_GlyphSlot( FT_Face face, FT_GlyphSlot *aslot ) { - FT_Error error; - FT_Driver driver; - FT_Driver_Class clazz; - FT_Memory memory; - FT_GlyphSlot slot; + FT_Error error; + FT_Driver driver; + FT_Driver_Class clazz; + FT_Memory memory; + FT_GlyphSlot slot; if ( !face || !face->driver ) @@ -474,6 +479,50 @@ ft_lookup_glyph_renderer( FT_GlyphSlot slot ); +#ifdef GRID_FIT_METRICS + static void + ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot, + FT_Bool vertical ) + { + FT_Glyph_Metrics* metrics = &slot->metrics; + FT_Pos right, bottom; + + + if ( vertical ) + { + metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); + metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); + + right = FT_PIX_CEIL( metrics->vertBearingX + metrics->width ); + bottom = FT_PIX_CEIL( metrics->vertBearingY + metrics->height ); + + metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); + metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); + + metrics->width = right - metrics->vertBearingX; + metrics->height = bottom - metrics->vertBearingY; + } + else + { + metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); + metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); + + right = FT_PIX_CEIL ( metrics->horiBearingX + metrics->width ); + bottom = FT_PIX_FLOOR( metrics->horiBearingY - metrics->height ); + + metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); + metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); + + metrics->width = right - metrics->horiBearingX; + metrics->height = metrics->horiBearingY - bottom; + } + + metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); + metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); + } +#endif /* GRID_FIT_METRICS */ + + /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) @@ -485,7 +534,7 @@ FT_Driver driver; FT_GlyphSlot slot; FT_Library library; - FT_Bool autohint; + FT_Bool autohint = 0; FT_Module hinter; @@ -498,42 +547,43 @@ slot = face->glyph; ft_glyphslot_clear( slot ); - driver = face->driver; + driver = face->driver; + library = driver->root.library; + hinter = library->auto_hinter; + + /* resolve load flags dependencies */ - /* if the flag NO_RECURSE is set, we disable hinting and scaling */ if ( load_flags & FT_LOAD_NO_RECURSE ) - { - /* disable scaling, hinting, and transformation */ load_flags |= FT_LOAD_NO_SCALE | - FT_LOAD_NO_HINTING | - FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM; - /* disable bitmap rendering */ + if ( load_flags & FT_LOAD_NO_SCALE ) + { + load_flags |= FT_LOAD_NO_HINTING | + FT_LOAD_NO_BITMAP; + load_flags &= ~FT_LOAD_RENDER; } - /* do we need to load the glyph through the auto-hinter? */ - library = driver->root.library; - hinter = library->auto_hinter; - autohint = - FT_BOOL( hinter && - !( load_flags & ( FT_LOAD_NO_SCALE | - FT_LOAD_NO_HINTING | - FT_LOAD_NO_AUTOHINT ) ) && - FT_DRIVER_IS_SCALABLE( driver ) && - FT_DRIVER_USES_OUTLINES( driver ) ); - if ( autohint ) + if ( FT_LOAD_TARGET_MODE( load_flags ) == FT_RENDER_MODE_LIGHT ) + load_flags |= FT_LOAD_FORCE_AUTOHINT; + + /* auto-hinter is preferred and should be used */ + if ( ( !FT_DRIVER_HAS_HINTER( driver ) || + ( load_flags & FT_LOAD_FORCE_AUTOHINT ) ) && + !( load_flags & FT_LOAD_NO_HINTING ) && + !( load_flags & FT_LOAD_NO_AUTOHINT ) ) { - if ( FT_DRIVER_HAS_HINTER( driver ) && - !( load_flags & FT_LOAD_FORCE_AUTOHINT ) ) - autohint = 0; + /* check whether it works for this face */ + autohint = + FT_BOOL( hinter && + FT_DRIVER_IS_SCALABLE( driver ) && + FT_DRIVER_USES_OUTLINES( driver ) && + face->internal->transform_matrix.yy > 0 && + face->internal->transform_matrix.yx == 0 ); } - /* don't apply autohinting if glyph is vertically distorted or */ - /* mirrored */ - if ( autohint && !( face->internal->transform_matrix.yy <= 0 || - face->internal->transform_matrix.yx != 0 ) ) + if ( autohint ) { FT_AutoHinter_Service hinting; @@ -570,10 +620,19 @@ if ( error ) goto Exit; - /* check that the loaded outline is correct */ - error = FT_Outline_Check( &slot->outline ); - if ( error ) - goto Exit; + if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) + { + /* check that the loaded outline is correct */ + error = FT_Outline_Check( &slot->outline ); + if ( error ) + goto Exit; + +#ifdef GRID_FIT_METRICS + if ( !( load_flags & FT_LOAD_NO_HINTING ) ) + ft_glyphslot_grid_fit_metrics( slot, + FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); +#endif + } } Load_Ok: @@ -596,6 +655,7 @@ FT_Size_Metrics* metrics = &face->size->metrics; + /* it's tricky! */ slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance, metrics->x_scale, 64 ); @@ -892,7 +952,7 @@ FT_Driver_Class clazz; FT_Face face = 0; FT_Error error, error2; - FT_Face_Internal internal; + FT_Face_Internal internal = NULL; clazz = driver->clazz; @@ -1195,7 +1255,7 @@ pfb_data[3] = 0; pfb_data[4] = 0; pfb_data[5] = 0; - pfb_pos = 7; + pfb_pos = 6; pfb_lenpos = 2; len = 0; @@ -1228,7 +1288,7 @@ len = rlen; pfb_data[pfb_pos++] = (FT_Byte)type; - pfb_lenpos = (FT_Byte)pfb_pos; + pfb_lenpos = pfb_pos; pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ pfb_data[pfb_pos++] = 0; pfb_data[pfb_pos++] = 0; @@ -1693,22 +1753,55 @@ /* now allocate a glyph slot object for the face */ FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" )); - error = FT_New_GlyphSlot( face, NULL ); - if ( error ) - goto Fail; - - /* finally, allocate a size object for the face */ + if ( face_index >= 0 ) { - FT_Size size; - - - FT_TRACE4(( "FT_Open_Face: Creating size object\n" )); - - error = FT_New_Size( face, &size ); + error = FT_New_GlyphSlot( face, NULL ); if ( error ) goto Fail; - face->size = size; + /* finally, allocate a size object for the face */ + { + FT_Size size; + + + FT_TRACE4(( "FT_Open_Face: Creating size object\n" )); + + error = FT_New_Size( face, &size ); + if ( error ) + goto Fail; + + face->size = size; + } + } + + /* some checks */ + + if ( FT_IS_SCALABLE( face ) ) + { + if ( face->height < 0 ) + face->height = (FT_Short)-face->height; + + if ( !FT_HAS_VERTICAL( face ) ) + face->max_advance_height = (FT_Short)face->height; + } + + if ( FT_HAS_FIXED_SIZES( face ) ) + { + FT_Int i; + + + for ( i = 0; i < face->num_fixed_sizes; i++ ) + { + FT_Bitmap_Size* bsize = face->available_sizes + i; + + + if ( bsize->height < 0 ) + bsize->height = (FT_Short)-bsize->height; + if ( bsize->x_ppem < 0 ) + bsize->x_ppem = (FT_Short)-bsize->x_ppem; + if ( bsize->y_ppem < 0 ) + bsize->y_ppem = -bsize->y_ppem; + } } /* initialize internal face data */ @@ -1727,6 +1820,9 @@ if ( aface ) *aface = face; + else + FT_Done_Face( face ); + goto Exit; Fail: @@ -1948,12 +2044,80 @@ } + /* documentation is in ftobjs.h */ + + FT_BASE_DEF( FT_Error ) + FT_Match_Size( FT_Face face, + FT_Size_Request req, + FT_Bool ignore_width, + FT_ULong* index ) + { + FT_Int i; + FT_Long w, h; + + + if ( !FT_HAS_FIXED_SIZES( face ) ) + return FT_Err_Invalid_Face_Handle; + + /* FT_Bitmap_Size doesn't provide enough info... */ + if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL ) + return FT_Err_Unimplemented_Feature; + + w = FT_REQUEST_WIDTH ( req ); + h = FT_REQUEST_HEIGHT( req ); + + if ( req->width && !req->height ) + h = w; + else if ( !req->width && req->height ) + w = h; + + w = FT_PIX_ROUND( w ); + h = FT_PIX_ROUND( h ); + + for ( i = 0; i < face->num_fixed_sizes; i++ ) + { + FT_Bitmap_Size* bsize = face->available_sizes + i; + + + if ( h != FT_PIX_ROUND( bsize->y_ppem ) ) + continue; + + if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width ) + { + if ( index ) + *index = (FT_ULong)i; + + return FT_Err_Ok; + } + } + + return FT_Err_Invalid_Pixel_Size; + } + + + /* documentation is in ftobjs.h */ + + FT_BASE_DEF( void ) + ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, + FT_Pos advance ) + { + /* the factor 1.2 is a heuristical value */ + if ( !advance ) + advance = metrics->height * 12 / 10; + + metrics->vertBearingX = -( metrics->width / 2 ); + metrics->vertBearingY = ( advance - metrics->height ) / 2; + metrics->vertAdvance = advance; + } + + static void ft_recompute_scaled_metrics( FT_Face face, FT_Size_Metrics* metrics ) { /* Compute root ascender, descender, test height, and max_advance */ +#ifdef GRID_FIT_METRICS metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender, metrics->y_scale ) ); @@ -1965,6 +2129,243 @@ metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width, metrics->x_scale ) ); +#else /* !GRID_FIT_METRICS */ + metrics->ascender = FT_MulFix( face->ascender, + metrics->y_scale ); + + metrics->descender = FT_MulFix( face->descender, + metrics->y_scale ); + + metrics->height = FT_MulFix( face->height, + metrics->y_scale ); + + metrics->max_advance = FT_MulFix( face->max_advance_width, + metrics->x_scale ); +#endif /* !GRID_FIT_METRICS */ + } + + + FT_BASE_DEF( void ) + FT_Select_Metrics( FT_Face face, + FT_ULong strike_index ) + { + FT_Size_Metrics* metrics; + FT_Bitmap_Size* bsize; + + + metrics = &face->size->metrics; + bsize = face->available_sizes + strike_index; + + metrics->x_ppem = (FT_UShort)( ( bsize->x_ppem + 32 ) >> 6 ); + metrics->y_ppem = (FT_UShort)( ( bsize->y_ppem + 32 ) >> 6 ); + + if ( FT_IS_SCALABLE( face ) ) + { + metrics->x_scale = FT_DivFix( bsize->x_ppem, + face->units_per_EM ); + metrics->y_scale = FT_DivFix( bsize->y_ppem, + face->units_per_EM ); + + ft_recompute_scaled_metrics( face, metrics ); + } + else + { + metrics->x_scale = 1L << 22; + metrics->y_scale = 1L << 22; + metrics->ascender = bsize->y_ppem; + metrics->descender = 0; + metrics->height = bsize->height << 6; + metrics->max_advance = bsize->x_ppem; + } + } + + + FT_BASE_DEF( void ) + FT_Request_Metrics( FT_Face face, + FT_Size_Request req ) + { + FT_Driver_Class clazz; + FT_Size_Metrics* metrics; + + + clazz = face->driver->clazz; + metrics = &face->size->metrics; + + if ( FT_IS_SCALABLE( face ) ) + { + FT_Long w, h, scaled_w = 0, scaled_h = 0; + + + switch ( req->type ) + { + case FT_SIZE_REQUEST_TYPE_NOMINAL: + w = h = face->units_per_EM; + break; + + case FT_SIZE_REQUEST_TYPE_REAL_DIM: + w = h = face->ascender - face->descender; + break; + + case FT_SIZE_REQUEST_TYPE_CELL: + w = face->max_advance_width; + h = face->ascender - face->descender; + break; + + case FT_SIZE_REQUEST_TYPE_BBOX: + w = face->bbox.xMax - face->bbox.xMin; + h = face->bbox.yMax - face->bbox.yMin; + break; + + case FT_SIZE_REQUEST_TYPE_SCALES: + metrics->x_scale = (FT_Fixed)req->width; + metrics->y_scale = (FT_Fixed)req->height; + if ( !metrics->x_scale ) + metrics->x_scale = metrics->y_scale; + else if ( !metrics->y_scale ) + metrics->y_scale = metrics->x_scale; + goto Calculate_Ppem; + break; + + default: + /* this never happens */ + return; + break; + } + + /* to be on the safe side */ + if ( w < 0 ) + w = -w; + + if ( h < 0 ) + h = -h; + + scaled_w = FT_REQUEST_WIDTH ( req ); + scaled_h = FT_REQUEST_HEIGHT( req ); + + /* determine scales */ + if ( req->width ) + { + metrics->x_scale = FT_DivFix( scaled_w, w ); + + if ( req->height ) + { + metrics->y_scale = FT_DivFix( scaled_h, h ); + + if ( req->type == FT_SIZE_REQUEST_TYPE_CELL ) + { + if ( metrics->y_scale > metrics->x_scale ) + metrics->y_scale = metrics->x_scale; + else + metrics->x_scale = metrics->y_scale; + } + } + else + { + metrics->y_scale = metrics->x_scale; + scaled_h = FT_MulDiv( scaled_w, h, w ); + } + } + else + { + metrics->x_scale = metrics->y_scale = FT_DivFix( scaled_h, h ); + scaled_w = FT_MulDiv( scaled_h, w, h ); + } + + Calculate_Ppem: + /* calculate the ppems */ + if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL ) + { + scaled_w = FT_MulFix( face->units_per_EM, metrics->x_scale ); + scaled_h = FT_MulFix( face->units_per_EM, metrics->y_scale ); + } + + metrics->x_ppem = (FT_UShort)( ( scaled_w + 32 ) >> 6 ); + metrics->y_ppem = (FT_UShort)( ( scaled_h + 32 ) >> 6 ); + + ft_recompute_scaled_metrics( face, metrics ); + } + else + { + FT_ZERO( metrics ); + metrics->x_scale = 1L << 22; + metrics->y_scale = 1L << 22; + } + } + + + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Select_Size( FT_Face face, + FT_Int strike_index ) + { + FT_Driver_Class clazz; + + + if ( !face || !FT_HAS_FIXED_SIZES( face ) ) + return FT_Err_Invalid_Face_Handle; + + if ( strike_index < 0 || strike_index >= face->num_fixed_sizes ) + return FT_Err_Invalid_Argument; + + clazz = face->driver->clazz; + + if ( clazz->select_size ) + return clazz->select_size( face->size, (FT_ULong)strike_index ); + + FT_Select_Metrics( face, (FT_ULong)strike_index ); + + return FT_Err_Ok; + } + + + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Request_Size( FT_Face face, + FT_Size_Request req ) + { + FT_Driver_Class clazz; + FT_ULong strike_index; + + + if ( !face ) + return FT_Err_Invalid_Face_Handle; + + if ( !req || req->width < 0 || req->height < 0 || + req->type >= FT_SIZE_REQUEST_TYPE_MAX ) + return FT_Err_Invalid_Argument; + + clazz = face->driver->clazz; + + if ( clazz->request_size ) + return clazz->request_size( face->size, req ); + + /* + * The reason that a driver doesn't have `request_size' defined is + * either that the scaling here suffices or that the supported formats + * are bitmap-only and size matching is not implemented. + * + * In the latter case, a simple size matching is done. + */ + if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) + { + FT_Error error; + + + error = FT_Match_Size( face, req, 0, &strike_index ); + if ( error ) + return error; + + FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n", + strike_index )); + + return FT_Select_Size( face, (FT_Int)strike_index ); + } + + FT_Request_Metrics( face, req ); + + return FT_Err_Ok; } @@ -1977,78 +2378,26 @@ FT_UInt horz_resolution, FT_UInt vert_resolution ) { - FT_Error error = FT_Err_Ok; - FT_Driver driver; - FT_Driver_Class clazz; - FT_Size_Metrics* metrics; - FT_Long dim_x, dim_y; + FT_Size_RequestRec req; - if ( !face || !face->size || !face->driver ) - return FT_Err_Invalid_Face_Handle; - - driver = face->driver; - metrics = &face->size->metrics; - clazz = driver->clazz; - if ( !char_width ) char_width = char_height; - else if ( !char_height ) char_height = char_width; - if ( !horz_resolution ) - horz_resolution = 72; - - if ( !vert_resolution ) - vert_resolution = 72; - - /* default processing -- this can be overridden by the driver */ if ( char_width < 1 * 64 ) char_width = 1 * 64; if ( char_height < 1 * 64 ) char_height = 1 * 64; - /* Compute pixel sizes in 26.6 units */ - dim_x = ( char_width * horz_resolution + 36 ) / 72; - dim_y = ( char_height * vert_resolution + 36 ) / 72; + req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; + req.width = char_width; + req.height = char_height; + req.horiResolution = ( horz_resolution ) ? horz_resolution : 72; + req.vertResolution = ( vert_resolution ) ? vert_resolution : 72; - { - FT_UShort x_ppem = (FT_UShort)( ( dim_x + 32 ) >> 6 ); - FT_UShort y_ppem = (FT_UShort)( ( dim_y + 32 ) >> 6 ); - - - /* Don't take, say, 12.5x12.5 equal to 13x13. If working with */ - /* fractional font sizes this would hide slightly different */ - /* font metrics. Consequently, the next two lines are */ - /* disabled. */ -#if 0 - if ( x_ppem == metrics->x_ppem && y_ppem == metrics->y_ppem ) - return FT_Err_Ok; -#endif - - metrics->x_ppem = x_ppem; - metrics->y_ppem = y_ppem; - } - - metrics->x_scale = 0x10000L; - metrics->y_scale = 0x10000L; - - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - { - metrics->x_scale = FT_DivFix( dim_x, face->units_per_EM ); - metrics->y_scale = FT_DivFix( dim_y, face->units_per_EM ); - - ft_recompute_scaled_metrics( face, metrics ); - } - - if ( clazz->set_char_sizes ) - error = clazz->set_char_sizes( face->size, - char_width, - char_height, - horz_resolution, - vert_resolution ); - return error; + return FT_Request_Size( face, &req ); } @@ -2059,22 +2408,11 @@ FT_UInt pixel_width, FT_UInt pixel_height ) { - FT_Error error = FT_Err_Ok; - FT_Driver driver; - FT_Driver_Class clazz; - FT_Size_Metrics* metrics; + FT_Size_RequestRec req; - if ( !face || !face->size || !face->driver ) - return FT_Err_Invalid_Face_Handle; - - driver = face->driver; - metrics = &face->size->metrics; - clazz = driver->clazz; - if ( pixel_width == 0 ) pixel_width = pixel_height; - else if ( pixel_height == 0 ) pixel_height = pixel_width; @@ -2089,25 +2427,13 @@ if ( pixel_height >= 0xFFFFU ) pixel_height = 0xFFFFU; - metrics->x_ppem = (FT_UShort)pixel_width; - metrics->y_ppem = (FT_UShort)pixel_height; + req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; + req.width = pixel_width << 6; + req.height = pixel_height << 6; + req.horiResolution = 0; + req.vertResolution = 0; - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - { - metrics->x_scale = FT_DivFix( metrics->x_ppem << 6, - face->units_per_EM ); - - metrics->y_scale = FT_DivFix( metrics->y_ppem << 6, - face->units_per_EM ); - - ft_recompute_scaled_metrics( face, metrics ); - } - - if ( clazz->set_pixel_sizes ) - error = clazz->set_pixel_sizes( face->size, - pixel_width, - pixel_height ); - return error; + return FT_Request_Size( face, &req ); } @@ -2171,6 +2497,40 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Track_Kerning( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ) + { + FT_Service_Kerning service; + FT_Error error = FT_Err_Ok; + FT_Driver driver; + + + if ( !face ) + return FT_Err_Invalid_Face_Handle; + + if ( !akerning ) + return FT_Err_Invalid_Argument; + + driver = face->driver; + + FT_FACE_FIND_SERVICE( face, service, KERNING ); + if ( !service ) + return FT_Err_Unimplemented_Feature; + + error = service->get_track( face, + point_size, + degree, + akerning ); + + return error; + } + + /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) @@ -2321,10 +2681,10 @@ FT_BASE_DEF( FT_Error ) - FT_CMap_New( FT_CMap_Class clazz, - FT_Pointer init_data, - FT_CharMap charmap, - FT_CMap *acmap ) + FT_CMap_New( FT_CMap_Class clazz, + FT_Pointer init_data, + FT_CharMap charmap, + FT_CMap *acmap ) { FT_Error error = FT_Err_Ok; FT_Face face; @@ -2999,7 +3359,7 @@ } - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( FT_Error ) FT_Add_Module( FT_Library library, @@ -3126,7 +3486,7 @@ } - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( FT_Module ) FT_Get_Module( FT_Library library, @@ -3215,7 +3575,7 @@ } - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( FT_Error ) FT_Remove_Module( FT_Library library, @@ -3270,7 +3630,7 @@ /*************************************************************************/ - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( FT_Error ) FT_New_Library( FT_Memory memory, @@ -3341,7 +3701,7 @@ } - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( FT_Error ) FT_Done_Library( FT_Library library ) @@ -3360,8 +3720,12 @@ /* Close all modules in the library */ #if 1 + /* XXX Modules are removed in the reversed order so that */ + /* type42 module is removed before truetype module. This */ + /* avoids double free in some occasions. It is a hack. */ while ( library->num_modules > 0 ) - FT_Remove_Module( library, library->modules[0] ); + FT_Remove_Module( library, + library->modules[library->num_modules - 1] ); #else { FT_UInt n; @@ -3390,7 +3754,7 @@ } - /* documentation is in ftmodule.h */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( void ) FT_Set_Debug_Hook( FT_Library library, @@ -3404,4 +3768,128 @@ } + /* documentation is in ftmodapi.h */ + + FT_EXPORT_DEF( FT_TrueTypeEngineType ) + FT_Get_TrueType_Engine_Type( FT_Library library ) + { + FT_TrueTypeEngineType result = FT_TRUETYPE_ENGINE_TYPE_NONE; + + + if ( library ) + { + FT_Module module = FT_Get_Module( library, "truetype" ); + + + if ( module ) + { + FT_Service_TrueTypeEngine service; + + + service = (FT_Service_TrueTypeEngine) + ft_module_get_service( module, + FT_SERVICE_ID_TRUETYPE_ENGINE ); + if ( service ) + result = service->engine_type; + } + } + + return result; + } + + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + FT_BASE_DEF( FT_Error ) + ft_stub_set_char_sizes( FT_Size size, + FT_F26Dot6 width, + FT_F26Dot6 height, + FT_UInt horz_res, + FT_UInt vert_res ) + { + FT_Size_RequestRec req; + FT_Driver driver = size->face->driver; + + + if ( driver->clazz->request_size ) + { + req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; + req.width = width; + req.height = height; + + if ( horz_res == 0 ) + horz_res = vert_res; + + if ( vert_res == 0 ) + vert_res = horz_res; + + if ( horz_res == 0 ) + horz_res = vert_res = 72; + + req.horiResolution = horz_res; + req.vertResolution = vert_res; + + return driver->clazz->request_size( size, &req ); + } + + return 0; + } + + + FT_BASE_DEF( FT_Error ) + ft_stub_set_pixel_sizes( FT_Size size, + FT_UInt width, + FT_UInt height ) + { + FT_Size_RequestRec req; + FT_Driver driver = size->face->driver; + + + if ( driver->clazz->request_size ) + { + req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; + req.width = width << 6; + req.height = height << 6; + req.horiResolution = 0; + req.vertResolution = 0; + + return driver->clazz->request_size( size, &req ); + } + + return 0; + } + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ) + { + FT_Error error = FT_Err_Invalid_Argument; + + + if ( glyph != NULL && + glyph->format == FT_GLYPH_FORMAT_COMPOSITE && + sub_index < glyph->num_subglyphs ) + { + FT_SubGlyph subg = glyph->subglyphs + sub_index; + + + *p_index = subg->index; + *p_flags = subg->flags; + *p_arg1 = subg->arg1; + *p_arg2 = subg->arg2; + *p_transform = subg->transform; + } + + return error; + } + + /* END */ diff --git a/src/libs/freetype2/base/ftotval.c b/src/libs/freetype2/base/ftotval.c index 1364d754ec..f14580d290 100644 --- a/src/libs/freetype2/base/ftotval.c +++ b/src/libs/freetype2/base/ftotval.c @@ -69,4 +69,15 @@ } + FT_EXPORT_DEF( void ) + FT_OpenType_Free( FT_Face face, + FT_Bytes table ) + { + FT_Memory memory = FT_FACE_MEMORY( face ); + + + FT_FREE( table ); + } + + /* END */ diff --git a/src/libs/freetype2/base/ftoutln.c b/src/libs/freetype2/base/ftoutln.c index d2e53cd772..b23b16439c 100644 --- a/src/libs/freetype2/base/ftoutln.c +++ b/src/libs/freetype2/base/ftoutln.c @@ -4,7 +4,7 @@ /* */ /* FreeType outline management (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -668,6 +668,172 @@ } +#if 0 + +#define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \ + do { \ + (first) = ( c > 0 ) ? (outline)->points + \ + (outline)->contours[c - 1] + 1 \ + : (outline)->points; \ + (last) = (outline)->points + (outline)->contours[c]; \ + } while ( 0 ) + + + /* Is a point in some contour? */ + /* */ + /* We treat every point of the contour as if it */ + /* it were ON. That is, we allow false positives, */ + /* but disallow false negatives. (XXX really?) */ + static FT_Bool + ft_contour_has( FT_Outline* outline, + FT_Short c, + FT_Vector* point ) + { + FT_Vector* first; + FT_Vector* last; + FT_Vector* a; + FT_Vector* b; + FT_UInt n = 0; + + + FT_OUTLINE_GET_CONTOUR( outline, c, first, last ); + + for ( a = first; a <= last; a++ ) + { + FT_Pos x; + FT_Int intersect; + + + b = ( a == last ) ? first : a + 1; + + intersect = ( a->y - point->y ) ^ ( b->y - point->y ); + + /* a and b are on the same side */ + if ( intersect >= 0 ) + { + if ( intersect == 0 && a->y == point->y ) + { + if ( ( a->x <= point->x && b->x >= point->x ) || + ( a->x >= point->x && b->x <= point->x ) ) + return 1; + } + + continue; + } + + x = a->x + ( b->x - a->x ) * (point->y - a->y ) / ( b->y - a->y ); + + if ( x < point->x ) + n++; + else if ( x == point->x ) + return 1; + } + + return ( n % 2 ); + } + + + static FT_Bool + ft_contour_enclosed( FT_Outline* outline, + FT_UShort c ) + { + FT_Vector* first; + FT_Vector* last; + FT_Short i; + + + FT_OUTLINE_GET_CONTOUR( outline, c, first, last ); + + for ( i = 0; i < outline->n_contours; i++ ) + { + if ( i != c && ft_contour_has( outline, i, first ) ) + { + FT_Vector* pt; + + + for ( pt = first + 1; pt <= last; pt++ ) + if ( !ft_contour_has( outline, i, pt ) ) + return 0; + + return 1; + } + } + + return 0; + } + + + /* This version differs from the public one in that each */ + /* part (contour not enclosed in another contour) of the */ + /* outline is checked for orientation. This is */ + /* necessary for some buggy CJK fonts. */ + static FT_Orientation + ft_outline_get_orientation( FT_Outline* outline ) + { + FT_Short i; + FT_Vector* first; + FT_Vector* last; + FT_Orientation orient = FT_ORIENTATION_NONE; + + + first = outline->points; + for ( i = 0; i < outline->n_contours; i++, first = last + 1 ) + { + FT_Vector* point; + FT_Vector* xmin_point; + FT_Pos xmin; + + + last = outline->points + outline->contours[i]; + + /* skip degenerate contours */ + if ( last < first + 2 ) + continue; + + if ( ft_contour_enclosed( outline, i ) ) + continue; + + xmin = first->x; + xmin_point = first; + + for ( point = first + 1; point <= last; point++ ) + { + if ( point->x < xmin ) + { + xmin = point->x; + xmin_point = point; + } + } + + /* check the orientation of the contour */ + { + FT_Vector* prev; + FT_Vector* next; + FT_Orientation o; + + + prev = ( xmin_point == first ) ? last : xmin_point - 1; + next = ( xmin_point == last ) ? first : xmin_point + 1; + + if ( FT_Atan2( prev->x - xmin_point->x, prev->y - xmin_point->y ) > + FT_Atan2( next->x - xmin_point->x, next->y - xmin_point->y ) ) + o = FT_ORIENTATION_POSTSCRIPT; + else + o = FT_ORIENTATION_TRUETYPE; + + if ( orient == FT_ORIENTATION_NONE ) + orient = o; + else if ( orient != o ) + return FT_ORIENTATION_NONE; + } + } + + return orient; + } + +#endif /* 0 */ + + /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) @@ -678,15 +844,26 @@ FT_Vector v_prev, v_first, v_next, v_cur; FT_Angle rotate, angle_in, angle_out; FT_Int c, n, first; + FT_Int orientation; if ( !outline ) return FT_Err_Invalid_Argument; + strength /= 2; if ( strength == 0 ) return FT_Err_Ok; - if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_TRUETYPE ) + orientation = FT_Outline_Get_Orientation( outline ); + if ( orientation == FT_ORIENTATION_NONE ) + { + if ( outline->n_contours ) + return FT_Err_Invalid_Argument; + else + return FT_Err_Ok; + } + + if ( orientation == FT_ORIENTATION_TRUETYPE ) rotate = -FT_ANGLE_PI2; else rotate = FT_ANGLE_PI2; @@ -778,7 +955,10 @@ contour++, first = last + 1 ) { FT_Vector* point; - + FT_Int on_curve; + FT_Int on_curve_count = 0; + FT_Pos tmp_xmin = 32768L; + FT_Vector* tmp_xmin_point = NULL; last = outline->points + *contour; @@ -786,16 +966,27 @@ if ( last < first + 2 ) continue; - for ( point = first; point <= last; point++ ) + for ( point = first; point <= last; ++point ) { - if ( point->x < xmin ) + /* Count on-curve points. If there are less than 3 on-curve */ + /* points, just bypass this contour. */ + on_curve = outline->tags[point - outline->points] & 1; + on_curve_count += on_curve; + + if ( point->x < tmp_xmin && on_curve ) { - xmin = point->x; - xmin_point = point; - xmin_first = first; - xmin_last = last; + tmp_xmin = point->x; + tmp_xmin_point = point; } } + + if ( on_curve_count > 2 && tmp_xmin < xmin ) + { + xmin = tmp_xmin; + xmin_point = tmp_xmin_point; + xmin_first = first; + xmin_last = last; + } } if ( !xmin_point ) @@ -804,6 +995,23 @@ prev = ( xmin_point == xmin_first ) ? xmin_last : xmin_point - 1; next = ( xmin_point == xmin_last ) ? xmin_first : xmin_point + 1; + /* Skip off-curve points */ + while ( ( outline->tags[prev - outline->points] & 1 ) == 0 ) + { + if ( prev == xmin_first ) + prev = xmin_last; + else + --prev; + } + + while ( ( outline->tags[next - outline->points] & 1 ) == 0 ) + { + if ( next == xmin_last ) + next = xmin_first; + else + ++next; + } + if ( FT_Atan2( prev->x - xmin_point->x, prev->y - xmin_point->y ) > FT_Atan2( next->x - xmin_point->x, next->y - xmin_point->y ) ) return FT_ORIENTATION_POSTSCRIPT; diff --git a/src/libs/freetype2/base/ftrfork.c b/src/libs/freetype2/base/ftrfork.c index 50dcf858c7..cfa5891c43 100644 --- a/src/libs/freetype2/base/ftrfork.c +++ b/src/libs/freetype2/base/ftrfork.c @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (body). */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ @@ -179,7 +179,7 @@ if ( error ) return error; - if ( FT_ALLOC( offsets_internal, *count * sizeof( FT_Long ) ) ) + if ( FT_NEW_ARRAY( offsets_internal, *count ) ) return error; for ( j = 0; j < *count; ++j ) @@ -426,20 +426,25 @@ FT_Error error; char* newpath; FT_Memory memory; + FT_Long base_file_len = ft_strlen( base_file_name ); FT_UNUSED( stream ); memory = library->memory; - if ( FT_ALLOC( newpath, - ft_strlen( base_file_name ) + ft_strlen( "/rsrc" ) + 1 ) ) + if ( base_file_len > FT_INT_MAX ) + return FT_Err_Array_Too_Large; + + if ( FT_ALLOC( newpath, base_file_len + 6 ) ) return error; - ft_strcpy( newpath, base_file_name ); - ft_strcat( newpath, "/rsrc" ); + FT_MEM_COPY( newpath, base_file_name, base_file_len ); + FT_MEM_COPY( newpath + base_file_len, "/rsrc", 6 ); + *result_file_name = newpath; - *result_offset = 0; + *result_offset = 0; + return FT_Err_Ok; } @@ -657,7 +662,7 @@ char* tmp; const char* slash; unsigned new_length; - FT_ULong error = FT_Err_Ok; + FT_Error error = FT_Err_Ok; FT_UNUSED( error ); diff --git a/src/libs/freetype2/base/ftstream.c b/src/libs/freetype2/base/ftstream.c index 3b7b29f904..a067a1fde7 100644 --- a/src/libs/freetype2/base/ftstream.c +++ b/src/libs/freetype2/base/ftstream.c @@ -4,7 +4,7 @@ /* */ /* I/O stream support (body). */ /* */ -/* Copyright 2000-2001, 2002, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -212,8 +212,12 @@ { FT_Memory memory = stream->memory; - +#ifdef FT_DEBUG_MEMORY + ft_mem_free( memory, *pbytes ); + *pbytes = NULL; +#else FT_FREE( *pbytes ); +#endif } *pbytes = 0; } @@ -235,10 +239,15 @@ /* allocate the frame in memory */ FT_Memory memory = stream->memory; - +#ifdef FT_DEBUG_MEMORY + /* assume _ft_debug_file and _ft_debug_lineno are already set */ + stream->base = (unsigned char*)ft_mem_qalloc( memory, count, &error ); + if ( error ) + goto Exit; +#else if ( FT_QALLOC( stream->base, count ) ) goto Exit; - +#endif /* read it */ read_bytes = stream->read( stream, stream->pos, stream->base, count ); @@ -298,8 +307,12 @@ { FT_Memory memory = stream->memory; - +#ifdef FT_DEBUG_MEMORY + ft_mem_free( memory, stream->base ); + stream->base = NULL; +#else FT_FREE( stream->base ); +#endif } stream->cursor = 0; stream->limit = 0; diff --git a/src/libs/freetype2/base/ftstroke.c b/src/libs/freetype2/base/ftstroke.c index 26ff21511b..8f7e0459da 100644 --- a/src/libs/freetype2/base/ftstroke.c +++ b/src/libs/freetype2/base/ftstroke.c @@ -4,7 +4,7 @@ /* */ /* FreeType path stroker (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -716,13 +716,19 @@ /* documentation is in ftstroke.h */ FT_EXPORT_DEF( FT_Error ) - FT_Stroker_New( FT_Memory memory, + FT_Stroker_New( FT_Library library, FT_Stroker *astroker ) { FT_Error error; + FT_Memory memory; FT_Stroker stroker; + if ( !library ) + return FT_Err_Invalid_Argument; + + memory = library->memory; + if ( !FT_NEW( stroker ) ) { stroker->memory = memory; diff --git a/src/libs/freetype2/base/ftsynth.c b/src/libs/freetype2/base/ftsynth.c index 020bfdfe4f..7ff2a3c38c 100644 --- a/src/libs/freetype2/base/ftsynth.c +++ b/src/libs/freetype2/base/ftsynth.c @@ -4,7 +4,7 @@ /* */ /* FreeType synthesizing code for emboldening and slanting (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -68,6 +68,29 @@ /*************************************************************************/ + FT_EXPORT_DEF( FT_Error ) + FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ) + { + if ( slot && slot->format == FT_GLYPH_FORMAT_BITMAP && + !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) + { + FT_Bitmap bitmap; + FT_Error error; + + + FT_Bitmap_New( &bitmap ); + error = FT_Bitmap_Copy( slot->library, &slot->bitmap, &bitmap ); + if ( error ) + return error; + + slot->bitmap = bitmap; + slot->internal->flags |= FT_GLYPH_OWN_BITMAP; + } + + return FT_Err_Ok; + } + + /* documentation is in ftsynth.h */ FT_EXPORT_DEF( void ) @@ -75,19 +98,27 @@ { FT_Library library = slot->library; FT_Face face = FT_SLOT_FACE( slot ); - FT_Error error = FT_Err_Ok; + FT_Error error; FT_Pos xstr, ystr; + if ( slot->format != FT_GLYPH_FORMAT_OUTLINE && + slot->format != FT_GLYPH_FORMAT_BITMAP ) + return; + /* some reasonable strength */ xstr = FT_MulFix( face->units_per_EM, - face->size->metrics.y_scale ) / 42; + face->size->metrics.y_scale ) / 24; ystr = xstr; if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { error = FT_Outline_Embolden( &slot->outline, xstr ); - xstr = xstr * 4; /* according to the documentation */ + /* ignore error */ + + /* this is more than enough for most glyphs; if you need accurate */ + /* values, you have to call FT_Outline_Get_CBox */ + xstr = xstr * 2; ystr = xstr; } else if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) @@ -97,45 +128,28 @@ xstr = 1 << 6; ystr = FT_PIX_FLOOR( ystr ); - /* slot must be bitmap-owner */ - if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) - { - FT_Bitmap bitmap; + error = FT_GlyphSlot_Own_Bitmap( slot ); + if ( error ) + return; - - FT_Bitmap_New( &bitmap ); - error = FT_Bitmap_Copy( library, &slot->bitmap, &bitmap ); - - if ( !error ) - { - slot->bitmap = bitmap; - slot->internal->flags |= FT_GLYPH_OWN_BITMAP; - } - } - - if ( !error ) - error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr ); + error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr ); + if ( error ) + return; } - else - error = FT_Err_Invalid_Argument; - /* modify the metrics accordingly */ - if ( !error ) - { - slot->advance.x += xstr; - slot->advance.y += ystr; + /* assume the layout is horizontal */ + slot->advance.x += xstr; - slot->metrics.width += xstr; - slot->metrics.height += ystr; - slot->metrics.horiBearingY += ystr; - slot->metrics.horiAdvance += xstr; - slot->metrics.vertBearingX -= xstr / 2; - slot->metrics.vertBearingY += ystr; - slot->metrics.vertAdvance += ystr; + slot->metrics.width += xstr; + slot->metrics.height += ystr; + slot->metrics.horiBearingY += ystr; + slot->metrics.horiAdvance += xstr; + slot->metrics.vertBearingX -= xstr / 2; + slot->metrics.vertBearingY += ystr; + slot->metrics.vertAdvance += ystr; - if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) - slot->bitmap_top += ystr >> 6; - } + if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) + slot->bitmap_top += ystr >> 6; } diff --git a/src/libs/freetype2/base/ftsysio.c b/src/libs/freetype2/base/ftsysio.c deleted file mode 100644 index 344ee516dd..0000000000 --- a/src/libs/freetype2/base/ftsysio.c +++ /dev/null @@ -1,131 +0,0 @@ -#include <ft2build.h> -#include FT_SYSTEM_STREAM_H - -#include <stdio.h> - - /* the ISO/ANSI standard stream object */ - typedef struct FT_StdStreamRec_ - { - FT_StreamRec stream; - FILE* file; - const char* pathname; - - } FT_StdStreamRec, *FT_StdStream; - - - - /* read bytes from a standard stream */ - static FT_ULong - ft_std_stream_read( FT_StdStream stream, - FT_Byte* buffer, - FT_ULong size ) - { - long read_bytes; - - read_bytes = fread( buffer, 1, size, stream->file ); - if ( read_bytes < 0 ) - read_bytes = 0; - - return (FT_ULong) read_bytes; - } - - - /* seek the standard stream to a new position */ - static FT_Error - ft_std_stream_seek( FT_StdStream stream, - FT_ULong pos ) - { - return ( fseek( stream->file, pos, SEEK_SET ) < 0 ) - ? FT_Err_Stream_Seek - : FT_Err_Ok; - } - - - /* close a standard stream */ - static void - ft_std_stream_done( FT_StdStream stream ) - { - fclose( stream->file ); - stream->file = NULL; - stream->pathname = NULL; - } - - - /* open a standard stream from a given pathname */ - static void - ft_std_stream_init( FT_StdStream stream, - const char* pathname ) - { - FT_ASSERT( pathname != NULL ); - - stream->file = fopen( pathname, "rb" ); - if ( stream->file == NULL ) - { - FT_ERROR(( "iso.stream.init: could not open '%s'\n", pathname )); - FT_XTHROW( FT_Err_Stream_Open ); - } - - /* compute total size in bytes */ - fseek( file, 0, SEEK_END ); - FT_STREAM__SIZE(stream) = ftell( file ); - fseek( file, 0, SEEK_SET ); - - stream->pathname = pathname; - stream->pos = 0; - - FT_TRACE1(( "iso.stream.init: opened '%s' (%ld bytes) succesfully\n", - pathname, FT_STREAM__SIZE(stream) )); - } - - - static void - ft_std_stream_class_init( FT_ClassRec* _clazz ) - { - FT_StreamClassRec* clazz = FT_STREAM_CLASS(_clazz); - - clazz->stream_read = (FT_Stream_ReadFunc) ft_std_stream_read; - clazz->stream_seek = (FT_Stream_SeekFunc) ft_std_stream_seek; - } - - - static const FT_TypeRec ft_std_stream_type; - { - "StreamClass", - NULL, - - sizeof( FT_ClassRec ), - ft_stream_class_init, - NULL, - - sizeof( FT_StdStreamRec ), - ft_std_stream_init, - ft_std_stream_done, - NULL, - }; - - - - FT_EXPORT_DEF( FT_Stream ) - ft_std_stream_new( FT_Memory memory, - const char* pathname ) - { - FT_Class clazz; - - clazz = ft_class_from_type( memory, &ft_std_stream_type ); - - return (FT_Stream) ft_object_new( clazz, pathname ); - } - - - FT_EXPORT_DEF( void ) - ft_std_stream_create( FT_Memory memory, - const char* pathname, - FT_Stream* astream ) - { - FT_Class clazz; - - clazz = ft_class_from_type( memory, &ft_std_stream_type ); - - ft_object_create( clazz, pathname, FT_OBJECT_P(astream) ); - } - diff --git a/src/libs/freetype2/base/ftsysmem.c b/src/libs/freetype2/base/ftsysmem.c deleted file mode 100644 index 6a34f693f3..0000000000 --- a/src/libs/freetype2/base/ftsysmem.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <ft2build.h> -#include FT_SYSTEM_MEMORY_H - - static FT_Memory - ft_memory_new_default( FT_ULong size ) - { - return (FT_Memory) ft_malloc( size ); - } - - static void - ft_memory_destroy_default( FT_Memory memory ) - { - ft_free( memory ); - } - - - /* notice that in normal builds, we use the ISO C library functions */ - /* 'malloc', 'free' and 'realloc' directly.. */ - /* */ - static const FT_Memory_FuncsRec ft_memory_funcs_default_rec = - { - (FT_Memory_CreateFunc) ft_memory_new_iso, - (FT_Memory_DestroyFunc) ft_memory_destroy_iso, - (FT_Memory_AllocFunc) ft_malloc, - (FT_Memory_FreeFunc) ft_free, - (FT_Memory_ReallocFunc) ft_realloc - }; - - FT_APIVAR_DEF( const FT_Memory_Funcs ) - ft_memory_funcs_default = &ft_memory_funcs_defaults_rec; diff --git a/src/libs/freetype2/base/ftsystem.c b/src/libs/freetype2/base/ftsystem.c index 2365de2571..f61a3edfb6 100644 --- a/src/libs/freetype2/base/ftsystem.c +++ b/src/libs/freetype2/base/ftsystem.c @@ -4,7 +4,7 @@ /* */ /* ANSI-specific FreeType low-level system interface (body). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,13 +28,11 @@ #include <ft2build.h> #include FT_CONFIG_CONFIG_H #include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H #include FT_SYSTEM_H #include FT_ERRORS_H #include FT_TYPES_H -#include <stdio.h> -#include <stdlib.h> - /*************************************************************************/ /* */ @@ -46,7 +44,7 @@ /* */ /* It is not necessary to do any error checking for the */ /* allocation-related functions. This will be done by the higher level */ - /* routines like FT_Alloc() or FT_Realloc(). */ + /* routines like ft_mem_alloc() or ft_mem_realloc(). */ /* */ /*************************************************************************/ @@ -73,7 +71,7 @@ { FT_UNUSED( memory ); - return malloc( size ); + return ft_smalloc( size ); } @@ -106,7 +104,7 @@ FT_UNUSED( memory ); FT_UNUSED( cur_size ); - return realloc( block, new_size ); + return ft_srealloc( block, new_size ); } @@ -129,7 +127,7 @@ { FT_UNUSED( memory ); - free( block ); + ft_sfree( block ); } @@ -151,7 +149,7 @@ /* We use the macro STREAM_FILE for convenience to extract the */ /* system-specific stream handle from a given FreeType stream object */ -#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) +#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer ) /*************************************************************************/ @@ -168,7 +166,7 @@ FT_CALLBACK_DEF( void ) ft_ansi_stream_close( FT_Stream stream ) { - fclose( STREAM_FILE( stream ) ); + ft_fclose( STREAM_FILE( stream ) ); stream->descriptor.pointer = NULL; stream->size = 0; @@ -202,30 +200,30 @@ unsigned char* buffer, unsigned long count ) { - FILE* file; + FT_FILE* file; file = STREAM_FILE( stream ); - fseek( file, offset, SEEK_SET ); + ft_fseek( file, offset, SEEK_SET ); - return (unsigned long)fread( buffer, 1, count, file ); + return (unsigned long)ft_fread( buffer, 1, count, file ); } - /* documentation is in ftobjs.h */ + /* documentation is in ftstream.h */ - FT_EXPORT_DEF( FT_Error ) + FT_BASE_DEF( FT_Error ) FT_Stream_Open( FT_Stream stream, const char* filepathname ) { - FILE* file; + FT_FILE* file; if ( !stream ) return FT_Err_Invalid_Stream_Handle; - file = fopen( filepathname, "rb" ); + file = ft_fopen( filepathname, "rb" ); if ( !file ) { FT_ERROR(( "FT_Stream_Open:" )); @@ -234,9 +232,9 @@ return FT_Err_Cannot_Open_Resource; } - fseek( file, 0, SEEK_END ); - stream->size = ftell( file ); - fseek( file, 0, SEEK_SET ); + ft_fseek( file, 0, SEEK_END ); + stream->size = ft_ftell( file ); + ft_fseek( file, 0, SEEK_SET ); stream->descriptor.pointer = file; stream->pathname.pointer = (char*)filepathname; @@ -266,13 +264,13 @@ /* documentation is in ftobjs.h */ - FT_EXPORT_DEF( FT_Memory ) + FT_BASE_DEF( FT_Memory ) FT_New_Memory( void ) { FT_Memory memory; - memory = (FT_Memory)malloc( sizeof ( *memory ) ); + memory = (FT_Memory)ft_smalloc( sizeof ( *memory ) ); if ( memory ) { memory->user = 0; @@ -290,7 +288,7 @@ /* documentation is in ftobjs.h */ - FT_EXPORT_DEF( void ) + FT_BASE_DEF( void ) FT_Done_Memory( FT_Memory memory ) { #ifdef FT_DEBUG_MEMORY diff --git a/src/libs/freetype2/base/fttrigon.c b/src/libs/freetype2/base/fttrigon.c index 1ab34384d8..9f513946b8 100644 --- a/src/libs/freetype2/base/fttrigon.c +++ b/src/libs/freetype2/base/fttrigon.c @@ -4,7 +4,7 @@ /* */ /* FreeType trigonometric functions (body). */ /* */ -/* Copyright 2001, 2002, 2003, 2004 by */ +/* Copyright 2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -109,6 +109,50 @@ z = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y ); shift = 0; +#if 1 + /* determine msb bit index in `shift' */ + if ( z >= ( 1L << 16 ) ) + { + z >>= 16; + shift += 16; + } + if ( z >= ( 1L << 8 ) ) + { + z >>= 8; + shift += 8; + } + if ( z >= ( 1L << 4 ) ) + { + z >>= 4; + shift += 4; + } + if ( z >= ( 1L << 2 ) ) + { + z >>= 2; + shift += 2; + } + if ( z >= ( 1L << 1 ) ) + { + z >>= 1; + shift += 1; + } + + if ( shift <= 27 ) + { + shift = 27 - shift; + vec->x = x << shift; + vec->y = y << shift; + } + else + { + shift -= 27; + vec->x = x >> shift; + vec->y = y >> shift; + shift = -shift; + } + +#else /* 0 */ + if ( z < ( 1L << 27 ) ) { do @@ -116,7 +160,6 @@ shift++; z <<= 1; } while ( z < ( 1L << 27 ) ); - vec->x = x << shift; vec->y = y << shift; } @@ -132,6 +175,9 @@ vec->y = y >> shift; shift = -shift; } + +#endif /* 0 */ + return shift; } diff --git a/src/libs/freetype2/base/ftutil.c b/src/libs/freetype2/base/ftutil.c index 5b3aa8b662..7ad780d389 100644 --- a/src/libs/freetype2/base/ftutil.c +++ b/src/libs/freetype2/base/ftutil.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for memory and list management (body). */ /* */ -/* Copyright 2002, 2004, 2005 by */ +/* Copyright 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -45,167 +45,126 @@ /*************************************************************************/ /*************************************************************************/ - /* documentation is in ftmemory.h */ - FT_BASE_DEF( FT_Error ) - FT_Alloc( FT_Memory memory, - FT_Long size, - void* *P ) + FT_BASE_DEF( FT_Pointer ) + ft_mem_alloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ) { - FT_ASSERT( P != 0 ); + FT_Error error; + FT_Pointer block = ft_mem_qalloc( memory, size, &error ); + + if ( !error && size > 0 ) + FT_MEM_ZERO( block, size ); + + *p_error = error; + return block; + } + + + FT_BASE_DEF( FT_Pointer ) + ft_mem_qalloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ) + { + FT_Error error = FT_Err_Ok; + FT_Pointer block = NULL; + if ( size > 0 ) { - *P = memory->alloc( memory, size ); - if ( !*P ) - { - FT_ERROR(( "FT_Alloc:" )); - FT_ERROR(( " Out of memory? (%ld requested)\n", - size )); + block = memory->alloc( memory, size ); + if ( block == NULL ) + error = FT_Err_Out_Of_Memory; + } + else if ( size < 0 ) + { + /* may help catch/prevent security issues */ + error = FT_Err_Invalid_Argument; + } - return FT_Err_Out_Of_Memory; - } - FT_MEM_ZERO( *P, size ); + *p_error = error; + return block; + } + + + FT_BASE_DEF( FT_Pointer ) + ft_mem_realloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ) + { + FT_Error error = FT_Err_Ok; + + block = ft_mem_qrealloc( memory, item_size, + cur_count, new_count, block, &error ); + if ( !error && new_count > cur_count ) + FT_MEM_ZERO( (char*)block + cur_count * item_size, + ( new_count - cur_count ) * item_size ); + + *p_error = error; + return block; + } + + + FT_BASE_DEF( FT_Pointer ) + ft_mem_qrealloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ) + { + FT_Error error = FT_Err_Ok; + + + if ( cur_count < 0 || new_count < 0 || item_size <= 0 ) + { + /* may help catch/prevent nasty security issues */ + error = FT_Err_Invalid_Argument; + } + else if ( new_count == 0 ) + { + ft_mem_free( memory, block ); + block = NULL; + } + else if ( new_count > FT_INT_MAX/item_size ) + { + error = FT_Err_Array_Too_Large; + } + else if ( cur_count == 0 ) + { + FT_ASSERT( block == NULL ); + + block = ft_mem_alloc( memory, new_count*item_size, &error ); } else - *P = NULL; - - FT_TRACE7(( "FT_Alloc:" )); - FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n", - size, *P, P )); - - return FT_Err_Ok; - } - - - /* documentation is in ftmemory.h */ - - FT_BASE_DEF( FT_Error ) - FT_QAlloc( FT_Memory memory, - FT_Long size, - void* *P ) - { - FT_ASSERT( P != 0 ); - - if ( size > 0 ) { - *P = memory->alloc( memory, size ); - if ( !*P ) - { - FT_ERROR(( "FT_QAlloc:" )); - FT_ERROR(( " Out of memory? (%ld requested)\n", - size )); - - return FT_Err_Out_Of_Memory; - } - } - else - *P = NULL; - - FT_TRACE7(( "FT_QAlloc:" )); - FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n", - size, *P, P )); - - return FT_Err_Ok; - } + FT_Pointer block2; + FT_Long cur_size = cur_count*item_size; + FT_Long new_size = new_count*item_size; - /* documentation is in ftmemory.h */ - - FT_BASE_DEF( FT_Error ) - FT_Realloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void** P ) - { - void* Q; - - - FT_ASSERT( P != 0 ); - - /* if the original pointer is NULL, call FT_Alloc() */ - if ( !*P ) - return FT_Alloc( memory, size, P ); - - /* if the new block if zero-sized, clear the current one */ - if ( size <= 0 ) - { - FT_Free( memory, P ); - return FT_Err_Ok; + block2 = memory->realloc( memory, cur_size, new_size, block ); + if ( block2 == NULL ) + error = FT_Err_Out_Of_Memory; + else + block = block2; } - Q = memory->realloc( memory, current, size, *P ); - if ( !Q ) - goto Fail; - - if ( size > current ) - FT_MEM_ZERO( (char*)Q + current, size - current ); - - *P = Q; - return FT_Err_Ok; - - Fail: - FT_ERROR(( "FT_Realloc:" )); - FT_ERROR(( " Failed (current %ld, requested %ld)\n", - current, size )); - return FT_Err_Out_Of_Memory; + *p_error = error; + return block; } - /* documentation is in ftmemory.h */ - - FT_BASE_DEF( FT_Error ) - FT_QRealloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void** P ) - { - void* Q; - - - FT_ASSERT( P != 0 ); - - /* if the original pointer is NULL, call FT_QAlloc() */ - if ( !*P ) - return FT_QAlloc( memory, size, P ); - - /* if the new block if zero-sized, clear the current one */ - if ( size <= 0 ) - { - FT_Free( memory, P ); - return FT_Err_Ok; - } - - Q = memory->realloc( memory, current, size, *P ); - if ( !Q ) - goto Fail; - - *P = Q; - return FT_Err_Ok; - - Fail: - FT_ERROR(( "FT_QRealloc:" )); - FT_ERROR(( " Failed (current %ld, requested %ld)\n", - current, size )); - return FT_Err_Out_Of_Memory; - } - - - /* documentation is in ftmemory.h */ - FT_BASE_DEF( void ) - FT_Free( FT_Memory memory, - void** P ) + ft_mem_free( FT_Memory memory, + const void *P ) { - FT_TRACE7(( "FT_Free:" )); - FT_TRACE7(( " Freeing block 0x%08p, ref 0x%08p\n", - P, P ? *P : (void*)0 )); - - if ( P && *P ) - { - memory->free( memory, *P ); - *P = 0; - } + if ( P ) + memory->free( memory, (void*)P ); } @@ -399,7 +358,7 @@ } - FT_BASE( FT_UInt32 ) + FT_BASE_DEF( FT_UInt32 ) ft_highpow2( FT_UInt32 value ) { FT_UInt32 value2; @@ -421,4 +380,70 @@ } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + FT_BASE_DEF( FT_Error ) + FT_Alloc( FT_Memory memory, + FT_Long size, + void* *P ) + { + FT_Error error; + + + (void)FT_ALLOC( *P, size ); + return error; + } + + + FT_BASE_DEF( FT_Error ) + FT_QAlloc( FT_Memory memory, + FT_Long size, + void* *p ) + { + FT_Error error; + + + (void)FT_QALLOC( *p, size ); + return error; + } + + + FT_BASE_DEF( FT_Error ) + FT_Realloc( FT_Memory memory, + FT_Long current, + FT_Long size, + void* *P ) + { + FT_Error error; + + + (void)FT_REALLOC( *P, current, size ); + return error; + } + + + FT_BASE_DEF( FT_Error ) + FT_QRealloc( FT_Memory memory, + FT_Long current, + FT_Long size, + void* *p ) + { + FT_Error error; + + + (void)FT_QREALLOC( *p, current, size ); + return error; + } + + + FT_BASE_DEF( void ) + FT_Free( FT_Memory memory, + void* *P ) + { + if ( *P ) + FT_MEM_FREE( *P ); + } + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + /* END */ diff --git a/src/libs/freetype2/base/rules.mk b/src/libs/freetype2/base/rules.mk index a92cb0df6c..bbc6cb7071 100644 --- a/src/libs/freetype2/base/rules.mk +++ b/src/libs/freetype2/base/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000, 2002, 2003, 2004, 2005 by +# Copyright 1996-2000, 2002, 2003, 2004, 2005, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -46,22 +46,11 @@ BASE_SRC := $(BASE_DIR)/ftapi.c \ # Base layer `extensions' sources # -# An extension is added to the library file (.a or .lib) as a separate -# object. It will then be linked to the final executable only if one of its -# symbols is used by the application. +# An extension is added to the library file as a separate object. It is +# then linked to the final executable only if one of its symbols is used by +# the application. # -BASE_EXT_SRC := $(BASE_DIR)/ftbitmap.c \ - $(BASE_DIR)/ftbbox.c \ - $(BASE_DIR)/ftbdf.c \ - $(BASE_DIR)/ftglyph.c \ - $(BASE_DIR)/ftmm.c \ - $(BASE_DIR)/ftotval.c \ - $(BASE_DIR)/ftpfr.c \ - $(BASE_DIR)/ftstroke.c \ - $(BASE_DIR)/ftsynth.c \ - $(BASE_DIR)/fttype1.c \ - $(BASE_DIR)/ftwinfnt.c \ - $(BASE_DIR)/ftxf86.c +BASE_EXT_SRC := $(patsubst %,$(BASE_DIR)/%,$(BASE_EXTENSIONS)) # Default extensions objects # diff --git a/src/libs/freetype2/bdf/bdfdrivr.c b/src/libs/freetype2/bdf/bdfdrivr.c index e14306efda..b03c8d0f85 100644 --- a/src/libs/freetype2/bdf/bdfdrivr.c +++ b/src/libs/freetype2/bdf/bdfdrivr.c @@ -2,7 +2,7 @@ FreeType font driver for bdf files - Copyright (C) 2001, 2002, 2003, 2004, 2005 by + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -248,7 +248,12 @@ THE SOFTWARE. } if ( !parts || !len ) - face->style_name = (char *)"Regular"; + { + if ( FT_ALLOC( face->style_name, ft_strlen( "Regular" ) + 1 ) ) + return error; + + ft_strcpy( face->style_name, "Regular" ); + } else { char *style, *s; @@ -311,6 +316,7 @@ THE SOFTWARE. FT_FREE( face->charset_encoding ); FT_FREE( face->charset_registry ); FT_FREE( bdfface->family_name ); + FT_FREE( bdfface->style_name ); FT_FREE( bdfface->available_sizes ); @@ -331,7 +337,7 @@ THE SOFTWARE. BDF_Face face = (BDF_Face)bdfface; FT_Memory memory = FT_FACE_MEMORY( face ); - bdf_font_t* font; + bdf_font_t* font = NULL; bdf_options_t options; FT_UNUSED( num_params ); @@ -469,7 +475,7 @@ THE SOFTWARE. (face->en_table[n]).enc = cur[n].encoding; FT_TRACE4(( "idx %d, val 0x%lX\n", n, cur[n].encoding )); (face->en_table[n]).glyph = (FT_Short)n; - + if ( cur[n].encoding == font->default_char ) face->default_glyph = n; } @@ -578,65 +584,62 @@ THE SOFTWARE. FT_CALLBACK_DEF( FT_Error ) - BDF_Set_Pixel_Size( FT_Size size, - FT_UInt char_width, - FT_UInt char_height ) + BDF_Size_Select( FT_Size size, + FT_ULong strike_index ) { - BDF_Face face = (BDF_Face)FT_SIZE_FACE( size ); - FT_Face root = FT_FACE( face ); - - FT_UNUSED( char_width ); + bdf_font_t* bdffont = ( (BDF_Face)size->face )->bdffont; - if ( char_height == (FT_UInt)root->available_sizes->height ) - { - size->metrics.ascender = face->bdffont->font_ascent << 6; - size->metrics.descender = -face->bdffont->font_descent << 6; - size->metrics.height = ( face->bdffont->font_ascent + - face->bdffont->font_descent ) << 6; - size->metrics.max_advance = face->bdffont->bbx.width << 6; + FT_Select_Metrics( size->face, strike_index ); - return BDF_Err_Ok; - } - else - return BDF_Err_Invalid_Pixel_Size; + size->metrics.ascender = bdffont->font_ascent << 6; + size->metrics.descender = -bdffont->font_descent << 6; + size->metrics.max_advance = bdffont->bbx.width << 6; + + return BDF_Err_Ok; } FT_CALLBACK_DEF( FT_Error ) - BDF_Set_Point_Size( FT_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) + BDF_Size_Request( FT_Size size, + FT_Size_Request req ) { - BDF_Face face = (BDF_Face)FT_SIZE_FACE( size ); - FT_Face root = FT_FACE( face ); - - FT_UNUSED( char_width ); - FT_UNUSED( char_height ); - FT_UNUSED( horz_resolution ); - FT_UNUSED( vert_resolution ); + FT_Face face = size->face; + FT_Bitmap_Size* bsize = face->available_sizes; + bdf_font_t* bdffont = ( (BDF_Face)face )->bdffont; + FT_Error error = BDF_Err_Invalid_Pixel_Size; + FT_Long height; - FT_TRACE4(( "rec %d - pres %d\n", - size->metrics.y_ppem, root->available_sizes->y_ppem )); + height = FT_REQUEST_HEIGHT( req ); + height = ( height + 32 ) >> 6; - if ( size->metrics.y_ppem == root->available_sizes->y_ppem >> 6 ) + switch ( req->type ) { - size->metrics.ascender = face->bdffont->font_ascent << 6; - size->metrics.descender = -face->bdffont->font_descent << 6; - size->metrics.height = ( face->bdffont->font_ascent + - face->bdffont->font_descent ) << 6; - size->metrics.max_advance = face->bdffont->bbx.width << 6; + case FT_SIZE_REQUEST_TYPE_NOMINAL: + if ( height == ( bsize->y_ppem + 32 ) >> 6 ) + error = BDF_Err_Ok; + break; - return BDF_Err_Ok; + case FT_SIZE_REQUEST_TYPE_REAL_DIM: + if ( height == ( bdffont->font_ascent + + bdffont->font_descent ) ) + error = BDF_Err_Ok; + break; + + default: + error = BDF_Err_Unimplemented_Feature; + break; } + + if ( error ) + return error; else - return BDF_Err_Invalid_Pixel_Size; + return BDF_Size_Select( size, 0 ); } + FT_CALLBACK_DEF( FT_Error ) BDF_Glyph_Load( FT_GlyphSlot slot, FT_Size size, @@ -692,18 +695,22 @@ THE SOFTWARE. break; } + slot->format = FT_GLYPH_FORMAT_BITMAP; slot->bitmap_left = glyph.bbx.x_offset; slot->bitmap_top = glyph.bbx.ascent; - /* FZ XXX: TODO: vertical metrics */ slot->metrics.horiAdvance = glyph.dwidth << 6; slot->metrics.horiBearingX = glyph.bbx.x_offset << 6; slot->metrics.horiBearingY = glyph.bbx.ascent << 6; slot->metrics.width = bitmap->width << 6; slot->metrics.height = bitmap->rows << 6; - slot->linearHoriAdvance = (FT_Fixed)glyph.dwidth << 16; - slot->format = FT_GLYPH_FORMAT_BITMAP; + /* + * XXX DWIDTH1 and VVECTOR should be parsed and + * used here, provided such fonts do exist. + */ + ft_synthesize_vertical_metrics( &slot->metrics, + face->bdffont->bbx.height << 6 ); Exit: return error; @@ -831,14 +838,18 @@ THE SOFTWARE. 0, /* FT_Slot_InitFunc */ 0, /* FT_Slot_DoneFunc */ - BDF_Set_Point_Size, - BDF_Set_Pixel_Size, - +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif BDF_Glyph_Load, 0, /* FT_Face_GetKerningFunc */ 0, /* FT_Face_AttachFunc */ 0, /* FT_Face_GetAdvancesFunc */ + + BDF_Size_Request, + BDF_Size_Select }; diff --git a/src/libs/freetype2/bdf/bdflib.c b/src/libs/freetype2/bdf/bdflib.c index 31100ed743..3c928e5634 100644 --- a/src/libs/freetype2/bdf/bdflib.c +++ b/src/libs/freetype2/bdf/bdflib.c @@ -1,6 +1,6 @@ /* * Copyright 2000 Computing Research Labs, New Mexico State University - * Copyright 2001, 2002, 2003, 2004, 2005 Francesco Zappa Nardelli + * Copyright 2001, 2002, 2003, 2004, 2005, 2006 Francesco Zappa Nardelli * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1064,8 +1064,8 @@ _BDF_BBX | \ _BDF_BITMAP ) -#define _BDF_GLYPH_WIDTH_CHECK 0x40000000L -#define _BDF_GLYPH_HEIGHT_CHECK 0x80000000L +#define _BDF_GLYPH_WIDTH_CHECK 0x40000000UL +#define _BDF_GLYPH_HEIGHT_CHECK 0x80000000UL /* Auto correction messages. */ @@ -1092,6 +1092,7 @@ #define ERRMSG1 "[line %ld] Missing \"%s\" line.\n" #define ERRMSG2 "[line %ld] Font header corrupted or missing fields.\n" #define ERRMSG3 "[line %ld] Font glyphs corrupted or missing fields.\n" +#define ERRMSG4 "[line %ld] BBX too big.\n" static FT_Error @@ -1561,6 +1562,14 @@ p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 ); + /* Check that the encoding is in the range [0,65536] because */ + /* otherwise p->have (a bitmap with static size) overflows. */ + if ( (size_t)p->glyph_enc >= sizeof ( p->have ) * 8 ) + { + error = BDF_Err_Invalid_File_Format; + goto Exit; + } + /* Check to see whether this encoding has already been encountered. */ /* If it has then change it to unencoded so it gets added if */ /* indicated. */ @@ -1666,7 +1675,7 @@ nibbles = glyph->bpr << 1; bp = glyph->bitmap + p->row * glyph->bpr; - for ( i = 0, *bp = 0; i < nibbles; i++ ) + for ( i = 0; i < nibbles; i++ ) { c = line[i]; *bp = (FT_Byte)( ( *bp << 4 ) + a2i[c] ); @@ -1676,7 +1685,8 @@ /* Remove possible garbage at the right. */ mask_index = ( glyph->bbx.width * p->font->bpp ) & 7; - *bp &= nibble_mask[mask_index]; + if ( glyph->bbx.width ) + *bp &= nibble_mask[mask_index]; /* If any line has extra columns, indicate they have been removed. */ if ( ( line[nibbles] == '0' || a2i[(int)line[nibbles]] != 0 ) && @@ -1805,6 +1815,9 @@ /* And finally, gather up the bitmap. */ if ( ft_memcmp( line, "BITMAP", 6 ) == 0 ) { + unsigned long bitmap_size; + + if ( !( p->flags & _BDF_BBX ) ) { /* Missing BBX field. */ @@ -1815,7 +1828,16 @@ /* Allocate enough space for the bitmap. */ glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3; - glyph->bytes = (unsigned short)( glyph->bpr * glyph->bbx.height ); + + bitmap_size = glyph->bpr * glyph->bbx.height; + if ( bitmap_size > 0xFFFFU ) + { + FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG4, lineno )); + error = BDF_Err_Bbx_Too_Big; + goto Exit; + } + else + glyph->bytes = (unsigned short)bitmap_size; if ( FT_NEW_ARRAY( glyph->bitmap, glyph->bytes ) ) goto Exit; diff --git a/src/libs/freetype2/bdf/descrip.mms b/src/libs/freetype2/bdf/descrip.mms deleted file mode 100644 index 4c32dc4499..0000000000 --- a/src/libs/freetype2/bdf/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 BDF driver compilation rules for VMS -# - - -# Copyright 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.bdf]) - -OBJS=bdf.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/bdf/module.mk b/src/libs/freetype2/bdf/module.mk index 24115e75d0..a9789736a0 100644 --- a/src/libs/freetype2/bdf/module.mk +++ b/src/libs/freetype2/bdf/module.mk @@ -2,7 +2,7 @@ # FreeType 2 BDF module definition # -# Copyright 2001, 2002 by +# Copyright 2001, 2002, 2006 by # Francesco Zappa Nardelli # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,9 +23,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -make_module_list: add_bdf_driver -add_bdf_driver: - $(OPEN_DRIVER)bdf_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)bdf $(ECHO_DRIVER_DESC)bdf bitmap fonts$(ECHO_DRIVER_DONE) +FTMODULE_H_COMMANDS += BDF_DRIVER +define BDF_DRIVER +$(OPEN_DRIVER)bdf_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)bdf $(ECHO_DRIVER_DESC)bdf bitmap fonts$(ECHO_DRIVER_DONE) +endef + +# EOF diff --git a/src/libs/freetype2/cache/Jamfile b/src/libs/freetype2/cache/Jamfile index 321faa1645..af134e3247 100644 --- a/src/libs/freetype2/cache/Jamfile +++ b/src/libs/freetype2/cache/Jamfile @@ -1,5 +1,13 @@ -# FreeType 2 src/cache Jamfile (c) 2001 David Turner +# FreeType 2 src/cache Jamfile # +# Copyright 2001, 2003, 2004 by +# David Turner, Robert Wilhelm, and Werner Lemberg. +# +# This file is part of the FreeType project, and may only be used, modified, +# and distributed under the terms of the FreeType project license, +# LICENSE.TXT. By continuing to use, modify, or distribute this file you +# indicate that you have read the license and understand and accept it +# fully. SubDir HAIKU_TOP src libs freetype2 cache ; @@ -19,7 +27,15 @@ UseFreeTypeHeaders ; if $(FT2_MULTI) { - _sources = ftlru ftcmanag ftccache ftcglyph ftcsbits ftcimage ftccmap ; + _sources = ftcmru + ftcmanag + ftccache + ftcglyph + ftcsbits + ftcimage + ftcbasic + ftccmap + ; } else { @@ -30,4 +46,3 @@ UseFreeTypeHeaders ; } # end of src/cache Jamfile - diff --git a/src/libs/freetype2/cache/descrip.mms b/src/libs/freetype2/cache/descrip.mms deleted file mode 100644 index 4d967dc181..0000000000 --- a/src/libs/freetype2/cache/descrip.mms +++ /dev/null @@ -1,25 +0,0 @@ -# -# FreeType 2 Cache compilation rules for VMS -# - - -# Copyright 2001, 2002, 2003, 2004 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.cache]) - -OBJS=ftcache.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -ftcache.obj : ftcache.c - -# EOF diff --git a/src/libs/freetype2/cache/ftcbasic.c b/src/libs/freetype2/cache/ftcbasic.c index 689cdc61b0..e9e8135ae9 100644 --- a/src/libs/freetype2/cache/ftcbasic.c +++ b/src/libs/freetype2/cache/ftcbasic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType basic cache interface (body). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,15 +18,53 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_GLYPH_H -#include FT_CACHE_INTERNAL_IMAGE_H -#include FT_CACHE_INTERNAL_SBITS_H +#include "ftcglyph.h" +#include "ftcimage.h" +#include "ftcsbits.h" #include FT_INTERNAL_MEMORY_H #include "ftccback.h" #include "ftcerror.h" +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + /* + * These structures correspond to the FTC_Font and FTC_ImageDesc types + * that were defined in version 2.1.7. + */ + typedef struct FTC_OldFontRec_ + { + FTC_FaceID face_id; + FT_UShort pix_width; + FT_UShort pix_height; + + } FTC_OldFontRec, *FTC_OldFont; + + + typedef struct FTC_OldImageDescRec_ + { + FTC_OldFontRec font; + FT_UInt32 flags; + + } FTC_OldImageDescRec, *FTC_OldImageDesc; + + + /* + * Notice that FTC_OldImageDescRec and FTC_ImageTypeRec are nearly + * identical, bit-wise. The only difference is that the `width' and + * `height' fields are expressed as 16-bit integers in the old structure, + * and as normal `int' in the new one. + * + * We are going to perform a weird hack to detect which structure is + * being passed to the image and sbit caches. If the new structure's + * `width' is larger than 0x10000, we assume that we are really receiving + * an FTC_OldImageDesc. + */ + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + /* * Basic Families * @@ -282,14 +320,36 @@ if ( anode ) *anode = NULL; - query.attrs.scaler.face_id = type->face_id; - query.attrs.scaler.width = type->width; - query.attrs.scaler.height = type->height; - query.attrs.scaler.pixel = 1; - query.attrs.load_flags = type->flags; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS - query.attrs.scaler.x_res = 0; /* make compilers happy */ - query.attrs.scaler.y_res = 0; + /* + * This one is a major hack used to detect whether we are passed a + * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. + */ + if ( type->width >= 0x10000 ) + { + FTC_OldImageDesc desc = (FTC_OldImageDesc)type; + + + query.attrs.scaler.face_id = desc->font.face_id; + query.attrs.scaler.width = desc->font.pix_width; + query.attrs.scaler.height = desc->font.pix_height; + query.attrs.load_flags = desc->flags; + } + else + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + { + query.attrs.scaler.face_id = type->face_id; + query.attrs.scaler.width = type->width; + query.attrs.scaler.height = type->height; + query.attrs.load_flags = type->flags; + } + + query.attrs.scaler.pixel = 1; + query.attrs.scaler.x_res = 0; /* make compilers happy */ + query.attrs.scaler.y_res = 0; hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex; @@ -323,6 +383,135 @@ } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + /* yet another backwards-legacy structure */ + typedef struct FTC_OldImage_Desc_ + { + FTC_FontRec font; + FT_UInt image_type; + + } FTC_OldImage_Desc; + + +#define FTC_OLD_IMAGE_FORMAT( x ) ( (x) & 7 ) + + +#define ftc_old_image_format_bitmap 0x0000 +#define ftc_old_image_format_outline 0x0001 + +#define ftc_old_image_format_mask 0x000F + +#define ftc_old_image_flag_monochrome 0x0010 +#define ftc_old_image_flag_unhinted 0x0020 +#define ftc_old_image_flag_autohinted 0x0040 +#define ftc_old_image_flag_unscaled 0x0080 +#define ftc_old_image_flag_no_sbits 0x0100 + + /* monochrome bitmap */ +#define ftc_old_image_mono ftc_old_image_format_bitmap | \ + ftc_old_image_flag_monochrome + + /* anti-aliased bitmap */ +#define ftc_old_image_grays ftc_old_image_format_bitmap + + /* scaled outline */ +#define ftc_old_image_outline ftc_old_image_format_outline + + + static void + ftc_image_type_from_old_desc( FTC_ImageType typ, + FTC_OldImage_Desc* desc ) + { + typ->face_id = desc->font.face_id; + typ->width = desc->font.pix_width; + typ->height = desc->font.pix_height; + + /* convert image type flags to load flags */ + { + FT_UInt load_flags = FT_LOAD_DEFAULT; + FT_UInt type = desc->image_type; + + + /* determine load flags, depending on the font description's */ + /* image type */ + + if ( FTC_OLD_IMAGE_FORMAT( type ) == ftc_old_image_format_bitmap ) + { + if ( type & ftc_old_image_flag_monochrome ) + load_flags |= FT_LOAD_MONOCHROME; + + /* disable embedded bitmaps loading if necessary */ + if ( type & ftc_old_image_flag_no_sbits ) + load_flags |= FT_LOAD_NO_BITMAP; + } + else + { + /* we want an outline, don't load embedded bitmaps */ + load_flags |= FT_LOAD_NO_BITMAP; + + if ( type & ftc_old_image_flag_unscaled ) + load_flags |= FT_LOAD_NO_SCALE; + } + + /* always render glyphs to bitmaps */ + load_flags |= FT_LOAD_RENDER; + + if ( type & ftc_old_image_flag_unhinted ) + load_flags |= FT_LOAD_NO_HINTING; + + if ( type & ftc_old_image_flag_autohinted ) + load_flags |= FT_LOAD_FORCE_AUTOHINT; + + typ->flags = load_flags; + } + } + + + FT_EXPORT( FT_Error ) + FTC_Image_Cache_New( FTC_Manager manager, + FTC_ImageCache *acache ); + + FT_EXPORT( FT_Error ) + FTC_Image_Cache_Lookup( FTC_ImageCache icache, + FTC_OldImage_Desc* desc, + FT_UInt gindex, + FT_Glyph *aglyph ); + + + FT_EXPORT_DEF( FT_Error ) + FTC_Image_Cache_New( FTC_Manager manager, + FTC_ImageCache *acache ) + { + return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache ); + } + + + + FT_EXPORT_DEF( FT_Error ) + FTC_Image_Cache_Lookup( FTC_ImageCache icache, + FTC_OldImage_Desc* desc, + FT_UInt gindex, + FT_Glyph *aglyph ) + { + FTC_ImageTypeRec type0; + + + if ( !desc ) + return FTC_Err_Invalid_Argument; + + ftc_image_type_from_old_desc( &type0, desc ); + + return FTC_ImageCache_Lookup( (FTC_ImageCache)icache, + &type0, + gindex, + aglyph, + NULL ); + } + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + /* * * basic small bitmap cache @@ -398,14 +587,35 @@ *ansbit = NULL; - query.attrs.scaler.face_id = type->face_id; - query.attrs.scaler.width = type->width; - query.attrs.scaler.height = type->height; - query.attrs.scaler.pixel = 1; - query.attrs.load_flags = type->flags; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS - query.attrs.scaler.x_res = 0; /* make compilers happy */ - query.attrs.scaler.y_res = 0; + /* This one is a major hack used to detect whether we are passed a + * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. + */ + if ( type->width >= 0x10000 ) + { + FTC_OldImageDesc desc = (FTC_OldImageDesc)type; + + + query.attrs.scaler.face_id = desc->font.face_id; + query.attrs.scaler.width = desc->font.pix_width; + query.attrs.scaler.height = desc->font.pix_height; + query.attrs.load_flags = desc->flags; + } + else + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + { + query.attrs.scaler.face_id = type->face_id; + query.attrs.scaler.width = type->width; + query.attrs.scaler.height = type->height; + query.attrs.load_flags = type->flags; + } + + query.attrs.scaler.pixel = 1; + query.attrs.scaler.x_res = 0; /* make compilers happy */ + query.attrs.scaler.y_res = 0; /* beware, the hash must be the same for all glyph ranges! */ hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + @@ -442,4 +652,49 @@ } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + FT_EXPORT( FT_Error ) + FTC_SBit_Cache_New( FTC_Manager manager, + FTC_SBitCache *acache ); + + FT_EXPORT( FT_Error ) + FTC_SBit_Cache_Lookup( FTC_SBitCache cache, + FTC_OldImage_Desc* desc, + FT_UInt gindex, + FTC_SBit *ansbit ); + + + FT_EXPORT_DEF( FT_Error ) + FTC_SBit_Cache_New( FTC_Manager manager, + FTC_SBitCache *acache ) + { + return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache ); + } + + + FT_EXPORT_DEF( FT_Error ) + FTC_SBit_Cache_Lookup( FTC_SBitCache cache, + FTC_OldImage_Desc* desc, + FT_UInt gindex, + FTC_SBit *ansbit ) + { + FTC_ImageTypeRec type0; + + + if ( !desc ) + return FT_Err_Invalid_Argument; + + ftc_image_type_from_old_desc( &type0, desc ); + + return FTC_SBitCache_Lookup( (FTC_SBitCache)cache, + &type0, + gindex, + ansbit, + NULL ); + } + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + /* END */ diff --git a/src/libs/freetype2/cache/ftccache.c b/src/libs/freetype2/cache/ftccache.c index ad036805f5..797d35f6dc 100644 --- a/src/libs/freetype2/cache/ftccache.c +++ b/src/libs/freetype2/cache/ftccache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType internal cache interface (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,7 +17,7 @@ #include <ft2build.h> -#include FT_CACHE_INTERNAL_MANAGER_H +#include "ftcmanag.h" #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H @@ -63,6 +63,8 @@ } +#ifndef FTC_INLINE + /* move a node to the head of the manager's MRU list */ static void ftc_node_mru_up( FTC_Node node, @@ -72,6 +74,8 @@ (FTC_MruNode)node ); } +#endif /* !FTC_INLINE */ + /* Note that this function cannot fail. If we cannot re-size the * buckets array appropriately, we simply degrade the hash table's @@ -100,10 +104,11 @@ if ( p >= mask ) { FT_Memory memory = cache->memory; + FT_Error error; /* if we can't expand the array, leave immediately */ - if ( FT_MEM_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) ) + if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) ) break; } @@ -152,11 +157,12 @@ if ( p == 0 ) { FT_Memory memory = cache->memory; + FT_Error error; /* if we can't shrink the array, leave immediately */ - if ( FT_MEM_RENEW_ARRAY( cache->buckets, - ( mask + 1 ) * 2, mask + 1 ) ) + if ( FT_RENEW_ARRAY( cache->buckets, + ( mask + 1 ) * 2, mask + 1 ) ) break; cache->mask >>= 1; @@ -246,7 +252,11 @@ /* remove a node from the cache manager */ - FT_EXPORT_DEF( void ) +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_BASE_DEF( void ) +#else + FT_LOCAL_DEF( void ) +#endif ftc_node_destroy( FTC_Node node, FTC_Manager manager ) { @@ -301,7 +311,7 @@ /*************************************************************************/ - FT_EXPORT_DEF( FT_Error ) + FT_LOCAL_DEF( FT_Error ) FTC_Cache_Init( FTC_Cache cache ) { return ftc_cache_init( cache ); @@ -312,17 +322,19 @@ ftc_cache_init( FTC_Cache cache ) { FT_Memory memory = cache->memory; + FT_Error error; cache->p = 0; cache->mask = FTC_HASH_INITIAL_SIZE - 1; cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD; - return ( FT_MEM_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) ); + (void)FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ); + return error; } - FT_EXPORT_DEF( void ) + static void FTC_Cache_Clear( FTC_Cache cache ) { if ( cache ) @@ -380,7 +392,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_Cache_Done( FTC_Cache cache ) { ftc_cache_done( cache ); @@ -415,7 +427,7 @@ } - FT_EXPORT_DEF( FT_Error ) + FT_LOCAL_DEF( FT_Error ) FTC_Cache_NewNode( FTC_Cache cache, FT_UInt32 hash, FT_Pointer query, @@ -452,7 +464,9 @@ } - FT_EXPORT_DEF( FT_Error ) +#ifndef FTC_INLINE + + FT_LOCAL_DEF( FT_Error ) FTC_Cache_Lookup( FTC_Cache cache, FT_UInt32 hash, FT_Pointer query, @@ -510,8 +524,10 @@ return FTC_Cache_NewNode( cache, hash, query, anode ); } +#endif /* !FTC_INLINE */ - FT_EXPORT_DEF( void ) + + FT_LOCAL_DEF( void ) FTC_Cache_RemoveFaceID( FTC_Cache cache, FTC_FaceID face_id ) { diff --git a/headers/libs/freetype2/freetype/cache/ftccache.h b/src/libs/freetype2/cache/ftccache.h similarity index 93% rename from headers/libs/freetype2/freetype/cache/ftccache.h rename to src/libs/freetype2/cache/ftccache.h index f2e10281b3..6c9b9b9e84 100644 --- a/headers/libs/freetype2/freetype/cache/ftccache.h +++ b/src/libs/freetype2/cache/ftccache.h @@ -4,7 +4,7 @@ /* */ /* FreeType internal cache interface (specification). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,7 +20,7 @@ #define __FTCCACHE_H__ -#include FT_CACHE_INTERNAL_MRU_H +#include "ftcmru.h" FT_BEGIN_HEADER @@ -66,21 +66,15 @@ FT_BEGIN_HEADER #define FTC_NODE( x ) ( (FTC_Node)(x) ) #define FTC_NODE_P( x ) ( (FTC_Node*)(x) ) -#define FTC_NODE__NEXT(x) FTC_NODE( (x)->mru.next ) -#define FTC_NODE__PREV(x) FTC_NODE( (x)->mru.prev ) +#define FTC_NODE__NEXT( x ) FTC_NODE( (x)->mru.next ) +#define FTC_NODE__PREV( x ) FTC_NODE( (x)->mru.prev ) - /*************************************************************************/ - /* */ - /* These functions are exported so that they can be called from */ - /* user-provided cache classes; otherwise, they are really part of the */ - /* cache sub-system internals. */ - /* */ - - /* reserved for manager's use */ - FT_EXPORT( void ) +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_BASE( void ) ftc_node_destroy( FTC_Node node, FTC_Manager manager ); +#endif /*************************************************************************/ @@ -158,11 +152,11 @@ FT_BEGIN_HEADER /* default cache initialize */ - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_Cache_Init( FTC_Cache cache ); /* default cache finalizer */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_Cache_Done( FTC_Cache cache ); /* Call this function to lookup the cache. If no corresponding @@ -170,13 +164,16 @@ FT_BEGIN_HEADER * is capable of flushing the cache adequately to make room for the * new cache object. */ - FT_EXPORT( FT_Error ) + +#ifndef FTC_INLINE + FT_LOCAL( FT_Error ) FTC_Cache_Lookup( FTC_Cache cache, FT_UInt32 hash, FT_Pointer query, FTC_Node *anode ); +#endif - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_Cache_NewNode( FTC_Cache cache, FT_UInt32 hash, FT_Pointer query, @@ -184,7 +181,7 @@ FT_BEGIN_HEADER /* Remove all nodes that relate to a given face_id. This is useful * when un-installing fonts. Note that if a cache node relates to - * the face_id, but is locked (i.e., has 'ref_count > 0'), the node + * the face_id, but is locked (i.e., has `ref_count > 0'), the node * will _not_ be destroyed, but its internal face_id reference will * be modified. * @@ -192,7 +189,7 @@ FT_BEGIN_HEADER * in further lookup requests, and will be flushed on demand from * the cache normally when its reference count reaches 0. */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_Cache_RemoveFaceID( FTC_Cache cache, FTC_FaceID face_id ); @@ -269,7 +266,7 @@ FT_BEGIN_HEADER * * It is used when creating a new cache node, or within a lookup * that needs to allocate data (e.g., the sbit cache lookup). - * + * * Example: * * { diff --git a/src/libs/freetype2/cache/ftccback.h b/src/libs/freetype2/cache/ftccback.h index 6b47e095e8..86e72a7514 100644 --- a/src/libs/freetype2/cache/ftccback.h +++ b/src/libs/freetype2/cache/ftccback.h @@ -4,7 +4,7 @@ /* */ /* Callback functions of the caching sub-system (specification only). */ /* */ -/* Copyright 2004 by */ +/* Copyright 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,11 +20,11 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_MRU_H -#include FT_CACHE_INTERNAL_IMAGE_H -#include FT_CACHE_INTERNAL_MANAGER_H -#include FT_CACHE_INTERNAL_GLYPH_H -#include FT_CACHE_INTERNAL_SBITS_H +#include "ftcmru.h" +#include "ftcimage.h" +#include "ftcmanag.h" +#include "ftcglyph.h" +#include "ftcsbits.h" FT_LOCAL( void ) @@ -79,6 +79,11 @@ FT_LOCAL( void ) ftc_cache_done( FTC_Cache cache ); +#ifndef FT_CONFIG_OPTION_OLD_INTERNALS + FT_LOCAL( void ) + ftc_node_destroy( FTC_Node node, + FTC_Manager manager ); +#endif #endif /* __FTCCBACK_H__ */ diff --git a/src/libs/freetype2/cache/ftccmap.c b/src/libs/freetype2/cache/ftccmap.c index 02b814818d..fefcbdfc05 100644 --- a/src/libs/freetype2/cache/ftccmap.c +++ b/src/libs/freetype2/cache/ftccmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType CharMap cache (body) */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,7 +19,7 @@ #include <ft2build.h> #include FT_FREETYPE_H #include FT_CACHE_H -#include FT_CACHE_INTERNAL_MANAGER_H +#include "ftcmanag.h" #include FT_INTERNAL_MEMORY_H #include FT_INTERNAL_DEBUG_H #include FT_TRUETYPE_IDS_H @@ -31,6 +31,43 @@ #define FT_COMPONENT trace_cache +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + typedef enum FTC_OldCMapType_ + { + FTC_OLD_CMAP_BY_INDEX = 0, + FTC_OLD_CMAP_BY_ENCODING = 1, + FTC_OLD_CMAP_BY_ID = 2 + + } FTC_OldCMapType; + + + typedef struct FTC_OldCMapIdRec_ + { + FT_UInt platform; + FT_UInt encoding; + + } FTC_OldCMapIdRec, *FTC_OldCMapId; + + + typedef struct FTC_OldCMapDescRec_ + { + FTC_FaceID face_id; + FTC_OldCMapType type; + + union + { + FT_UInt index; + FT_Encoding encoding; + FTC_OldCMapIdRec id; + + } u; + + } FTC_OldCMapDescRec, *FTC_OldCMapDesc; + +#endif /* FT_CONFIG_OLD_INTERNALS */ + + /*************************************************************************/ /* */ /* Each FTC_CMapNode contains a simple array to map a range of character */ @@ -95,8 +132,6 @@ /*************************************************************************/ - /* no need for specific finalizer; we use `ftc_node_done' directly */ - FT_CALLBACK_DEF( void ) ftc_cmap_node_free( FTC_Node ftcnode, FTC_Cache cache ) @@ -224,6 +259,21 @@ } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + /* + * Unfortunately, it is not possible to support binary backwards + * compatibility in the cmap cache. The FTC_CMapCache_Lookup signature + * changes were too deep, and there is no clever hackish way to detect + * what kind of structure we are being passed. + * + * On the other hand it seems that no production code is using this + * function on Unix distributions. + */ + +#endif + + /* documentation is in ftcache.h */ FT_EXPORT_DEF( FT_UInt ) @@ -246,9 +296,62 @@ return 0; } - query.face_id = face_id; - query.cmap_index = (FT_UInt)cmap_index; - query.char_code = char_code; +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + /* + * Detect a call from a rogue client that thinks it is linking + * to FreeType 2.1.7. This is possible because the third parameter + * is then a character code, and we have never seen any font with + * more than a few charmaps, so if the index is very large... + * + * It is also very unlikely that a rogue client is interested + * in Unicode values 0 to 3. + */ + if ( cmap_index >= 4 ) + { + FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id; + + + char_code = (FT_UInt32)cmap_index; + query.face_id = desc->face_id; + + + switch ( desc->type ) + { + case FTC_OLD_CMAP_BY_INDEX: + query.cmap_index = desc->u.index; + query.char_code = (FT_UInt32)cmap_index; + break; + + case FTC_OLD_CMAP_BY_ENCODING: + { + FT_Face face; + + + error = FTC_Manager_LookupFace( cache->manager, desc->face_id, + &face ); + if ( error ) + return 0; + + FT_Select_Charmap( face, desc->u.encoding ); + + return FT_Get_Char_Index( face, char_code ); + } + break; + + default: + return 0; + } + } + else + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + { + query.face_id = face_id; + query.cmap_index = (FT_UInt)cmap_index; + query.char_code = char_code; + } hash = FTC_CMAP_HASH( face_id, cmap_index, char_code ); @@ -263,6 +366,10 @@ FT_ASSERT( (FT_UInt)( char_code - node->first ) < FTC_CMAP_INDICES_MAX ); + /* something rotten can happen with rogue clients */ + if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) ) + return 0; + gindex = node->indices[char_code - node->first]; if ( gindex == FTC_CMAP_UNKNOWN ) { diff --git a/src/libs/freetype2/cache/ftcglyph.c b/src/libs/freetype2/cache/ftcglyph.c index 46d5965b69..5c03abe055 100644 --- a/src/libs/freetype2/cache/ftcglyph.c +++ b/src/libs/freetype2/cache/ftcglyph.c @@ -4,7 +4,7 @@ /* */ /* FreeType Glyph Image (FT_Glyph) cache (body). */ /* */ -/* Copyright 2000-2001, 2003, 2004 by */ +/* Copyright 2000-2001, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,7 +18,7 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_GLYPH_H +#include "ftcglyph.h" #include FT_ERRORS_H #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H @@ -28,7 +28,7 @@ /* create a new chunk node, setting its cache index and ref count */ - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_GNode_Init( FTC_GNode gnode, FT_UInt gindex, FTC_Family family ) @@ -39,7 +39,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_GNode_UnselectFamily( FTC_GNode gnode, FTC_Cache cache ) { @@ -52,7 +52,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_GNode_Done( FTC_GNode gnode, FTC_Cache cache ) { @@ -78,7 +78,7 @@ } - FT_EXPORT_DEF( FT_Bool ) + FT_LOCAL_DEF( FT_Bool ) FTC_GNode_Compare( FTC_GNode gnode, FTC_GQuery gquery ) { @@ -94,7 +94,7 @@ /*************************************************************************/ /*************************************************************************/ - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_Family_Init( FTC_Family family, FTC_Cache cache ) { @@ -130,12 +130,16 @@ } - FT_EXPORT_DEF( FT_Error ) +#if 0 + + FT_LOCAL_DEF( FT_Error ) FTC_GCache_Init( FTC_GCache cache ) { return ftc_gcache_init( FTC_CACHE( cache ) ); } +#endif /* 0 */ + FT_LOCAL_DEF( void ) ftc_gcache_done( FTC_Cache ftccache ) @@ -148,14 +152,18 @@ } - FT_EXPORT_DEF( void ) +#if 0 + + FT_LOCAL_DEF( void ) FTC_GCache_Done( FTC_GCache cache ) { ftc_gcache_done( FTC_CACHE( cache ) ); } +#endif /* 0 */ - FT_EXPORT_DEF( FT_Error ) + + FT_LOCAL_DEF( FT_Error ) FTC_GCache_New( FTC_Manager manager, FTC_GCacheClass clazz, FTC_GCache *acache ) @@ -165,7 +173,9 @@ } - FT_EXPORT_DEF( FT_Error ) +#ifndef FTC_INLINE + + FT_LOCAL_DEF( FT_Error ) FTC_GCache_Lookup( FTC_GCache cache, FT_UInt32 hash, FT_UInt gindex, @@ -195,5 +205,7 @@ return error; } +#endif /* !FTC_INLINE */ + /* END */ diff --git a/headers/libs/freetype2/freetype/cache/ftcglyph.h b/src/libs/freetype2/cache/ftcglyph.h similarity index 96% rename from headers/libs/freetype2/freetype/cache/ftcglyph.h rename to src/libs/freetype2/cache/ftcglyph.h index 3f8301a514..1a5d12deb3 100644 --- a/headers/libs/freetype2/freetype/cache/ftcglyph.h +++ b/src/libs/freetype2/cache/ftcglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType abstract glyph cache (specification). */ /* */ -/* Copyright 2000-2001, 2003, 2004 by */ +/* Copyright 2000-2001, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -118,7 +118,7 @@ #include <ft2build.h> -#include FT_CACHE_INTERNAL_MANAGER_H +#include "ftcmanag.h" FT_BEGIN_HEADER @@ -175,31 +175,31 @@ FT_BEGIN_HEADER /* */ /* must be called by derived FTC_Node_InitFunc routines */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_GNode_Init( FTC_GNode node, FT_UInt gindex, /* glyph index for node */ FTC_Family family ); /* returns TRUE iff the query's glyph index correspond to the node; */ - /* this assumes that the "family" and "hash" fields of the query are */ + /* this assumes that the `family' and `hash' fields of the query are */ /* already correctly set */ - FT_EXPORT( FT_Bool ) + FT_LOCAL( FT_Bool ) FTC_GNode_Compare( FTC_GNode gnode, FTC_GQuery gquery ); /* call this function to clear a node's family -- this is necessary */ /* to implement the `node_remove_faceid' cache method correctly */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_GNode_UnselectFamily( FTC_GNode gnode, FTC_Cache cache ); /* must be called by derived FTC_Node_DoneFunc routines */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_GNode_Done( FTC_GNode node, FTC_Cache cache ); - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_Family_Init( FTC_Family family, FTC_Cache cache ); @@ -213,14 +213,18 @@ FT_BEGIN_HEADER #define FTC_GCACHE( x ) ((FTC_GCache)(x)) +#if 0 /* can be used as @FTC_Cache_InitFunc */ - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_GCache_Init( FTC_GCache cache ); +#endif +#if 0 /* can be used as @FTC_Cache_DoneFunc */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_GCache_Done( FTC_GCache cache ); +#endif /* the glyph cache class adds fields for the family implementation */ @@ -242,17 +246,19 @@ FT_BEGIN_HEADER /* convenience function; use it instead of FTC_Manager_Register_Cache */ - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_GCache_New( FTC_Manager manager, FTC_GCacheClass clazz, FTC_GCache *acache ); - FT_EXPORT( FT_Error ) +#ifndef FTC_INLINE + FT_LOCAL( FT_Error ) FTC_GCache_Lookup( FTC_GCache cache, FT_UInt32 hash, FT_UInt gindex, FTC_GQuery query, FTC_Node *anode ); +#endif /* */ diff --git a/src/libs/freetype2/cache/ftcimage.c b/src/libs/freetype2/cache/ftcimage.c index 508ed6c153..15d4e80c8c 100644 --- a/src/libs/freetype2/cache/ftcimage.c +++ b/src/libs/freetype2/cache/ftcimage.c @@ -4,7 +4,7 @@ /* */ /* FreeType Image cache (body). */ /* */ -/* Copyright 2000-2001, 2003, 2004 by */ +/* Copyright 2000-2001, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,7 +18,7 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_IMAGE_H +#include "ftcimage.h" #include FT_INTERNAL_MEMORY_H #include "ftccback.h" @@ -45,7 +45,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_INode_Free( FTC_INode inode, FTC_Cache cache ) { @@ -54,7 +54,7 @@ /* initialize a new glyph image node */ - FT_EXPORT_DEF( FT_Error ) + FT_LOCAL_DEF( FT_Error ) FTC_INode_New( FTC_INode *pinode, FTC_GQuery gquery, FTC_Cache cache ) @@ -78,6 +78,11 @@ /* we will now load the glyph image */ error = clazz->family_load_glyph( family, gindex, cache, &inode->glyph ); + if ( error ) + { + FTC_INode_Free( inode, cache ); + inode = NULL; + } } *pinode = inode; @@ -117,7 +122,7 @@ bitg = (FT_BitmapGlyph)glyph; - size = bitg->bitmap.rows * labs( bitg->bitmap.pitch ) + + size = bitg->bitmap.rows * ft_labs( bitg->bitmap.pitch ) + sizeof ( *bitg ); } break; @@ -144,11 +149,15 @@ } - FT_EXPORT_DEF( FT_ULong ) +#if 0 + + FT_LOCAL_DEF( FT_ULong ) FTC_INode_Weight( FTC_INode inode ) { return ftc_inode_weight( FTC_NODE( inode ), NULL ); } +#endif /* 0 */ + /* END */ diff --git a/headers/libs/freetype2/freetype/cache/ftcimage.h b/src/libs/freetype2/cache/ftcimage.h similarity index 95% rename from headers/libs/freetype2/freetype/cache/ftcimage.h rename to src/libs/freetype2/cache/ftcimage.h index 1bf12db13d..20d5d3e07d 100644 --- a/headers/libs/freetype2/freetype/cache/ftcimage.h +++ b/src/libs/freetype2/cache/ftcimage.h @@ -4,7 +4,7 @@ /* */ /* FreeType Generic Image cache (specification) */ /* */ -/* Copyright 2000-2001, 2002, 2003 by */ +/* Copyright 2000-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,7 +23,7 @@ * FTC_ICache extends FTC_GCache. For an implementation example, * see FTC_ImageCache in `src/cache/ftbasic.c'. */ - + /*************************************************************************/ /* */ @@ -38,7 +38,7 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_GLYPH_H +#include "ftcglyph.h" FT_BEGIN_HEADER @@ -77,7 +77,7 @@ FT_BEGIN_HEADER /* can be used as a @FTC_Node_FreeFunc */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_INode_Free( FTC_INode inode, FTC_Cache cache ); @@ -85,14 +85,17 @@ FT_BEGIN_HEADER * must be set correctly. This function will call the `family_load_glyph' * method to load the FT_Glyph into the cache node. */ - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_INode_New( FTC_INode *pinode, FTC_GQuery gquery, FTC_Cache cache ); +#if 0 /* can be used as @FTC_Node_WeightFunc */ - FT_EXPORT( FT_ULong ) + FT_LOCAL( FT_ULong ) FTC_INode_Weight( FTC_INode inode ); +#endif + /* */ diff --git a/src/libs/freetype2/cache/ftcmanag.c b/src/libs/freetype2/cache/ftcmanag.c index 337bea5f95..9d7347c3df 100644 --- a/src/libs/freetype2/cache/ftcmanag.c +++ b/src/libs/freetype2/cache/ftcmanag.c @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,11 +18,12 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_MANAGER_H +#include "ftcmanag.h" #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_SIZES_H +#include "ftccback.h" #include "ftcerror.h" @@ -453,7 +454,7 @@ #ifdef FT_DEBUG_ERROR - FT_EXPORT_DEF( void ) + static void FTC_Manager_Check( FTC_Manager manager ) { FTC_Node node, first; @@ -519,7 +520,7 @@ /* documentation is in ftcmanag.h */ - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_Manager_Compress( FTC_Manager manager ) { FTC_Node node, first; @@ -561,7 +562,7 @@ /* documentation is in ftcmanag.h */ - FT_EXPORT_DEF( FT_Error ) + FT_LOCAL_DEF( FT_Error ) FTC_Manager_RegisterCache( FTC_Manager manager, FTC_CacheClass clazz, FTC_Cache *acache ) @@ -612,7 +613,7 @@ } - FT_EXPORT_DEF( FT_UInt ) + FT_LOCAL_DEF( FT_UInt ) FTC_Manager_FlushN( FTC_Manager manager, FT_UInt count ) { @@ -677,4 +678,55 @@ } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + FT_EXPORT_DEF( FT_Error ) + FTC_Manager_Lookup_Face( FTC_Manager manager, + FTC_FaceID face_id, + FT_Face *aface ) + { + return FTC_Manager_LookupFace( manager, face_id, aface ); + } + + + FT_EXPORT( FT_Error ) + FTC_Manager_Lookup_Size( FTC_Manager manager, + FTC_Font font, + FT_Face *aface, + FT_Size *asize ) + { + FTC_ScalerRec scaler; + FT_Error error; + FT_Size size; + FT_Face face; + + + scaler.face_id = font->face_id; + scaler.width = font->pix_width; + scaler.height = font->pix_height; + scaler.pixel = TRUE; + scaler.x_res = 0; + scaler.y_res = 0; + + error = FTC_Manager_LookupSize( manager, &scaler, &size ); + if ( error ) + { + face = NULL; + size = NULL; + } + else + face = size->face; + + if ( aface ) + *aface = face; + + if ( asize ) + *asize = size; + + return error; + } + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + /* END */ diff --git a/headers/libs/freetype2/freetype/cache/ftcmanag.h b/src/libs/freetype2/cache/ftcmanag.h similarity index 97% rename from headers/libs/freetype2/freetype/cache/ftcmanag.h rename to src/libs/freetype2/cache/ftcmanag.h index 5265848228..3fdc2c773b 100644 --- a/headers/libs/freetype2/freetype/cache/ftcmanag.h +++ b/src/libs/freetype2/cache/ftcmanag.h @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (specification). */ /* */ -/* Copyright 2000-2001, 2003, 2004 by */ +/* Copyright 2000-2001, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -65,8 +65,8 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_MRU_H -#include FT_CACHE_INTERNAL_CACHE_H +#include "ftcmru.h" +#include "ftccache.h" FT_BEGIN_HEADER @@ -131,20 +131,20 @@ FT_BEGIN_HEADER /* The reason this function is exported is to allow client-specific */ /* cache classes. */ /* */ - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_Manager_Compress( FTC_Manager manager ); /* try to flush `count' old nodes from the cache; return the number * of really flushed nodes */ - FT_EXPORT( FT_UInt ) + FT_LOCAL( FT_UInt ) FTC_Manager_FlushN( FTC_Manager manager, FT_UInt count ); /* this must be used internally for the moment */ - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_Manager_RegisterCache( FTC_Manager manager, FTC_CacheClass clazz, FTC_Cache *acache ); diff --git a/src/libs/freetype2/cache/ftcmru.c b/src/libs/freetype2/cache/ftcmru.c index d4f733a110..3a6c625afa 100644 --- a/src/libs/freetype2/cache/ftcmru.c +++ b/src/libs/freetype2/cache/ftcmru.c @@ -4,7 +4,7 @@ /* */ /* FreeType MRU support (body). */ /* */ -/* Copyright 2003, 2004 by */ +/* Copyright 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,14 +18,14 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_MRU_H +#include "ftcmru.h" #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include "ftcerror.h" - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_MruNode_Prepend( FTC_MruNode *plist, FTC_MruNode node ) { @@ -69,7 +69,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_MruNode_Up( FTC_MruNode *plist, FTC_MruNode node ) { @@ -118,7 +118,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_MruNode_Remove( FTC_MruNode *plist, FTC_MruNode node ) { @@ -165,7 +165,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_MruList_Init( FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, @@ -181,7 +181,7 @@ } - FT_EXPORT( void ) + FT_LOCAL_DEF( void ) FTC_MruList_Reset( FTC_MruList list ) { while ( list->nodes ) @@ -191,14 +191,15 @@ } - FT_EXPORT( void ) + FT_LOCAL_DEF( void ) FTC_MruList_Done( FTC_MruList list ) { FTC_MruList_Reset( list ); } - FT_EXPORT_DEF( FTC_MruNode ) +#ifndef FTC_INLINE + FT_LOCAL_DEF( FTC_MruNode ) FTC_MruList_Find( FTC_MruList list, FT_Pointer key ) { @@ -229,9 +230,9 @@ return NULL; } +#endif - - FT_EXPORT_DEF( FT_Error ) + FT_LOCAL_DEF( FT_Error ) FTC_MruList_New( FTC_MruList list, FT_Pointer key, FTC_MruNode *anode ) @@ -285,7 +286,8 @@ } - FT_EXPORT( FT_Error ) +#ifndef FTC_INLINE + FT_LOCAL_DEF( FT_Error ) FTC_MruList_Lookup( FTC_MruList list, FT_Pointer key, FTC_MruNode *anode ) @@ -300,9 +302,9 @@ *anode = node; return 0; } +#endif /* FTC_INLINE */ - - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_MruList_Remove( FTC_MruList list, FTC_MruNode node ) { @@ -321,7 +323,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_MruList_RemoveSelection( FTC_MruList list, FTC_MruNode_CompareFunc selection, FT_Pointer key ) diff --git a/headers/libs/freetype2/freetype/cache/ftcmru.h b/src/libs/freetype2/cache/ftcmru.h similarity index 96% rename from headers/libs/freetype2/freetype/cache/ftcmru.h rename to src/libs/freetype2/cache/ftcmru.h index ac1a1a92e4..c8f0c6ef6e 100644 --- a/headers/libs/freetype2/freetype/cache/ftcmru.h +++ b/src/libs/freetype2/cache/ftcmru.h @@ -4,7 +4,7 @@ /* */ /* Simple MRU list-cache (specification). */ /* */ -/* Copyright 2000-2001, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -68,15 +68,15 @@ FT_BEGIN_HEADER } FTC_MruNodeRec; - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruNode_Prepend( FTC_MruNode *plist, FTC_MruNode node ); - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruNode_Up( FTC_MruNode *plist, FTC_MruNode node ); - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruNode_Remove( FTC_MruNode *plist, FTC_MruNode node ); @@ -127,40 +127,31 @@ FT_BEGIN_HEADER } FTC_MruListRec; - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruList_Init( FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, FT_Pointer data, FT_Memory memory ); - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruList_Reset( FTC_MruList list ); - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruList_Done( FTC_MruList list ); - FT_EXPORT( FTC_MruNode ) - FTC_MruList_Find( FTC_MruList list, - FT_Pointer key ); - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_MruList_New( FTC_MruList list, FT_Pointer key, FTC_MruNode *anode ); - FT_EXPORT( FT_Error ) - FTC_MruList_Lookup( FTC_MruList list, - FT_Pointer key, - FTC_MruNode *pnode ); - - - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruList_Remove( FTC_MruList list, FTC_MruNode node ); - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_MruList_RemoveSelection( FTC_MruList list, FTC_MruNode_CompareFunc selection, FT_Pointer key ); @@ -208,6 +199,15 @@ FT_BEGIN_HEADER #else /* !FTC_INLINE */ + FT_LOCAL( FTC_MruNode ) + FTC_MruList_Find( FTC_MruList list, + FT_Pointer key ); + + FT_LOCAL( FT_Error ) + FTC_MruList_Lookup( FTC_MruList list, + FT_Pointer key, + FTC_MruNode *pnode ); + #define FTC_MRULIST_LOOKUP( list, key, node, error ) \ error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) ) diff --git a/src/libs/freetype2/cache/ftcsbits.c b/src/libs/freetype2/cache/ftcsbits.c index 891c7ab8e9..72f139d565 100644 --- a/src/libs/freetype2/cache/ftcsbits.c +++ b/src/libs/freetype2/cache/ftcsbits.c @@ -4,7 +4,7 @@ /* */ /* FreeType sbits manager (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,7 +18,7 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_SBITS_H +#include "ftcsbits.h" #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_ERRORS_H @@ -77,7 +77,7 @@ } - FT_EXPORT_DEF( void ) + FT_LOCAL_DEF( void ) FTC_SNode_Free( FTC_SNode snode, FTC_Cache cache ) { @@ -197,7 +197,7 @@ } - FT_EXPORT_DEF( FT_Error ) + FT_LOCAL_DEF( FT_Error ) FTC_SNode_New( FTC_SNode *psnode, FTC_GQuery gquery, FTC_Cache cache ) @@ -298,12 +298,16 @@ } - FT_EXPORT_DEF( FT_ULong ) +#if 0 + + FT_LOCAL_DEF( FT_ULong ) FTC_SNode_Weight( FTC_SNode snode ) { return ftc_snode_weight( FTC_NODE( snode ), NULL ); } +#endif /* 0 */ + FT_LOCAL_DEF( FT_Bool ) ftc_snode_compare( FTC_Node ftcsnode, @@ -341,7 +345,7 @@ * However, we need to `lock' the node before this operation to * prevent it from being flushed within the loop. * - * When we exit the loop, we unlock the node, then check the `error' + * When we exit the loop, we unlock the node, then check the `error' * variable. If it is non-zero, this means that the cache was * completely flushed and that no usable memory was found to load * the bitmap. @@ -385,7 +389,7 @@ } - FT_EXPORT_DEF( FT_Bool ) + FT_LOCAL_DEF( FT_Bool ) FTC_SNode_Compare( FTC_SNode snode, FTC_GQuery gquery, FTC_Cache cache ) diff --git a/headers/libs/freetype2/freetype/cache/ftcsbits.h b/src/libs/freetype2/cache/ftcsbits.h similarity index 93% rename from headers/libs/freetype2/freetype/cache/ftcsbits.h rename to src/libs/freetype2/cache/ftcsbits.h index b2ef0f1818..6261745f1e 100644 --- a/headers/libs/freetype2/freetype/cache/ftcsbits.h +++ b/src/libs/freetype2/cache/ftcsbits.h @@ -4,7 +4,7 @@ /* */ /* A small-bitmap cache (specification). */ /* */ -/* Copyright 2000-2001, 2002, 2003 by */ +/* Copyright 2000-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,7 +22,7 @@ #include <ft2build.h> #include FT_CACHE_H -#include FT_CACHE_INTERNAL_GLYPH_H +#include "ftcglyph.h" FT_BEGIN_HEADER @@ -68,20 +68,22 @@ FT_BEGIN_HEADER FTC_SFAMILY_CLASS( FTC_CACHE__GCACHE_CLASS( x )->family_class ) - FT_EXPORT( void ) + FT_LOCAL( void ) FTC_SNode_Free( FTC_SNode snode, FTC_Cache cache ); - FT_EXPORT( FT_Error ) + FT_LOCAL( FT_Error ) FTC_SNode_New( FTC_SNode *psnode, FTC_GQuery gquery, FTC_Cache cache ); - FT_EXPORT( FT_ULong ) +#if 0 + FT_LOCAL( FT_ULong ) FTC_SNode_Weight( FTC_SNode inode ); +#endif - FT_EXPORT( FT_Bool ) + FT_LOCAL( FT_Bool ) FTC_SNode_Compare( FTC_SNode snode, FTC_GQuery gquery, FTC_Cache cache ); diff --git a/src/libs/freetype2/cache/rules.mk b/src/libs/freetype2/cache/rules.mk index 381104ad65..457dec848d 100644 --- a/src/libs/freetype2/cache/rules.mk +++ b/src/libs/freetype2/cache/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2000, 2001, 2003, 2004 by +# Copyright 2000, 2001, 2003, 2004, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -16,7 +16,6 @@ # Cache driver directory # CACHE_DIR := $(SRC_DIR)/cache -CACHE_H_DIR := $(PUBLIC_DIR)/cache # compilation flags for the driver # @@ -25,24 +24,23 @@ CACHE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(CACHE_DIR)) # Cache driver sources (i.e., C files) # -CACHE_DRV_SRC := $(CACHE_DIR)/ftcmru.c \ - $(CACHE_DIR)/ftcmanag.c \ - $(CACHE_DIR)/ftcbasic.c \ +CACHE_DRV_SRC := $(CACHE_DIR)/ftcbasic.c \ $(CACHE_DIR)/ftccache.c \ + $(CACHE_DIR)/ftccmap.c \ $(CACHE_DIR)/ftcglyph.c \ - $(CACHE_DIR)/ftcsbits.c \ $(CACHE_DIR)/ftcimage.c \ - $(CACHE_DIR)/ftccmap.c + $(CACHE_DIR)/ftcmanag.c \ + $(CACHE_DIR)/ftcmru.c \ + $(CACHE_DIR)/ftcsbits.c # Cache driver headers # -CACHE_DRV_H := $(CACHE_H_DIR)/ftcmru.h \ - $(CACHE_H_DIR)/ftcmanag.h \ - $(CACHE_H_DIR)/ftcglyph.h \ - $(CACHE_H_DIR)/ftcimage.h \ - $(CACHE_H_DIR)/ftccmap.h \ - $(CACHE_DIR)/ftcerror.h \ - $(CACHE_DIR)/ftccback.h +CACHE_DRV_H := $(CACHE_DIR)/ftccback.h \ + $(CACHE_DIR)/ftcerror.h \ + $(CACHE_DIR)/ftcglyph.h \ + $(CACHE_DIR)/ftcimage.h \ + $(CACHE_DIR)/ftcmanag.h \ + $(CACHE_DIR)/ftcmru.h # Cache driver object(s) diff --git a/src/libs/freetype2/cff/cffcmap.c b/src/libs/freetype2/cff/cffcmap.c index 88169d0b35..cfaaebc9fb 100644 --- a/src/libs/freetype2/cff/cffcmap.c +++ b/src/libs/freetype2/cff/cffcmap.c @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -119,30 +119,23 @@ /*************************************************************************/ /*************************************************************************/ - FT_CALLBACK_DEF( FT_Int ) - cff_cmap_uni_pair_compare( const void* pair1, - const void* pair2 ) + FT_CALLBACK_DEF( const char* ) + cff_sid_to_glyph_name( CFF_Font cff, + FT_UInt idx ) { - FT_UInt32 u1 = ((CFF_CMapUniPair)pair1)->unicode; - FT_UInt32 u2 = ((CFF_CMapUniPair)pair2)->unicode; + CFF_Charset charset = &cff->charset; + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; + FT_UInt sid = charset->sids[idx]; - if ( u1 < u2 ) - return -1; - - if ( u1 > u2 ) - return +1; - - return 0; + return cff_index_get_sid_string( &cff->string_index, sid, psnames ); } FT_CALLBACK_DEF( FT_Error ) - cff_cmap_unicode_init( CFF_CMapUnicode cmap ) + cff_cmap_unicode_init( PS_Unicodes unicodes ) { - FT_Error error; - FT_UInt count; - TT_Face face = (TT_Face)FT_CMAP_FACE( cmap ); + TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); CFF_Font cff = (CFF_Font)face->extra.data; CFF_Charset charset = &cff->charset; @@ -151,178 +144,58 @@ /* can't build Unicode map for CID-keyed font */ if ( !charset->sids ) - { - error = CFF_Err_Invalid_Argument; - goto Exit; - } + return CFF_Err_Invalid_Argument; - cmap->num_pairs = 0; - cmap->pairs = NULL; - - count = cff->num_glyphs; - - if ( !FT_NEW_ARRAY( cmap->pairs, count ) ) - { - FT_UInt n, new_count; - CFF_CMapUniPair pair; - FT_UInt32 uni_code; - - - pair = cmap->pairs; - for ( n = 0; n < count; n++ ) - { - FT_UInt sid = charset->sids[n]; - const char* gname; - - - gname = cff_index_get_sid_string( &cff->string_index, sid, psnames ); - - /* build unsorted pair table by matching glyph names */ - if ( gname ) - { - uni_code = psnames->unicode_value( gname ); - - if ( uni_code != 0 ) - { - pair->unicode = uni_code; - pair->gindex = n; - pair++; - } - - FT_FREE( gname ); - } - } - - new_count = (FT_UInt)( pair - cmap->pairs ); - if ( new_count == 0 ) - { - /* there are no unicode characters in here! */ - FT_FREE( cmap->pairs ); - error = CFF_Err_Invalid_Argument; - } - else - { - /* re-allocate if the new array is much smaller than the original */ - /* one */ - if ( new_count != count && new_count < count / 2 ) - { - (void)FT_RENEW_ARRAY( cmap->pairs, count, new_count ); - error = CFF_Err_Ok; - } - - /* sort the pairs table to allow efficient binary searches */ - ft_qsort( cmap->pairs, - new_count, - sizeof ( CFF_CMapUniPairRec ), - cff_cmap_uni_pair_compare ); - - cmap->num_pairs = new_count; - } - } - - Exit: - return error; + return psnames->unicodes_init( memory, + unicodes, + cff->num_glyphs, + (PS_Glyph_NameFunc)&cff_sid_to_glyph_name, + (FT_Pointer)cff ); } FT_CALLBACK_DEF( void ) - cff_cmap_unicode_done( CFF_CMapUnicode cmap ) + cff_cmap_unicode_done( PS_Unicodes unicodes ) { - FT_Face face = FT_CMAP_FACE( cmap ); + FT_Face face = FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); - FT_FREE( cmap->pairs ); - cmap->num_pairs = 0; + FT_FREE( unicodes->maps ); + unicodes->num_maps = 0; } FT_CALLBACK_DEF( FT_UInt ) - cff_cmap_unicode_char_index( CFF_CMapUnicode cmap, - FT_UInt32 char_code ) + cff_cmap_unicode_char_index( PS_Unicodes unicodes, + FT_UInt32 char_code ) { - FT_UInt min = 0; - FT_UInt max = cmap->num_pairs; - FT_UInt mid; - CFF_CMapUniPair pair; + TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); + CFF_Font cff = (CFF_Font)face->extra.data; + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; - while ( min < max ) - { - mid = min + ( max - min ) / 2; - pair = cmap->pairs + mid; - - if ( pair->unicode == char_code ) - return pair->gindex; - - if ( pair->unicode < char_code ) - min = mid + 1; - else - max = mid; - } - return 0; + return psnames->unicodes_char_index( unicodes, char_code ); } FT_CALLBACK_DEF( FT_UInt ) - cff_cmap_unicode_char_next( CFF_CMapUnicode cmap, - FT_UInt32 *pchar_code ) + cff_cmap_unicode_char_next( PS_Unicodes unicodes, + FT_UInt32 *pchar_code ) { - FT_UInt result = 0; - FT_UInt32 char_code = *pchar_code + 1; + TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); + CFF_Font cff = (CFF_Font)face->extra.data; + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames; - Restart: - { - FT_UInt min = 0; - FT_UInt max = cmap->num_pairs; - FT_UInt mid; - CFF_CMapUniPair pair; - - - while ( min < max ) - { - mid = min + ( ( max - min ) >> 1 ); - pair = cmap->pairs + mid; - - if ( pair->unicode == char_code ) - { - result = pair->gindex; - if ( result != 0 ) - goto Exit; - - char_code++; - goto Restart; - } - - if ( pair->unicode < char_code ) - min = mid+1; - else - max = mid; - } - - /* we didn't find it, but we have a pair just above it */ - char_code = 0; - - if ( min < cmap->num_pairs ) - { - pair = cmap->pairs + min; - result = pair->gindex; - if ( result != 0 ) - char_code = pair->unicode; - } - } - - Exit: - *pchar_code = char_code; - return result; + return psnames->unicodes_char_next( unicodes, pchar_code ); } FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec cff_cmap_unicode_class_rec = { - sizeof ( CFF_CMapUnicodeRec ), + sizeof ( PS_UnicodesRec ), (FT_CMap_InitFunc) cff_cmap_unicode_init, (FT_CMap_DoneFunc) cff_cmap_unicode_done, diff --git a/src/libs/freetype2/cff/cffcmap.h b/src/libs/freetype2/cff/cffcmap.h index ceb32cd3c3..f3d8e7af1a 100644 --- a/src/libs/freetype2/cff/cffcmap.h +++ b/src/libs/freetype2/cff/cffcmap.h @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (specification). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -56,24 +56,6 @@ FT_BEGIN_HEADER /*************************************************************************/ /* unicode (synthetic) cmaps */ - typedef struct CFF_CMapUnicodeRec_* CFF_CMapUnicode; - - typedef struct CFF_CMapUniPairRec_ - { - FT_UInt32 unicode; - FT_UInt gindex; - - } CFF_CMapUniPairRec, *CFF_CMapUniPair; - - - typedef struct CFF_CMapUnicodeRec_ - { - FT_CMapRec cmap; - FT_UInt num_pairs; - CFF_CMapUniPair pairs; - - } CFF_CMapUnicodeRec; - FT_CALLBACK_TABLE const FT_CMap_ClassRec cff_cmap_unicode_class_rec; diff --git a/src/libs/freetype2/cff/cffdrivr.c b/src/libs/freetype2/cff/cffdrivr.c index 8298e412f7..e90e2b04e1 100644 --- a/src/libs/freetype2/cff/cffdrivr.c +++ b/src/libs/freetype2/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -313,8 +313,8 @@ /* * TT CMAP INFO * - * If the charmap is a synthetic Unicode encoding cmap or - * a Type 1 standard (or expert) encoding cmap, hide TT CMAP INFO + * If the charmap is a synthetic Unicode encoding cmap or + * a Type 1 standard (or expert) encoding cmap, hide TT CMAP INFO * service defined in SFNT module. * * Otherwise call the service function in the sfnt module. @@ -330,7 +330,7 @@ cmap_info->language = 0; - if ( cmap->clazz != &cff_cmap_encoding_class_rec && + if ( cmap->clazz != &cff_cmap_encoding_class_rec && cmap->clazz != &cff_cmap_unicode_class_rec ) { FT_Face face = FT_CMAP_FACE( cmap ); @@ -433,14 +433,24 @@ cff_slot_init, cff_slot_done, - cff_point_size_reset, - cff_size_reset, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif Load_Glyph, cff_get_kerning, 0, /* FT_Face_AttachFunc */ - 0 /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_GetAdvancesFunc */ + + cff_size_request, + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + cff_size_select +#else + 0 /* FT_Size_SelectFunc */ +#endif }; diff --git a/src/libs/freetype2/cff/cffgload.c b/src/libs/freetype2/cff/cffgload.c index 3c0ef6bc26..673a814d75 100644 --- a/src/libs/freetype2/cff/cffgload.c +++ b/src/libs/freetype2/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -403,7 +403,7 @@ check_points( CFF_Builder* builder, FT_Int count ) { - return FT_GlyphLoader_CheckPoints( builder->loader, count, 0 ); + return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); } @@ -465,7 +465,7 @@ return CFF_Err_Ok; } - error = FT_GlyphLoader_CheckPoints( builder->loader, 0, 1 ); + error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); if ( !error ) { if ( outline->n_contours > 0 ) @@ -508,6 +508,9 @@ FT_Outline* outline = builder->current; + if ( !outline ) + return; + /* XXXX: We must not include the last point in the path if it */ /* is located on the first point. */ if ( outline->n_points > 1 ) @@ -1296,7 +1299,7 @@ goto Fail; args = stack; - while (args < decoder->top ) + while ( args < decoder->top ) { if ( phase ) x += args[0]; @@ -1422,7 +1425,7 @@ goto Fail; args = stack; - if (num_args < 4 || ( num_args % 4 ) > 1 ) + if ( num_args < 4 || ( num_args % 4 ) > 1 ) goto Stack_Underflow; if ( check_points( builder, ( num_args / 4 ) * 3 ) ) @@ -1769,7 +1772,8 @@ /* close hints recording session */ if ( hinter ) { - if (hinter->close( hinter->hints, builder->current->n_points ) ) + if ( hinter->close( hinter->hints, + builder->current->n_points ) ) goto Syntax_Error; /* apply hints to the loaded glyph outline now */ @@ -2045,7 +2049,7 @@ case cff_op_ifelse: { - FT_Fixed cond = (args[2] <= args[3]); + FT_Fixed cond = ( args[2] <= args[3] ); FT_TRACE4(( " ifelse" )); @@ -2265,26 +2269,10 @@ #endif /* 0 */ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** UNHINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of loading a *********/ - /********** single outline. It completely ignores hinting *********/ - /********** and is used when FT_LOAD_NO_HINTING is set. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - FT_LOCAL_DEF( FT_Error ) cff_slot_load( CFF_GlyphSlot glyph, CFF_Size size, - FT_Int glyph_index, + FT_UInt glyph_index, FT_Int32 load_flags ) { FT_Error error; @@ -2321,16 +2309,16 @@ FT_Stream stream = cff_face->root.stream; - if ( size->strike_index != 0xFFFFU && - sfnt->load_sbits && + if ( size->strike_index != 0xFFFFFFFFUL && + sfnt->load_eblc && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) { TT_SBit_MetricsRec metrics; error = sfnt->load_sbit_image( face, - (FT_ULong)size->strike_index, - (FT_UInt)glyph_index, + size->strike_index, + glyph_index, (FT_Int)load_flags, stream, &glyph->root.bitmap, @@ -2393,7 +2381,12 @@ /* subsetted font, glyph_indices and CIDs are identical, though */ if ( cff->top_font.font_dict.cid_registry != 0xFFFFU && cff->charset.cids ) - glyph_index = cff->charset.cids[glyph_index]; + { + if ( glyph_index < cff->charset.max_cid ) + glyph_index = cff->charset.cids[glyph_index]; + else + glyph_index = 0; + } cff_decoder_init( &decoder, face, size, glyph, hinting, FT_LOAD_TARGET_MODE( load_flags ) ); @@ -2503,6 +2496,7 @@ FT_BBox cbox; FT_Glyph_Metrics* metrics = &glyph->root.metrics; FT_Vector advance; + FT_Bool has_vertical_info; /* copy the _unscaled_ advance width */ @@ -2510,12 +2504,36 @@ glyph->root.linearHoriAdvance = decoder.glyph_width; glyph->root.internal->glyph_transformed = 0; - /* make up vertical metrics */ - metrics->vertBearingX = 0; - metrics->vertBearingY = 0; - metrics->vertAdvance = 0; + has_vertical_info = FT_BOOL( face->vertical_info && + face->vertical.number_Of_VMetrics > 0 && + face->vertical.long_metrics != 0 ); - glyph->root.linearVertAdvance = 0; + /* get the vertical metrics from the vtmx table if we have one */ + if ( has_vertical_info ) + { + FT_Short vertBearingY = 0; + FT_UShort vertAdvance = 0; + + + ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, + glyph_index, + &vertBearingY, + &vertAdvance ); + metrics->vertBearingY = vertBearingY; + metrics->vertAdvance = vertAdvance; + } + else + { + /* make up vertical ones */ + if ( face->os2.version != 0xFFFFU ) + metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender - + face->os2.sTypoDescender ); + else + metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender - + face->horizontal.Descender ); + } + + glyph->root.linearVertAdvance = metrics->vertAdvance; glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; @@ -2536,6 +2554,7 @@ advance.y = 0; FT_Vector_Transform( &advance, &font_matrix ); metrics->horiAdvance = advance.x + font_offset.x; + advance.x = 0; advance.y = metrics->vertAdvance; FT_Vector_Transform( &advance, &font_matrix ); @@ -2552,49 +2571,32 @@ /* First of all, scale the points */ - if ( !hinting ) + if ( !hinting || !decoder.builder.hints_funcs ) for ( n = cur->n_points; n > 0; n--, vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } - FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - /* Then scale the metrics */ - metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); - - metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); - metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - - if ( hinting ) - { - metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); - metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); - - metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); - metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); - } + metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); + metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); } /* compute the other metrics */ FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - /* grid fit the bounding box if necessary */ - if ( hinting ) - { - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; - } - metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; + + if ( has_vertical_info ) + metrics->vertBearingX = -metrics->width / 2; + else + ft_synthesize_vertical_metrics( metrics, + metrics->vertAdvance ); } } diff --git a/src/libs/freetype2/cff/cffgload.h b/src/libs/freetype2/cff/cffgload.h index 89ae049b53..01c6bcb964 100644 --- a/src/libs/freetype2/cff/cffgload.h +++ b/src/libs/freetype2/cff/cffgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -196,7 +196,7 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) cff_slot_load( CFF_GlyphSlot glyph, CFF_Size size, - FT_Int glyph_index, + FT_UInt glyph_index, FT_Int32 load_flags ); diff --git a/src/libs/freetype2/cff/cffload.c b/src/libs/freetype2/cff/cffload.c index 237915cfd4..a7b7d70e91 100644 --- a/src/libs/freetype2/cff/cffload.c +++ b/src/libs/freetype2/cff/cffload.c @@ -4,7 +4,7 @@ /* */ /* OpenType and CFF data/program tables loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1235,7 +1235,7 @@ } /* access element */ - if ( off1 ) + if ( off1 && off2 > off1 ) { *pbyte_len = off2 - off1; @@ -1688,6 +1688,8 @@ for ( i = 0; i < num_glyphs; i++ ) charset->cids[charset->sids[i]] = (FT_UShort)i; + + charset->max_cid = max_cid; } Exit: @@ -2011,7 +2013,7 @@ if ( error ) goto Exit; - + /* if it is a CID font, we stop there */ if ( top->cid_registry != 0xFFFFU ) goto Exit; @@ -2040,6 +2042,9 @@ FT_FRAME_EXIT(); if ( error ) goto Exit; + + /* ensure that `num_blue_values' is even */ + priv->num_blue_values &= ~1; } /* read the local subrs, if any */ @@ -2190,11 +2195,11 @@ if ( FT_NEW_ARRAY( sub, fd_index.count ) ) goto Fail_CID; - /* setup pointer table */ + /* set up pointer table */ for ( idx = 0; idx < fd_index.count; idx++ ) font->subfonts[idx] = sub + idx; - /* now load each sub font independently */ + /* now load each subfont independently */ for ( idx = 0; idx < fd_index.count; idx++ ) { sub = font->subfonts[idx]; @@ -2293,8 +2298,6 @@ { for ( idx = 0; idx < font->num_subfonts; idx++ ) cff_subfont_done( memory, font->subfonts[idx] ); - - FT_FREE( font->subfonts ); } cff_encoding_done( &font->encoding ); diff --git a/src/libs/freetype2/cff/cffobjs.c b/src/libs/freetype2/cff/cffobjs.c index 8522c1f1f4..2d1204e381 100644 --- a/src/libs/freetype2/cff/cffobjs.c +++ b/src/libs/freetype2/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -52,90 +52,6 @@ /*************************************************************************/ -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - static FT_Error - sbit_size_reset( CFF_Size size ) - { - CFF_Face face; - FT_Error error = CFF_Err_Ok; - - FT_ULong strike_index; - FT_Size_Metrics* metrics; - FT_Size_Metrics* sbit_metrics; - SFNT_Service sfnt; - - - metrics = &size->root.metrics; - - face = (CFF_Face)size->root.face; - sfnt = (SFNT_Service)face->sfnt; - - sbit_metrics = &size->strike_metrics; - - error = sfnt->set_sbit_strike( face, - metrics->x_ppem, - metrics->y_ppem, - &strike_index ); - - if ( !error ) - { - /* XXX: TODO: move this code to the SFNT module where it belongs */ - -#ifdef FT_OPTIMIZE_MEMORY - - FT_Byte* strike = face->sbit_table + 8 + strike_index*48; - - sbit_metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */ - sbit_metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */ - - /* XXX: Is this correct? */ - sbit_metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */ - strike[18] + /* max_width */ - (FT_Char)strike[23] /* min_advance_SB */ - ) << 6; - -#else /* !OPTIMIZE_MEMORY */ - - TT_SBit_Strike strike = face->sbit_strikes + strike_index; - - - sbit_metrics->ascender = strike->hori.ascender << 6; - sbit_metrics->descender = strike->hori.descender << 6; - - /* XXX: Is this correct? */ - sbit_metrics->max_advance = ( strike->hori.min_origin_SB + - strike->hori.max_width + - strike->hori.min_advance_SB ) << 6; - -#endif /* !OPTIMIZE_MEMORY */ - - /* XXX: Is this correct? */ - sbit_metrics->height = sbit_metrics->ascender - - sbit_metrics->descender; - - sbit_metrics->x_ppem = metrics->x_ppem; - sbit_metrics->y_ppem = metrics->y_ppem; - size->strike_index = (FT_UInt)strike_index; - } - else - { - size->strike_index = 0xFFFFU; - - sbit_metrics->x_ppem = 0; - sbit_metrics->y_ppem = 0; - sbit_metrics->ascender = 0; - sbit_metrics->descender = 0; - sbit_metrics->height = 0; - sbit_metrics->max_advance = 0; - } - - return error; - } - -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - - static PSH_Globals_Funcs cff_size_get_globals_funcs( CFF_Size size ) { @@ -243,62 +159,76 @@ cffsize->internal = (FT_Size_Internal)(void*)globals; } + size->strike_index = 0xFFFFFFFFUL; + return error; } +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + FT_LOCAL_DEF( FT_Error ) - cff_size_reset( FT_Size cffsize, /* CFF_Size */ - FT_UInt char_width, - FT_UInt char_height ) + cff_size_select( FT_Size size, + FT_ULong strike_index ) { - CFF_Size size = (CFF_Size)cffsize; - PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size ); - FT_Error error = CFF_Err_Ok; - FT_Face face = cffsize->face; + CFF_Size cffsize = (CFF_Size)size; + PSH_Globals_Funcs funcs; - FT_UNUSED( char_width ); - FT_UNUSED( char_height ); + cffsize->strike_index = strike_index; + + FT_Select_Metrics( size->face, strike_index ); + + funcs = cff_size_get_globals_funcs( cffsize ); if ( funcs ) - error = funcs->set_scale( (PSH_Globals)cffsize->internal, - cffsize->metrics.x_scale, - cffsize->metrics.y_scale, - 0, 0 ); + funcs->set_scale( (PSH_Globals)size->internal, + size->metrics.x_scale, + size->metrics.y_scale, + 0, 0 ); + + return CFF_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + + + FT_LOCAL_DEF( FT_Error ) + cff_size_request( FT_Size size, + FT_Size_Request req ) + { + CFF_Size cffsize = (CFF_Size)size; + PSH_Globals_Funcs funcs; + #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - if ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) + if ( FT_HAS_FIXED_SIZES( size->face ) ) { - error = sbit_size_reset( size ); + CFF_Face cffface = (CFF_Face)size->face; + SFNT_Service sfnt = (SFNT_Service)cffface->sfnt; + FT_ULong index; - if ( !error && !( face->face_flags & FT_FACE_FLAG_SCALABLE ) ) - cffsize->metrics = size->strike_metrics; + + if ( sfnt->set_sbit_strike( cffface, req, &index ) ) + cffsize->strike_index = 0xFFFFFFFFUL; + else + return cff_size_select( size, index ); } -#endif +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - return CFF_Err_Ok; - else - return error; - } + FT_Request_Metrics( size->face, req ); + funcs = cff_size_get_globals_funcs( cffsize ); - FT_LOCAL_DEF( FT_Error ) - cff_point_size_reset( FT_Size cffsize, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) - { - FT_UNUSED( char_width ); - FT_UNUSED( char_height ); - FT_UNUSED( horz_resolution ); - FT_UNUSED( vert_resolution ); + if ( funcs ) + funcs->set_scale( (PSH_Globals)size->internal, + size->metrics.x_scale, + size->metrics.y_scale, + 0, 0 ); - return cff_size_reset( cffsize, 0, 0 ); + return CFF_Err_Ok; } @@ -450,7 +380,7 @@ else { /* load the `cmap' table explicitly */ - error = sfnt->load_charmaps( face, stream ); + error = sfnt->load_cmap( face, stream ); if ( error ) goto Exit; @@ -531,16 +461,18 @@ cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFFU ) >> 16; cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFFU ) >> 16; - cffface->ascender = (FT_Short)( cffface->bbox.yMax ); - cffface->descender = (FT_Short)( cffface->bbox.yMin ); - cffface->height = (FT_Short)( - ( ( cffface->ascender - cffface->descender ) * 12 ) / 10 ); - if ( !dict->units_per_em ) dict->units_per_em = 1000; cffface->units_per_EM = dict->units_per_em; + cffface->ascender = (FT_Short)( cffface->bbox.yMax ); + cffface->descender = (FT_Short)( cffface->bbox.yMin ); + + cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 ); + if ( cffface->height < cffface->ascender - cffface->descender ) + cffface->height = (FT_Short)( cffface->ascender - cffface->descender ); + cffface->underline_position = (FT_Short)( dict->underline_position >> 16 ); cffface->underline_thickness = @@ -636,8 +568,9 @@ /* */ /* Compute face flags. */ /* */ - flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ - FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ + flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ + FT_FACE_FLAG_HINTER; /* has native hinter */ if ( sfnt_format ) flags |= FT_FACE_FLAG_SFNT; @@ -679,8 +612,8 @@ /* double check */ if ( !(flags & FT_STYLE_FLAG_BOLD) && cffface->style_name ) - if ( !strncmp( cffface->style_name, "Bold", 4 ) || - !strncmp( cffface->style_name, "Black", 5 ) ) + if ( !ft_strncmp( cffface->style_name, "Bold", 4 ) || + !ft_strncmp( cffface->style_name, "Black", 5 ) ) flags |= FT_STYLE_FLAG_BOLD; cffface->style_flags = flags; diff --git a/src/libs/freetype2/cff/cffobjs.h b/src/libs/freetype2/cff/cffobjs.h index 338ec748bb..cc4ab644c7 100644 --- a/src/libs/freetype2/cff/cffobjs.h +++ b/src/libs/freetype2/cff/cffobjs.h @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -54,13 +54,7 @@ FT_BEGIN_HEADER typedef struct CFF_SizeRec_ { FT_SizeRec root; - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - FT_UInt strike_index; /* 0xFFFF to indicate invalid */ - FT_Size_Metrics strike_metrics; /* current strike's metrics */ - -#endif + FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ } CFF_SizeRec, *CFF_Size; @@ -119,16 +113,16 @@ FT_BEGIN_HEADER cff_size_done( FT_Size size ); /* CFF_Size */ FT_LOCAL( FT_Error ) - cff_size_reset( FT_Size size, /* CFF_Size */ - FT_UInt char_width, - FT_UInt char_height ); + cff_size_request( FT_Size size, + FT_Size_Request req ); + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_LOCAL( FT_Error ) - cff_point_size_reset( FT_Size cffsize, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); + cff_size_select( FT_Size size, + FT_ULong index ); + +#endif FT_LOCAL( void ) cff_slot_done( FT_GlyphSlot slot ); diff --git a/src/libs/freetype2/cff/cfftypes.h b/src/libs/freetype2/cff/cfftypes.h index 9ddc663dea..364b7cb6e9 100644 --- a/src/libs/freetype2/cff/cfftypes.h +++ b/src/libs/freetype2/cff/cfftypes.h @@ -5,7 +5,7 @@ /* Basic OpenType/CFF type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -84,6 +84,7 @@ FT_BEGIN_HEADER FT_UShort* sids; FT_UShort* cids; /* the inverse mapping of `sids'; only needed */ /* for CID-keyed fonts */ + FT_UInt max_cid; } CFF_CharsetRec, *CFF_Charset; diff --git a/src/libs/freetype2/cff/descrip.mms b/src/libs/freetype2/cff/descrip.mms deleted file mode 100644 index 2401f2ee2b..0000000000 --- a/src/libs/freetype2/cff/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 OpenType/CFF driver compilation rules for VMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.cff]) - -OBJS=cff.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/cff/module.mk b/src/libs/freetype2/cff/module.mk index 68789c98ac..0474e37b69 100644 --- a/src/libs/freetype2/cff/module.mk +++ b/src/libs/freetype2/cff/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_cff_driver +FTMODULE_H_COMMANDS += CFF_DRIVER -add_cff_driver: - $(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)cff $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE) +define CFF_DRIVER +$(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)cff $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/cid/cidgload.c b/src/libs/freetype2/cid/cidgload.c index cbd0865d3c..ed706ade7d 100644 --- a/src/libs/freetype2/cid/cidgload.c +++ b/src/libs/freetype2/cid/cidgload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -252,22 +252,6 @@ #endif /* 0 */ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** UNHINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of loading a *********/ - /********** single outline. It completely ignores hinting *********/ - /********** and is used when FT_LOAD_NO_HINTING is set. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - FT_LOCAL_DEF( FT_Error ) cid_slot_load_glyph( FT_GlyphSlot cidglyph, /* CID_GlyphSlot */ FT_Size cidsize, /* CID_Size */ @@ -358,12 +342,11 @@ cidglyph->linearHoriAdvance = decoder.builder.advance.x; cidglyph->internal->glyph_transformed = 0; - /* make up vertical metrics */ - metrics->vertBearingX = 0; - metrics->vertBearingY = 0; - metrics->vertAdvance = 0; + /* make up vertical ones */ + metrics->vertAdvance = ( face->cid.font_bbox.yMax - + face->cid.font_bbox.yMin ) >> 16; + cidglyph->linearVertAdvance = metrics->vertAdvance; - cidglyph->linearVertAdvance = 0; cidglyph->format = FT_GLYPH_FORMAT_OUTLINE; if ( size && cidsize->metrics.y_ppem < 24 ) @@ -396,49 +379,30 @@ /* First of all, scale the points */ - if ( !hinting ) + if ( !hinting || !decoder.builder.hints_funcs ) for ( n = cur->n_points; n > 0; n--, vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } - FT_Outline_Get_CBox( &cidglyph->outline, &cbox ); - /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); - - metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); - metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - - if ( hinting ) - { - metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); - metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); - - metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); - metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); - } } /* compute the other metrics */ FT_Outline_Get_CBox( &cidglyph->outline, &cbox ); - /* grid fit the bounding box if necessary */ - if ( hinting ) - { - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL( cbox.yMax ); - } - metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; + + /* make up vertical ones */ + ft_synthesize_vertical_metrics( metrics, + metrics->vertAdvance ); } } diff --git a/src/libs/freetype2/cid/cidobjs.c b/src/libs/freetype2/cid/cidobjs.c index 3fb47bccec..1b3bfbf749 100644 --- a/src/libs/freetype2/cid/cidobjs.c +++ b/src/libs/freetype2/cid/cidobjs.c @@ -4,7 +4,7 @@ /* */ /* CID objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -152,41 +152,24 @@ } - FT_LOCAL_DEF( FT_Error ) - cid_size_reset( FT_Size cidsize, /* CID_Size */ - FT_UInt char_width, - FT_UInt char_height ) + FT_LOCAL( FT_Error ) + cid_size_request( FT_Size size, + FT_Size_Request req ) { - CID_Size size = (CID_Size)cidsize; - PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size ); - FT_Error error = 0; + PSH_Globals_Funcs funcs; - FT_UNUSED( char_width ); - FT_UNUSED( char_height ); + FT_Request_Metrics( size->face, req ); + + funcs = cid_size_get_globals_funcs( (CID_Size)size ); if ( funcs ) - error = funcs->set_scale( (PSH_Globals)cidsize->internal, - cidsize->metrics.x_scale, - cidsize->metrics.y_scale, - 0, 0 ); - return error; - } + funcs->set_scale( (PSH_Globals)size->internal, + size->metrics.x_scale, + size->metrics.y_scale, + 0, 0 ); - - FT_LOCAL_DEF( FT_Error ) - cid_point_size_reset( FT_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) - { - FT_UNUSED( char_width ); - FT_UNUSED( char_height ); - FT_UNUSED( horz_resolution ); - FT_UNUSED( vert_resolution ); - - return cid_size_reset( size, 0, 0 ); + return CID_Err_Ok; } @@ -362,9 +345,9 @@ cidface->num_charmaps = 0; cidface->face_index = face_index; - cidface->face_flags = FT_FACE_FLAG_SCALABLE; - - cidface->face_flags |= FT_FACE_FLAG_HORIZONTAL; + cidface->face_flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ + FT_FACE_FLAG_HINTER; /* has native hinter */ if ( info->is_fixed_pitch ) cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; @@ -439,14 +422,13 @@ cidface->ascender = (FT_Short)( cidface->bbox.yMax ); cidface->descender = (FT_Short)( cidface->bbox.yMin ); - cidface->height = (FT_Short)( - ( ( cidface->ascender - cidface->descender ) * 12 ) / 10 ); + + cidface->height = (FT_Short)( ( cidface->units_per_EM * 12 ) / 10 ); + if ( cidface->height < cidface->ascender - cidface->descender ) + cidface->height = (FT_Short)( cidface->ascender - cidface->descender ); cidface->underline_position = (FT_Short)info->underline_position; cidface->underline_thickness = (FT_Short)info->underline_thickness; - - cidface->internal->max_points = 0; - cidface->internal->max_contours = 0; } Exit: diff --git a/src/libs/freetype2/cid/cidobjs.h b/src/libs/freetype2/cid/cidobjs.h index 9d230baf8c..aee346d1c8 100644 --- a/src/libs/freetype2/cid/cidobjs.h +++ b/src/libs/freetype2/cid/cidobjs.h @@ -4,7 +4,7 @@ /* */ /* CID objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004 by */ +/* Copyright 1996-2001, 2002, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -125,17 +125,8 @@ FT_BEGIN_HEADER cid_size_init( FT_Size size ); /* CID_Size */ FT_LOCAL( FT_Error ) - cid_size_reset( FT_Size size, /* CID_Size */ - FT_UInt char_width, - FT_UInt char_height ); - - FT_LOCAL( FT_Error ) - cid_point_size_reset( FT_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); - + cid_size_request( FT_Size size, /* CID_Size */ + FT_Size_Request req ); FT_LOCAL( FT_Error ) cid_face_init( FT_Stream stream, diff --git a/src/libs/freetype2/cid/cidparse.c b/src/libs/freetype2/cid/cidparse.c index a964d81575..ac56363f68 100644 --- a/src/libs/freetype2/cid/cidparse.c +++ b/src/libs/freetype2/cid/cidparse.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -56,8 +56,6 @@ { FT_Error error; FT_ULong base_offset, offset, ps_len; - FT_Byte buffer[256 + 10]; - FT_Int buff_len; FT_Byte *cur, *limit; FT_Byte *arg1, *arg2; @@ -86,43 +84,49 @@ Again: /* now, read the rest of the file until we find a `StartData' */ - buff_len = 256; - for (;;) { - FT_Byte* p; - FT_ULong top_position; + FT_Byte buffer[256 + 10]; + FT_Int read_len = 256 + 10; + FT_Byte* p = buffer; - /* fill input buffer */ - limit = buffer + 256; - buff_len -= 256; - if ( buff_len > 0 ) - FT_MEM_MOVE( buffer, limit, buff_len ); - - p = buffer + buff_len; - - if ( FT_STREAM_READ( p, 256 + 10 - buff_len ) ) - goto Exit; - - top_position = FT_STREAM_POS() - buff_len; - buff_len = 256 + 10; - - /* look for `StartData' */ - for ( p = buffer; p < limit; p++ ) + for ( offset = (FT_ULong)FT_STREAM_POS(); ; offset += 256 ) { - if ( p[0] == 'S' && ft_strncmp( (char*)p, "StartData", 9 ) == 0 ) + FT_Int stream_len; + + + stream_len = stream->size - FT_STREAM_POS(); + if ( stream_len == 0 ) + goto Exit; + + read_len = FT_MIN( read_len, stream_len ); + if ( FT_STREAM_READ( p, read_len ) ) + goto Exit; + + if ( read_len < 256 ) + p[read_len] = '\0'; + + limit = p + read_len - 10; + + for ( p = buffer; p < limit; p++ ) { - /* save offset of binary data after `StartData' */ - offset = (FT_ULong)( top_position - ( limit - p ) + 10 ); - goto Found; + if ( p[0] == 'S' && ft_strncmp( (char*)p, "StartData", 9 ) == 0 ) + { + /* save offset of binary data after `StartData' */ + offset += p - buffer + 10; + goto Found; + } } + + FT_MEM_MOVE( buffer, p, 10 ); + read_len = 256; + p = buffer + 10; } } Found: - /* we have found the start of the binary data. We will now */ - /* rewind and extract the frame corresponding to the PostScript */ - /* section */ + /* We have found the start of the binary data. Now rewind and */ + /* extract the frame corresponding to the PostScript section. */ ps_len = offset - base_offset; if ( FT_STREAM_SEEK( base_offset ) || diff --git a/src/libs/freetype2/cid/cidriver.c b/src/libs/freetype2/cid/cidriver.c index 377835b3c9..5c5a72957c 100644 --- a/src/libs/freetype2/cid/cidriver.c +++ b/src/libs/freetype2/cid/cidriver.c @@ -4,7 +4,7 @@ /* */ /* CID driver interface (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -143,15 +143,20 @@ cid_slot_init, cid_slot_done, - cid_point_size_reset, - cid_size_reset, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif cid_slot_load_glyph, 0, /* FT_Face_GetKerningFunc */ 0, /* FT_Face_AttachFunc */ - 0 /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_GetAdvancesFunc */ + + cid_size_request, + 0 /* FT_Size_SelectFunc */ }; diff --git a/src/libs/freetype2/cid/descrip.mms b/src/libs/freetype2/cid/descrip.mms deleted file mode 100644 index 592fd587a7..0000000000 --- a/src/libs/freetype2/cid/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 CID driver compilation rules for VMS -# - - -# Copyright 2001 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.cid]) - -OBJS=type1cid.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/cid/module.mk b/src/libs/freetype2/cid/module.mk index f59d8a9516..41e5a68e59 100644 --- a/src/libs/freetype2/cid/module.mk +++ b/src/libs/freetype2/cid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,9 +13,11 @@ # fully. -make_module_list: add_type1cid_driver +FTMODULE_H_COMMANDS += TYPE1CID_DRIVER + +define TYPE1CID_DRIVER +$(OPEN_DRIVER)t1cid_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)cid $(ECHO_DRIVER_DESC)Postscript CID-keyed fonts, no known extension$(ECHO_DRIVER_DONE) +endef -add_type1cid_driver: - $(OPEN_DRIVER)t1cid_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)cid $(ECHO_DRIVER_DESC)Postscript CID-keyed fonts, no known extension$(ECHO_DRIVER_DONE) # EOF diff --git a/src/libs/freetype2/gzip/descrip.mms b/src/libs/freetype2/gzip/descrip.mms deleted file mode 100644 index 68d7a870d6..0000000000 --- a/src/libs/freetype2/gzip/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 GZip support compilation rules for VMS -# - - -# Copyright 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.gzip]) - -OBJS=ftgzip.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/gzip/ftgzip.c b/src/libs/freetype2/gzip/ftgzip.c index 67e7bb8f05..6f7bad777c 100644 --- a/src/libs/freetype2/gzip/ftgzip.c +++ b/src/libs/freetype2/gzip/ftgzip.c @@ -8,7 +8,7 @@ /* parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,6 +24,7 @@ #include FT_INTERNAL_MEMORY_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_DEBUG_H +#include FT_GZIP_H #include <string.h> @@ -99,12 +100,12 @@ uInt size ) { FT_ULong sz = (FT_ULong)size * items; + FT_Error error; FT_Pointer p; - FT_MEM_ALLOC( p, sz ); - - return (voidpf) p; + (void)FT_ALLOC( p, sz ); + return p; } diff --git a/src/libs/freetype2/gzip/zutil.c b/src/libs/freetype2/gzip/zutil.c index 5da9f98134..0b47dd420f 100644 --- a/src/libs/freetype2/gzip/zutil.c +++ b/src/libs/freetype2/gzip/zutil.c @@ -157,8 +157,8 @@ void zcfree (voidpf opaque, voidpf ptr) #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); +extern voidp ft_scalloc OF((uInt items, uInt size)); +extern void ft_sfree OF((voidpf ptr)); #endif voidpf zcalloc (opaque, items, size) @@ -167,14 +167,14 @@ voidpf zcalloc (opaque, items, size) unsigned size; { if (opaque) items += size - size; /* make compiler happy */ - return (voidpf)calloc(items, size); + return (voidpf)ft_scalloc(items, size); } void zcfree (opaque, ptr) voidpf opaque; voidpf ptr; { - free(ptr); + ft_sfree(ptr); if (opaque) return; /* make compiler happy */ } diff --git a/src/libs/freetype2/gzip/zutil.h b/src/libs/freetype2/gzip/zutil.h index ce02022aa7..5f2d543130 100644 --- a/src/libs/freetype2/gzip/zutil.h +++ b/src/libs/freetype2/gzip/zutil.h @@ -80,7 +80,6 @@ typedef unsigned long ulg; # include <alloc.h> # endif # else /* MSC or DJGPP */ -# include <malloc.h> # endif #endif @@ -95,7 +94,7 @@ typedef unsigned long ulg; #if defined(VAXC) || defined(VMS) # define OS_CODE 0x02 # define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") + ft_fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #ifdef AMIGA @@ -141,7 +140,7 @@ typedef unsigned long ulg; #endif #ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) +# define F_OPEN(name, mode) ft_fopen((name), (mode)) #endif /* functions */ diff --git a/src/libs/freetype2/lzw/ftlzw.c b/src/libs/freetype2/lzw/ftlzw.c index 5d23cd2420..45fbf7b6ea 100644 --- a/src/libs/freetype2/lzw/ftlzw.c +++ b/src/libs/freetype2/lzw/ftlzw.c @@ -8,7 +8,7 @@ /* be used to parse compressed PCF fonts, as found with many X11 server */ /* distributions. */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* Albert Chin-A-Young. */ /* */ /* Based on code in src/gzip/ftgzip.c, Copyright 2004 by */ @@ -26,6 +26,7 @@ #include FT_INTERNAL_MEMORY_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_DEBUG_H +#include FT_LZW_H #include <string.h> #include <stdio.h> @@ -42,7 +43,7 @@ #ifdef FT_CONFIG_OPTION_USE_LZW -#include "zopen.h" +#include "ftzopen.h" /***************************************************************************/ @@ -61,22 +62,19 @@ /***************************************************************************/ /***************************************************************************/ -#define FT_LZW_BUFFER_SIZE 4096 +#define FT_LZW_BUFFER_SIZE 4096 - typedef struct FT_LZWFileRec_ + typedef struct FT_LZWFileRec_ { - FT_Stream source; /* parent/source stream */ - FT_Stream stream; /* embedding stream */ - FT_Memory memory; /* memory allocator */ - s_zstate_t zstream; /* lzw input stream */ + FT_Stream source; /* parent/source stream */ + FT_Stream stream; /* embedding stream */ + FT_Memory memory; /* memory allocator */ + FT_LzwStateRec lzw; /* lzw decompressor state */ - FT_ULong start; /* starting position, after .Z header */ - FT_Byte input[FT_LZW_BUFFER_SIZE]; /* input buffer */ - - FT_Byte buffer[FT_LZW_BUFFER_SIZE]; /* output buffer */ - FT_ULong pos; /* position in output */ - FT_Byte* cursor; - FT_Byte* limit; + FT_Byte buffer[FT_LZW_BUFFER_SIZE]; /* output buffer */ + FT_ULong pos; /* position in output */ + FT_Byte* cursor; + FT_Byte* limit; } FT_LZWFileRec, *FT_LZWFile; @@ -93,7 +91,7 @@ FT_STREAM_READ( head, 2 ) ) goto Exit; - /* head[0] && head[1] are the magic numbers */ + /* head[0] && head[1] are the magic numbers */ if ( head[0] != 0x1f || head[1] != 0x9d ) error = LZW_Err_Invalid_File_Format; @@ -108,8 +106,8 @@ FT_Stream stream, FT_Stream source ) { - s_zstate_t* zstream = &zip->zstream; - FT_Error error = LZW_Err_Ok; + FT_LzwState lzw = &zip->lzw; + FT_Error error = LZW_Err_Ok; zip->stream = stream; @@ -127,19 +125,10 @@ error = ft_lzw_check_header( source ); if ( error ) goto Exit; - - zip->start = FT_STREAM_POS(); } /* initialize internal lzw variable */ - zinit( zstream ); - - zstream->avail_in = 0; - zstream->next_in = zip->buffer; - zstream->zs_in_count = source->size - 2; - - if ( zstream->next_in == NULL ) - error = LZW_Err_Invalid_File_Format; + ft_lzwstate_init( lzw, source ); Exit: return error; @@ -149,16 +138,8 @@ static void ft_lzw_file_done( FT_LZWFile zip ) { - s_zstate_t* zstream = &zip->zstream; - - /* clear the rest */ - zstream->next_in = NULL; - zstream->next_out = NULL; - zstream->avail_in = 0; - zstream->avail_out = 0; - zstream->total_in = 0; - zstream->total_out = 0; + ft_lzwstate_done( &zip->lzw ); zip->memory = NULL; zip->source = NULL; @@ -173,20 +154,9 @@ FT_Error error; - if ( !FT_STREAM_SEEK( zip->start ) ) + if ( !FT_STREAM_SEEK( 0 ) ) { - s_zstate_t* zstream = &zip->zstream; - - - zinit( zstream ); - - zstream->avail_in = 0; - zstream->next_in = zip->input; - zstream->total_in = 0; - zstream->avail_out = 0; - zstream->next_out = zip->buffer; - zstream->total_out = 0; - zstream->zs_in_count = zip->source->size - 2; + ft_lzwstate_reset( &zip->lzw ); zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE; zip->cursor = zip->limit; @@ -197,79 +167,22 @@ } - static FT_Error - ft_lzw_file_fill_input( FT_LZWFile zip ) - { - s_zstate_t* zstream = &zip->zstream; - FT_Stream stream = zip->source; - FT_ULong size; - - - if ( stream->read ) - { - size = stream->read( stream, stream->pos, zip->input, - FT_LZW_BUFFER_SIZE ); - if ( size == 0 ) - return LZW_Err_Invalid_Stream_Operation; - } - else - { - size = stream->size - stream->pos; - if ( size > FT_LZW_BUFFER_SIZE ) - size = FT_LZW_BUFFER_SIZE; - - if ( size == 0 ) - return LZW_Err_Invalid_Stream_Operation; - - FT_MEM_COPY( zip->input, stream->base + stream->pos, size ); - } - stream->pos += size; - - zstream->next_in = zip->input; - zstream->avail_in = size; - - return LZW_Err_Ok; - } - - - static FT_Error ft_lzw_file_fill_output( FT_LZWFile zip ) { - s_zstate_t* zstream = &zip->zstream; + FT_LzwState lzw = &zip->lzw; + FT_ULong count; FT_Error error = 0; - zip->cursor = zip->buffer; - zstream->next_out = zip->cursor; - zstream->avail_out = FT_LZW_BUFFER_SIZE; + zip->cursor = zip->buffer; - while ( zstream->avail_out > 0 ) - { - int num_read = 0; + count = ft_lzwstate_io( lzw, zip->buffer, FT_LZW_BUFFER_SIZE ); + zip->limit = zip->cursor + count; - if ( zstream->avail_in == 0 ) - { - error = ft_lzw_file_fill_input( zip ); - if ( error ) - break; - } - - num_read = zread( zstream ); - - if ( num_read == -1 && zstream->zs_in_count == 0 ) - { - zip->limit = zstream->next_out; - if ( zip->limit == zip->cursor ) - error = LZW_Err_Invalid_Stream_Operation; - break; - } - else if ( num_read == -1 ) - break; - else - zstream->avail_out -= num_read; - } + if ( count == 0 ) + error = LZW_Err_Invalid_Stream_Operation; return error; } @@ -281,12 +194,13 @@ FT_ULong count ) { FT_Error error = LZW_Err_Ok; - FT_ULong delta; - for (;;) + /* first, we skip what we can from the output buffer */ { - delta = (FT_ULong)( zip->limit - zip->cursor ); + FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor ); + + if ( delta >= count ) delta = count; @@ -294,12 +208,28 @@ zip->pos += delta; count -= delta; - if ( count == 0 ) - break; + } - error = ft_lzw_file_fill_output( zip ); - if ( error ) + /* next, we skip as many bytes remaining as possible */ + while ( count > 0 ) + { + FT_ULong delta = FT_LZW_BUFFER_SIZE; + FT_ULong numread; + + + if ( delta > count ) + delta = count; + + numread = ft_lzwstate_io( &zip->lzw, NULL, delta ); + if ( numread < delta ) + { + /* not enough bytes */ + error = LZW_Err_Invalid_Stream_Operation; break; + } + + zip->pos += delta; + count -= delta; } return error; @@ -316,13 +246,22 @@ FT_Error error; - /* Teset inflate stream if we're seeking backwards. */ - /* Yes, that is not too efficient, but it saves memory :-) */ + /* seeking backwards. */ if ( pos < zip->pos ) { - error = ft_lzw_file_reset( zip ); - if ( error ) - goto Exit; + /* If the new position is within the output buffer, simply */ + /* decrement pointers, otherwise we reset the stream completely! */ + if ( ( zip->pos - pos ) <= (FT_ULong)( zip->cursor - zip->buffer ) ) + { + zip->cursor -= zip->pos - pos; + zip->pos = pos; + } + else + { + error = ft_lzw_file_reset( zip ); + if ( error ) + goto Exit; + } } /* skip unwanted bytes */ @@ -346,8 +285,7 @@ if ( delta >= count ) delta = count; - FT_MEM_COPY( buffer, zip->cursor, delta ); - buffer += delta; + FT_MEM_COPY( buffer + result, zip->cursor, delta ); result += delta; zip->cursor += delta; zip->pos += delta; @@ -416,11 +354,11 @@ /* - * Check the header right now; this prevents allocation a huge + * Check the header right now; this prevents allocation of a huge * LZWFile object (400 KByte of heap memory) if not necessary. * * Did I mention that you should never use .Z compressed font - * file? + * files? */ error = ft_lzw_check_header( source ); if ( error ) @@ -451,7 +389,8 @@ return error; } -#include "zopen.c" + +#include "ftzopen.c" #else /* !FT_CONFIG_OPTION_USE_LZW */ diff --git a/src/libs/freetype2/lzw/ftzopen.c b/src/libs/freetype2/lzw/ftzopen.c new file mode 100644 index 0000000000..a9d25c5fa6 --- /dev/null +++ b/src/libs/freetype2/lzw/ftzopen.c @@ -0,0 +1,384 @@ +/***************************************************************************/ +/* */ +/* ftzopen.c */ +/* */ +/* FreeType support for .Z compressed files. */ +/* */ +/* This optional component relies on NetBSD's zopen(). It should mainly */ +/* be used to parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2005, 2006 by David Turner. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include "ftzopen.h" +#include FT_INTERNAL_MEMORY_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_DEBUG_H + + /* refill input buffer, return 0 on success, or -1 if eof */ + static int + ft_lzwstate_refill( FT_LzwState state ) + { + int result = -1; + + + if ( !state->in_eof ) + { + FT_ULong count = FT_Stream_TryRead( state->source, + state->in_buff, + sizeof ( state->in_buff ) ); + + state->in_cursor = state->in_buff; + state->in_limit = state->in_buff + count; + state->in_eof = FT_BOOL( count < sizeof ( state->in_buff ) ); + + if ( count > 0 ) + result = 0; + } + return result; + } + + + /* return new code of 'num_bits', or -1 if eof */ + static FT_Int32 + ft_lzwstate_get_code( FT_LzwState state, + FT_UInt num_bits ) + { + FT_Int32 result = -1; + FT_UInt32 pad = state->pad; + FT_UInt pad_bits = state->pad_bits; + + + while ( num_bits > pad_bits ) + { + if ( state->in_cursor >= state->in_limit && + ft_lzwstate_refill( state ) < 0 ) + goto Exit; + + pad |= (FT_UInt32)(*state->in_cursor++) << pad_bits; + pad_bits += 8; + } + + result = (FT_Int32)( pad & LZW_MASK( num_bits ) ); + state->pad_bits = pad_bits - num_bits; + state->pad = pad >> num_bits; + + Exit: + return result; + } + + + /* grow the character stack */ + static int + ft_lzwstate_stack_grow( FT_LzwState state ) + { + if ( state->stack_top >= state->stack_size ) + { + FT_Memory memory = state->memory; + FT_Error error; + FT_UInt old_size = state->stack_size; + FT_UInt new_size = old_size; + + new_size = new_size + ( new_size >> 1 ) + 4; + + if ( state->stack == state->stack_0 ) + { + state->stack = NULL; + old_size = 0; + } + + if ( FT_RENEW_ARRAY( state->stack, old_size, new_size ) ) + return -1; + + state->stack_size = new_size; + } + return 0; + } + + + /* grow the prefix/suffix arrays */ + static int + ft_lzwstate_prefix_grow( FT_LzwState state ) + { + FT_UInt old_size = state->prefix_size; + FT_UInt new_size = old_size; + FT_Memory memory = state->memory; + FT_Error error; + + + if ( new_size == 0 ) /* first allocation -> 9 bits */ + new_size = 512; + else + new_size += new_size >> 2; /* don't grow too fast */ + + /* + * Note that the `suffix' array is located in the same memory block + * pointed to by `prefix'. + * + * I know that sizeof(FT_Byte) == 1 by definition, but it is clearer + * to write it literally. + * + */ + if ( FT_REALLOC_MULT( state->prefix, old_size, new_size, + sizeof ( FT_UShort ) + sizeof ( FT_Byte ) ) ) + return -1; + + /* now adjust `suffix' and move the data accordingly */ + state->suffix = (FT_Byte*)( state->prefix + new_size ); + + FT_MEM_MOVE( state->suffix, + state->prefix + old_size, + old_size * sizeof ( FT_Byte ) ); + + state->prefix_size = new_size; + return 0; + } + + + FT_LOCAL_DEF( void ) + ft_lzwstate_reset( FT_LzwState state ) + { + state->in_cursor = state->in_buff; + state->in_limit = state->in_buff; + state->in_eof = 0; + state->pad_bits = 0; + state->pad = 0; + + state->stack_top = 0; + state->num_bits = LZW_INIT_BITS; + state->phase = FT_LZW_PHASE_START; + } + + + FT_LOCAL_DEF( void ) + ft_lzwstate_init( FT_LzwState state, + FT_Stream source ) + { + FT_ZERO( state ); + + state->source = source; + state->memory = source->memory; + + state->prefix = NULL; + state->suffix = NULL; + state->prefix_size = 0; + + state->stack = state->stack_0; + state->stack_size = sizeof ( state->stack_0 ); + + ft_lzwstate_reset( state ); + } + + + FT_LOCAL_DEF( void ) + ft_lzwstate_done( FT_LzwState state ) + { + FT_Memory memory = state->memory; + + + ft_lzwstate_reset( state ); + + if ( state->stack != state->stack_0 ) + FT_FREE( state->stack ); + + FT_FREE( state->prefix ); + state->suffix = NULL; + + FT_ZERO( state ); + } + + +#define FTLZW_STACK_PUSH( c ) \ + FT_BEGIN_STMNT \ + if ( state->stack_top >= state->stack_size && \ + ft_lzwstate_stack_grow( state ) < 0 ) \ + goto Eof; \ + \ + state->stack[ state->stack_top++ ] = (FT_Byte)(c); \ + FT_END_STMNT + + + FT_LOCAL_DEF( FT_ULong ) + ft_lzwstate_io( FT_LzwState state, + FT_Byte* buffer, + FT_ULong out_size ) + { + FT_ULong result = 0; + + FT_UInt num_bits = state->num_bits; + FT_UInt free_ent = state->free_ent; + FT_UInt old_char = state->old_char; + FT_UInt old_code = state->old_code; + FT_UInt in_code = state->in_code; + + + if ( out_size == 0 ) + goto Exit; + + switch ( state->phase ) + { + case FT_LZW_PHASE_START: + { + FT_Byte max_bits; + FT_Int32 c; + + + /* skip magic bytes, and read max_bits + block_flag */ + if ( FT_Stream_Seek( state->source, 2 ) != 0 || + FT_Stream_TryRead( state->source, &max_bits, 1 ) != 1 ) + goto Eof; + + state->max_bits = max_bits & LZW_BIT_MASK; + state->block_mode = max_bits & LZW_BLOCK_MASK; + state->max_free = (FT_UInt)( ( 1UL << state->max_bits ) - 256 ); + + if ( state->max_bits > LZW_MAX_BITS ) + goto Eof; + + num_bits = LZW_INIT_BITS; + free_ent = ( state->block_mode ? LZW_FIRST : LZW_CLEAR ) - 256; + in_code = 0; + + state->free_bits = num_bits < state->max_bits + ? (FT_UInt)( ( 1UL << num_bits ) - 256 ) + : state->max_free + 1; + + c = ft_lzwstate_get_code( state, num_bits ); + if ( c < 0 ) + goto Eof; + + old_code = old_char = (FT_UInt)c; + + if ( buffer ) + buffer[result] = (FT_Byte)old_char; + + if ( ++result >= out_size ) + goto Exit; + + state->phase = FT_LZW_PHASE_CODE; + } + /* fall-through */ + + case FT_LZW_PHASE_CODE: + { + FT_Int32 c; + FT_UInt code; + + + NextCode: + c = ft_lzwstate_get_code( state, num_bits ); + if ( c < 0 ) + goto Eof; + + code = (FT_UInt)c; + + if ( code == LZW_CLEAR && state->block_mode ) + { + free_ent = ( LZW_FIRST - 1 ) - 256; /* why not LZW_FIRST-256 ? */ + num_bits = LZW_INIT_BITS; + + state->free_bits = num_bits < state->max_bits + ? (FT_UInt)( ( 1UL << num_bits ) - 256 ) + : state->max_free + 1; + + c = ft_lzwstate_get_code( state, num_bits ); + if ( c < 0 ) + goto Eof; + + code = (FT_UInt)c; + } + + in_code = code; /* save code for later */ + + if ( code >= 256U ) + { + /* special case for KwKwKwK */ + if ( code - 256U >= free_ent ) + { + FTLZW_STACK_PUSH( old_char ); + code = old_code; + } + + while ( code >= 256U ) + { + FTLZW_STACK_PUSH( state->suffix[code - 256] ); + code = state->prefix[code - 256]; + } + } + + old_char = code; + FTLZW_STACK_PUSH( old_char ); + + state->phase = FT_LZW_PHASE_STACK; + } + /* fall-through */ + + case FT_LZW_PHASE_STACK: + { + while ( state->stack_top > 0 ) + { + --state->stack_top; + + if ( buffer ) + buffer[result] = state->stack[state->stack_top]; + + if ( ++result == out_size ) + goto Exit; + } + + /* now create new entry */ + if ( free_ent < state->max_free ) + { + if ( free_ent >= state->prefix_size && + ft_lzwstate_prefix_grow( state ) < 0 ) + goto Eof; + + FT_ASSERT( free_ent < state->prefix_size ); + + state->prefix[free_ent] = (FT_UShort)old_code; + state->suffix[free_ent] = (FT_Byte) old_char; + + if ( ++free_ent == state->free_bits ) + { + num_bits++; + + state->free_bits = num_bits < state->max_bits + ? (FT_UInt)( ( 1UL << num_bits ) - 256 ) + : state->max_free + 1; + } + } + + old_code = in_code; + + state->phase = FT_LZW_PHASE_CODE; + goto NextCode; + } + + default: /* state == EOF */ + ; + } + + Exit: + state->num_bits = num_bits; + state->free_ent = free_ent; + state->old_code = old_code; + state->old_char = old_char; + state->in_code = in_code; + + return result; + + Eof: + state->phase = FT_LZW_PHASE_EOF; + goto Exit; + } + + +/* END */ diff --git a/src/libs/freetype2/lzw/ftzopen.h b/src/libs/freetype2/lzw/ftzopen.h new file mode 100644 index 0000000000..8b1831b567 --- /dev/null +++ b/src/libs/freetype2/lzw/ftzopen.h @@ -0,0 +1,173 @@ +/***************************************************************************/ +/* */ +/* ftzopen.h */ +/* */ +/* FreeType support for .Z compressed files. */ +/* */ +/* This optional component relies on NetBSD's zopen(). It should mainly */ +/* be used to parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2005, 2006 by David Turner. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#ifndef __FT_ZOPEN_H__ +#define __FT_ZOPEN_H__ + +#include <ft2build.h> +#include FT_FREETYPE_H + + + /* + * This is a complete re-implementation of the LZW file reader, + * since the old one was incredibly badly written, using + * 400 KByte of heap memory before decompressing anything. + * + */ + +#define FT_LZW_IN_BUFF_SIZE 64 +#define FT_LZW_DEFAULT_STACK_SIZE 64 + +#define LZW_INIT_BITS 9 +#define LZW_MAX_BITS 16 + +#define LZW_CLEAR 256 +#define LZW_FIRST 257 + +#define LZW_BIT_MASK 0x1f +#define LZW_BLOCK_MASK 0x80 +#define LZW_MASK( n ) ( ( 1U << (n) ) - 1U ) + + + typedef enum + { + FT_LZW_PHASE_START = 0, + FT_LZW_PHASE_CODE, + FT_LZW_PHASE_STACK, + FT_LZW_PHASE_EOF + + } FT_LzwPhase; + + + /* + * state of LZW decompressor + * + * small technical note + * -------------------- + * + * We use a few tricks in this implementation that are explained here to + * ease debugging and maintenance. + * + * - First of all, the `prefix' and `suffix' arrays contain the suffix + * and prefix for codes over 256; this means that + * + * prefix_of(code) == state->prefix[code-256] + * suffix_of(code) == state->suffix[code-256] + * + * Each prefix is a 16-bit code, and each suffix an 8-bit byte. + * + * Both arrays are stored in a single memory block, pointed to by + * `state->prefix'. This means that the following equality is always + * true: + * + * state->suffix == (FT_Byte*)(state->prefix + state->prefix_size) + * + * Of course, state->prefix_size is the number of prefix/suffix slots + * in the arrays, corresponding to codes 256..255+prefix_size. + * + * - `free_ent' is the index of the next free entry in the `prefix' + * and `suffix' arrays. This means that the corresponding `next free + * code' is really `256+free_ent'. + * + * Moreover, `max_free' is the maximum value that `free_ent' can reach. + * + * `max_free' corresponds to `(1 << max_bits) - 256'. Note that this + * value is always <= 0xFF00, which means that both `free_ent' and + * `max_free' can be stored in an FT_UInt variable, even on 16-bit + * machines. + * + * If `free_ent == max_free', you cannot add new codes to the + * prefix/suffix table. + * + * - `num_bits' is the current number of code bits, starting at 9 and + * growing each time `free_ent' reaches the value of `free_bits'. The + * latter is computed as follows + * + * if num_bits < max_bits: + * free_bits = (1 << num_bits)-256 + * else: + * free_bits = max_free + 1 + * + * Since the value of `max_free + 1' can never be reached by + * `free_ent', `num_bits' cannot grow larger than `max_bits'. + */ + + typedef struct _FT_LzwStateRec + { + FT_LzwPhase phase; + + FT_Int in_eof; + FT_Byte* in_cursor; /* current buffer pos */ + FT_Byte* in_limit; /* current buffer limit */ + + FT_UInt32 pad; /* a pad value where incoming bits were read */ + FT_Int pad_bits; /* number of meaningful bits in pad value */ + + FT_UInt max_bits; /* max code bits, from file header */ + FT_Int block_mode; /* block mode flag, from file header */ + FT_UInt max_free; /* (1 << max_bits) - 256 */ + + FT_UInt num_bits; /* current code bit number */ + FT_UInt free_ent; /* index of next free entry */ + FT_UInt free_bits; /* if reached by free_ent, increment num_bits */ + FT_UInt old_code; + FT_UInt old_char; + FT_UInt in_code; + + FT_UShort* prefix; /* always dynamically allocated / reallocated */ + FT_Byte* suffix; /* suffix = (FT_Byte*)(prefix + prefix_size) */ + FT_UInt prefix_size; /* number of slots in `prefix' or `suffix' */ + + FT_Byte* stack; /* character stack */ + FT_UInt stack_top; + FT_UInt stack_size; + + FT_Byte in_buff[FT_LZW_IN_BUFF_SIZE]; /* small read-buffer */ + FT_Byte stack_0[FT_LZW_DEFAULT_STACK_SIZE]; /* minimize heap alloc */ + + FT_Stream source; /* source stream */ + FT_Memory memory; + + } FT_LzwStateRec, *FT_LzwState; + + + FT_LOCAL( void ) + ft_lzwstate_init( FT_LzwState state, + FT_Stream source ); + + FT_LOCAL( void ) + ft_lzwstate_done( FT_LzwState state ); + + + FT_LOCAL( void ) + ft_lzwstate_reset( FT_LzwState state ); + + + FT_LOCAL( FT_ULong ) + ft_lzwstate_io( FT_LzwState state, + FT_Byte* buffer, + FT_ULong out_size ); + +/* */ + +#endif /* __FT_ZOPEN_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/lzw/rules.mk b/src/libs/freetype2/lzw/rules.mk index 73ce718044..5550a48d64 100644 --- a/src/libs/freetype2/lzw/rules.mk +++ b/src/libs/freetype2/lzw/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004 by +# Copyright 2004, 2005, 2006 by # Albert Chin-A-Young. # # Based on src/lzw/rules.mk, Copyright 2002 by @@ -28,12 +28,12 @@ LZW_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(LZW_DIR)) # LZW support sources (i.e., C files) # -LZW_DRV_SRC := $(LZW_DIR)/ftlzw.c \ - $(LZW_DIR)/zopen.c +LZW_DRV_SRC := $(LZW_DIR)/ftlzw.c # LZW support headers # -LZW_DRV_H := $(LZW_DIR)/zopen.h +LZW_DRV_H := $(LZW_DIR)/ftzopen.h \ + $(LZW_DIR)/ftzopen.c # LZW driver object(s) diff --git a/src/libs/freetype2/lzw/zopen.c b/src/libs/freetype2/lzw/zopen.c deleted file mode 100644 index 5a3c5bc2b3..0000000000 --- a/src/libs/freetype2/lzw/zopen.c +++ /dev/null @@ -1,400 +0,0 @@ -/* $NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp $ */ - -/*- - * Copyright (c) 1985, 1986, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Diomidis Spinellis and James A. Woods, derived from original - * work by Spencer Thomas and Joseph Orost. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/*- - * - * Copyright (c) 2004, 2005 - * Albert Chin-A-Young. - * - * Modified to work with FreeType's PCF driver. - * - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)zopen.c 8.1 (Berkeley) 6/27/93"; -#else -static char rcsid[] = "$NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp $"; -#endif -#endif /* LIBC_SCCS and not lint */ - -/*- - * fcompress.c - File compression ala IEEE Computer, June 1984. - * - * Compress authors: - * Spencer W. Thomas (decvax!utah-cs!thomas) - * Jim McKie (decvax!mcvax!jim) - * Steve Davies (decvax!vax135!petsd!peora!srd) - * Ken Turkowski (decvax!decwrl!turtlevax!ken) - * James A. Woods (decvax!ihnp4!ames!jaw) - * Joe Orost (decvax!vax135!petsd!joe) - * - * Cleaned up and converted to library returning I/O streams by - * Diomidis Spinellis <dds@doc.ic.ac.uk>. - */ - -#include <ctype.h> -#if 0 -#include <signal.h> -#endif -#include <stdlib.h> -#include <string.h> -#if 0 -#include <unistd.h> -#endif - -#if 0 -static char_type magic_header[] = - { 0x1f, 0x9d }; /* 1F 9D */ -#endif - -#define BIT_MASK 0x1f /* Defines for third byte of header. */ -#define BLOCK_MASK 0x80 - -/* - * Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is - * a fourth header byte (for expansion). - */ -#define INIT_BITS 9 /* Initial number of bits/code. */ - -#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) - -/* Definitions to retain old variable names */ -#define fp zs->zs_fp -#define state zs->zs_state -#define n_bits zs->zs_n_bits -#define maxbits zs->zs_maxbits -#define maxcode zs->zs_maxcode -#define maxmaxcode zs->zs_maxmaxcode -#define htab zs->zs_htab -#define codetab zs->zs_codetab -#define hsize zs->zs_hsize -#define free_ent zs->zs_free_ent -#define block_compress zs->zs_block_compress -#define clear_flg zs->zs_clear_flg -#define offset zs->zs_offset -#define in_count zs->zs_in_count -#define buf_len zs->zs_buf_len -#define buf zs->zs_buf -#define stackp zs->u.r.zs_stackp -#define finchar zs->u.r.zs_finchar -#define code zs->u.r.zs_code -#define oldcode zs->u.r.zs_oldcode -#define incode zs->u.r.zs_incode -#define roffset zs->u.r.zs_roffset -#define size zs->u.r.zs_size -#define gbuf zs->u.r.zs_gbuf - -/* - * To save much memory, we overlay the table used by compress() with those - * used by decompress(). The tab_prefix table is the same size and type as - * the codetab. The tab_suffix table needs 2**BITS characters. We get this - * from the beginning of htab. The output stack uses the rest of htab, and - * contains characters. There is plenty of room for any possible stack - * (stack used to be 8000 characters). - */ - -#define htabof(i) htab[i] -#define codetabof(i) codetab[i] - -#define tab_prefixof(i) codetabof(i) -#define tab_suffixof(i) ((char_type *)(htab))[i] -#define de_stack ((char_type *)&tab_suffixof(1 << BITS)) - -#define CHECK_GAP 10000 /* Ratio check interval. */ - -/* - * the next two codes should not be changed lightly, as they must not - * lie within the contiguous general code space. - */ -#define FIRST 257 /* First free entry. */ -#define CLEAR 256 /* Table clear output code. */ - -/*- - * Algorithm from "A Technique for High Performance Data Compression", - * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19. - * - * Algorithm: - * Modified Lempel-Ziv method (LZW). Basically finds common - * substrings and replaces them with a variable size code. This is - * deterministic, and can be done on the fly. Thus, the decompression - * procedure needs no input table, but tracks the way the table was built. - */ - -#if 0 -static int -zclose(s_zstate_t *zs) -{ - free(zs); - return (0); -} -#endif - -/*- - * Output the given code. - * Inputs: - * code: A n_bits-bit integer. If == -1, then EOF. This assumes - * that n_bits =< (long)wordsize - 1. - * Outputs: - * Outputs code to the file. - * Assumptions: - * Chars are 8 bits long. - * Algorithm: - * Maintain a BITS character long buffer (so that 8 codes will - * fit in it exactly). Use the VAX insv instruction to insert each - * code in turn. When the buffer fills up empty it and start over. - */ - -static const char_type rmask[9] = - {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; - -/* - * Decompress read. This routine adapts to the codes in the file building - * the "string" table on-the-fly; requiring no table to be stored in the - * compressed file. The tables used herein are shared with those of the - * compress() routine. See the definitions above. - */ -static int -zread(s_zstate_t *zs) -{ - unsigned int count; - - if (in_count == 0) - return -1; - if (zs->avail_out == 0) - return 0; - - count = zs->avail_out; - switch (state) { - case S_START: - state = S_MIDDLE; - break; - case S_MIDDLE: - goto middle; - case S_EOF: - goto eof; - } - - maxbits = *(zs->next_in); /* Set -b from file. */ - zs->avail_in--; - zs->next_in++; - zs->total_in++; - in_count--; - block_compress = maxbits & BLOCK_MASK; - maxbits &= BIT_MASK; - maxmaxcode = 1L << maxbits; - if (maxbits > BITS) { - return -1; - } - /* As above, initialize the first 256 entries in the table. */ - maxcode = MAXCODE(n_bits = INIT_BITS); - for (code = 255; code >= 0; code--) { - tab_prefixof(code) = 0; - tab_suffixof(code) = (char_type) code; - } - free_ent = block_compress ? FIRST : 256; - - finchar = oldcode = getcode(zs); - if (oldcode == -1) /* EOF already? */ - return 0; /* Get out of here */ - - /* First code must be 8 bits = char. */ - *(zs->next_out)++ = (unsigned char)finchar; - zs->total_out++; - count--; - stackp = de_stack; - - while ((code = getcode(zs)) > -1) { - if ((code == CLEAR) && block_compress) { - for (code = 255; code >= 0; code--) - tab_prefixof(code) = 0; - clear_flg = 1; - free_ent = FIRST - 1; - if ((code = getcode(zs)) == -1) - /* O, untimely death! */ - break; - } - incode = code; - - /* Special case for KwKwK string. */ - if (code >= free_ent) { - *stackp++ = (unsigned char)finchar; - code = oldcode; - } - - /* Generate output characters in reverse order. */ - while (code >= 256) { - *stackp++ = tab_suffixof(code); - code = tab_prefixof(code); - } - *stackp++ = (unsigned char)(finchar = tab_suffixof(code)); - - /* And put them out in forward order. */ -middle: - if (stackp == de_stack) - continue; - - do { - if (count-- == 0) { - return zs->avail_out; - } - *(zs->next_out)++ = *--stackp; - zs->total_out++; - } while (stackp > de_stack); - - /* Generate the new entry. */ - if ((code = free_ent) < maxmaxcode) { - tab_prefixof(code) = (unsigned short)oldcode; - tab_suffixof(code) = (unsigned char)finchar; - free_ent = code + 1; - } - - /* Remember previous code. */ - oldcode = incode; - } - /* state = S_EOF; */ -eof: return (zs->avail_out - count); -} - -/*- - * Read one code from the standard input. If EOF, return -1. - * Inputs: - * stdin - * Outputs: - * code or -1 is returned. - */ -static code_int -getcode(s_zstate_t *zs) -{ - code_int gcode; - int r_off, bits; - char_type *bp; - - bp = gbuf; - if (clear_flg > 0 || roffset >= size || free_ent > maxcode) { - /* - * If the next entry will be too big for the current gcode - * size, then we must increase the size. This implies reading - * a new buffer full, too. - */ - if (free_ent > maxcode) { - n_bits++; - if (n_bits == maxbits) /* Won't get any bigger now. */ - maxcode = maxmaxcode; - else - maxcode = MAXCODE(n_bits); - } - if (clear_flg > 0) { - maxcode = MAXCODE(n_bits = INIT_BITS); - clear_flg = 0; - } - if ( zs->avail_in < (unsigned int)n_bits && in_count > (long)n_bits ) { - memcpy (buf, zs->next_in, zs->avail_in); - buf_len = (unsigned char)zs->avail_in; - zs->avail_in = 0; - return -1; - } - if (buf_len) { - memcpy (gbuf, buf, buf_len); - memcpy (gbuf + buf_len, zs->next_in, - n_bits - buf_len); - zs->next_in += n_bits - buf_len; - zs->avail_in -= n_bits - buf_len; - buf_len = 0; - zs->total_in += n_bits; - size = n_bits; - in_count -= n_bits; - } else { - if (in_count > n_bits) { - memcpy (gbuf, zs->next_in, n_bits); - zs->next_in += n_bits; - zs->avail_in -= n_bits; - zs->total_in += n_bits; - size = n_bits; - in_count -= n_bits; - } else { - memcpy (gbuf, zs->next_in, in_count); - zs->next_in += in_count; - zs->avail_in -= in_count; - zs->total_in += in_count; - size = in_count; - in_count = 0; - } - } - roffset = 0; - /* Round size down to integral number of codes. */ - size = (size << 3) - (n_bits - 1); - } - r_off = roffset; - bits = n_bits; - - /* Get to the first byte. */ - bp += (r_off >> 3); - r_off &= 7; - - /* Get first part (low order bits). */ - gcode = (*bp++ >> r_off); - bits -= (8 - r_off); - r_off = 8 - r_off; /* Now, roffset into gcode word. */ - - /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ - if (bits >= 8) { - gcode |= *bp++ << r_off; - r_off += 8; - bits -= 8; - } - - /* High order bits. */ - gcode |= (*bp & rmask[bits]) << r_off; - roffset += n_bits; - - return (gcode); -} - -static void -zinit(s_zstate_t *zs) -{ - memset(zs, 0, sizeof (s_zstate_t)); - - maxbits = BITS; /* User settable max # bits/code. */ - maxmaxcode = 1 << maxbits; /* Should NEVER generate this code. */ - hsize = HSIZE; /* For dynamic table sizing. */ - free_ent = 0; /* First unused entry. */ - block_compress = BLOCK_MASK; - clear_flg = 0; - state = S_START; - roffset = 0; - size = 0; -} diff --git a/src/libs/freetype2/lzw/zopen.h b/src/libs/freetype2/lzw/zopen.h deleted file mode 100644 index 483b47e5c6..0000000000 --- a/src/libs/freetype2/lzw/zopen.h +++ /dev/null @@ -1,114 +0,0 @@ -/* $NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp $ */ - -/*- - * Copyright (c) 1985, 1986, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Diomidis Spinellis and James A. Woods, derived from original - * work by Spencer Thomas and Joseph Orost. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/*- - * - * Copyright (c) 2004 - * Albert Chin-A-Young. - * - * Modified to work with FreeType's PCF driver. - * - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)zopen.c 8.1 (Berkeley) 6/27/93"; -#else -static char rcsid[] = "$NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp $"; -#endif -#endif /* LIBC_SCCS and not lint */ - -#include <stdio.h> - -#define BITS 16 /* Default bits. */ -#define HSIZE 69001 /* 95% occupancy */ - -/* A code_int must be able to hold 2**BITS values of type int, and also -1. */ -typedef long code_int; -typedef long count_int; - -typedef unsigned char char_type; - -typedef enum { - S_START, S_MIDDLE, S_EOF -} zs_enum; - -typedef struct { - unsigned char *next_in; - unsigned int avail_in; - unsigned long total_in; - - unsigned char *next_out; - unsigned int avail_out; - unsigned long total_out; - - zs_enum zs_state; /* State of computation */ - int zs_n_bits; /* Number of bits/code. */ - int zs_maxbits; /* User settable max # bits/code. */ - code_int zs_maxcode; /* Maximum code, given n_bits. */ - code_int zs_maxmaxcode; /* Should NEVER generate this code. */ - count_int zs_htab [HSIZE]; - unsigned short zs_codetab [HSIZE]; - code_int zs_hsize; /* For dynamic table sizing. */ - code_int zs_free_ent; /* First unused entry. */ - /* - * Block compression parameters -- after all codes are used up, - * and compression rate changes, start over. - */ - int zs_block_compress; - int zs_clear_flg; - int zs_offset; - long zs_in_count; /* Remaining uncompressed bytes. */ - char_type zs_buf_len; - char_type zs_buf[BITS]; /* Temporary buffer if we need - to read more to accumulate - n_bits. */ - union { - struct { - char_type *zs_stackp; - int zs_finchar; - code_int zs_code, zs_oldcode, zs_incode; - int zs_roffset, zs_size; - char_type zs_gbuf[BITS]; - } r; /* Read parameters */ - } u; -} s_zstate_t; - -static code_int getcode(s_zstate_t *); -#if 0 -static int zclose(s_zstate_t *); -#endif -static void zinit(s_zstate_t *); -static int zread(s_zstate_t *); diff --git a/src/libs/freetype2/otlayout/otlayout.h b/src/libs/freetype2/otlayout/otlayout.h deleted file mode 100644 index 2cd67f568f..0000000000 --- a/src/libs/freetype2/otlayout/otlayout.h +++ /dev/null @@ -1,205 +0,0 @@ -#ifndef __OT_LAYOUT_H__ -#define __OT_LAYOUT_H__ - - -#include "otlconf.h" - -OTL_BEGIN_HEADER - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** BASE DATA TYPES *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - typedef unsigned char OTL_Byte; - typedef const OTL_Byte* OTL_Bytes; - - typedef int OTL_Error; - - typedef void* OTL_Pointer; - - typedef int OTL_Int; - typedef unsigned int OTL_UInt; - - typedef long OTL_Long; - typedef unsigned long OTL_ULong; - - typedef short OTL_Int16; - typedef unsigned short OTL_UInt16; - - -#if OTL_SIZEOF_INT == 4 - - typedef int OTL_Int32; - typedef unsigned int OTL_UInt32; - -#elif OTL_SIZEOF_LONG == 4 - - typedef long OTL_Int32; - typedef unsigned long OTL_UInt32; - -#else -# error "no 32-bits type found" -#endif - - typedef OTL_UInt32 OTL_Tag; - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** ERROR CODES *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - typedef enum - { - OTL_Err_Ok = 0, - OTL_Err_InvalidArgument, - OTL_Err_InvalidFormat, - OTL_Err_InvalidOffset, - - OTL_Err_Max - - } OTL_Error; - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** MEMORY MANAGEMENT *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - typedef OTL_Pointer (*OTL_AllocFunc)( OTL_ULong size, - OTL_Pointer data ); - - typedef OTL_Pointer (*OTL_ReallocFunc)( OTL_Pointer block, - OTL_ULong size, - OTL_Pointer data ); - - typedef void (*OTL_FreeFunc)( OTL_Pointer block, - OTL_Pointer data ); - - typedef struct OTL_MemoryRec_ - { - OTL_Pointer mem_data; - OTL_AllocFunc mem_alloc; - OTL_ReallocFunc mem_realloc; - OTL_FreeFunc mem_free; - - } OTL_MemoryRec, *OTL_Memory; - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** ENUMERATIONS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - -/* re-define OTL_MAKE_TAG to something different if you're not */ -/* using an ASCII-based character set (Vaxes anyone ?) */ -#ifndef OTL_MAKE_TAG -#define OTL_MAKE_TAG(c1,c2,c3,c4) \ - ( ( (OTL_UInt32)(c1) << 24 ) | \ - (OTL_UInt32)(c2) << 16 ) | \ - (OTL_UInt32)(c3) << 8 ) | \ - (OTL_UInt32)(c4) ) -#endif - - typedef enum OTL_ScriptTag_ - { - OTL_SCRIPT_NONE = 0, - -#define OTL_SCRIPT_TAG(c1,c2,c3,c4,s,n) OTL_SCRIPT_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4), -#include "otltags.h" - - OTL_SCRIPT_MAX - - } OTL_ScriptTag; - - - typedef enum OTL_LangTag_ - { - OTL_LANG_DEFAULT = 0, - -#define OTL_LANG_TAG(c1,c2,c3,c4,s,n) OTL_LANG_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4), -#include "otltags.h" - - OTL_LANG_MAX - - } OTL_LangTag; - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** MEMORY READS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - -#define OTL_PEEK_USHORT(p) ( ((OTL_UInt)((p)[0]) << 8) | \ - ((OTL_UInt)((p)[1]) ) ) - -#define OTL_PEEK_ULONG(p) ( ((OTL_UInt32)((p)[0]) << 24) | \ - ((OTL_UInt32)((p)[1]) << 16) | \ - ((OTL_UInt32)((p)[2]) << 8) | \ - ((OTL_UInt32)((p)[3]) ) ) - -#define OTL_PEEK_SHORT(p) ((OTL_Int16)OTL_PEEK_USHORT(p)) - -#define OTL_PEEK_LONG(p) ((OTL_Int32)OTL_PEEK_ULONG(p)) - -#define OTL_NEXT_USHORT(p) ( (p) += 2, OTL_PEEK_USHORT((p)-2) ) -#define OTL_NEXT_ULONG(p) ( (p) += 4, OTL_PEEK_ULONG((p)-4) ) - -#define OTL_NEXT_SHORT(p) ((OTL_Int16)OTL_NEXT_USHORT(p)) -#define OTL_NEXT_LONG(p) ((OTL_Int32)OTL_NEXT_ULONG(p)) - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** VALIDATION *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - typedef struct OTL_ValidatorRec_* OTL_Validator; - - typedef struct OTL_ValidatorRec_ - { - OTL_Bytes limit; - OTL_Bytes base; - OTL_Error error; - OTL_jmp_buf jump_buffer; - - } OTL_ValidatorRec; - - typedef void (*OTL_ValidateFunc)( OTL_Bytes table, - OTL_Valid valid ); - - OTL_API( void ) - otl_validator_error( OTL_Validator validator, - OTL_Error error ); - -#define OTL_INVALID(e) otl_validator_error( valid, e ) - -#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset ) -#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat ) - -#define OTL_CHECK(_count) OTL_BEGIN_STMNT \ - if ( p + (_count) > valid->limit ) \ - OTL_INVALID_TOO_SHORT; \ - OTL_END_STMNT - - /* */ - -OTL_END_HEADER - -#endif /* __OPENTYPE_LAYOUT_H__ */ diff --git a/src/libs/freetype2/otlayout/otlbase.c b/src/libs/freetype2/otlayout/otlbase.c deleted file mode 100644 index 614e13c1ad..0000000000 --- a/src/libs/freetype2/otlayout/otlbase.c +++ /dev/null @@ -1,181 +0,0 @@ -#include "otlbase.h" -#include "otlcommn.h" - - static void - otl_base_coord_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 4 ); - - format = OTL_NEXT_USHORT( p ); - p += 2; - - switch ( format ) - { - case 1: - break; - - case 2: - OTL_CHECK( 4 ); - break; - - case 3: - OTL_CHECK( 2 ); - otl_device_table_validate( table + OTL_PEEK_USHORT( p ) ); - break; - - default: - OTL_INVALID_DATA; - } - } - - - static void - otl_base_tag_list_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK(2); - - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( count*4 ); - } - - - - static void - otl_base_values_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 4 ); - - p += 2; /* skip default index */ - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - - for ( ; count > 0; count-- ) - otl_base_coord_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_base_minmax_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt min_coord, max_coord, count; - - OTL_CHECK(6); - min_coord = OTL_NEXT_USHORT( p ); - max_coord = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - if ( min_coord ) - otl_base_coord_validate( table + min_coord, valid ); - - if ( max_coord ) - otl_base_coord_validate( table + max_coord, valid ); - - OTL_CHECK( count*8 ); - for ( ; count > 0; count-- ) - { - p += 4; /* ignore tag */ - min_coord = OTL_NEXT_USHORT( p ); - max_coord = OTL_NEXT_USHORT( p ); - - if ( min_coord ) - otl_base_coord_validate( table + min_coord, valid ); - - if ( max_coord ) - otl_base_coord_validate( table + max_coord, valid ); - } - } - - - static void - otl_base_script_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt values, default_minmax; - - OTL_CHECK(6); - - values = OTL_NEXT_USHORT( p ); - default_minmax = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - if ( values ) - otl_base_values_validate( table + values, valid ); - - if ( default_minmax ) - otl_base_minmax_validate( table + default_minmax, valid ); - - OTL_CHECK( count*6 ); - for ( ; count > 0; count-- ) - { - p += 4; /* ignore tag */ - otl_base_minmax_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - } - - - static void - otl_base_script_list_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK(2); - - count = OTL_NEXT_USHORT( p ); - OTL_CHECK(count*6); - - for ( ; count > 0; count-- ) - { - p += 4; /* ignore script tag */ - otl_base_script_validate( table + OTL_NEXT_USHORT( p ) ); - } - } - - static void - otl_axis_table_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt tags; - - OTL_CHECK(4); - - tags = OTL_NEXT_USHORT( p ); - if ( tags ) - otl_base_tag_list_validate ( table + tags ); - - otl_base_script_list_validate( table + OTL_NEXT_USHORT( p ) ); - } - - - OTL_LOCALDEF( void ) - otl_base_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - - OTL_CHECK(6); - - if ( OTL_NEXT_ULONG( p ) != 0x10000UL ) - OTL_INVALID_DATA; - - otl_axis_table_validate( table + OTL_NEXT_USHORT( p ) ); - otl_axis_table_validate( table + OTL_NEXT_USHORT( p ) ); - } \ No newline at end of file diff --git a/src/libs/freetype2/otlayout/otlbase.h b/src/libs/freetype2/otlayout/otlbase.h deleted file mode 100644 index 563d3002d0..0000000000 --- a/src/libs/freetype2/otlayout/otlbase.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __OTL_BASE_H__ -#define __OTL_BASE_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - OTL_LOCAL( void ) - otl_base_validate( OTL_Bytes table, - OTL_Validator valid ); - -OTL_END_HEADER - -#endif /* __OTL_BASE_H__ */ diff --git a/src/libs/freetype2/otlayout/otlcommn.c b/src/libs/freetype2/otlayout/otlcommn.c deleted file mode 100644 index 742ff5b36e..0000000000 --- a/src/libs/freetype2/otlayout/otlcommn.c +++ /dev/null @@ -1,940 +0,0 @@ -/***************************************************************************/ -/* */ -/* otlcommn.c */ -/* */ -/* OpenType layout support, common tables (body). */ -/* */ -/* Copyright 2002 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include "otlayout.h" - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** COVERAGE TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_coverage_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p; - OTL_UInt format; - - - if ( table + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt count = OTL_NEXT_USHORT( p ); - - - if ( p + count * 2 >= valid->limit ) - OTL_INVALID_TOO_SHORT; - - /* XXX: check glyph indices */ - } - break; - - case 2: - { - OTL_UInt n, num_ranges = OTL_NEXT_USHORT( p ); - OTL_UInt start, end, start_cover, total = 0, last = 0; - - - if ( p + num_ranges * 6 >= valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( n = 0; n < num_ranges; n++ ) - { - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - start_cover = OTL_NEXT_USHORT( p ); - - if ( start > end || start_cover != total ) - OTL_INVALID_DATA; - - if ( n > 0 && start <= last ) - OTL_INVALID_DATA; - - total += end - start + 1; - last = end; - } - } - break; - - default: - OTL_INVALID_FORMAT; - } - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_coverage_get_count( OTL_Bytes table ) - { - OTL_Bytes p = table; - OTL_UInt format = OTL_NEXT_USHORT( p ); - OTL_UInt count = OTL_NEXT_USHORT( p ); - OTL_UInt result = 0; - - - switch ( format ) - { - case 1: - return count; - - case 2: - { - OTL_UInt start, end; - - - for ( ; count > 0; count-- ) - { - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - p += 2; /* skip start_index */ - - result += end - start + 1; - } - } - break; - - default: - ; - } - - return result; - } - - - OTL_LOCALDEF( OTL_Int ) - otl_coverage_get_index( OTL_Bytes table, - OTL_UInt glyph_index ) - { - OTL_Bytes p = table; - OTL_UInt format = OTL_NEXT_USHORT( p ); - OTL_UInt count = OTL_NEXT_USHORT( p ); - - - switch ( format ) - { - case 1: - { - OTL_UInt min = 0, max = count, mid, gindex; - - - table += 4; - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 2 * mid; - gindex = OTL_PEEK_USHORT( p ); - - if ( glyph_index == gindex ) - return (OTL_Int)mid; - - if ( glyph_index < gindex ) - max = mid; - else - min = mid + 1; - } - } - break; - - case 2: - { - OTL_UInt min = 0, max = count, mid; - OTL_UInt start, end, delta, start_cover; - - - table += 4; - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 6 * mid; - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - - if ( glyph_index < start ) - max = mid; - else if ( glyph_index > end ) - min = mid + 1; - else - return (OTL_Int)( glyph_index + OTL_NEXT_USHORT( p ) - start ); - } - } - break; - - default: - ; - } - - return -1; - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** CLASS DEFINITION TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_class_definition_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - - if ( p + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt count, start = OTL_NEXT_USHORT( p ); - - - if ( p + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - count = OTL_NEXT_USHORT( p ); - - if ( p + count * 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - /* XXX: check glyph indices */ - } - break; - - case 2: - { - OTL_UInt n, num_ranges = OTL_NEXT_USHORT( p ); - OTL_UInt start, end, value, last = 0; - - - if ( p + num_ranges * 6 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( n = 0; n < num_ranges; n++ ) - { - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - value = OTL_NEXT_USHORT( p ); /* ignored */ - - if ( start > end || ( n > 0 && start <= last ) ) - OTL_INVALID_DATA; - - last = end; - } - } - break; - - default: - OTL_INVALID_FORMAT; - } - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_class_definition_get_value( OTL_Bytes table, - OTL_UInt glyph_index ) - { - OTL_Bytes p = table; - OTL_UInt format = OTL_NEXT_USHORT( p ); - - - switch ( format ) - { - case 1: - { - OTL_UInt start = OTL_NEXT_USHORT( p ); - OTL_UInt count = OTL_NEXT_USHORT( p ); - OTL_UInt idx = (OTL_UInt)( glyph_index - start ); - - - if ( idx < count ) - { - p += 2 * idx; - return OTL_PEEK_USHORT( p ); - } - } - break; - - case 2: - { - OTL_UInt count = OTL_NEXT_USHORT( p ); - OTL_UInt min = 0, max = count, mid, gindex; - - - table += 4; - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 6 * mid; - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - - if ( glyph_index < start ) - max = mid; - else if ( glyph_index > end ) - min = mid + 1; - else - return OTL_PEEK_USHORT( p ); - } - } - break; - - default: - ; - } - - return 0; - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** DEVICE TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_device_table_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt start, end, count, format, count; - - - if ( p + 8 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - format = OTL_NEXT_USHORT( p ); - - if ( format < 1 || format > 3 || end < start ) - OTL_INVALID_DATA; - - count = (OTL_UInt)( end - start + 1 ); - - if ( p + ( ( 1 << format ) * count ) / 8 > valid->limit ) - OTL_INVALID_TOO_SHORT; - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_device_table_get_start( OTL_Bytes table ) - { - OTL_Bytes p = table; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_device_table_get_end( OTL_Bytes table ) - { - OTL_Bytes p = table + 2; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_Int ) - otl_device_table_get_delta( OTL_Bytes table, - OTL_UInt size ) - { - OTL_Bytes p = table; - OTL_Int result = 0; - OTL_UInt start, end, format, idx, value; - - - start = OTL_NEXT_USHORT( p ); - end = OTL_NEXT_USHORT( p ); - format = OTL_NEXT_USHORT( p ); - - if ( size >= start && size <= end ) - { - /* we could do that with clever bit operations, but a switch is */ - /* much simpler to understand and maintain */ - /* */ - switch ( format ) - { - case 1: - idx = (OTL_UInt)( ( size - start ) * 2 ); - p += idx / 16; - value = OTL_PEEK_USHORT( p ); - shift = idx & 15; - result = (OTL_Short)( value << shift ) >> ( 14 - shift ); - - break; - - case 2: - idx = (OTL_UInt)( ( size - start ) * 4 ); - p += idx / 16; - value = OTL_PEEK_USHORT( p ); - shift = idx & 15; - result = (OTL_Short)( value << shift ) >> ( 12 - shift ); - - break; - - case 3: - idx = (OTL_UInt)( ( size - start ) * 8 ); - p += idx / 16; - value = OTL_PEEK_USHORT( p ); - shift = idx & 15; - result = (OTL_Short)( value << shift ) >> ( 8 - shift ); - - break; - - default: - ; - } - } - - return result; - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LOOKUP LISTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_lookup_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt num_tables; - - - if ( table + 6 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - p += 4; - num_tables = OTL_NEXT_USHORT( p ); - - if ( p + num_tables * 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; num_tables > 0; num_tables-- ) - { - offset = OTL_NEXT_USHORT( p ); - - if ( table + offset >= valid->limit ) - OTL_INVALID_OFFSET; - } - - /* XXX: check sub-tables? */ - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_lookup_get_count( OTL_Bytes table ) - { - OTL_Bytes p = table + 4; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_Bytes ) - otl_lookup_get_table( OTL_Bytes table, - OTL_UInt idx ) - { - OTL_Bytes p, result = NULL; - OTL_UInt count; - - - p = table + 4; - count = OTL_NEXT_USHORT( p ); - if ( idx < count ) - { - p += idx * 2; - result = table + OTL_PEEK_USHORT( p ); - } - - return result; - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LOOKUP LISTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_lookup_list_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table, q; - OTL_UInt num_lookups, offset; - - - if ( p + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - num_lookups = OTL_NEXT_USHORT( p ); - - if ( p + num_lookups * 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; num_lookups > 0; num_lookups-- ) - { - offset = OTL_NEXT_USHORT( p ); - - otl_lookup_validate( table + offset, valid ); - } - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_lookup_list_get_count( OTL_Bytes table ) - { - OTL_Bytes p = table; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_Bytes ) - otl_lookup_list_get_lookup( OTL_Bytes table, - OTL_UInt idx ) - { - OTL_Bytes p, result = 0; - OTL_UInt count; - - - p = table; - count = OTL_NEXT_USHORT( p ); - if ( idx < count ) - { - p += idx * 2; - result = table + OTL_PEEK_USHORT( p ); - } - - return result; - } - - - OTL_LOCALDEF( OTL_Bytes ) - otl_lookup_list_get_table( OTL_Bytes table, - OTL_UInt lookup_index, - OTL_UInt table_index ) - { - OTL_Bytes result = NULL; - - - result = otl_lookup_list_get_lookup( table, lookup_index ); - if ( result ) - result = otl_lookup_get_table( result, table_index ); - - return result; - } - - - OTL_LOCALDEF( void ) - otl_lookup_list_foreach( OTL_Bytes table, - OTL_ForeachFunc func, - OTL_Pointer func_data ) - { - OTL_Bytes p = table; - OTL_UInt count = OTL_NEXT_USHORT( p ); - - - for ( ; count > 0; count-- ) - func( table + OTL_NEXT_USHORT( p ), func_data ); - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FEATURES *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_feature_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt feat_params, num_lookups; - - - if ( p + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - feat_params = OTL_NEXT_USHORT( p ); /* ignored */ - num_lookups = OTL_NEXT_USHORT( p ); - - if ( p + num_lookups * 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - /* XXX: check lookup indices */ - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_feature_get_count( OTL_Bytes table ) - { - OTL_Bytes p = table + 4; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_feature_get_lookups( OTL_Bytes table, - OTL_UInt start, - OTL_UInt count, - OTL_UInt *lookups ) - { - OTL_Bytes p; - OTL_UInt num_features, result = 0; - - - p = table + 4; - num_features = OTL_NEXT_USHORT( p ); - - p += start * 2; - - for ( ; count > 0 && start < num_features; count--, start++ ) - { - lookups[0] = OTL_NEXT_USHORT(p); - lookups++; - result++; - } - - return result; - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FEATURE LIST *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCALDEF( void ) - otl_feature_list_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt num_features, offset; - - - if ( table + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - num_features = OTL_NEXT_USHORT( p ); - - if ( p + num_features * 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; num_features > 0; num_features-- ) - { - p += 4; /* skip tag */ - offset = OTL_NEXT_USHORT( p ); - - otl_feature_table_validate( table + offset, valid ); - } - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_feature_list_get_count( OTL_Bytes table ) - { - OTL_Bytes p = table; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_Bytes ) - otl_feature_list_get_feature( OTL_Bytes table, - OTL_UInt idx ) - { - OTL_Bytes p, result = NULL; - OTL_UInt count; - - - p = table; - count = OTL_NEXT_USHORT( p ); - - if ( idx < count ) - { - p += idx * 2; - result = table + OTL_PEEK_USHORT( p ); - } - - return result; - } - - - OTL_LOCALDEF( void ) - otl_feature_list_foreach( OTL_Bytes table, - OTL_ForeachFunc func, - OTL_Pointer func_data ) - { - OTL_Bytes p; - OTL_UInt count; - - - p = table; - count = OTL_NEXT_USHORT( p ); - - for ( ; count > 0; count-- ) - func( table + OTL_NEXT_USHORT( p ), func_data ); - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LANGUAGE SYSTEM *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - - OTL_LOCALDEF( void ) - otl_lang_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt lookup_order; - OTL_UInt req_feature; - OTL_UInt num_features; - - - if ( table + 6 >= valid->limit ) - OTL_INVALID_TOO_SHORT; - - lookup_order = OTL_NEXT_USHORT( p ); - req_feature = OTL_NEXT_USHORT( p ); - num_features = OTL_NEXT_USHORT( p ); - - /* XXX: check req_feature if not 0xFFFFU */ - - if ( p + 2 * num_features >= valid->limit ) - OTL_INVALID_TOO_SHORT; - - /* XXX: check features indices! */ - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_lang_get_count( OTL_Bytes table ) - { - OTL_Bytes p = table + 4; - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_lang_get_req_feature( OTL_Bytes table ) - { - OTL_Bytes p = table + 2; - - - return OTL_PEEK_USHORT( p ); - } - - - OTL_LOCALDEF( OTL_UInt ) - otl_lang_get_features( OTL_Bytes table, - OTL_UInt start, - OTL_UInt count, - OTL_UInt *features ) - { - OTL_Bytes p = table + 4; - OTL_UInt num_features = OTL_NEXT_USHORT( p ); - OTL_UInt result = 0; - - - p += start * 2; - - for ( ; count > 0 && start < num_features; start++, count-- ) - { - features[0] = OTL_NEXT_USHORT( p ); - features++; - result++; - } - - return result; - } - - - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** SCRIPTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - - OTL_LOCALDEF( void ) - otl_script_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_UInt default_lang; - OTL_Bytes p = table; - - - if ( table + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - default_lang = OTL_NEXT_USHORT( p ); - num_langs = OTL_NEXT_USHORT( p ); - - if ( default_lang != 0 ) - { - if ( table + default_lang >= valid->limit ) - OTL_INVALID_OFFSET; - } - - if ( p + num_langs * 6 >= valid->limit ) - OTL_INVALID_OFFSET; - - for ( ; num_langs > 0; num_langs-- ) - { - OTL_UInt offset; - - - p += 4; /* skip tag */ - offset = OTL_NEXT_USHORT( p ); - - otl_lang_validate( table + offset, valid ); - } - } - - - OTL_LOCALDEF( void ) - otl_script_list_validate( OTL_Bytes list, - OTL_Validator valid ) - { - OTL_UInt num_scripts; - OTL_Bytes p = list; - - - if ( list + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - num_scripts = OTL_NEXT_USHORT( p ); - - if ( p + num_scripts * 6 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; num_scripts > 0; num_scripts-- ) - { - OTL_UInt offset; - - - p += 4; /* skip tag */ - offset = OTL_NEXT_USHORT( p ); - - otl_script_table_validate( list + offset, valid ); - } - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LOOKUP LISTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - static void - otl_lookup_table_validate( OTL_Bytes table, - OTL_UInt type_count, - OTL_ValidateFunc* type_funcs, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt lookup_type, lookup_flag, count; - OTL_ValidateFunc validate; - - OTL_CHECK( 6 ); - lookup_type = OTL_NEXT_USHORT( p ); - lookup_flag = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - if ( lookup_type == 0 || lookup_type >= type_count ) - OTL_INVALID_DATA; - - validate = type_funcs[ lookup_type - 1 ]; - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - OTL_LOCALDEF( void ) - otl_lookup_list_validate( OTL_Bytes table, - OTL_UInt type_count, - OTL_ValidateFunc* type_funcs, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_lookup_table_validate( table + OTL_NEXT_USHORT( p ), - type_count, type_funcs, valid ); - } - -/* END */ diff --git a/src/libs/freetype2/otlayout/otlcommn.h b/src/libs/freetype2/otlayout/otlcommn.h deleted file mode 100644 index 25914fb9f7..0000000000 --- a/src/libs/freetype2/otlayout/otlcommn.h +++ /dev/null @@ -1,277 +0,0 @@ -/***************************************************************************/ -/* */ -/* otlcommn.h */ -/* */ -/* OpenType layout support, common tables (specification). */ -/* */ -/* Copyright 2002 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __OTLCOMMN_H__ -#define __OTLCOMMN_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** COVERAGE TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate coverage table */ - OTL_LOCALDEF( void ) - otl_coverage_validate( OTL_Bytes base, - OTL_Validator valid ); - - /* return number of covered glyphs */ - OTL_LOCALDEF( OTL_UInt ) - otl_coverage_get_count( OTL_Bytes base ); - - /* Return the coverage index corresponding to a glyph glyph index. */ - /* Return -1 if the glyph isn't covered. */ - OTL_LOCALDEF( OTL_Int ) - otl_coverage_get_index( OTL_Bytes base, - OTL_UInt glyph_index ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** CLASS DEFINITION TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate class definition table */ - OTL_LOCALDEF( void ) - otl_class_definition_validate( OTL_Bytes table, - OTL_Validator valid ); - - /* return class value for a given glyph index */ - OTL_LOCALDEF( OTL_UInt ) - otl_class_definition_get_value( OTL_Bytes table, - OTL_UInt glyph_index ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** DEVICE TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate a device table */ - OTL_LOCALDEF( void ) - otl_device_table_validate( OTL_Bytes table, - OTL_Validator valid ); - - /* return a device table's first size */ - OTL_LOCALDEF( OTL_UInt ) - otl_device_table_get_start( OTL_Bytes table ); - - /* return a device table's last size */ - OTL_LOCALDEF( OTL_UInt ) - otl_device_table_get_end( OTL_Bytes table ); - - /* return pixel adjustment for a given size */ - OTL_LOCALDEF( OTL_Int ) - otl_device_table_get_delta( OTL_Bytes table, - OTL_UInt size ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LOOKUPS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate lookup table */ - OTL_LOCALDEF( void ) - otl_lookup_validate( OTL_Bytes table, - OTL_Validator valid ); - - /* return number of sub-tables in a lookup */ - OTL_LOCALDEF( OTL_UInt ) - otl_lookup_get_count( OTL_Bytes table ); - - - /* return lookup sub-table */ - OTL_LOCALDEF( OTL_Bytes ) - otl_lookup_get_table( OTL_Bytes table, - OTL_UInt idx ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LOOKUP LISTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate lookup list */ - OTL_LOCALDEF( void ) - otl_lookup_list_validate( OTL_Bytes table, - OTL_Validator valid ); - - /* return number of lookups in list */ - OTL_LOCALDEF( OTL_UInt ) - otl_lookup_list_get_count( OTL_Bytes table ); - - /* return a given lookup from a list */ - OTL_LOCALDEF( OTL_Bytes ) - otl_lookup_list_get_lookup( OTL_Bytes table, - OTL_UInt idx ); - - /* return lookup sub-table from a list */ - OTL_LOCALDEF( OTL_Bytes ) - otl_lookup_list_get_table( OTL_Bytes table, - OTL_UInt lookup_index, - OTL_UInt table_index ); - - /* iterate over lookup list */ - OTL_LOCALDEF( void ) - otl_lookup_list_foreach( OTL_Bytes table, - OTL_ForeachFunc func, - OTL_Pointer func_data ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FEATURES *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate feature table */ - OTL_LOCALDEF( void ) - otl_feature_validate( OTL_Bytes table, - OTL_Validator valid ); - - /* return feature's lookup count */ - OTL_LOCALDEF( OTL_UInt ) - otl_feature_get_count( OTL_Bytes table ); - - /* get several lookups indices from a feature. returns the number of */ - /* lookups grabbed */ - OTL_LOCALDEF( OTL_UInt ) - otl_feature_get_lookups( OTL_Bytes table, - OTL_UInt start, - OTL_UInt count, - OTL_UInt *lookups ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FEATURE LIST *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* validate a feature list */ - OTL_LOCALDEF( void ) - otl_feature_list_validate( OTL_Bytes table, - OTL_Validator valid ); - - /* return number of features in list */ - OTL_LOCALDEF( OTL_UInt ) - otl_feature_list_get_count( OTL_Bytes table ); - - - /* return a given feature from a list */ - OTL_LOCALDEF( OTL_Bytes ) - otl_feature_list_get_feature( OTL_Bytes table, - OTL_UInt idx ); - - /* iterate over all features in a list */ - OTL_LOCALDEF( void ) - otl_feature_list_foreach( OTL_Bytes table, - OTL_ForeachFunc func, - OTL_Pointer func_data ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LANGUAGE SYSTEM *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCAL( void ) - otl_lang_validate( OTL_Bytes table, - OTL_Validator valid ); - - - OTL_LOCAL( OTL_UInt ) - otl_lang_get_req_feature( OTL_Bytes table ); - - - OTL_LOCAL( OTL_UInt ) - otl_lang_get_count( OTL_Bytes table ); - - - OTL_LOCAL( OTL_UInt ) - otl_lang_get_features( OTL_Bytes table, - OTL_UInt start, - OTL_UInt count, - OTL_UInt *features ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** SCRIPTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCAL( void ) - otl_script_list_validate( OTL_Bytes list, - OTL_Validator valid ); - - OTL_LOCAL( OTL_Bytes ) - otl_script_list_get_script( OTL_Bytes table ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** LOOKUP LISTS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - OTL_LOCAL( void ) - otl_lookup_list_validate( OTL_Bytes list, - OTL_UInt type_count, - OTL_ValidateFunc* type_funcs, - OTL_Validator valid ); - - /* */ - -OTL_END_HEADER - -#endif /* __OTLCOMMN_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/otlayout/otlconf.h b/src/libs/freetype2/otlayout/otlconf.h deleted file mode 100644 index 3ef17a0799..0000000000 --- a/src/libs/freetype2/otlayout/otlconf.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __OT_LAYOUT_CONFIG_H__ -#define __OT_LAYOUT_CONFIG_H__ - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** CONFIGURATION MACROS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - -#ifdef __cplusplus -# define OTL_BEGIN_HEADER extern "C" { -#else -# define OTL_BEGIN_HEADER /* nothing */ -#endif - -#ifdef __cplusplus -# define OTL_END_HEADER } -#else -# define OTL_END_HEADER /* nothing */ -#endif - -#ifndef OTL_API -# ifdef __cplusplus -# define OTL_API( x ) extern "C" -# else -# define OTL_API( x ) extern x -# endif -#endif - -#ifndef OTL_APIDEF -# define OTL_APIDEF( x ) x -#endif - -#ifndef OTL_LOCAL -# define OTL_LOCAL( x ) extern x -#endif - -#ifndef OTL_LOCALDEF -# define OTL_LOCALDEF( x ) x -#endif - -#define OTL_BEGIN_STMNT do { -#define OTL_END_STMNT } while (0) -#define OTL_DUMMY_STMNT OTL_BEGIN_STMNT OTL_END_STMNT - -#define OTL_UNUSED( x ) (x)=(x) -#define OTL_UNUSED_CONST(x) (void)(x) - - -#include <limits.h> -#if UINT_MAX == 0xFFFFU -# define OTL_SIZEOF_INT 2 -#elif UINT_MAX == 0xFFFFFFFFU -# define OTL_SIZEOF_INT 4 -#elif UINT_MAX > 0xFFFFFFFFU && UINT_MAX == 0xFFFFFFFFFFFFFFFFU -# define OTL_SIZEOF_INT 8 -#else -# error "unsupported number of bytes in 'int' type!" -#endif - -#if ULONG_MAX == 0xFFFFFFFFU -# define OTL_SIZEOF_LONG 4 -#elif ULONG_MAX > 0xFFFFFFFFU && ULONG_MAX == 0xFFFFFFFFFFFFFFFFU -# define OTL_SIZEOF_LONG 8 -#else -# error "unsupported number of bytes in 'long' type!" -#endif - -#include <setjmp.h> -#define OTL_jmp_buf jmp_buf -#define otl_setjmp setjmp -#define otl_longjmp longjmp - -/* */ - -#endif /* __OT_LAYOUT_CONFIG_H__ */ diff --git a/src/libs/freetype2/otlayout/otlgdef.c b/src/libs/freetype2/otlayout/otlgdef.c deleted file mode 100644 index ff1c2a1e86..0000000000 --- a/src/libs/freetype2/otlayout/otlgdef.c +++ /dev/null @@ -1,175 +0,0 @@ -#include "otlgdef.h" -#include "otlcommn.h" - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** ATTACHMENTS LIST *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_attach_point_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - if ( p + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - count = OTL_NEXT_USHORT( p ); - if ( table + count*2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - } - - - static void - otl_attach_list_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_Bytes coverage; - OTL_UInt count; - - if ( p + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - coverage = table + OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( coverage, valid ); - if ( count != otl_coverage_get_count( coverage ) ) - OTL_INVALID_DATA; - - if ( p + count*2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; count > 0; count-- ) - otl_attach_point_validate( table + OTL_NEXT_USHORT( p ) ); - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** LIGATURE CARETS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_caret_value_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - - if ( p + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - case 2: - break; - - case 3: - { - OTL_Bytes device; - - p += 2; - if ( p + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - otl_device_table_validate( table + OTL_PEEK_USHORT( p ) ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - static void - otl_ligature_glyph_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - if ( p + 2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - count = OTL_NEXT_USHORT( p ); - - if ( p + count*2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; count > 0; count-- ) - otl_caret_value_validate( table + OTL_NEXT_USHORT( p ) ); - } - - - static void - otl_ligature_caret_list_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_Bytes coverage; - OTL_UInt count; - - if ( p + 4 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - coverage = table + OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( coverage, valid ); - if ( count != otl_coverage_get_count( coverage ) ) - OTL_INVALID_DATA; - - if ( p + count*2 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - for ( ; count > 0; count-- ) - otl_ligature_glyph_validate( table + OTL_NEXT_USHORT( p ) ); - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GDEF TABLE *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - OTL_APIDEF( void ) - otl_gdef_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - - if ( p + 12 > valid->limit ) - OTL_INVALID_TOO_SHORT; - - /* check format */ - if ( OTL_NEXT_ULONG( p ) != 0x00010000UL ) - OTL_INVALID_FORMAT; - - /* validate class definition table */ - otl_class_definition_validate( table + OTL_NEXT_USHORT( p ) ); - - /* validate attachment point list */ - otl_attach_list_validate( table + OTL_NEXT_USHORT( p ) ); - - /* validate ligature caret list */ - otl_ligature_caret_list_validate( table + OTL_NEXT_USHORT( p ) ); - - /* validate mark attach class */ - otl_class_definition_validate( table + OTL_NEXT_USHORT( p ) ); - } - diff --git a/src/libs/freetype2/otlayout/otlgdef.h b/src/libs/freetype2/otlayout/otlgdef.h deleted file mode 100644 index 5046cc4364..0000000000 --- a/src/libs/freetype2/otlayout/otlgdef.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __OTL_GDEF_H__ -#define __OTL_GDEF_H__ - -#include "otltable.h" - -OTL_BEGIN_HEADER - - OTL_API( void ) - otl_gdef_validate( OTL_Bytes table, - OTL_Valid valid ); - -OTL_END_HEADER - -#endif /* __OTL_GDEF_H__ */ diff --git a/src/libs/freetype2/otlayout/otlgpos.c b/src/libs/freetype2/otlayout/otlgpos.c deleted file mode 100644 index 01942d7f05..0000000000 --- a/src/libs/freetype2/otlayout/otlgpos.c +++ /dev/null @@ -1,980 +0,0 @@ -#include "otlgpos.h" -#include "otlcommn.h" - - /* forward declaration */ - static OTL_ValidateFunc otl_gpos_validate_funcs[]; - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** VALUE RECORDS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static OTL_UInt - otl_value_length( OTL_UInt format ) - { - FT_UInt count; - - count = (( format & 0xAA ) >> 1) + ( format & 0x55 ); - count = (( count & 0xCC ) >> 2) + ( count & 0x33 ); - count = (( count & 0xF0 ) >> 4) + ( count & 0x0F ); - - return count; - } - - - static void - otl_value_validate( OTL_Bytes table, - OTL_Bytes pos_table, - OTL_UInt format, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count, device; - - if ( format >= 0x100U ) - OTL_INVALID_DATA; - - for ( count = 4; count > 0; count-- ) - { - if ( format & 1 ) - { - OTL_CHECK( 2 ); - p += 2; - } - - format >>= 1; - } - - for ( count = 4; count > 0; count-- ) - { - if ( format & 1 ) - { - OTL_CHECK( 2 ); - device = OTL_NEXT_USHORT( p ); - if ( device ) - otl_device_table_validate( pos_table + device, valid ); - } - format >>= 1; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** ANCHORS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_anchor_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 6 ); - format = OTL_NEXT_USHORT( p ); - p += 4; - - switch ( format ) - { - case 1: - break; - - case 2: - OTL_CHECK( 2 ); /* anchor point */ - break; - - case 3: - { - OTL_UInt x_device, y_device; - - OTL_CHECK( 4 ); - x_device = OTL_NEXT_USHORT( p ); - y_device = OTL_NEXT_USHORT( p ); - - if ( x_device ) - otl_device_table_validate( table + x_device, valid ); - - if ( y_device ) - otl_device_table_validate( table + y_device, valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** MARK ARRAY *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_mark_array_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( count * 4 ); - for ( ; count > 0; count-- ) - { - p += 2; /* ignore class index */ - otl_anchor_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 1 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_gpos_lookup1_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - FT_UInt coverage, value_format; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - value_format = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - otl_value_validate( p, table, value_format, valid ); - } - break; - - case 2: - { - FT_UInt coverage, value_format, count, len; - - OTL_CHECK( 6 ); - coverage = OTL_NEXT_USHORT( p ); - value_format = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - len = otl_value_length( value_format ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( count * len ); - for ( ; count > 0; count-- ) - { - otl_value_validate( p, table, value_format, valid ); - p += len; - } - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 2 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static otl_gpos_pairset_validate( OTL_Bytes table, - OTL_Bytes pos_table, - OTL_UInt format1, - OTL_UInt format2, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt len1, len2, count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - len1 = otl_value_length( format1 ); - len2 = otl_value_length( format2 ); - - OTL_CHECK( count * (len1+len2+2) ); - for ( ; count > 0; count-- ) - { - p += 2; /* ignore glyph id */ - otl_value_validate( p, pos_table, format1, valid ); - p += len1; - - otl_value_validate( p, pos_table, format2, valid ); - p += len2; - } - } - - static void - otl_gpos_lookup2_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt coverage, value1, value2, count; - - OTL_CHECK( 8 ); - coverage = OTL_NEXT_USHORT( p ); - value1 = OTL_NEXT_USHORT( p ); - value2 = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - { - otl_gpos_pairset_validate( table + OTL_NEXT_USHORT( p ), - table, value1, value2, valid ); - } - } - break; - - case 2: - { - OTL_UInt coverage, value1, value2, class1, class2, count1, count2; - OTL_UInt len1, len2; - - OTL_CHECK( 14 ); - coverage = OTL_NEXT_USHORT( p ); - value1 = OTL_NEXT_USHORT( p ); - value2 = OTL_NEXT_USHORT( p ); - class1 = OTL_NEXT_USHORT( p ); - class2 = OTL_NEXT_USHORT( p ); - count1 = OTL_NEXT_USHORT( p ); - count2 = OTL_NEXT_USHORT( p ); - - len1 = otl_value_length( value1 ); - len2 = otl_value_length( value2 ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( count1*count2*(len1+len2) ); - for ( ; count1 > 0; count1-- ) - { - for ( ; count2 > 0; count2-- ) - { - otl_value_validate( p, table, value1, valid ); - p += len1; - - otl_value_validate( p, table, value2, valid ); - p += len2; - } - } - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 3 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_gpos_lookup3_validate( OTL_Bytes table, - OTL_Valid valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt coverage, count, anchor1, anchor2; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( count*4 ); - for ( ; count > 0; count-- ) - { - anchor1 = OTL_NEXT_USHORT( p ); - anchor2 = OTL_NEXT_USHORT( p ); - - if ( anchor1 ) - otl_anchor_validate( table + anchor1, valid ); - - if ( anchor2 ) - otl_anchor_validate( table + anchor2, valid ); - } - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 4 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_base_array_validate( OTL_Bytes table, - OTL_UInt class_count, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count, count2; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*class_count*2 ); - for ( ; count > 0; count-- ) - for ( count2 = class_count; count2 > 0; count2-- ) - otl_anchor_validate( table + OTL_NEXT_USHORT( p ) ); - } - - - static void - otl_gpos_lookup4_validate( OTL_Bytes table, - OTL_Valid valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt mark_coverage, base_coverage, class_count; - OTL_UInt mark_array, base_array; - - OTL_CHECK( 10 ); - mark_coverage = OTL_NEXT_USHORT( p ); - base_coverage = OTL_NEXT_USHORT( p ); - class_count = OTL_NEXT_USHORT( p ); - mark_array = OTL_NEXT_USHORT( p ); - base_array = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + mark_coverage, valid ); - otl_coverage_validate( table + base_coverage, valid ); - - otl_mark_array_validate( table + mark_array, valid ); - otl_base_array_validate( table, class_count, valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 5 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_liga_attach_validate( OTL_Bytes table, - OTL_UInt class_count, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count, count2; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*class_count*2 ); - for ( ; count > 0; count-- ) - for ( count2 = class_count; class_count > 0; class_count-- ) - otl_anchor_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_liga_array_validate( OTL_Bytes table, - OTL_UInt class_count, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count, count2; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_liga_attach_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_gpos_lookup5_validate( OTL_Bytes table, - OTL_Valid valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt mark_coverage, lig_coverage, class_count; - OTL_UInt mar_array, lig_array; - - OTL_CHECK( 10 ); - mark_coverage = OTL_NEXT_USHORT( p ); - liga_coverage = OTL_NEXT_USHORT( p ); - class_count = OTL_NEXT_USHORT( p ); - mark_array = OTL_NEXT_USHORT( p ); - liga_array = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + mark_coverage, valid ); - otl_coverage_validate( table + liga_coverage, valid ); - - otl_mark_array_validate( table + mark_array, valid ); - otl_liga_array_validate( table + liga_array, class_count, valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 6 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - static void - otl_mark2_array_validate( OTL_Bytes table, - OTL_UInt class_count, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count, count2; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*class_count*2 ); - for ( ; count > 0; count-- ) - for ( count2 = class_count; class_count > 0; class_count-- ) - otl_anchor_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_gpos_lookup6_validate( OTL_Bytes table, - OTL_Valid valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt coverage1, coverage2, class_count, array1, array2; - - OTL_CHECK( 10 ); - coverage1 = OTL_NEXT_USHORT( p ); - coverage2 = OTL_NEXT_USHORT( p ); - class_count = OTL_NEXT_USHORT( p ); - array1 = OTL_NEXT_USHORT( p ); - array2 = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage1, valid ); - otl_coverage_validate( table + coverage2, valid ); - - otl_mark_array_validate( table + array1, valid ); - otl_mark2_array_validate( table + array2, valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 7 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_pos_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt glyph_count, pos_count; - - OTL_CHECK( 4 ); - glyph_count = OTL_NEXT_USHORT( p ); - pos_count = OTL_NEXT_USHORT( p ); - - if ( glyph_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( (glyph_count-1)*2 + pos_count*4 ); - - /* XXX: check glyph indices and pos lookups */ - } - - - static void - otl_pos_rule_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_pos_rule_validate( table + OTL_NEXT_USHORT(p), valid ); - } - - - - static void - otl_pos_class_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt glyph_count, pos_count; - - OTL_CHECK( 4 ); - glyph_count = OTL_NEXT_USHORT( p ); - pos_count = OTL_NEXT_USHORT( p ); - - if ( glyph_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( (glyph_count-1)*2 + pos_count*4 ); - - /* XXX: check glyph indices and pos lookups */ - } - - - static void - otl_pos_class_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_pos_rule_validate( table + OTL_NEXT_USHORT(p), valid ); - } - - - static void - otl_gpos_lookup7_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_pos_rule_set_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - break; - - case 2: - { - OTL_UInt coverage, class_def, count; - - OTL_CHECK( 6 ); - coverage = OTL_NEXT_USHORT( p ); - class_def = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate ( table + coverage, valid ); - otl_class_definition_validate( table + class_def, valid ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_ - } - break; - - case 3: - { - OTL_UInt glyph_count, pos_count; - - OTL_CHECK( 4 ); - glyph_count = OTL_NEXT_USHORT( p ); - pos_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( glyph_count*2 + pos_count*4 ); - for ( ; glyph_count > 0; glyph_count ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - /* XXX: check pos lookups */ - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 8 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_chain_pos_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt back_count, input_count, ahead_count, pos_count; - - OTL_CHECK( 2 ); - back_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( back_count*2 + 2 ); - p += back_count*2; - - input_count = OTL_NEXT_USHORT( p ); - if ( input_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( input_count*2 ); - p += (input_count-1)*2; - - ahead_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( ahead_count*2 + 2 ); - p += ahead_count*2; - - pos_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( pos_count*4 ); - } - - - static void - otl_chain_pos_rule_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_chain_pos_rule_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - - static void - otl_chain_pos_class_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt back_count, input_count, ahead_count, pos_count; - - OTL_CHECK( 2 ); - back_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( back_count*2 + 2 ); - p += back_count*2; - - input_count = OTL_NEXT_USHORT( p ); - if ( input_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( input_count*2 ); - p += (input_count-1)*2; - - ahead_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( ahead_count*2 + 2 ); - p += ahead_count*2; - - pos_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( pos_count*4 ); - } - - - static void - otl_chain_pos_class_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_chain_pos_class_rule_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_gpos_lookup8_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_chain_pos_rule_set_validate( table + OTL_NEXT_USHORT( p ), - valid ); - } - break; - - case 2: - { - OTL_UInt coverage, back_class, input_class, ahead_class, count; - - OTL_CHECK( 10 ); - coverage = OTL_NEXT_USHORT( p ); - back_class = OTL_NEXT_USHORT( p ); - input_class = OTL_NEXT_USHORT( p ); - ahead_class = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - otl_class_definition_validate( table + back_class, valid ); - otl_class_definition_validate( table + input_class, valid ); - otl_class_definition_validate( table + ahead_class, valid ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_chain_pos_class_set_validate( table + OTL_NEXT_USHORT( p ), - valid ); - } - break; - - case 3: - { - OTL_UInt back_count, input_count, ahead_count, pos_count, count; - - OTL_CHECK( 2 ); - back_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*back_count+2 ); - for ( count = back_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - input_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*input_count+2 ); - for ( count = input_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - ahead_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*ahead_count+2 ); - for ( count = ahead_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - pos_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( pos_count*4 ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS LOOKUP TYPE 9 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_gpos_lookup9_validate( OTL_Bytes table, - OTL_Valid valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch (format) - { - case 1: - { - OTL_UInt lookup_type, lookup_offset; - OTL_ValidateFunc validate; - - OTL_CHECK( 6 ); - lookup_type = OTL_NEXT_USHORT( p ); - lookup_offset = OTL_NEXT_ULONG( p ); - - if ( lookup_type == 0 || lookup_type >= 9 ) - OTL_INVALID_DATA; - - validate = otl_gpos_validate_funcs[ lookup_type-1 ]; - validate( table + lookup_offset, valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - static OTL_ValidateFunc otl_gpos_validate_funcs[ 9 ] = - { - otl_gpos_lookup1_validate, - otl_gpos_lookup2_validate, - otl_gpos_lookup3_validate, - otl_gpos_lookup4_validate, - otl_gpos_lookup5_validate, - otl_gpos_lookup6_validate, - otl_gpos_lookup7_validate, - otl_gpos_lookup8_validate, - otl_gpos_lookup9_validate, - }; - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GPOS TABLE *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - OTL_LOCALDEF( void ) - otl_gpos_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt scripts, features, lookups; - - OTL_CHECK( 10 ); - - if ( OTL_NEXT_USHORT( p ) != 0x10000UL ) - OTL_INVALID_DATA; - - scripts = OTL_NEXT_USHORT( p ); - features = OTL_NEXT_USHORT( p ); - lookups = OTL_NEXT_USHORT( p ); - - otl_script_list_validate ( table + scripts, valid ); - otl_feature_list_validate( table + features, valid ); - - otl_lookup_list_validate( table + lookups, 9, otl_gpos_validate_funcs, - valid ); - } - \ No newline at end of file diff --git a/src/libs/freetype2/otlayout/otlgpos.h b/src/libs/freetype2/otlayout/otlgpos.h deleted file mode 100644 index 1d10cab495..0000000000 --- a/src/libs/freetype2/otlayout/otlgpos.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __OTL_GPOS_H__ -#define __OTL_GPOS_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - OTL_LOCAL( void ) - otl_gpos_validate( OTL_Bytes table, - OTL_Validator valid ); - -OTL_END_HEADER - -#endif /* __OTL_GPOS_H__ */ diff --git a/src/libs/freetype2/otlayout/otlgsub.c b/src/libs/freetype2/otlayout/otlgsub.c deleted file mode 100644 index 13a8eae98d..0000000000 --- a/src/libs/freetype2/otlayout/otlgsub.c +++ /dev/null @@ -1,867 +0,0 @@ -#include "otlgsub.h" -#include "otlcommn.h" - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 1 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - /* - * 1: Single Substitution - Table format(s) - * - * This table is used to substiture individual glyph indices - * with another one. There are only two sub-formats: - * - * Name Offset Size Description - * ------------------------------------------ - * format 0 2 sub-table format (1) - * offset 2 2 offset to coverage table - * delta 4 2 16-bit delta to apply on all - * covered glyph indices - * - * Name Offset Size Description - * ------------------------------------------ - * format 0 2 sub-table format (2) - * offset 2 2 offset to coverage table - * count 4 2 coverage table count - * substs[] 6 2*count substituted glyph indices, - * - */ - - static void - otl_gsub_lookup1_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt coverage; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - } - break; - - case 2: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( 2*count ); - - /* NB: we don't check that there are at most 'count' */ - /* elements in the coverage table. This is delayed */ - /* to the lookup function... */ - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - static OTL_Bool - otl_gsub_lookup1_apply( OTL_Bytes table, - OTL_Parser parser ) - { - OTL_Bytes p = table; - OTL_Bytes coverage; - OTL_UInt format, gindex, property; - OTL_Int index; - OTL_Bool subst = 0; - - if ( parser->context_len != 0xFFFFU && parser->context_len < 1 ) - goto Exit; - - gindex = otl_parser_get_gindex( parser ); - - if ( !otl_parser_check_property( parser, gindex, &property ) ) - goto Exit; - - format = OTL_NEXT_USHORT(p); - coverage = table + OTL_NEXT_USHORT(p); - index = otl_coverage_lookup( coverage, gindex ); - - if ( index >= 0 ) - { - switch ( format ) - { - case 1: - { - OTL_Int delta = OTL_NEXT_SHORT(p); - - gindex = ( gindex + delta ) & 0xFFFFU; - otl_parser_replace_1( parser, gindex ); - subst = 1; - } - break; - - case 2: - { - OTL_UInt count = OTL_NEXT_USHORT(p); - - if ( (OTL_UInt) index < count ) - { - p += index*2; - otl_parser_replace_1( parser, OTL_PEEK_USHORT(p) ); - subst = 1; - } - } - break; - - default: - ; - } - } - Exit: - return subst; - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 2 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - /* - * 2: Multiple Substitution - Table format(s) - * - * Replaces a single glyph with one or more glyphs. - * - * Name Offset Size Description - * ----------------------------------------------------------- - * format 0 2 sub-table format (1) - * offset 2 2 offset to coverage table - * count 4 2 coverage table count - * sequencess[] 6 2*count offsets to sequence items - * - * each sequence item has the following format: - * - * Name Offset Size Description - * ----------------------------------------------------------- - * count 0 2 number of replacement glyphs - * gindices[] 2 2*count string of glyph indices - */ - - static void - otl_seq_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - /* XXX: according to the spec, 'count' should be > 0 */ - /* we can deal with these cases pretty well however */ - - OTL_CHECK( 2*count ); - /* check glyph indices */ - } - - - static void - otl_gsub_lookup2_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format, coverage; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt coverage, seq_count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - seq_count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( seq_count*2 ); - for ( ; seq_count > 0; seq_count-- ) - otl_seq_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - static OTL_Bool - otl_gsub_lookup2_apply( OTL_Bytes table, - OTL_Parser parser ) - { - OTL_Bytes p = table; - OTL_Bytes coverage, sequence; - OTL_UInt format, gindex, index, property; - OTL_Int index; - OTL_Bool subst = 0; - - if ( context_len != 0xFFFFU && context_len < 1 ) - goto Exit; - - gindex = otl_parser_get_gindex( parser ); - - if ( !otl_parser_check_property( parser, gindex, &property ) ) - goto Exit; - - p += 2; /* skip format */ - coverage = table + OTL_NEXT_USHORT(p); - seq_count = OTL_NEXT_USHORT(p); - index = otl_coverage_lookup( coverage, gindex ); - - if ( (OTL_UInt) index >= seq_count ) - goto Exit; - - p += index*2; - sequence = table + OTL_PEEK_USHORT(p); - p = sequence; - count = OTL_NEXT_USHORT(p); - - otl_parser_replace_n( parser, count, p ); - subst = 1; - - Exit: - return subst; - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 3 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - /* - * 3: Alternate Substitution - Table format(s) - * - * Replaces a single glyph by another one taken liberally - * in a list of alternatives - * - * Name Offset Size Description - * ----------------------------------------------------------- - * format 0 2 sub-table format (1) - * offset 2 2 offset to coverage table - * count 4 2 coverage table count - * alternates[] 6 2*count offsets to alternate items - * - * each alternate item has the following format: - * - * Name Offset Size Description - * ----------------------------------------------------------- - * count 0 2 number of replacement glyphs - * gindices[] 2 2*count string of glyph indices, each one - * is a valid alternative - */ - - static void - otl_alternate_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - /* XXX: check glyph indices */ - } - - - static void - otl_gsub_lookup3_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format, coverage; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_alternate_set_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - static OTL_Bool - otl_gsub_lookup3_apply( OTL_Bytes table, - OTL_Parser parser ) - { - OTL_Bytes p = table; - OTL_Bytes coverage, alternates; - OTL_UInt format, gindex, index, property; - OTL_Int index; - OTL_Bool subst = 0; - - OTL_GSUB_Alternate alternate = parser->alternate; - - if ( context_len != 0xFFFFU && context_len < 1 ) - goto Exit; - - if ( alternate == NULL ) - goto Exit; - - gindex = otl_parser_get_gindex( parser ); - - if ( !otl_parser_check_property( parser, gindex, &property ) ) - goto Exit; - - p += 2; /* skip format */ - coverage = table + OTL_NEXT_USHORT(p); - seq_count = OTL_NEXT_USHORT(p); - index = otl_coverage_lookup( coverage, gindex ); - - if ( (OTL_UInt) index >= seq_count ) - goto Exit; - - p += index*2; - alternates = table + OTL_PEEK_USHORT(p); - p = alternates; - count = OTL_NEXT_USHORT(p); - - gindex = alternate->handler_func( - gindex, count, p, alternate->handler_data ); - - otl_parser_replace_1( parser, gindex ); - subst = 1; - - Exit: - return subst; - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 4 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_ligature_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_UInt glyph_id, count; - - OTL_CHECK( 4 ); - glyph_id = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - if ( count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( 2*(count-1) ); - /* XXX: check glyph indices */ - } - - - static void - otl_ligature_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_ligature_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_gsub_lookup4_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format, coverage; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_ligature_set_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 5 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - static void - otl_sub_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt glyph_count, subst_count; - - OTL_CHECK( 4 ); - glyph_count = OTL_NEXT_USHORT( p ); - subst_count = OTL_NEXT_USHORT( p ); - - if ( glyph_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( (glyph_count-1)*2 + substcount*4 ); - - /* XXX: check glyph indices and subst lookups */ - } - - - static void - otl_sub_rule_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_sub_rule_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_sub_class_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_UInt glyph_count, subst_count; - - OTL_CHECK( 4 ); - glyph_count = OTL_NEXT_USHORT( p ); - subst_count = OTL_NEXT_USHORT( p ); - - if ( glyph_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( (glyph_count-1)*2 + substcount*4 ); - - /* XXX: check glyph indices and subst lookups */ - } - - - static void - otl_sub_class_rule_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_sub_class_rule_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_gsub_lookup5_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format, coverage; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_sub_rule_set_validate( table + coverage, valid ); - } - break; - - case 2: - { - OTL_UInt coverage, class_def, count; - - OTL_CHECK( 6 ); - coverage = OTL_NEXT_USHORT( p ); - class_def = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate ( table + coverage, valid ); - otl_class_definition_validate( table + class_def, valid ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_sub_class_rule_set_validate( table + coveragen valid ); - } - break; - - case 3: - { - OTL_UInt glyph_count, subst_count, count; - - OTL_CHECK( 4 ); - glyph_count = OTL_NEXT_USHORT( p ); - subst_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*glyph_count + 4*subst_count ); - for ( count = glyph_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 6 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - static void - otl_chain_sub_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt back_count, input_count, ahead_count, subst_count, count; - - OTL_CHECK( 2 ); - back_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*back_count+2 ); - p += 2*back_count; - - input_count = OTL_NEXT_USHORT( p ); - if ( input_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( 2*input_count ); - p += 2*(input_count-1); - - ahead_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( 2*ahead_count + 2 ); - p += 2*ahead_count; - - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( 4*count ); - - /* XXX: check glyph indices and subst lookups */ - } - - - static void - otl_chain_sub_rule_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_chain_sub_rule_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_chain_sub_class_rule_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt back_count, input_count, ahead_count, subst_count, count; - - OTL_CHECK( 2 ); - back_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*back_count+2 ); - p += 2*back_count; - - input_count = OTL_NEXT_USHORT( p ); - if ( input_count == 0 ) - OTL_INVALID_DATA; - - OTL_CHECK( 2*input_count ); - p += 2*(input_count-1); - - ahead_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( 2*ahead_count + 2 ); - p += 2*ahead_count; - - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( 4*count ); - - /* XXX: check class indices and subst lookups */ - } - - - - static void - otl_chain_sub_class_set_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_chain_sub_rule_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_gsub_lookup6_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format, coverage; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt coverage, count; - - OTL_CHECK( 4 ); - coverage = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_chain_sub_rule_set_validate( table + coverage, valid ); - } - break; - - case 2: - { - OTL_UInt coverage, back_class, input_class, ahead_class, count; - - OTL_CHECK( 10 ); - coverage = OTL_NEXT_USHORT( p ); - back_class = OTL_NEXT_USHORT( p ); - input_class = OTL_NEXT_USHORT( p ); - ahead_class = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - otl_coverage_validate( table + coverage, valid ); - - otl_class_definition_validate( table + back_class, valid ); - otl_class_definition_validate( table + input_class, valid ); - otl_class_definition_validate( table + ahead_class, valid ); - - OTL_CHECK( 2*count ); - for ( ; count > 0; count-- ) - otl_chain_sub_class_set( table + OTL_NEXT_USHORT( p ), valid ); - } - break; - - case 3: - { - OTL_UInt back_count, input_count, ahead_count, subst_count, count; - - OTL_CHECK( 2 ); - back_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*back_count+2 ); - for ( count = back_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - input_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*input_count+2 ); - for ( count = input_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - ahead_count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( 2*ahead_count+2 ); - for ( count = ahead_count; count > 0; count-- ) - otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid ); - - subst_count = OTL_NEXT_USHORT( p ); - OTL_CHECK( subst_count*4 ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB LOOKUP TYPE 6 *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - static void - otl_gsub_lookup7_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt format, coverage; - - OTL_CHECK( 2 ); - format = OTL_NEXT_USHORT( p ); - switch ( format ) - { - case 1: - { - OTL_UInt lookup_type, lookup_offset; - OTL_ValidateFunc validate; - - OTL_CHECK( 6 ); - lookup_type = OTL_NEXT_USHORT( p ); - lookup_offset = OTL_NEXT_ULONG( p ); - - if ( lookup_type == 0 || lookup_type >= 7 ) - OTL_INVALID_DATA; - - validate = otl_gsub_validate_funcs[ lookup_type-1 ]; - validate( table + lookup_offset, valid ); - } - break; - - default: - OTL_INVALID_DATA; - } - } - - - static const OTL_ValidateFunc otl_gsub_validate_funcs[ 7 ] = - { - otl_gsub_lookup1_validate, - otl_gsub_lookup2_validate, - otl_gsub_lookup3_validate, - otl_gsub_lookup4_validate, - otl_gsub_lookup5_validate, - otl_gsub_lookup6_validate - }; - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** GSUB TABLE *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - - - OTL_LOCALDEF( void ) - otl_gsub_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt scripts, features, lookups; - - OTL_CHECK( 10 ); - - if ( OTL_NEXT_USHORT( p ) != 0x10000UL ) - OTL_INVALID_DATA; - - scripts = OTL_NEXT_USHORT( p ); - features = OTL_NEXT_USHORT( p ); - lookups = OTL_NEXT_USHORT( p ); - - otl_script_list_validate ( table + scripts, valid ); - otl_feature_list_validate( table + features, valid ); - - otl_lookup_list_validate( table + lookups, 7, otl_gsub_validate_funcs, - valid ); - } diff --git a/src/libs/freetype2/otlayout/otlgsub.h b/src/libs/freetype2/otlayout/otlgsub.h deleted file mode 100644 index db5edecf12..0000000000 --- a/src/libs/freetype2/otlayout/otlgsub.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __OTL_GSUB_H__ -#define __OTL_GSUB_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - typedef OTL_UInt (*OTL_GSUB_AlternateFunc)( OTL_UInt gindex, - OTL_UInt count, - OTL_Bytes alternates, - OTL_Pointer data ); - - typedef struct OTL_GSUB_AlternateRec_ - { - OTL_GSUB_AlternateFunc handler_func; - OTL_Pointer handler_data; - - } OTL_GSUB_AlternateRec, *OTL_GSUB_Alternate; - - OTL_LOCAL( void ) - otl_gsub_validate( OTL_Bytes table, - OTL_Validator valid ); - -OTL_END_HEADER - -#endif /* __OTL_GSUB_H__ */ diff --git a/src/libs/freetype2/otlayout/otljstf.c b/src/libs/freetype2/otlayout/otljstf.c deleted file mode 100644 index b0fa9f406a..0000000000 --- a/src/libs/freetype2/otlayout/otljstf.c +++ /dev/null @@ -1,189 +0,0 @@ -#include "otljstf.h" -#include "otlcommn.h" -#include "otlgpos.h" - - static void - otl_jstf_extender_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - } - - - static void - otl_jstf_gsub_mods_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( count*2 ); - - /* XXX: check GSUB lookup indices */ - } - - - static void - otl_jstf_gpos_mods_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( count*2 ); - - /* XXX: check GPOS lookup indices */ - } - - - static void - otl_jstf_max_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_gpos_subtable_check( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_jstf_priority_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt offset; - - OTL_CHECK( 20 ); - - /* shrinkage GSUB enable/disable */ - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gsub_mods_validate( table + val, valid ); - - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gsub_mods_validate( table + val, valid ); - - /* shrinkage GPOS enable/disable */ - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gpos_mods_validate( table + val, valid ); - - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gpos_mods_validate( table + val, valid ); - - /* shrinkage JSTF max */ - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_max_validate( table + val, valid ); - - /* extension GSUB enable/disable */ - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gsub_mods_validate( table + val, valid ); - - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gsub_mods_validate( table + val, valid ); - - /* extension GPOS enable/disable */ - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gpos_mods_validate( table + val, valid ); - - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_gpos_mods_validate( table + val, valid ); - - /* extension JSTF max */ - val = OTL_NEXT_USHORT( p ); - if ( val ) - otl_jstf_max_validate( table + val, valid ); - } - - static void - otl_jstf_lang_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 2 ); - - count = OTL_NEXT_USHORT( p ); - - OTL_CHECK( count*2 ); - for ( ; count > 0; count-- ) - otl_jstf_priority_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - - - static void - otl_jstf_script_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count, extender, default_lang; - - OTL_CHECK( 6 ); - extender = OTL_NEXT_USHORT( p ); - default_lang = OTL_NEXT_USHORT( p ); - count = OTL_NEXT_USHORT( p ); - - if ( extender ) - otl_jstf_extender_validate( table + extender, valid ); - - if ( default_lang ) - otl_jstf_lang_validate( table + default_lang, valid ); - - OTL_CHECK( 6*count ); - - for ( ; count > 0; count-- ) - { - p += 4; /* ignore tag */ - otl_jstf_lang_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - } - - - OTL_LOCALDEF( void ) - otl_jstf_validate( OTL_Bytes table, - OTL_Validator valid ) - { - OTL_Bytes p = table; - OTL_UInt count; - - OTL_CHECK( 4 ); - - if ( OTL_NEXT_ULONG( p ) != 0x10000UL ) - OTL_INVALID_DATA; - - count = OTL_NEXT_USHORT( p ); - OTL_CHECK( count*6 ); - - for ( ; count > 0; count++ ) - { - p += 4; /* ignore tag */ - otl_jstf_script_validate( table + OTL_NEXT_USHORT( p ), valid ); - } - } - \ No newline at end of file diff --git a/src/libs/freetype2/otlayout/otljstf.h b/src/libs/freetype2/otlayout/otljstf.h deleted file mode 100644 index c8a98a64a1..0000000000 --- a/src/libs/freetype2/otlayout/otljstf.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __OTL_JSTF_H__ -#define __OTL_JSTF_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - OTL_LOCAL( void ) - otl_jstf_validate( OTL_Bytes table, - OTL_Validator valid ); - -OTL_END_HEADER - -#endif /* __OTL_JSTF_H__ */ \ No newline at end of file diff --git a/src/libs/freetype2/otlayout/otlparse.c b/src/libs/freetype2/otlayout/otlparse.c deleted file mode 100644 index 705c0c60fa..0000000000 --- a/src/libs/freetype2/otlayout/otlparse.c +++ /dev/null @@ -1,142 +0,0 @@ -#include "otlparse.h" -#include "otlutils.h" - - static void - otl_string_ensure( OTL_String string, - OTL_UInt count, - OTL_Parser parser ) - { - count += string->length; - - if ( count > string->capacity ) - { - OTL_UInt old_count = string->capacity; - OTL_UInt new_count = old_count; - OTL_Memory memory = parser->memory; - - while ( new_count < count ) - new_count += (new_count >> 1) + 16; - - if ( OTL_MEM_RENEW_ARRAY( string->glyphs, old_count, new_count ) ) - otl_parser_error( parser, OTL_Parse_Err_Memory ); - - string->capacity = new_count; - } - } - -#define OTL_STRING_ENSURE(str,count,parser) \ - OTL_BEGIN_STMNT \ - if ( (str)->length + (count) > (str)>capacity ) \ - otl_string_ensure( str, count, parser ); \ - OTL_END_STMNT - - - OTL_LOCALDEF( OTL_UInt ) - otl_parser_get_gindex( OTL_Parser parser ) - { - OTL_String in = parser->str_in; - - if ( in->cursor >= in->num_glyphs ) - otl_parser_error( parser, OTL_Err_Parser_Internal ); - - return in->str[ in->cursor ].gindex; - } - - - OTL_LOCALDEF( void ) - otl_parser_error( OTL_Parser parser, - OTL_ParseError error; ) - { - parser->error = error; - otl_longjmp( parser->jump_buffer, 1 ); - } - -#define OTL_PARSER_UNCOVERED(x) otl_parser_error( x, OTL_Parse_Err_UncoveredGlyph ); - - OTL_LOCAL( void ) - otl_parser_check_property( OTL_Parser parser, - OTL_UInt gindex, - OTL_UInt flags, - OTL_UInt *aproperty ); - - OTL_LOCALDEF( void ) - otl_parser_replace_1( OTL_Parser parser, - OTL_UInt gindex ) - { - OTL_String in = parser->str_in; - OTL_String out = parser->str_out; - OTL_StringGlyph glyph, in_glyph; - - /* sanity check */ - if ( in == NULL || - out == NULL || - in->length == 0 || - in->cursor >= in->length ) - { - /* report as internal error, since these should */ - /* never happen !! */ - otl_parser_error( parser, OTL_Err_Parse_Internal ); - } - - OTL_STRING_ENSURE( out, 1, parser ); - glyph = out->glyphs + out->length; - in_glyph = in->glyphs + in->cursor; - - glyph->gindex = gindex; - glyph->property = in_glyph->property; - glyph->lig_component = in_glyph->lig_component; - glyph->lig_id = in_glyph->lig_id; - - out->length += 1; - out->cursor = out->length; - in->cursor += 1; - } - - OTL_LOCALDEF( void ) - otl_parser_replace_n( OTL_Parser parser, - OTL_UInt count, - OTL_Bytes indices ) - { - OTL_UInt lig_component, lig_id, property; - OTL_String in = parser->str_in; - OTL_String out = parser->str_out; - OTL_StringGlyph glyph, in_glyph; - OTL_Bytes p = indices; - - /* sanity check */ - if ( in == NULL || - out == NULL || - in->length == 0 || - in->cursor >= in->length ) - { - /* report as internal error, since these should */ - /* never happen !! */ - otl_parser_error( parser, OTL_Err_Parse_Internal ); - } - - OTL_STRING_ENSURE( out, count, parser ); - glyph = out->glyphs + out->length; - in_glyph = in->glyphs + in->cursor; - - glyph->gindex = gindex; - - lig_component = in_glyph->lig_component; - lig_id = in_glyph->lid_id; - property = in_glyph->property; - - for ( ; count > 0; count-- ) - { - glyph->gindex = OTL_NEXT_USHORT(p); - glyph->property = property; - glyph->lig_component = lig_component; - glyph->lig_id = lig_id; - - out->length ++; - } - - out->cursor = out->length; - in->cursor += 1; - } - - - diff --git a/src/libs/freetype2/otlayout/otlparse.h b/src/libs/freetype2/otlayout/otlparse.h deleted file mode 100644 index 92f34bfdc2..0000000000 --- a/src/libs/freetype2/otlayout/otlparse.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __OTL_PARSER_H__ -#define __OTL_PARSER_H__ - -#include "otlayout.h" -#include "otlgdef.h" -#include "otlgsub.h" -#include "otlgpos.h" - -OTL_BEGIN_HEADER - - typedef struct OTL_ParserRec_* OTL_Parser; - - typedef struct OTL_StringRec_* OTL_String; - - typedef struct OTL_StringGlyphRec_ - { - OTL_UInt gindex; - OTL_UInt properties; - OTL_UInt lig_component; - OTL_UInt lig_id; - - } OTL_StringGlyphRec, *OTL_StringGlyph; - - typedef struct OTL_StringRec_ - { - OTL_StringGlyph glyphs; - OTL_UInt cursor; - OTL_UInt length; - OTL_UInt capacity; - - } OTL_StringRec; - - typedef struct OTL_ParserRec_ - { - OTL_Bytes tab_gdef; - OTL_Bytes tab_gsub; - OTL_Bytes tab_gpos; - OTL_Bytes tab_base; - OTL_Bytes tab_jstf; - - OTL_Alternate alternate; /* external alternate handler */ - - OTL_UInt context_len; - OTL_UInt markup_flags; - - OTL_jmp_buf jump_buffer; - OTL_Memory memory; - OTL_Error error; - - OTL_StringRec strings[2]; - OTL_String str_in; - OTL_String str_out; - - } OTL_ParserRec; - - typedef enum - { - OTL_Err_Parser_Ok = 0, - OTL_Err_Parser_InvalidData, - OTL_Err_Parser_UncoveredGlyph - - } OTL_ParseError; - - OTL_LOCAL( OTL_UInt ) - otl_parser_get_gindex( OTL_Parser parser ); - - - OTL_LOCAL( void ) - otl_parser_error( OTL_Parser parser, OTL_ParserError error ); - -#define OTL_PARSER_UNCOVERED(x) \ - otl_parser_error( x, OTL_Err_Parser_UncoveredGlyph ) - - OTL_LOCAL( void ) - otl_parser_check_property( OTL_Parser parser, - OTL_UInt gindex, - OTL_UInt flags, - OTL_UInt *aproperty ); - - /* copy current input glyph to output */ - OTL_LOCAL( void ) - otl_parser_copy_1( OTL_Parser parser ); - - /* copy current input glyph to output, replacing its index */ - OTL_LOCAL( void ) - otl_parser_replace_1( OTL_Parser parser, - OTL_UInt gindex ); - - /* copy current input glyph to output, replacing it by several indices */ - /* read directly from the table */ - OTL_LOCAL( void ) - otl_parser_replace_n( OTL_Parser parser, - OTL_UInt count, - OTL_Bytes indices ); - -OTL_END_HEADER - -#endif /* __OTL_PARSER_H__ */ - diff --git a/src/libs/freetype2/otlayout/otltable.h b/src/libs/freetype2/otlayout/otltable.h deleted file mode 100644 index af7bd78a58..0000000000 --- a/src/libs/freetype2/otlayout/otltable.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __OTL_TABLE_H__ -#define __OTL_TABLE_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - typedef struct OTL_TableRec_* OTL_Table; - - typedef enum - { - OTL_TABLE_TYPE_GDEF = 1, - OTL_TABLE_TYPE_GSUB, - OTL_TABLE_TYPE_GPOS, - OTL_TABLE_TYPE_BASE, - OTL_TABLE_TYPE_JSTF - - } OTL_TableType; - - - /* this may become a private structure later */ - typedef struct OTL_TableRec_ - { - OTL_TableType type; - OTL_Bytes base; - OTL_Bytes limit; - - OTL_Tag script_tag; - OTL_Tag lang_tag; - - OTL_UInt lookup_count; - OTL_Byte* lookup_flags; - - OTL_UInt feature_count; - OTL_Tag feature_tags; - OTL_Byte* feature_flags; - - } OTL_TableRec; - - - OTL_API( OTL_Error ) - otl_table_validate( OTL_Bytes table, - OTL_Size size, - OTL_TableType type, - OTL_Size *abyte_size ); - - OTL_API( void ) - otl_table_init( OTL_Table table, - OTL_TableType type, - OTL_Bytes base, - OTL_Size size ); - - OTL_API( void ) - otl_table_set_script( OTL_Table table, - OTL_ScriptTag script, - OTL_LangTag language ); - -OTL_END_HEADER - -#endif /* __OTL_TABLE_H__ */ diff --git a/src/libs/freetype2/otlayout/otltags.h b/src/libs/freetype2/otlayout/otltags.h deleted file mode 100644 index d954b58514..0000000000 --- a/src/libs/freetype2/otlayout/otltags.h +++ /dev/null @@ -1,88 +0,0 @@ -/* this file may be included several times by other parts of */ -/* the OpenType Layout library.. don't add #ifdef .. #endif */ -/* delimiters to it... */ - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** SCRIPT TAGS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - -#ifndef OTL_SCRIPT_TAG -#define OTL_SCRIPT_TAG(c1,c2,c3,c4,s,n) /* void */ -#endif - -OTL_SCRIPT_TAG( 'a','r','a','b', "Arabic", ARABIC ) -OTL_SCRIPT_TAG( 'a','r','m','n', "Armenian", ARMENIAN ) -OTL_SCRIPT_TAG( 'b','e','n','g', "Bengali", BENGALI ) -OTL_SCRIPT_TAG( 'b','o','p','o', "Bopomofo", BOPOMOFO ) -OTL_SCRIPT_TAG( 'b','r','a','i', "Braille", BRAILLE ) -OTL_SCRIPT_TAG( 'b','y','z','m', "Byzantine Music", BYZANTINE_MUSIC ) -OTL_SCRIPT_TAG( 'c','a','n','s', "Canadian Syllabic", CANADIAN ) -OTL_SCRIPT_TAG( 'c','h','e','r', "Cherokee", CHEROKEE ) -OTL_SCRIPT_TAG( 'h','a','n','i', "CJK Ideographic", CJK ) -OTL_SCRIPT_TAG( 'c','y','r','l', "Cyrillic", CYRILLIC ) -OTL_SCRIPT_TAG( 'd','f','l','t', "Default", DEFAULT ) -OTL_SCRIPT_TAG( 'd','e','v','a', "Devanagari", DEVANAGARI ) -OTL_SCRIPT_TAG( 'e','t','h','i', "Ethiopic", ETHIOPIC ) -OTL_SCRIPT_TAG( 'g','e','o','r', "Georgian", GEORGIAN ) -OTL_SCRIPT_TAG( 'g','r','e','k', "Greek", GREEK ) -OTL_SCRIPT_TAG( 'g','u','j','r', "Gujarati", GUJARATI ) -OTL_SCRIPT_TAG( 'g','u','r','u', "Gurmukhi", GURMUKHI ) -OTL_SCRIPT_TAG( 'j','a','m','o', "Hangul Jamo", JAMO ) -OTL_SCRIPT_TAG( 'h','a','n','g', "Hangul", HANGUL ) -OTL_SCRIPT_TAG( 'h','e','b','r', "Hebrew", HEBREW ) -OTL_SCRIPT_TAG( 'h','i','r','a', "Hiragana", HIRAGANA ) /* not in TAGS.txt */ -OTL_SCRIPT_TAG( 'k','n','d','a', "Kannada", KANNADA ) -OTL_SCRIPT_TAG( 'k','a','n','a', "Katakana", KATAKANA ) /* in TAGS.txt, means Hiragana _and_ Katakana */ -OTL_SCRIPT_TAG( 'k','h','m','r', "Khmer", KHMER ) -OTL_SCRIPT_TAG( 'l','a','o',' ', "Lao", LAO ) -OTL_SCRIPT_TAG( 'l','a','t','n', "Latin", LATIN ) -OTL_SCRIPT_TAG( 'm','l','y','m', "Malayalam", MALAYALAM ) -OTL_SCRIPT_TAG( 'm','o','n','g', "Mongolian", MONGOLIAN ) -OTL_SCRIPT_TAG( 'm','y','m','r', "Myanmar", MYANMAR ) -OTL_SCRIPT_TAG( 'o','g','a','m', "Ogham", OGHAM ) -OTL_SCRIPT_TAG( 'o','r','y','a', "Oriya", ORIYA ) -OTL_SCRIPT_TAG( 'r','u','n','r', "Runic", RUNIC ) -OTL_SCRIPT_TAG( 's','i','n','h', "Sinhala", SINHALA ) -OTL_SCRIPT_TAG( 's','y','r','c', "Syriac", SYRIAC ) -OTL_SCRIPT_TAG( 't','a','m','l', "Tamil", TAMIL ) -OTL_SCRIPT_TAG( 't','e','l','u', "Telugu", TELUGU ) -OTL_SCRIPT_TAG( 't','h','a','a', "Thaana", THAANA ) -OTL_SCRIPT_TAG( 't','h','a','i', "Thai", THAI ) -OTL_SCRIPT_TAG( 't','i','b','t', "Tibetan", TIBETAN ) -OTL_SCRIPT_TAG( 'y','i',' ',' ', "Yi", YI ) - -#undef OTL_SCRIPT_TAG - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** LANGUAGE TAGS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - -#ifndef OTL_LANG_TAG -#define OTL_LANG_TAG(c1,c2,c3,c4,s,n) /* void */ -#endif - -#undef OTL_LANG_TAG - - - /************************************************************************/ - /************************************************************************/ - /***** *****/ - /***** FEATURE TAGS *****/ - /***** *****/ - /************************************************************************/ - /************************************************************************/ - -#ifndef OTL_FEATURE_TAG -#define OTL_FEATURE_TAG(c1,c2,c3,c4,s,n) /* void */ -#endif - -#undef OTL_FEATURE_TAG - diff --git a/src/libs/freetype2/otlayout/otlutils.h b/src/libs/freetype2/otlayout/otlutils.h deleted file mode 100644 index de50f66f07..0000000000 --- a/src/libs/freetype2/otlayout/otlutils.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __OTLAYOUT_UTILS_H__ -#define __OTLAYOUT_UTILS_H__ - -#include "otlayout.h" - -OTL_BEGIN_HEADER - - OTL_LOCAL( OTL_Error ) - otl_mem_alloc( OTL_Pointer* pblock, - OTL_ULong size, - OTL_Memory memory ); - - OTL_LOCAL( void ) - otl_mem_free( OTL_Pointer* pblock, - OTL_Memory memory ); - - OTL_LOCAL( OTL_Error ) - otl_mem_realloc( OTL_Pointer *pblock, - OTL_ULong cur_size, - OTL_ULong new_size, - OTL_Memory memory ); - -#define OTL_MEM_ALLOC(p,s) otl_mem_alloc( (void**)&(p), (s), memory ) -#define OTL_MEM_FREE(p) otl_mem_free( (void**)&(p), memory ) -#define OTL_MEM_REALLOC(p,c,n) otl_mem_realloc( (void**)&(p), (c), (s), memory ) - -#define OTL_MEM_NEW(p) OTL_MEM_ALLOC(p,sizeof(*(p))) -#define OTL_MEM_NEW_ARRAY(p,c) OTL_MEM_ALLOC(p,(c)*sizeof(*(p))) -#define OTL_MEM_RENEW_ARRAY(p,c,n) OTL_MEM_REALLOC(p,(c)*sizeof(*(p)),(n)*sizeof(*(p))) - -OTL_END_HEADER - -#endif /* __OTLAYOUT_UTILS_H__ */ diff --git a/src/libs/freetype2/otvalid/module.mk b/src/libs/freetype2/otvalid/module.mk index 8f7cdf26c4..aa4db047d5 100644 --- a/src/libs/freetype2/otvalid/module.mk +++ b/src/libs/freetype2/otvalid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2004 by +# Copyright 2004, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_otvalid_module +FTMODULE_H_COMMANDS += OTVALID_MODULE -add_otvalid_module: - $(OPEN_DRIVER)otvalid_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)otvalid $(ECHO_DRIVER_DESC)OpenType validation module$(ECHO_DRIVER_DONE) +define OTVALID_MODULE +$(OPEN_DRIVER)otv_module_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)otvalid $(ECHO_DRIVER_DESC)OpenType validation module$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/otvalid/otvcommn.c b/src/libs/freetype2/otvalid/otvcommn.c index 1b9d77c425..d94e4f3cb6 100644 --- a/src/libs/freetype2/otvalid/otvcommn.c +++ b/src/libs/freetype2/otvalid/otvcommn.c @@ -4,7 +4,7 @@ /* */ /* OpenType common tables validation (body). */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -222,10 +222,10 @@ OTV_LIMIT_CHECK( 2 ); - OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount )); - GlyphCount = FT_NEXT_USHORT( p ); + OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount )); + OTV_LIMIT_CHECK( GlyphCount * 2 ); /* ClassValueArray */ } break; diff --git a/src/libs/freetype2/otvalid/otvcommn.h b/src/libs/freetype2/otvalid/otvcommn.h index 9f84910d51..be6ac69c28 100644 --- a/src/libs/freetype2/otvalid/otvcommn.h +++ b/src/libs/freetype2/otvalid/otvcommn.h @@ -4,7 +4,7 @@ /* */ /* OpenType common tables validation (specification). */ /* */ -/* Copyright 2004 by */ +/* Copyright 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -70,8 +70,8 @@ FT_BEGIN_HEADER #define FT_INVALID_( _prefix, _error ) \ ft_validator_error( valid->root, _prefix ## _error ) -#define OTV_OPTIONAL_TABLE( _table ) FT_UInt _table; \ - FT_Bytes _table ## _p +#define OTV_OPTIONAL_TABLE( _table ) FT_UShort _table; \ + FT_Bytes _table ## _p #define OTV_OPTIONAL_OFFSET( _offset ) \ FT_BEGIN_STMNT \ @@ -109,39 +109,39 @@ FT_BEGIN_HEADER FT_END_STMNT +#define OTV_NAME_(x) #x +#define OTV_NAME(x) OTV_NAME_(x) + +#define OTV_FUNC_(x) x##Func +#define OTV_FUNC(x) OTV_FUNC_(x) + #ifdef FT_DEBUG_LEVEL_TRACE - /* use preprocessor's argument prescan to expand one argument into two */ -#define OTV_NEST1( x ) OTV_NEST1_( x ) -#define OTV_NEST1_( func0, name0 ) \ - FT_BEGIN_STMNT \ - valid->nesting_level = 0; \ - valid->func[0] = func0; \ - valid->debug_function_name[0] = name0; \ +#define OTV_NEST1( x ) \ + FT_BEGIN_STMNT \ + valid->nesting_level = 0; \ + valid->func[0] = OTV_FUNC( x ); \ + valid->debug_function_name[0] = OTV_NAME( x ); \ FT_END_STMNT - /* use preprocessor's argument prescan to expand two arguments into four */ -#define OTV_NEST2( x, y ) OTV_NEST2_( x, y ) -#define OTV_NEST2_( func0, name0, func1, name1 ) \ - FT_BEGIN_STMNT \ - valid->nesting_level = 0; \ - valid->func[0] = func0; \ - valid->func[1] = func1; \ - valid->debug_function_name[0] = name0; \ - valid->debug_function_name[1] = name1; \ +#define OTV_NEST2( x, y ) \ + FT_BEGIN_STMNT \ + valid->nesting_level = 0; \ + valid->func[0] = OTV_FUNC( x ); \ + valid->func[1] = OTV_FUNC( y ); \ + valid->debug_function_name[0] = OTV_NAME( x ); \ + valid->debug_function_name[1] = OTV_NAME( y ); \ FT_END_STMNT - /* use preprocessor's argument prescan to expand three arguments into six */ -#define OTV_NEST3( x, y, z ) OTV_NEST3_( x, y, z ) -#define OTV_NEST3_( func0, name0, func1, name1, func2, name2 ) \ - FT_BEGIN_STMNT \ - valid->nesting_level = 0; \ - valid->func[0] = func0; \ - valid->func[1] = func1; \ - valid->func[2] = func2; \ - valid->debug_function_name[0] = name0; \ - valid->debug_function_name[1] = name1; \ - valid->debug_function_name[2] = name2; \ +#define OTV_NEST3( x, y, z ) \ + FT_BEGIN_STMNT \ + valid->nesting_level = 0; \ + valid->func[0] = OTV_FUNC( x ); \ + valid->func[1] = OTV_FUNC( y ); \ + valid->func[2] = OTV_FUNC( z ); \ + valid->debug_function_name[0] = OTV_NAME( x ); \ + valid->debug_function_name[1] = OTV_NAME( y ); \ + valid->debug_function_name[2] = OTV_NAME( z ); \ FT_END_STMNT #define OTV_INIT valid->debug_indent = 0 @@ -171,31 +171,25 @@ FT_BEGIN_HEADER #else /* !FT_DEBUG_LEVEL_TRACE */ - /* use preprocessor's argument prescan to expand one argument into two */ -#define OTV_NEST1( x ) OTV_NEST1_( x ) -#define OTV_NEST1_( func0, name0 ) \ - FT_BEGIN_STMNT \ - valid->nesting_level = 0; \ - valid->func[0] = func0; \ +#define OTV_NEST1( x ) \ + FT_BEGIN_STMNT \ + valid->nesting_level = 0; \ + valid->func[0] = OTV_FUNC( x ); \ FT_END_STMNT - /* use preprocessor's argument prescan to expand two arguments into four */ -#define OTV_NEST2( x, y ) OTV_NEST2_( x, y ) -#define OTV_NEST2_( func0, name0, func1, name1 ) \ - FT_BEGIN_STMNT \ - valid->nesting_level = 0; \ - valid->func[0] = func0; \ - valid->func[1] = func1; \ +#define OTV_NEST2( x, y ) \ + FT_BEGIN_STMNT \ + valid->nesting_level = 0; \ + valid->func[0] = OTV_FUNC( x ); \ + valid->func[1] = OTV_FUNC( y ); \ FT_END_STMNT - /* use preprocessor's argument prescan to expand three arguments into six */ -#define OTV_NEST3( x, y, z ) OTV_NEST3_( x, y, z ) -#define OTV_NEST3_( func0, name0, func1, name1, func2, name2 ) \ - FT_BEGIN_STMNT \ - valid->nesting_level = 0; \ - valid->func[0] = func0; \ - valid->func[1] = func1; \ - valid->func[2] = func2; \ +#define OTV_NEST3( x, y, z ) \ + FT_BEGIN_STMNT \ + valid->nesting_level = 0; \ + valid->func[0] = OTV_FUNC( x ); \ + valid->func[1] = OTV_FUNC( y ); \ + valid->func[2] = OTV_FUNC( z ); \ FT_END_STMNT #define OTV_INIT do ; while ( 0 ) @@ -338,88 +332,88 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ -#define ChainPosClassSet otv_x_Ox, "ChainPosClassSet" -#define ChainPosRuleSet otv_x_Ox, "ChainPosRuleSet" -#define ChainSubClassSet otv_x_Ox, "ChainSubClassSet" -#define ChainSubRuleSet otv_x_Ox, "ChainSubRuleSet" -#define JstfLangSys otv_x_Ox, "JstfLangSys" -#define JstfMax otv_x_Ox, "JstfMax" -#define LigGlyph otv_x_Ox, "LigGlyph" -#define LigatureArray otv_x_Ox, "LigatureArray" -#define LigatureSet otv_x_Ox, "LigatureSet" -#define PosClassSet otv_x_Ox, "PosClassSet" -#define PosRuleSet otv_x_Ox, "PosRuleSet" -#define SubClassSet otv_x_Ox, "SubClassSet" -#define SubRuleSet otv_x_Ox, "SubRuleSet" +#define ChainPosClassSetFunc otv_x_Ox +#define ChainPosRuleSetFunc otv_x_Ox +#define ChainSubClassSetFunc otv_x_Ox +#define ChainSubRuleSetFunc otv_x_Ox +#define JstfLangSysFunc otv_x_Ox +#define JstfMaxFunc otv_x_Ox +#define LigGlyphFunc otv_x_Ox +#define LigatureArrayFunc otv_x_Ox +#define LigatureSetFunc otv_x_Ox +#define PosClassSetFunc otv_x_Ox +#define PosRuleSetFunc otv_x_Ox +#define SubClassSetFunc otv_x_Ox +#define SubRuleSetFunc otv_x_Ox FT_LOCAL( void ) otv_x_Ox ( FT_Bytes table, OTV_Validator valid ); -#define AlternateSubstFormat1 otv_u_C_x_Ox, "AlternateSubstFormat1" -#define ChainContextPosFormat1 otv_u_C_x_Ox, "ChainContextPosFormat1" -#define ChainContextSubstFormat1 otv_u_C_x_Ox, "ChainContextSubstFormat1" -#define ContextPosFormat1 otv_u_C_x_Ox, "ContextPosFormat1" -#define ContextSubstFormat1 otv_u_C_x_Ox, "ContextSubstFormat1" -#define LigatureSubstFormat1 otv_u_C_x_Ox, "LigatureSubstFormat1" -#define MultipleSubstFormat1 otv_u_C_x_Ox, "MultipleSubstFormat1" +#define AlternateSubstFormat1Func otv_u_C_x_Ox +#define ChainContextPosFormat1Func otv_u_C_x_Ox +#define ChainContextSubstFormat1Func otv_u_C_x_Ox +#define ContextPosFormat1Func otv_u_C_x_Ox +#define ContextSubstFormat1Func otv_u_C_x_Ox +#define LigatureSubstFormat1Func otv_u_C_x_Ox +#define MultipleSubstFormat1Func otv_u_C_x_Ox FT_LOCAL( void ) otv_u_C_x_Ox( FT_Bytes table, OTV_Validator valid ); -#define AlternateSet otv_x_ux, "AlternateSet" -#define AttachPoint otv_x_ux, "AttachPoint" -#define ExtenderGlyph otv_x_ux, "ExtenderGlyph" -#define JstfGPOSModList otv_x_ux, "JstfGPOSModList" -#define JstfGSUBModList otv_x_ux, "JstfGSUBModList" -#define Sequence otv_x_ux, "Sequence" +#define AlternateSetFunc otv_x_ux +#define AttachPointFunc otv_x_ux +#define ExtenderGlyphFunc otv_x_ux +#define JstfGPOSModListFunc otv_x_ux +#define JstfGSUBModListFunc otv_x_ux +#define SequenceFunc otv_x_ux FT_LOCAL( void ) otv_x_ux( FT_Bytes table, OTV_Validator valid ); -#define PosClassRule otv_x_y_ux_sy, "PosClassRule" -#define PosRule otv_x_y_ux_sy, "PosRule" -#define SubClassRule otv_x_y_ux_sy, "SubClassRule" -#define SubRule otv_x_y_ux_sy, "SubRule" +#define PosClassRuleFunc otv_x_y_ux_sy +#define PosRuleFunc otv_x_y_ux_sy +#define SubClassRuleFunc otv_x_y_ux_sy +#define SubRuleFunc otv_x_y_ux_sy FT_LOCAL( void ) otv_x_y_ux_sy( FT_Bytes table, OTV_Validator valid ); -#define ChainPosClassRule otv_x_ux_y_uy_z_uz_p_sp, "ChainPosClassRule" -#define ChainPosRule otv_x_ux_y_uy_z_uz_p_sp, "ChainPosRule" -#define ChainSubClassRule otv_x_ux_y_uy_z_uz_p_sp, "ChainSubClassRule" -#define ChainSubRule otv_x_ux_y_uy_z_uz_p_sp, "ChainSubRule" +#define ChainPosClassRuleFunc otv_x_ux_y_uy_z_uz_p_sp +#define ChainPosRuleFunc otv_x_ux_y_uy_z_uz_p_sp +#define ChainSubClassRuleFunc otv_x_ux_y_uy_z_uz_p_sp +#define ChainSubRuleFunc otv_x_ux_y_uy_z_uz_p_sp FT_LOCAL( void ) otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes table, OTV_Validator valid ); -#define ContextPosFormat2 otv_u_O_O_x_Onx, "ContextPosFormat2" -#define ContextSubstFormat2 otv_u_O_O_x_Onx, "ContextSubstFormat2" +#define ContextPosFormat2Func otv_u_O_O_x_Onx +#define ContextSubstFormat2Func otv_u_O_O_x_Onx FT_LOCAL( void ) otv_u_O_O_x_Onx( FT_Bytes table, OTV_Validator valid ); -#define ContextPosFormat3 otv_u_x_y_Ox_sy, "ContextPosFormat3" -#define ContextSubstFormat3 otv_u_x_y_Ox_sy, "ContextSubstFormat3" +#define ContextPosFormat3Func otv_u_x_y_Ox_sy +#define ContextSubstFormat3Func otv_u_x_y_Ox_sy FT_LOCAL( void ) otv_u_x_y_Ox_sy( FT_Bytes table, OTV_Validator valid ); -#define ChainContextPosFormat2 otv_u_O_O_O_O_x_Onx, "ChainContextPosFormat2" -#define ChainContextSubstFormat2 otv_u_O_O_O_O_x_Onx, "ChainContextSubstFormat2" +#define ChainContextPosFormat2Func otv_u_O_O_O_O_x_Onx +#define ChainContextSubstFormat2Func otv_u_O_O_O_O_x_Onx FT_LOCAL( void ) otv_u_O_O_O_O_x_Onx( FT_Bytes table, OTV_Validator valid ); -#define ChainContextPosFormat3 otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextPosFormat3" -#define ChainContextSubstFormat3 otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextSubstFormat3" +#define ChainContextPosFormat3Func otv_u_x_Ox_y_Oy_z_Oz_p_sp +#define ChainContextSubstFormat3Func otv_u_x_Ox_y_Oy_z_Oz_p_sp FT_LOCAL( void ) otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes table, diff --git a/src/libs/freetype2/otvalid/otvgdef.c b/src/libs/freetype2/otvalid/otvgdef.c index e408c709ad..7d24902e88 100644 --- a/src/libs/freetype2/otvalid/otvgdef.c +++ b/src/libs/freetype2/otvalid/otvgdef.c @@ -38,8 +38,8 @@ /*************************************************************************/ /*************************************************************************/ -#define AttachList otv_O_x_Ox, "AttachList" -#define LigCaretList otv_O_x_Ox, "LigCaretList" +#define AttachListFunc otv_O_x_Ox +#define LigCaretListFunc otv_O_x_Ox /* sets valid->extra1 (0) */ @@ -88,7 +88,7 @@ /*************************************************************************/ /*************************************************************************/ -#define CaretValue otv_CaretValue_validate, "CaretValue" +#define CaretValueFunc otv_CaretValue_validate static void otv_CaretValue_validate( FT_Bytes table, diff --git a/src/libs/freetype2/otvalid/otvgpos.c b/src/libs/freetype2/otvalid/otvgpos.c index ceffd2f8ef..ed347053d6 100644 --- a/src/libs/freetype2/otvalid/otvgpos.c +++ b/src/libs/freetype2/otvalid/otvgpos.c @@ -4,7 +4,7 @@ /* */ /* OpenType GPOS table validation (body). */ /* */ -/* Copyright 2002, 2004, 2005 by */ +/* Copyright 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -48,9 +48,9 @@ /*************************************************************************/ /*************************************************************************/ -#define BaseArray otv_x_sxy, "BaseArray" -#define LigatureAttach otv_x_sxy, "LigatureAttach" -#define Mark2Array otv_x_sxy, "Mark2Array" +#define BaseArrayFunc otv_x_sxy +#define LigatureAttachFunc otv_x_sxy +#define Mark2ArrayFunc otv_x_sxy /* uses valid->extra1 (counter) */ /* uses valid->extra2 (boolean to handle NULL anchor field) */ @@ -67,10 +67,10 @@ OTV_LIMIT_CHECK( 2 ); - OTV_TRACE(( " (Count = %d)\n", Count )); - Count = FT_NEXT_USHORT( p ); + OTV_TRACE(( " (Count = %d)\n", Count )); + OTV_LIMIT_CHECK( Count * valid->extra1 * 2 ); table_size = Count * valid->extra1 * 2 + 2; @@ -88,8 +88,8 @@ OTV_SIZE_CHECK( anchor_offset ); if ( anchor_offset ) otv_Anchor_validate( table + anchor_offset, valid ); - } - else + } + else otv_Anchor_validate( table + anchor_offset, valid ); } @@ -97,9 +97,9 @@ } -#define MarkBasePosFormat1 otv_u_O_O_u_O_O, "MarkBasePosFormat1" -#define MarkLigPosFormat1 otv_u_O_O_u_O_O, "MarkLigPosFormat1" -#define MarkMarkPosFormat1 otv_u_O_O_u_O_O, "MarkMarkPosFormat1" +#define MarkBasePosFormat1Func otv_u_O_O_u_O_O +#define MarkLigPosFormat1Func otv_u_O_O_u_O_O +#define MarkMarkPosFormat1Func otv_u_O_O_u_O_O /* sets valid->extra1 (class count) */ @@ -130,7 +130,7 @@ otv_MarkArray_validate( table + Array1, valid ); valid->nesting_level++; - func = valid->func[valid->nesting_level]; + func = valid->func[valid->nesting_level]; valid->extra1 = ClassCount; func( table + Array2, valid ); diff --git a/src/libs/freetype2/otvalid/otvgsub.c b/src/libs/freetype2/otvalid/otvgsub.c index 022fa46f6d..91dae0bb16 100644 --- a/src/libs/freetype2/otvalid/otvgsub.c +++ b/src/libs/freetype2/otvalid/otvgsub.c @@ -200,7 +200,7 @@ /*************************************************************************/ /*************************************************************************/ -#define Ligature otv_Ligature_validate, "Ligature" +#define LigatureFunc otv_Ligature_validate /* uses valid->glyph_count */ diff --git a/src/libs/freetype2/otvalid/otvjstf.c b/src/libs/freetype2/otvalid/otvjstf.c index a230b36fbc..80b8dd6604 100644 --- a/src/libs/freetype2/otvalid/otvjstf.c +++ b/src/libs/freetype2/otvalid/otvjstf.c @@ -31,8 +31,8 @@ #define FT_COMPONENT trace_otvjstf -#define JstfPriority otv_JstfPriority_validate, "JstfPriority" -#define JstfLookup otv_GPOS_subtable_validate, "" +#define JstfPriorityFunc otv_JstfPriority_validate +#define JstfLookupFunc otv_GPOS_subtable_validate /* uses valid->extra1 (GSUB lookup count) */ /* uses valid->extra2 (GPOS lookup count) */ @@ -69,7 +69,7 @@ table_size = 20; valid->extra1 = gsub_lookup_count; - + OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB ); OTV_SIZE_CHECK( ShrinkageEnableGSUB ); if ( ShrinkageEnableGSUB ) diff --git a/src/libs/freetype2/otvalid/otvmod.c b/src/libs/freetype2/otvalid/otvmod.c index 3572a3dd8f..4c46e6baf5 100644 --- a/src/libs/freetype2/otvalid/otvmod.c +++ b/src/libs/freetype2/otvalid/otvmod.c @@ -124,7 +124,7 @@ if ( base ) { ft_validator_init( &valid, base, base + len_base, FT_VALIDATE_DEFAULT ); - if ( ft_setjmp( valid.jump_buffer ) == 0 ) + if ( ft_validator_run( &valid ) == 0 ) otv_BASE_validate( base, &valid ); error = valid.error; if ( error ) @@ -134,7 +134,7 @@ if ( gpos ) { ft_validator_init( &valid, gpos, gpos + len_gpos, FT_VALIDATE_DEFAULT ); - if (ft_setjmp( valid.jump_buffer ) == 0 ) + if ( ft_validator_run( &valid ) == 0 ) otv_GPOS_validate( gpos, face->num_glyphs, &valid ); error = valid.error; if ( error ) @@ -144,7 +144,7 @@ if ( gsub ) { ft_validator_init( &valid, gsub, gsub + len_gsub, FT_VALIDATE_DEFAULT ); - if ( ft_setjmp( valid.jump_buffer ) == 0 ) + if ( ft_validator_run( &valid ) == 0 ) otv_GSUB_validate( gsub, face->num_glyphs, &valid ); error = valid.error; if ( error ) @@ -154,7 +154,7 @@ if ( gdef ) { ft_validator_init( &valid, gdef, gdef + len_gdef, FT_VALIDATE_DEFAULT ); - if ( ft_setjmp( valid.jump_buffer ) == 0 ) + if ( ft_validator_run( &valid ) == 0 ) otv_GDEF_validate( gdef, gsub, gpos, &valid ); error = valid.error; if ( error ) @@ -164,7 +164,7 @@ if ( jstf ) { ft_validator_init( &valid, jstf, jstf + len_jstf, FT_VALIDATE_DEFAULT ); - if ( ft_setjmp( valid.jump_buffer ) == 0 ) + if ( ft_validator_run( &valid ) == 0 ) otv_JSTF_validate( jstf, gsub, gpos, face->num_glyphs, &valid ); error = valid.error; if ( error ) diff --git a/src/libs/freetype2/pcf/descrip.mms b/src/libs/freetype2/pcf/descrip.mms deleted file mode 100644 index a3fd23180f..0000000000 --- a/src/libs/freetype2/pcf/descrip.mms +++ /dev/null @@ -1,35 +0,0 @@ -# -# FreeType 2 pcf driver compilation rules for VMS -# - - -# Copyright (C) 2001, 2002 by -# Francesco Zappa Nardelli -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.pcf]) - -OBJS=pcf.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/pcf/module.mk b/src/libs/freetype2/pcf/module.mk index 614c319208..5bc7ce3c66 100644 --- a/src/libs/freetype2/pcf/module.mk +++ b/src/libs/freetype2/pcf/module.mk @@ -2,7 +2,7 @@ # FreeType 2 PCF module definition # -# Copyright 2000 by +# Copyright 2000, 2006 by # Francesco Zappa Nardelli # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,10 +23,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -make_module_list: add_pcf_driver -add_pcf_driver: - $(OPEN_DRIVER)pcf_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)pcf $(ECHO_DRIVER_DESC)pcf bitmap fonts$(ECHO_DRIVER_DONE) +FTMODULE_H_COMMANDS += PCF_DRIVER + +define PCF_DRIVER +$(OPEN_DRIVER)pcf_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)pcf $(ECHO_DRIVER_DESC)pcf bitmap fonts$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/pcf/pcf.h b/src/libs/freetype2/pcf/pcf.h index 64acefc4ee..9d2d8e0e42 100644 --- a/src/libs/freetype2/pcf/pcf.h +++ b/src/libs/freetype2/pcf/pcf.h @@ -2,7 +2,7 @@ FreeType font driver for pcf fonts - Copyright (C) 2000, 2001, 2002, 2003 by + Copyright (C) 2000, 2001, 2002, 2003, 2006 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -171,12 +171,12 @@ FT_BEGIN_HEADER #define PCF_FILE_VERSION ( ( 'p' << 24 ) | \ ( 'c' << 16 ) | \ ( 'f' << 8 ) | 1 ) -#define PCF_FORMAT_MASK 0xFFFFFF00L +#define PCF_FORMAT_MASK 0xFFFFFF00UL -#define PCF_DEFAULT_FORMAT 0x00000000L -#define PCF_INKBOUNDS 0x00000200L -#define PCF_ACCEL_W_INKBOUNDS 0x00000100L -#define PCF_COMPRESSED_METRICS 0x00000100L +#define PCF_DEFAULT_FORMAT 0x00000000UL +#define PCF_INKBOUNDS 0x00000200UL +#define PCF_ACCEL_W_INKBOUNDS 0x00000100UL +#define PCF_COMPRESSED_METRICS 0x00000100UL #define PCF_FORMAT_MATCH( a, b ) \ ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) ) diff --git a/src/libs/freetype2/pcf/pcfdrivr.c b/src/libs/freetype2/pcf/pcfdrivr.c index e47a684525..91de2b2292 100644 --- a/src/libs/freetype2/pcf/pcfdrivr.c +++ b/src/libs/freetype2/pcf/pcfdrivr.c @@ -2,7 +2,7 @@ FreeType font driver for pcf files - Copyright (C) 2000, 2001, 2002, 2003, 2004 by + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -213,7 +213,7 @@ THE SOFTWARE. FT_FREE( prop->name ); if ( prop->isString ) - FT_FREE( prop->value ); + FT_FREE( prop->value.atom ); } FT_FREE( face->properties ); @@ -363,75 +363,57 @@ THE SOFTWARE. FT_CALLBACK_DEF( FT_Error ) - PCF_Set_Pixel_Size( FT_Size size, - FT_UInt pixel_width, - FT_UInt pixel_height ) + PCF_Size_Select( FT_Size size, + FT_ULong strike_index ) { - PCF_Face face = (PCF_Face)FT_SIZE_FACE( size ); - - FT_UNUSED( pixel_width ); + PCF_Accel accel = &( (PCF_Face)size->face )->accel; - if ( pixel_height == (FT_UInt)face->root.available_sizes->height ) - { - size->metrics.ascender = face->accel.fontAscent << 6; - size->metrics.descender = face->accel.fontDescent * (-64); -#if 0 - size->metrics.height = face->accel.maxbounds.ascent << 6; -#endif - size->metrics.height = size->metrics.ascender - - size->metrics.descender; + FT_Select_Metrics( size->face, strike_index ); - size->metrics.max_advance = face->accel.maxbounds.characterWidth << 6; + size->metrics.ascender = accel->fontAscent << 6; + size->metrics.descender = -accel->fontDescent << 6; + size->metrics.max_advance = accel->maxbounds.characterWidth << 6; - return PCF_Err_Ok; - } - else - { - FT_TRACE4(( "pixel size WRONG\n" )); - return PCF_Err_Invalid_Pixel_Size; - } + return PCF_Err_Ok; } FT_CALLBACK_DEF( FT_Error ) - PCF_Set_Point_Size( FT_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) + PCF_Size_Request( FT_Size size, + FT_Size_Request req ) { - PCF_Face face = (PCF_Face)FT_SIZE_FACE( size ); - - FT_UNUSED( char_width ); - FT_UNUSED( char_height ); - FT_UNUSED( horz_resolution ); - FT_UNUSED( vert_resolution ); + PCF_Face face = (PCF_Face)size->face; + FT_Bitmap_Size* bsize = size->face->available_sizes; + FT_Error error = PCF_Err_Invalid_Pixel_Size; + FT_Long height; - FT_TRACE4(( "rec %d - pres %d\n", - size->metrics.y_ppem, - face->root.available_sizes->y_ppem >> 6 )); + height = FT_REQUEST_HEIGHT( req ); + height = ( height + 32 ) >> 6; - if ( size->metrics.y_ppem == face->root.available_sizes->y_ppem >> 6 ) + switch ( req->type ) { - size->metrics.ascender = face->accel.fontAscent << 6; - size->metrics.descender = face->accel.fontDescent * (-64); -#if 0 - size->metrics.height = face->accel.maxbounds.ascent << 6; -#endif - size->metrics.height = size->metrics.ascender - - size->metrics.descender; + case FT_SIZE_REQUEST_TYPE_NOMINAL: + if ( height == ( bsize->y_ppem + 32 ) >> 6 ) + error = PCF_Err_Ok; + break; - size->metrics.max_advance = face->accel.maxbounds.characterWidth << 6; + case FT_SIZE_REQUEST_TYPE_REAL_DIM: + if ( height == ( face->accel.fontAscent + + face->accel.fontDescent ) ) + error = PCF_Err_Ok; + break; - return PCF_Err_Ok; + default: + error = PCF_Err_Unimplemented_Feature; + break; } + + if ( error ) + return error; else - { - FT_TRACE4(( "size WRONG\n" )); - return PCF_Err_Invalid_Pixel_Size; - } + return PCF_Size_Select( size, 0 ); } @@ -528,6 +510,7 @@ THE SOFTWARE. } } + slot->format = FT_GLYPH_FORMAT_BITMAP; slot->bitmap_left = metric->leftSideBearing; slot->bitmap_top = metric->ascent; @@ -538,8 +521,9 @@ THE SOFTWARE. metric->leftSideBearing ) << 6; slot->metrics.height = bitmap->rows << 6; - slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16; - slot->format = FT_GLYPH_FORMAT_BITMAP; + ft_synthesize_vertical_metrics( &slot->metrics, + ( face->accel.fontAscent + + face->accel.fontDescent ) << 6 ); FT_TRACE4(( " --- ok\n" )); @@ -659,14 +643,18 @@ THE SOFTWARE. 0, /* FT_Slot_InitFunc */ 0, /* FT_Slot_DoneFunc */ - PCF_Set_Point_Size, - PCF_Set_Pixel_Size, - +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif PCF_Glyph_Load, 0, /* FT_Face_GetKerningFunc */ 0, /* FT_Face_AttachFunc */ - 0 /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_GetAdvancesFunc */ + + PCF_Size_Request, + PCF_Size_Select }; diff --git a/src/libs/freetype2/pcf/pcfread.c b/src/libs/freetype2/pcf/pcfread.c index ea74d17d5f..e775b1abf1 100644 --- a/src/libs/freetype2/pcf/pcfread.c +++ b/src/libs/freetype2/pcf/pcfread.c @@ -2,7 +2,7 @@ FreeType font driver for pcf fonts - Copyright 2000, 2001, 2002, 2003, 2004, 2005 by + Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -571,7 +571,6 @@ THE SOFTWARE. FT_Long bitmapSizes[GLYPHPADOPTIONS]; FT_ULong format, size; int nbitmaps, i, sizebitmaps = 0; - char* bitmaps; error = pcf_seek_to_table_type( stream, @@ -650,7 +649,6 @@ THE SOFTWARE. Bail: FT_FREE ( offsets ); - FT_FREE ( bitmaps ); return error; } @@ -1103,6 +1101,9 @@ THE SOFTWARE. FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) ); +#if 0 + bsize->height = face->accel.maxbounds.ascent << 6; +#endif bsize->height = (FT_Short)( face->accel.fontAscent + face->accel.fontDescent ); diff --git a/src/libs/freetype2/pfr/descrip.mms b/src/libs/freetype2/pfr/descrip.mms deleted file mode 100644 index 75178d0eff..0000000000 --- a/src/libs/freetype2/pfr/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 PFR driver compilation rules for VMS -# - - -# Copyright 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.pfr]) - -OBJS=pfr.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/pfr/module.mk b/src/libs/freetype2/pfr/module.mk index 3da0d5a3c7..53ab34aa9f 100644 --- a/src/libs/freetype2/pfr/module.mk +++ b/src/libs/freetype2/pfr/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002 by +# Copyright 2002, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_pfr_driver +FTMODULE_H_COMMANDS += PFR_DRIVER -add_pfr_driver: - $(OPEN_DRIVER)pfr_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)pfr $(ECHO_DRIVER_DESC)PFR/TrueDoc font files with extension *.pfr$(ECHO_DRIVER_DONE) +define PFR_DRIVER +$(OPEN_DRIVER)pfr_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)pfr $(ECHO_DRIVER_DESC)PFR/TrueDoc font files with extension *.pfr$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/pfr/pfrdrivr.c b/src/libs/freetype2/pfr/pfrdrivr.c index 55752a5f46..40206720ef 100644 --- a/src/libs/freetype2/pfr/pfrdrivr.c +++ b/src/libs/freetype2/pfr/pfrdrivr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver interface (body). */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -190,13 +190,17 @@ pfr_slot_init, pfr_slot_done, - 0, /* FT_Size_ResetPointsFunc */ - 0, /* FT_Size_ResetPixelsFunc */ +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif pfr_slot_load, pfr_get_kerning, 0, /* FT_Face_AttachFunc */ - 0 /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Size_RequestFunc */ + 0, /* FT_Size_SelectFunc */ }; diff --git a/src/libs/freetype2/pfr/pfrgload.c b/src/libs/freetype2/pfr/pfrgload.c index f9615824c8..7cee187607 100644 --- a/src/libs/freetype2/pfr/pfrgload.c +++ b/src/libs/freetype2/pfr/pfrgload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (body). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -133,7 +133,7 @@ /* check that we have begun a new path */ FT_ASSERT( glyph->path_begun != 0 ); - error = FT_GlyphLoader_CheckPoints( loader, 1, 0 ); + error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 0 ); if ( !error ) { FT_UInt n = outline->n_points; @@ -163,7 +163,7 @@ /* check that we have begun a new path */ FT_ASSERT( glyph->path_begun != 0 ); - error = FT_GlyphLoader_CheckPoints( loader, 3, 0 ); + error = FT_GLYPHLOADER_CHECK_POINTS( loader, 3, 0 ); if ( !error ) { FT_Vector* vec = outline->points + outline->n_points; @@ -199,7 +199,7 @@ glyph->path_begun = 1; /* check that there is space for a new contour and a new point */ - error = FT_GlyphLoader_CheckPoints( loader, 1, 1 ); + error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 ); if ( !error ) /* add new start point */ error = pfr_glyph_line_to( glyph, to ); diff --git a/src/libs/freetype2/pfr/pfrload.c b/src/libs/freetype2/pfr/pfrload.c index 6961dc499b..656444da6f 100644 --- a/src/libs/freetype2/pfr/pfrload.c +++ b/src/libs/freetype2/pfr/pfrload.c @@ -609,148 +609,6 @@ } -#ifndef FT_OPTIMIZE_MEMORY - - /* - * The kerning data embedded in a PFR font are (charcode,charcode) - * pairs; we need to translate them to (gindex,gindex) and sort - * the resulting array. - */ - static FT_UInt - pfr_get_gindex( PFR_Char chars, - FT_UInt count, - FT_UInt charcode ) - { - FT_UInt min = 0; - FT_UInt max = count; - - - while ( min < max ) - { - FT_UInt mid = ( min + max ) >> 1; - PFR_Char c = chars + mid; - - - if ( c->char_code == charcode ) - return mid + 1; - - if ( c->char_code < charcode ) - min = mid + 1; - else - max = mid; - } - return 0; - } - - - FT_CALLBACK_DEF( int ) - pfr_compare_kern_pairs( const void* pair1, - const void* pair2 ) - { - FT_UInt32 p1 = PFR_KERN_PAIR_INDEX( (PFR_KernPair)pair1 ); - FT_UInt32 p2 = PFR_KERN_PAIR_INDEX( (PFR_KernPair)pair2 ); - - - if ( p1 < p2 ) - return -1; - if ( p1 > p2 ) - return 1; - return 0; - } - - - static FT_Error - pfr_sort_kerning_pairs( FT_Stream stream, - PFR_PhyFont phy_font ) - { - FT_Error error; - FT_Memory memory = stream->memory; - PFR_KernPair pairs; - PFR_KernItem item; - PFR_Char chars = phy_font->chars; - FT_UInt num_chars = phy_font->num_chars; - FT_UInt count; - - - /* create kerning pairs array */ - if ( FT_NEW_ARRAY( phy_font->kern_pairs, phy_font->num_kern_pairs ) ) - goto Exit; - - /* - * load all kerning items into the array, - * converting character codes into glyph indices - */ - pairs = phy_font->kern_pairs; - item = phy_font->kern_items; - count = 0; - - for ( ; item; item = item->next ) - { - FT_UInt limit = count + item->pair_count; - FT_Byte* p; - - - if ( limit > phy_font->num_kern_pairs ) - { - error = PFR_Err_Invalid_Table; - goto Exit; - } - - if ( FT_STREAM_SEEK( item->offset ) || - FT_FRAME_ENTER( item->pair_count * item->pair_size ) ) - goto Exit; - - p = stream->cursor; - - for ( ; count < limit; count++ ) - { - PFR_KernPair pair = pairs + count; - FT_UInt char1, char2; - FT_Int kerning; - - - if ( item->flags & PFR_KERN_2BYTE_CHAR ) - { - char1 = FT_NEXT_USHORT( p ); - char2 = FT_NEXT_USHORT( p ); - } - else - { - char1 = FT_NEXT_BYTE( p ); - char2 = FT_NEXT_BYTE( p ); - } - - if ( item->flags & PFR_KERN_2BYTE_ADJ ) - kerning = item->base_adj + FT_NEXT_SHORT( p ); - else - kerning = item->base_adj + FT_NEXT_BYTE( p ); - - pair->glyph1 = pfr_get_gindex( chars, num_chars, char1 ); - pair->glyph2 = pfr_get_gindex( chars, num_chars, char2 ); - pair->kerning = kerning; - } - - FT_FRAME_EXIT(); - } - - /* sort the resulting array */ - ft_qsort( pairs, count, - sizeof ( PFR_KernPairRec ), - pfr_compare_kern_pairs ); - - Exit: - if ( error ) - { - /* disable kerning data in case of error - */ - phy_font->num_kern_pairs = 0; - } - - return error; - } - -#endif /* !FT_OPTIMIZE_MEMORY */ - static const PFR_ExtraItemRec pfr_phy_font_extra_items[] = { @@ -829,10 +687,6 @@ FT_FREE( phy_font->blue_values ); phy_font->num_blue_values = 0; -#ifndef FT_OPTIMIZE_MEMORY - FT_FREE( phy_font->kern_pairs ); -#endif - { PFR_KernItem item, next; @@ -1071,11 +925,6 @@ phy_font->bct_offset = FT_STREAM_POS(); phy_font->cursor = NULL; -#ifndef FT_OPTIMIZE_MEMORY - /* now sort kerning pairs */ - error = pfr_sort_kerning_pairs( stream, phy_font ); -#endif - Exit: return error; diff --git a/src/libs/freetype2/pfr/pfrobjs.c b/src/libs/freetype2/pfr/pfrobjs.c index a4eefb0da5..6c0ce903fd 100644 --- a/src/libs/freetype2/pfr/pfrobjs.c +++ b/src/libs/freetype2/pfr/pfrobjs.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -165,8 +165,10 @@ pfrface->units_per_EM = (FT_UShort)phy_font->outline_resolution; pfrface->ascender = (FT_Short) phy_font->bbox.yMax; pfrface->descender = (FT_Short) phy_font->bbox.yMin; - pfrface->height = (FT_Short)( - ( ( pfrface->ascender - pfrface->descender ) * 12 ) / 10 ); + + pfrface->height = (FT_Short)( ( pfrface->units_per_EM * 12 ) / 10 ); + if ( pfrface->height < pfrface->ascender - pfrface->descender ) + pfrface->height = (FT_Short)(pfrface->ascender - pfrface->descender); if ( phy_font->num_strikes > 0 ) { @@ -185,6 +187,9 @@ { size->height = (FT_UShort)strike->y_ppm; size->width = (FT_UShort)strike->x_ppm; + size->size = strike->y_ppm << 6; + size->x_ppem = strike->x_ppm << 6; + size->y_ppem = strike->y_ppm << 6; } pfrface->num_fixed_sizes = count; } @@ -422,8 +427,6 @@ /*************************************************************************/ /*************************************************************************/ -#ifdef FT_OPTIMIZE_MEMORY - FT_LOCAL_DEF( FT_Error ) pfr_face_get_kerning( FT_Face pfrface, /* PFR_Face */ FT_UInt glyph1, @@ -479,7 +482,7 @@ FT_UInt probe = power * size; FT_UInt extra = count - power; FT_Byte* base = stream->cursor; - FT_Bool twobytes = item->flags & 1; + FT_Bool twobytes = FT_BOOL( item->flags & 1 ); FT_Byte* p; FT_UInt32 cpair; @@ -546,51 +549,4 @@ return error; } -#else /* !FT_OPTIMIZE_MEMORY */ - - FT_LOCAL_DEF( FT_Error ) - pfr_face_get_kerning( FT_Face pfrface, /* PFR_Face */ - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ) - { - PFR_Face face = (PFR_Face)pfrface; - FT_Error error = PFR_Err_Ok; - PFR_PhyFont phy_font = &face->phy_font; - PFR_KernPair pairs = phy_font->kern_pairs; - FT_UInt32 idx = PFR_KERN_INDEX( glyph1, glyph2 ); - FT_UInt min, max; - - - kerning->x = 0; - kerning->y = 0; - - min = 0; - max = phy_font->num_kern_pairs; - - while ( min < max ) - { - FT_UInt mid = ( min + max ) >> 1; - PFR_KernPair pair = pairs + mid; - FT_UInt32 pidx = PFR_KERN_PAIR_INDEX( pair ); - - - if ( pidx == idx ) - { - kerning->x = pair->kerning; - break; - } - - if ( pidx < idx ) - min = mid + 1; - else - max = mid; - } - - return error; - } - -#endif /* !FT_OPTIMIZE_MEMORY */ - - /* END */ diff --git a/src/libs/freetype2/pfr/pfrsbit.c b/src/libs/freetype2/pfr/pfrsbit.c index da8fdba337..45ff6663b3 100644 --- a/src/libs/freetype2/pfr/pfrsbit.c +++ b/src/libs/freetype2/pfr/pfrsbit.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (body). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -605,12 +605,21 @@ FT_Byte* p; - advance = FT_MulDiv( size->root.metrics.x_ppem << 8, + /* compute linear advance */ + advance = character->advance; + if ( phys->metrics_resolution != phys->outline_resolution ) + advance = FT_MulDiv( advance, + phys->outline_resolution, + phys->metrics_resolution ); + + glyph->root.linearHoriAdvance = advance; + + /* compute default advance, i.e., scaled advance. This can be */ + /* overridden in the bitmap header of certain glyphs. */ + advance = FT_MulDiv( (FT_Fixed)size->root.metrics.x_ppem << 8, character->advance, phys->metrics_resolution ); - /* XXX: handle linearHoriAdvance correctly! */ - if ( FT_STREAM_SEEK( face->header.gps_section_offset + gps_offset ) || FT_FRAME_ENTER( gps_size ) ) goto Exit; diff --git a/src/libs/freetype2/pfr/pfrtypes.h b/src/libs/freetype2/pfr/pfrtypes.h index b8bd557b2e..df12ecf197 100644 --- a/src/libs/freetype2/pfr/pfrtypes.h +++ b/src/libs/freetype2/pfr/pfrtypes.h @@ -217,14 +217,6 @@ FT_BEGIN_HEADER ( (FT_UInt32)p[-2] << 16 ) | p[-1] ) - typedef struct PFR_KernPairRec_ - { - FT_UInt glyph1; - FT_UInt glyph2; - FT_Int kerning; - - } PFR_KernPairRec, *PFR_KernPair; - /************************************************************************/ typedef struct PFR_PhyFontRec_ @@ -266,9 +258,6 @@ FT_BEGIN_HEADER FT_UInt num_kern_pairs; PFR_KernItem kern_items; PFR_KernItem* kern_items_tail; -#ifndef FT_OPTIMIZE_MEMORY - PFR_KernPair kern_pairs; -#endif /* not part of the spec, but used during load */ FT_UInt32 bct_offset; diff --git a/src/libs/freetype2/psaux/Jamfile b/src/libs/freetype2/psaux/Jamfile index be72c9b215..26b2d75ab4 100644 --- a/src/libs/freetype2/psaux/Jamfile +++ b/src/libs/freetype2/psaux/Jamfile @@ -13,7 +13,7 @@ UseFreeTypeHeaders ; if $(FT2_MULTI) { - _sources = psauxmod psobjs t1decode t1cmap ; + _sources = psauxmod psobjs t1decode t1cmap psconv afmparse ; } else { diff --git a/src/libs/freetype2/psaux/afmparse.c b/src/libs/freetype2/psaux/afmparse.c new file mode 100644 index 0000000000..012ff8c75d --- /dev/null +++ b/src/libs/freetype2/psaux/afmparse.c @@ -0,0 +1,965 @@ +/***************************************************************************/ +/* */ +/* afmparse.c */ +/* */ +/* AFM parser (body). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_DEBUG_H + +#include "afmparse.h" +#include "psconv.h" + +#include "psauxerr.h" + + +/***************************************************************************/ +/* */ +/* AFM_Stream */ +/* */ +/* The use of AFM_Stream is largely inspired by parseAFM.[ch] from t1lib. */ +/* */ +/* */ + + enum + { + AFM_STREAM_STATUS_NORMAL, + AFM_STREAM_STATUS_EOC, + AFM_STREAM_STATUS_EOL, + AFM_STREAM_STATUS_EOF + }; + + + typedef struct AFM_StreamRec_ + { + FT_Byte* cursor; + FT_Byte* base; + FT_Byte* limit; + + FT_Int status; + + } AFM_StreamRec; + + +#ifndef EOF +#define EOF -1 +#endif + + + /* this works because empty lines are ignored */ +#define AFM_IS_NEWLINE( ch ) ( (ch) == '\r' || (ch) == '\n' ) + +#define AFM_IS_EOF( ch ) ( (ch) == EOF || (ch) == '\x1a' ) +#define AFM_IS_SPACE( ch ) ( (ch) == ' ' || (ch) == '\t' ) + + /* column separator; there is no `column' in the spec actually */ +#define AFM_IS_SEP( ch ) ( (ch) == ';' ) + +#define AFM_GETC() \ + ( ( (stream)->cursor < (stream)->limit ) ? *(stream)->cursor++ \ + : EOF ) + +#define AFM_STREAM_KEY_BEGIN( stream ) \ + (char*)( (stream)->cursor - 1 ) + +#define AFM_STREAM_KEY_LEN( stream, key ) \ + ( (char*)(stream)->cursor - key - 1 ) + +#define AFM_STATUS_EOC( stream ) \ + ( (stream)->status >= AFM_STREAM_STATUS_EOC ) + +#define AFM_STATUS_EOL( stream ) \ + ( (stream)->status >= AFM_STREAM_STATUS_EOL ) + +#define AFM_STATUS_EOF( stream ) \ + ( (stream)->status >= AFM_STREAM_STATUS_EOF ) + + + static int + afm_stream_skip_spaces( AFM_Stream stream ) + { + int ch = 0; /* make stupid compiler happy */ + + + if ( AFM_STATUS_EOC( stream ) ) + return ';'; + + while ( 1 ) + { + ch = AFM_GETC(); + if ( !AFM_IS_SPACE( ch ) ) + break; + } + + if ( AFM_IS_NEWLINE( ch ) ) + stream->status = AFM_STREAM_STATUS_EOL; + else if ( AFM_IS_SEP( ch ) ) + stream->status = AFM_STREAM_STATUS_EOC; + else if ( AFM_IS_EOF( ch ) ) + stream->status = AFM_STREAM_STATUS_EOF; + + return ch; + } + + + /* read a key or value in current column */ + static char* + afm_stream_read_one( AFM_Stream stream ) + { + char* str; + int ch; + + + afm_stream_skip_spaces( stream ); + if ( AFM_STATUS_EOC( stream ) ) + return NULL; + + str = AFM_STREAM_KEY_BEGIN( stream ); + + while ( 1 ) + { + ch = AFM_GETC(); + if ( AFM_IS_SPACE( ch ) ) + break; + else if ( AFM_IS_NEWLINE( ch ) ) + { + stream->status = AFM_STREAM_STATUS_EOL; + break; + } + else if ( AFM_IS_SEP( ch ) ) + { + stream->status = AFM_STREAM_STATUS_EOC; + break; + } + else if ( AFM_IS_EOF( ch ) ) + { + stream->status = AFM_STREAM_STATUS_EOF; + break; + } + } + + return str; + } + + + /* read a string (i.e., read to EOL) */ + static char* + afm_stream_read_string( AFM_Stream stream ) + { + char* str; + int ch; + + + afm_stream_skip_spaces( stream ); + if ( AFM_STATUS_EOL( stream ) ) + return NULL; + + str = AFM_STREAM_KEY_BEGIN( stream ); + + /* scan to eol */ + while ( 1 ) + { + ch = AFM_GETC(); + if ( AFM_IS_NEWLINE( ch ) ) + { + stream->status = AFM_STREAM_STATUS_EOL; + break; + } + else if ( AFM_IS_EOF( ch ) ) + { + stream->status = AFM_STREAM_STATUS_EOF; + break; + } + } + + return str; + } + + + /*************************************************************************/ + /* */ + /* AFM_Parser */ + /* */ + /* */ + + /* all keys defined in Ch. 7-10 of 5004.AFM_Spec.pdf */ + typedef enum AFM_Token_ + { + AFM_TOKEN_ASCENDER, + AFM_TOKEN_AXISLABEL, + AFM_TOKEN_AXISTYPE, + AFM_TOKEN_B, + AFM_TOKEN_BLENDAXISTYPES, + AFM_TOKEN_BLENDDESIGNMAP, + AFM_TOKEN_BLENDDESIGNPOSITIONS, + AFM_TOKEN_C, + AFM_TOKEN_CC, + AFM_TOKEN_CH, + AFM_TOKEN_CAPHEIGHT, + AFM_TOKEN_CHARWIDTH, + AFM_TOKEN_CHARACTERSET, + AFM_TOKEN_CHARACTERS, + AFM_TOKEN_DESCENDER, + AFM_TOKEN_ENCODINGSCHEME, + AFM_TOKEN_ENDAXIS, + AFM_TOKEN_ENDCHARMETRICS, + AFM_TOKEN_ENDCOMPOSITES, + AFM_TOKEN_ENDDIRECTION, + AFM_TOKEN_ENDFONTMETRICS, + AFM_TOKEN_ENDKERNDATA, + AFM_TOKEN_ENDKERNPAIRS, + AFM_TOKEN_ENDTRACKKERN, + AFM_TOKEN_ESCCHAR, + AFM_TOKEN_FAMILYNAME, + AFM_TOKEN_FONTBBOX, + AFM_TOKEN_FONTNAME, + AFM_TOKEN_FULLNAME, + AFM_TOKEN_ISBASEFONT, + AFM_TOKEN_ISCIDFONT, + AFM_TOKEN_ISFIXEDPITCH, + AFM_TOKEN_ISFIXEDV, + AFM_TOKEN_ITALICANGLE, + AFM_TOKEN_KP, + AFM_TOKEN_KPH, + AFM_TOKEN_KPX, + AFM_TOKEN_KPY, + AFM_TOKEN_L, + AFM_TOKEN_MAPPINGSCHEME, + AFM_TOKEN_METRICSSETS, + AFM_TOKEN_N, + AFM_TOKEN_NOTICE, + AFM_TOKEN_PCC, + AFM_TOKEN_STARTAXIS, + AFM_TOKEN_STARTCHARMETRICS, + AFM_TOKEN_STARTCOMPOSITES, + AFM_TOKEN_STARTDIRECTION, + AFM_TOKEN_STARTFONTMETRICS, + AFM_TOKEN_STARTKERNDATA, + AFM_TOKEN_STARTKERNPAIRS, + AFM_TOKEN_STARTKERNPAIRS0, + AFM_TOKEN_STARTKERNPAIRS1, + AFM_TOKEN_STARTTRACKKERN, + AFM_TOKEN_STDHW, + AFM_TOKEN_STDVW, + AFM_TOKEN_TRACKKERN, + AFM_TOKEN_UNDERLINEPOSITION, + AFM_TOKEN_UNDERLINETHICKNESS, + AFM_TOKEN_VV, + AFM_TOKEN_VVECTOR, + AFM_TOKEN_VERSION, + AFM_TOKEN_W, + AFM_TOKEN_W0, + AFM_TOKEN_W0X, + AFM_TOKEN_W0Y, + AFM_TOKEN_W1, + AFM_TOKEN_W1X, + AFM_TOKEN_W1Y, + AFM_TOKEN_WX, + AFM_TOKEN_WY, + AFM_TOKEN_WEIGHT, + AFM_TOKEN_WEIGHTVECTOR, + AFM_TOKEN_XHEIGHT, + N_AFM_TOKENS, + AFM_TOKEN_UNKNOWN + + } AFM_Token; + + + static const char* const afm_key_table[N_AFM_TOKENS] = + { + "Ascender", + "AxisLabel", + "AxisType", + "B", + "BlendAxisTypes", + "BlendDesignMap", + "BlendDesignPositions", + "C", + "CC", + "CH", + "CapHeight", + "CharWidth", + "CharacterSet", + "Characters", + "Descender", + "EncodingScheme", + "EndAxis", + "EndCharMetrics", + "EndComposites", + "EndDirection", + "EndFontMetrics", + "EndKernData", + "EndKernPairs", + "EndTrackKern", + "EscChar", + "FamilyName", + "FontBBox", + "FontName", + "FullName", + "IsBaseFont", + "IsCIDFont", + "IsFixedPitch", + "IsFixedV", + "ItalicAngle", + "KP", + "KPH", + "KPX", + "KPY", + "L", + "MappingScheme", + "MetricsSets", + "N", + "Notice", + "PCC", + "StartAxis", + "StartCharMetrics", + "StartComposites", + "StartDirection", + "StartFontMetrics", + "StartKernData", + "StartKernPairs", + "StartKernPairs0", + "StartKernPairs1", + "StartTrackKern", + "StdHW", + "StdVW", + "TrackKern", + "UnderlinePosition", + "UnderlineThickness", + "VV", + "VVector", + "Version", + "W", + "W0", + "W0X", + "W0Y", + "W1", + "W1X", + "W1Y", + "WX", + "WY", + "Weight", + "WeightVector", + "XHeight" + }; + + + /* + * `afm_parser_read_vals' and `afm_parser_next_key' provide + * high-level operations to an AFM_Stream. The rest of the + * parser functions should use them without accessing the + * AFM_Stream directly. + */ + + FT_LOCAL_DEF( FT_Int ) + afm_parser_read_vals( AFM_Parser parser, + AFM_Value vals, + FT_Int n ) + { + AFM_Stream stream = parser->stream; + char* str; + FT_Int i; + + + if ( n > AFM_MAX_ARGUMENTS ) + return 0; + + for ( i = 0; i < n; i++ ) + { + FT_UInt len; + AFM_Value val = vals + i; + + + if ( val->type == AFM_VALUE_TYPE_STRING ) + str = afm_stream_read_string( stream ); + else + str = afm_stream_read_one( stream ); + + if ( !str ) + break; + + len = AFM_STREAM_KEY_LEN( stream, str ); + + switch ( val->type ) + { + case AFM_VALUE_TYPE_STRING: + case AFM_VALUE_TYPE_NAME: + { + FT_Memory memory = parser->memory; + FT_Error error; + + + if ( !FT_QALLOC( val->u.s, len + 1 ) ) + { + ft_memcpy( val->u.s, str, len ); + val->u.s[len] = '\0'; + } + } + break; + + case AFM_VALUE_TYPE_FIXED: + val->u.f = PS_Conv_ToFixed( (FT_Byte**)(void*)&str, + (FT_Byte*)str + len, 0 ); + break; + + case AFM_VALUE_TYPE_INTEGER: + val->u.i = PS_Conv_ToInt( (FT_Byte**)(void*)&str, + (FT_Byte*)str + len ); + break; + + case AFM_VALUE_TYPE_BOOL: + val->u.b = FT_BOOL( len == 4 && + !ft_strncmp( str, "true", 4 ) ); + break; + + case AFM_VALUE_TYPE_INDEX: + if ( parser->get_index ) + val->u.i = parser->get_index( str, len, parser->user_data ); + else + val->u.i = 0; + break; + } + } + + return i; + } + + + FT_LOCAL_DEF( char* ) + afm_parser_next_key( AFM_Parser parser, + FT_Bool line, + FT_UInt* len ) + { + AFM_Stream stream = parser->stream; + char* key = 0; /* make stupid compiler happy */ + + + if ( line ) + { + while ( 1 ) + { + /* skip current line */ + if ( !AFM_STATUS_EOL( stream ) ) + afm_stream_read_string( stream ); + + stream->status = AFM_STREAM_STATUS_NORMAL; + key = afm_stream_read_one( stream ); + + /* skip empty line */ + if ( !key && + !AFM_STATUS_EOF( stream ) && + AFM_STATUS_EOL( stream ) ) + continue; + + break; + } + } + else + { + while ( 1 ) + { + /* skip current column */ + while ( !AFM_STATUS_EOC( stream ) ) + afm_stream_read_one( stream ); + + stream->status = AFM_STREAM_STATUS_NORMAL; + key = afm_stream_read_one( stream ); + + /* skip empty column */ + if ( !key && + !AFM_STATUS_EOF( stream ) && + AFM_STATUS_EOC( stream ) ) + continue; + + break; + } + } + + if ( len ) + *len = ( key ) ? AFM_STREAM_KEY_LEN( stream, key ) + : 0; + + return key; + } + + + static AFM_Token + afm_tokenize( const char* key, + FT_UInt len ) + { + int n; + + + for ( n = 0; n < N_AFM_TOKENS; n++ ) + { + if ( *( afm_key_table[n] ) == *key ) + { + for ( ; n < N_AFM_TOKENS; n++ ) + { + if ( *( afm_key_table[n] ) != *key ) + return AFM_TOKEN_UNKNOWN; + + if ( ft_strncmp( afm_key_table[n], key, len ) == 0 ) + return (AFM_Token) n; + } + } + } + + return AFM_TOKEN_UNKNOWN; + } + + + FT_LOCAL_DEF( FT_Error ) + afm_parser_init( AFM_Parser parser, + FT_Memory memory, + FT_Byte* base, + FT_Byte* limit ) + { + AFM_Stream stream; + FT_Error error; + + + if ( FT_NEW( stream ) ) + return error; + + stream->cursor = stream->base = base; + stream->limit = limit; + + /* don't skip the first line during the first call */ + stream->status = AFM_STREAM_STATUS_EOL; + + parser->memory = memory; + parser->stream = stream; + parser->FontInfo = NULL; + parser->get_index = NULL; + + return PSaux_Err_Ok; + } + + + FT_LOCAL( void ) + afm_parser_done( AFM_Parser parser ) + { + FT_Memory memory = parser->memory; + + + FT_FREE( parser->stream ); + } + + + FT_LOCAL_DEF( FT_Error ) + afm_parser_read_int( AFM_Parser parser, + FT_Int* aint ) + { + AFM_ValueRec val; + + + val.type = AFM_VALUE_TYPE_INTEGER; + + if ( afm_parser_read_vals( parser, &val, 1 ) == 1 ) + { + *aint = val.u.i; + + return PSaux_Err_Ok; + } + else + return PSaux_Err_Syntax_Error; + } + + + static FT_Error + afm_parse_track_kern( AFM_Parser parser ) + { + AFM_FontInfo fi = parser->FontInfo; + AFM_TrackKern tk; + char* key; + FT_UInt len; + int n = -1; + + + if ( afm_parser_read_int( parser, &fi->NumTrackKern ) ) + goto Fail; + + if ( fi->NumTrackKern ) + { + FT_Memory memory = parser->memory; + FT_Error error; + + + if ( FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern ) ) + return error; + } + + while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) + { + AFM_ValueRec shared_vals[5]; + + + switch ( afm_tokenize( key, len ) ) + { + case AFM_TOKEN_TRACKKERN: + n++; + + if ( n >= fi->NumTrackKern ) + goto Fail; + + tk = fi->TrackKerns + n; + + shared_vals[0].type = AFM_VALUE_TYPE_INTEGER; + shared_vals[1].type = AFM_VALUE_TYPE_FIXED; + shared_vals[2].type = AFM_VALUE_TYPE_FIXED; + shared_vals[3].type = AFM_VALUE_TYPE_FIXED; + shared_vals[4].type = AFM_VALUE_TYPE_FIXED; + if ( afm_parser_read_vals( parser, shared_vals, 5 ) != 5 ) + goto Fail; + + tk->degree = shared_vals[0].u.i; + tk->min_ptsize = shared_vals[1].u.f; + tk->min_kern = shared_vals[2].u.f; + tk->max_ptsize = shared_vals[3].u.f; + tk->max_kern = shared_vals[4].u.f; + + /* is this correct? */ + if ( tk->degree < 0 && tk->min_kern > 0 ) + tk->min_kern = -tk->min_kern; + break; + + case AFM_TOKEN_ENDTRACKKERN: + case AFM_TOKEN_ENDKERNDATA: + case AFM_TOKEN_ENDFONTMETRICS: + fi->NumTrackKern = n + 1; + return PSaux_Err_Ok; + break; + + case AFM_TOKEN_UNKNOWN: + break; + + default: + goto Fail; + break; + } + } + + Fail: + return PSaux_Err_Syntax_Error; + } + + +#undef KERN_INDEX +#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) + + + /* compare two kerning pairs */ + FT_CALLBACK_DEF( int ) + afm_compare_kern_pairs( const void* a, + const void* b ) + { + AFM_KernPair kp1 = (AFM_KernPair)a; + AFM_KernPair kp2 = (AFM_KernPair)b; + + FT_ULong index1 = KERN_INDEX( kp1->index1, kp1->index2 ); + FT_ULong index2 = KERN_INDEX( kp2->index1, kp2->index2 ); + + + return (int)( index1 - index2 ); + } + + + static FT_Error + afm_parse_kern_pairs( AFM_Parser parser ) + { + AFM_FontInfo fi = parser->FontInfo; + AFM_KernPair kp; + char* key; + FT_UInt len; + int n = -1; + + + if ( afm_parser_read_int( parser, &fi->NumKernPair ) ) + goto Fail; + + if ( fi->NumKernPair ) + { + FT_Memory memory = parser->memory; + FT_Error error; + + + if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) ) + return error; + } + + while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) + { + AFM_Token token = afm_tokenize( key, len ); + + + switch ( token ) + { + case AFM_TOKEN_KP: + case AFM_TOKEN_KPX: + case AFM_TOKEN_KPY: + { + FT_Int r; + AFM_ValueRec shared_vals[4]; + + + n++; + + if ( n >= fi->NumKernPair ) + goto Fail; + + kp = fi->KernPairs + n; + + shared_vals[0].type = AFM_VALUE_TYPE_INDEX; + shared_vals[1].type = AFM_VALUE_TYPE_INDEX; + shared_vals[2].type = AFM_VALUE_TYPE_INTEGER; + shared_vals[3].type = AFM_VALUE_TYPE_INTEGER; + r = afm_parser_read_vals( parser, shared_vals, 4 ); + if ( r < 3 ) + goto Fail; + + kp->index1 = shared_vals[0].u.i; + kp->index2 = shared_vals[1].u.i; + if ( token == AFM_TOKEN_KPY ) + { + kp->x = 0; + kp->y = shared_vals[2].u.i; + } + else + { + kp->x = shared_vals[2].u.i; + kp->y = ( token == AFM_TOKEN_KP && r == 4 ) + ? shared_vals[3].u.i : 0; + } + } + break; + + case AFM_TOKEN_ENDKERNPAIRS: + case AFM_TOKEN_ENDKERNDATA: + case AFM_TOKEN_ENDFONTMETRICS: + fi->NumKernPair = n + 1; + ft_qsort( fi->KernPairs, fi->NumKernPair, + sizeof( AFM_KernPairRec ), + afm_compare_kern_pairs ); + return PSaux_Err_Ok; + + case AFM_TOKEN_UNKNOWN: + break; + + default: + goto Fail; + break; + } + } + + Fail: + return PSaux_Err_Syntax_Error; + } + + + static FT_Error + afm_parse_kern_data( AFM_Parser parser ) + { + FT_Error error; + char* key; + FT_UInt len; + + + while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) + { + switch ( afm_tokenize( key, len ) ) + { + case AFM_TOKEN_STARTTRACKKERN: + error = afm_parse_track_kern( parser ); + if ( error ) + return error; + break; + + case AFM_TOKEN_STARTKERNPAIRS: + case AFM_TOKEN_STARTKERNPAIRS0: + error = afm_parse_kern_pairs( parser ); + if ( error ) + return error; + break; + + case AFM_TOKEN_ENDKERNDATA: + case AFM_TOKEN_ENDFONTMETRICS: + return PSaux_Err_Ok; + + case AFM_TOKEN_UNKNOWN: + break; + + default: + goto Fail; + break; + } + } + + Fail: + return PSaux_Err_Syntax_Error; + } + + + static FT_Error + afm_parser_skip_section( AFM_Parser parser, + FT_UInt n, + AFM_Token end_section ) + { + char* key; + FT_UInt len; + + + while ( n-- > 0 ) + { + key = afm_parser_next_key( parser, 1, NULL ); + if ( !key ) + goto Fail; + } + + while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) + { + AFM_Token token = afm_tokenize( key, len ); + + + if ( token == end_section || token == AFM_TOKEN_ENDFONTMETRICS ) + return PSaux_Err_Ok; + } + + Fail: + return PSaux_Err_Syntax_Error; + } + + + FT_LOCAL_DEF( FT_Error ) + afm_parser_parse( AFM_Parser parser ) + { + FT_Memory memory = parser->memory; + AFM_FontInfo fi = parser->FontInfo; + FT_Error error = PSaux_Err_Syntax_Error; + char* key; + FT_UInt len; + FT_Int metrics_sets = 0; + + + if ( !fi ) + return PSaux_Err_Invalid_Argument; + + key = afm_parser_next_key( parser, 1, &len ); + if ( !key || len != 16 || + ft_strncmp( key, "StartFontMetrics", 16 ) != 0 ) + return PSaux_Err_Unknown_File_Format; + + while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) + { + AFM_ValueRec shared_vals[4]; + + + switch ( afm_tokenize( key, len ) ) + { + case AFM_TOKEN_METRICSSETS: + if ( afm_parser_read_int( parser, &metrics_sets ) ) + goto Fail; + + if ( metrics_sets != 0 && metrics_sets != 2 ) + { + error = PSaux_Err_Unimplemented_Feature; + + goto Fail; + } + break; + + case AFM_TOKEN_ISCIDFONT: + shared_vals[0].type = AFM_VALUE_TYPE_BOOL; + if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 ) + goto Fail; + + fi->IsCIDFont = shared_vals[0].u.b; + break; + + case AFM_TOKEN_FONTBBOX: + shared_vals[0].type = AFM_VALUE_TYPE_FIXED; + shared_vals[1].type = AFM_VALUE_TYPE_FIXED; + shared_vals[2].type = AFM_VALUE_TYPE_FIXED; + shared_vals[3].type = AFM_VALUE_TYPE_FIXED; + if ( afm_parser_read_vals( parser, shared_vals, 4 ) != 4 ) + goto Fail; + + fi->FontBBox.xMin = shared_vals[0].u.f; + fi->FontBBox.yMin = shared_vals[1].u.f; + fi->FontBBox.xMax = shared_vals[2].u.f; + fi->FontBBox.yMax = shared_vals[3].u.f; + break; + + case AFM_TOKEN_ASCENDER: + shared_vals[0].type = AFM_VALUE_TYPE_FIXED; + if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 ) + goto Fail; + + fi->Ascender = shared_vals[0].u.f; + break; + + case AFM_TOKEN_DESCENDER: + shared_vals[0].type = AFM_VALUE_TYPE_FIXED; + if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 ) + goto Fail; + + fi->Descender = shared_vals[0].u.f; + break; + + case AFM_TOKEN_STARTCHARMETRICS: + { + FT_Int n; + + + if ( afm_parser_read_int( parser, &n ) ) + goto Fail; + + error = afm_parser_skip_section( parser, n, + AFM_TOKEN_ENDCHARMETRICS ); + if ( error ) + return error; + } + break; + + case AFM_TOKEN_STARTKERNDATA: + error = afm_parse_kern_data( parser ); + if ( error ) + goto Fail; + /* fall through since we only support kern data */ + + case AFM_TOKEN_ENDFONTMETRICS: + return PSaux_Err_Ok; + break; + + default: + break; + } + } + + Fail: + FT_FREE( fi->TrackKerns ); + fi->NumTrackKern = 0; + + FT_FREE( fi->KernPairs ); + fi->NumKernPair = 0; + + fi->IsCIDFont = 0; + + return error; + } + + +/* END */ diff --git a/src/libs/freetype2/psaux/afmparse.h b/src/libs/freetype2/psaux/afmparse.h new file mode 100644 index 0000000000..c2fce75c86 --- /dev/null +++ b/src/libs/freetype2/psaux/afmparse.h @@ -0,0 +1,87 @@ +/***************************************************************************/ +/* */ +/* afmparse.h */ +/* */ +/* AFM parser (specification). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __AFMPARSE_H__ +#define __AFMPARSE_H__ + + +#include <ft2build.h> +#include FT_INTERNAL_POSTSCRIPT_AUX_H + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + afm_parser_init( AFM_Parser parser, + FT_Memory memory, + FT_Byte* base, + FT_Byte* limit ); + + + FT_LOCAL( void ) + afm_parser_done( AFM_Parser parser ); + + + FT_LOCAL( FT_Error ) + afm_parser_parse( AFM_Parser parser ); + + + enum AFM_ValueType_ + { + AFM_VALUE_TYPE_STRING, + AFM_VALUE_TYPE_NAME, + AFM_VALUE_TYPE_FIXED, /* real number */ + AFM_VALUE_TYPE_INTEGER, + AFM_VALUE_TYPE_BOOL, + AFM_VALUE_TYPE_INDEX /* glyph index */ + }; + + + typedef struct AFM_ValueRec_ + { + enum AFM_ValueType_ type; + union { + char* s; + FT_Fixed f; + FT_Int i; + FT_Bool b; + + } u; + + } AFM_ValueRec, *AFM_Value; + +#define AFM_MAX_ARGUMENTS 5 + + FT_LOCAL( FT_Int ) + afm_parser_read_vals( AFM_Parser parser, + AFM_Value vals, + FT_Int n ); + + /* read the next key from the next line or column */ + FT_LOCAL( char* ) + afm_parser_next_key( AFM_Parser parser, + FT_Bool line, + FT_UInt* len ); + +FT_END_HEADER + +#endif /* __AFMPARSE_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/psaux/descrip.mms b/src/libs/freetype2/psaux/descrip.mms deleted file mode 100644 index bff019243d..0000000000 --- a/src/libs/freetype2/psaux/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 PSaux driver compilation rules for VMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.psaux]) - -OBJS=psaux.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/psaux/module.mk b/src/libs/freetype2/psaux/module.mk index 29c3e28a91..5431522084 100644 --- a/src/libs/freetype2/psaux/module.mk +++ b/src/libs/freetype2/psaux/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_psaux_module +FTMODULE_H_COMMANDS += PSAUX_MODULE -add_psaux_module: - $(OPEN_DRIVER)psaux_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)psaux $(ECHO_DRIVER_DESC)Postscript Type 1 & Type 2 helper module$(ECHO_DRIVER_DONE) +define PSAUX_MODULE +$(OPEN_DRIVER)psaux_module_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)psaux $(ECHO_DRIVER_DESC)Postscript Type 1 & Type 2 helper module$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/psaux/psaux.c b/src/libs/freetype2/psaux/psaux.c index 9928184143..a4b9c5c6e4 100644 --- a/src/libs/freetype2/psaux/psaux.c +++ b/src/libs/freetype2/psaux/psaux.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript driver component (body only). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,5 +24,11 @@ #include "t1decode.c" #include "t1cmap.c" +#ifndef T1_CONFIG_OPTION_NO_AFM +#include "afmparse.c" +#endif + +#include "psconv.c" + /* END */ diff --git a/src/libs/freetype2/psaux/psauxmod.c b/src/libs/freetype2/psaux/psauxmod.c index 756ec1c565..4c3579f7b8 100644 --- a/src/libs/freetype2/psaux/psauxmod.c +++ b/src/libs/freetype2/psaux/psauxmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003 by */ +/* Copyright 2000-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,10 @@ #include "t1decode.h" #include "t1cmap.h" +#ifndef T1_CONFIG_OPTION_NO_AFM +#include "afmparse.h" +#endif + FT_CALLBACK_TABLE_DEF const PS_Table_FuncsRec ps_table_funcs = @@ -75,6 +79,17 @@ }; +#ifndef T1_CONFIG_OPTION_NO_AFM + FT_CALLBACK_TABLE_DEF + const AFM_Parser_FuncsRec afm_parser_funcs = + { + afm_parser_init, + afm_parser_done, + afm_parser_parse + }; +#endif + + FT_CALLBACK_TABLE_DEF const T1_CMap_ClassesRec t1_cmap_classes = { @@ -92,10 +107,15 @@ &ps_parser_funcs, &t1_builder_funcs, &t1_decoder_funcs, - t1_decrypt, - + (const T1_CMap_ClassesRec*) &t1_cmap_classes, + +#ifndef T1_CONFIG_OPTION_NO_AFM + &afm_parser_funcs, +#else + 0, +#endif }; diff --git a/src/libs/freetype2/psaux/psconv.c b/src/libs/freetype2/psaux/psconv.c new file mode 100644 index 0000000000..010d08cb53 --- /dev/null +++ b/src/libs/freetype2/psaux/psconv.c @@ -0,0 +1,399 @@ +/***************************************************************************/ +/* */ +/* psconv.c */ +/* */ +/* Some convenience conversions (body). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_DEBUG_H + +#include "psconv.h" +#include "psobjs.h" +#include "psauxerr.h" + + + /* The following array is used by various functions to quickly convert */ + /* digits (both decimal and non-decimal) into numbers. */ + +#if 'A' == 65 + /* ASCII */ + + static const FT_Char ft_char_table[128] = + { + /* 0x00 */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + }; + + /* no character >= 0x80 can represent a valid number */ +#define OP >= + +#endif /* 'A' == 65 */ + +#if 'A' == 193 + /* EBCDIC */ + + static const FT_Char ft_char_table[128] = + { + /* 0x80 */ + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1, + -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, + -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1, + -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, + -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + }; + + /* no character < 0x80 can represent a valid number */ +#define OP < + +#endif /* 'A' == 193 */ + + + FT_LOCAL_DEF( FT_Int ) + PS_Conv_Strtol( FT_Byte** cursor, + FT_Byte* limit, + FT_Int base ) + { + FT_Byte* p = *cursor; + FT_Int num = 0; + FT_Bool sign = 0; + + + if ( p == limit || base < 2 || base > 36 ) + return 0; + + if ( *p == '-' || *p == '+' ) + { + sign = FT_BOOL( *p == '-' ); + + p++; + if ( p == limit ) + return 0; + } + + for ( ; p < limit; p++ ) + { + FT_Char c; + + + if ( IS_PS_SPACE( *p ) || *p OP 0x80 ) + break; + + c = ft_char_table[*p & 0x7f]; + + if ( c < 0 || c >= base ) + break; + + num = num * base + c; + } + + if ( sign ) + num = -num; + + *cursor = p; + + return num; + } + + + FT_LOCAL_DEF( FT_Int ) + PS_Conv_ToInt( FT_Byte** cursor, + FT_Byte* limit ) + + { + FT_Byte* p; + FT_Int num; + + + num = PS_Conv_Strtol( cursor, limit, 10 ); + p = *cursor; + + if ( p < limit && *p == '#' ) + { + *cursor = p + 1; + + return PS_Conv_Strtol( cursor, limit, num ); + } + else + return num; + } + + + FT_LOCAL_DEF( FT_Fixed ) + PS_Conv_ToFixed( FT_Byte** cursor, + FT_Byte* limit, + FT_Int power_ten ) + { + FT_Byte* p = *cursor; + FT_Fixed integral; + FT_Long decimal = 0, divider = 1; + FT_Bool sign = 0; + + + if ( p == limit ) + return 0; + + if ( *p == '-' || *p == '+' ) + { + sign = FT_BOOL( *p == '-' ); + + p++; + if ( p == limit ) + return 0; + } + + if ( *p != '.' ) + integral = PS_Conv_ToInt( &p, limit ) << 16; + else + integral = 0; + + /* read the decimal part */ + if ( p < limit && *p == '.' ) + { + p++; + + for ( ; p < limit; p++ ) + { + FT_Char c; + + + if ( IS_PS_SPACE( *p ) || *p OP 0x80 ) + break; + + c = ft_char_table[*p & 0x7f]; + + if ( c < 0 || c >= 10 ) + break; + + if ( divider < 10000000L ) + { + decimal = decimal * 10 + c; + divider *= 10; + } + } + } + + /* read exponent, if any */ + if ( p + 1 < limit && ( *p == 'e' || *p == 'E' ) ) + { + p++; + power_ten += PS_Conv_ToInt( &p, limit ); + } + + while ( power_ten > 0 ) + { + integral *= 10; + decimal *= 10; + power_ten--; + } + + while ( power_ten < 0 ) + { + integral /= 10; + divider *= 10; + power_ten++; + } + + if ( decimal ) + integral += FT_DivFix( decimal, divider ); + + if ( sign ) + integral = -integral; + + *cursor = p; + + return integral; + } + + +#if 0 + FT_LOCAL_DEF( FT_UInt ) + PS_Conv_StringDecode( FT_Byte** cursor, + FT_Byte* limit, + FT_Byte* buffer, + FT_UInt n ) + { + FT_Byte* p; + FT_UInt r = 0; + + + for ( p = *cursor; r < n && p < limit; p++ ) + { + FT_Byte b; + + + if ( *p != '\\' ) + { + buffer[r++] = *p; + + continue; + } + + p++; + + switch ( *p ) + { + case 'n': + b = '\n'; + break; + case 'r': + b = '\r'; + break; + case 't': + b = '\t'; + break; + case 'b': + b = '\b'; + break; + case 'f': + b = '\f'; + break; + case '\r': + p++; + if ( *p != '\n' ) + { + b = *p; + + break; + } + /* no break */ + case '\n': + continue; + break; + default: + if ( IS_PS_DIGIT( *p ) ) + { + b = *p - '0'; + + p++; + + if ( IS_PS_DIGIT( *p ) ) + { + b = b * 8 + *p - '0'; + + p++; + + if ( IS_PS_DIGIT( *p ) ) + b = b * 8 + *p - '0'; + else + { + buffer[r++] = b; + b = *p; + } + } + else + { + buffer[r++] = b; + b = *p; + } + } + else + b = *p; + break; + } + + buffer[r++] = b; + } + + *cursor = p; + + return r; + } +#endif /* 0 */ + + + FT_LOCAL_DEF( FT_UInt ) + PS_Conv_ASCIIHexDecode( FT_Byte** cursor, + FT_Byte* limit, + FT_Byte* buffer, + FT_UInt n ) + { + FT_Byte* p; + FT_UInt r = 0; + + + n *= 2; + for ( p = *cursor; r < n && p < limit; p++ ) + { + FT_Char c; + + + if ( IS_PS_SPACE( *p ) ) + continue; + + if ( *p OP 0x80 ) + break; + + c = ft_char_table[*p & 0x7f]; + + if ( c < 0 || c >= 16 ) + break; + + if ( r % 2 ) + { + *buffer = (FT_Byte)(*buffer + c); + buffer++; + } + else + *buffer = (FT_Byte)(c << 4); + + r++; + } + + *cursor = p; + + return ( r + 1 ) / 2; + } + + + FT_LOCAL_DEF( FT_UInt ) + PS_Conv_EexecDecode( FT_Byte** cursor, + FT_Byte* limit, + FT_Byte* buffer, + FT_UInt n, + FT_UShort* seed ) + { + FT_Byte* p; + FT_UInt r; + FT_UShort s = *seed; + + + for ( r = 0, p = *cursor; r < n && p < limit; r++, p++ ) + { + FT_Byte b = (FT_Byte)( *p ^ ( s >> 8 ) ); + + + s = (FT_UShort)( ( *p + s ) * 52845U + 22719 ); + *buffer++ = b; + } + + *cursor = p; + *seed = s; + + return r; + } + + +/* END */ diff --git a/src/libs/freetype2/psaux/psconv.h b/src/libs/freetype2/psaux/psconv.h new file mode 100644 index 0000000000..82c370787f --- /dev/null +++ b/src/libs/freetype2/psaux/psconv.h @@ -0,0 +1,107 @@ +/***************************************************************************/ +/* */ +/* psconv.h */ +/* */ +/* Some convenience conversions (specification). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __PSCONV_H__ +#define __PSCONV_H__ + + +#include <ft2build.h> +#include FT_INTERNAL_POSTSCRIPT_AUX_H + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Int ) + PS_Conv_Strtol( FT_Byte** cursor, + FT_Byte* limit, + FT_Int base ); + + + FT_LOCAL( FT_Int ) + PS_Conv_ToInt( FT_Byte** cursor, + FT_Byte* limit ); + + FT_LOCAL( FT_Fixed ) + PS_Conv_ToFixed( FT_Byte** cursor, + FT_Byte* limit, + FT_Int power_ten ); + +#if 0 + FT_LOCAL( FT_UInt ) + PS_Conv_StringDecode( FT_Byte** cursor, + FT_Byte* limit, + FT_Byte* buffer, + FT_UInt n ); +#endif + + FT_LOCAL( FT_UInt ) + PS_Conv_ASCIIHexDecode( FT_Byte** cursor, + FT_Byte* limit, + FT_Byte* buffer, + FT_UInt n ); + + FT_LOCAL( FT_UInt ) + PS_Conv_EexecDecode( FT_Byte** cursor, + FT_Byte* limit, + FT_Byte* buffer, + FT_UInt n, + FT_UShort* seed ); + + +#define IS_PS_NEWLINE( ch ) \ + ( ( ch ) == '\r' || \ + ( ch ) == '\n' ) + +#define IS_PS_SPACE( ch ) \ + ( ( ch ) == ' ' || \ + IS_PS_NEWLINE( ch ) || \ + ( ch ) == '\t' || \ + ( ch ) == '\f' || \ + ( ch ) == '\0' ) + +#define IS_PS_SPECIAL( ch ) \ + ( ( ch ) == '/' || \ + ( ch ) == '(' || \ + ( ch ) == ')' || \ + ( ch ) == '<' || \ + ( ch ) == '>' || \ + ( ch ) == '[' || \ + ( ch ) == ']' || \ + ( ch ) == '{' || \ + ( ch ) == '}' || \ + ( ch ) == '%' ) + +#define IS_PS_DELIM( ch ) \ + ( IS_PS_SPACE( ch ) || \ + IS_PS_SPECIAL( ch ) ) + +#define IS_PS_DIGIT( ch ) ( ( ch ) >= '0' && ( ch ) <= '9' ) + +#define IS_PS_XDIGIT( ch ) \ + ( IS_PS_DIGIT( ( ch ) ) || \ + ( ( ch ) >= 'A' && ( ch ) <= 'F' ) || \ + ( ( ch ) >= 'a' && ( ch ) <= 'f' ) ) + +#define IS_PS_BASE85( ch ) ( ( ch ) >= '!' && ( ch ) <= 'u' ) + +FT_END_HEADER + +#endif /* __PSCONV_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/psaux/psobjs.c b/src/libs/freetype2/psaux/psobjs.c index 2480c3fa26..2b2892f3c4 100644 --- a/src/libs/freetype2/psaux/psobjs.c +++ b/src/libs/freetype2/psaux/psobjs.c @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,6 +21,7 @@ #include FT_INTERNAL_DEBUG_H #include "psobjs.h" +#include "psconv.h" #include "psauxerr.h" @@ -87,9 +88,9 @@ shift_elements( PS_Table table, FT_Byte* old_base ) { - FT_Long delta = (FT_Long)( table->block - old_base ); - FT_Byte** offset = table->elements; - FT_Byte** limit = offset + table->max_elems; + FT_PtrDist delta = table->block - old_base; + FT_Byte** offset = table->elements; + FT_Byte** limit = offset + table->max_elems; for ( ; offset < limit; offset++ ) @@ -266,64 +267,6 @@ /*************************************************************************/ /*************************************************************************/ - /* In the PostScript Language Reference Manual (PLRM) the following */ - /* characters are called `whitespace characters'. */ -#define IS_T1_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' ) -#define IS_T1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' || (c) == '\f' ) -#define IS_T1_NULLSPACE( c ) ( (c) == '\0' ) - - /* According to the PLRM all whitespace characters are equivalent, */ - /* except in comments and strings. */ -#define IS_T1_SPACE( c ) ( IS_T1_WHITESPACE( c ) || \ - IS_T1_LINESPACE( c ) || \ - IS_T1_NULLSPACE( c ) ) - - - /* The following array is used by various functions to quickly convert */ - /* digits (both decimal and non-decimal) into numbers. */ - -#if 'A' == 65 - /* ASCII */ - - static const char ft_char_table[128] = - { - /* 0x00 */ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - }; - - /* no character >= 0x80 can represent a valid number */ -#define OP >= - -#endif /* 'A' == 65 */ - -#if 'A' == 193 - /* EBCDIC */ - - static const char ft_char_table[128] = - { - /* 0x80 */ - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1, - -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, - -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1, - -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, - -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - } - - /* no character < 0x80 can represent a valid number */ -#define OP < - -#endif /* 'A' == 193 */ - /* first character must be already part of the comment */ @@ -336,7 +279,7 @@ while ( cur < limit ) { - if ( IS_T1_LINESPACE( *cur ) ) + if ( IS_PS_NEWLINE( *cur ) ) break; cur++; } @@ -354,7 +297,7 @@ while ( cur < limit ) { - if ( !IS_T1_SPACE( *cur ) ) + if ( !IS_PS_SPACE( *cur ) ) { if ( *cur == '%' ) /* According to the PLRM, a comment is equal to a space. */ @@ -412,19 +355,12 @@ while ( ++cur < limit ) { - int d; - - /* All whitespace characters are ignored. */ skip_spaces( &cur, limit ); if ( cur >= limit ) break; - if ( *cur OP 0x80 ) - break; - - d = ft_char_table[*cur & 0x7F]; - if ( d < 0 || d >= 16 ) + if ( !IS_PS_XDIGIT( *cur ) ) break; } @@ -510,15 +446,6 @@ /* anything else */ while ( cur < limit ) { - if ( IS_T1_SPACE( *cur ) || - *cur == '(' || - *cur == '/' || - *cur == '%' || - *cur == '[' || *cur == ']' || - *cur == '{' || *cur == '}' || - *cur == '<' || *cur == '>' ) - break; - if ( *cur == ')' ) { FT_ERROR(( "ps_parser_skip_PS_token: " @@ -526,6 +453,8 @@ parser->error = PSaux_Err_Invalid_File_Format; goto Exit; } + else if ( IS_PS_DELIM( *cur ) ) + break; cur++; } @@ -692,270 +621,6 @@ } - /* first character must be already part of the number */ - - static FT_Long - ps_radix( FT_Long radixBase, - FT_Byte* *acur, - FT_Byte* limit ) - { - FT_Long result = 0; - FT_Byte* cur = *acur; - - - if ( radixBase < 2 || radixBase > 36 ) - return 0; - - while ( cur < limit ) - { - int d; - - - if ( *cur OP 0x80 ) - break; - - d = ft_char_table[*cur & 0x7F]; - if ( d < 0 || d >= radixBase ) - break; - - result = result * radixBase + d; - - cur++; - } - - *acur = cur; - - return result; - } - - - /* first character must be already part of the number */ - - static FT_Long - ps_toint( FT_Byte* *acur, - FT_Byte* limit ) - { - FT_Long result = 0; - FT_Byte* cur = *acur; - FT_Byte c; - - - if ( cur >= limit ) - goto Exit; - - c = *cur; - if ( c == '-' ) - cur++; - - while ( cur < limit ) - { - int d; - - - if ( *cur == '#' ) - { - cur++; - result = ps_radix( result, &cur, limit ); - break; - } - - if ( *cur OP 0x80 ) - break; - - d = ft_char_table[*cur & 0x7F]; - if ( d < 0 || d >= 10 ) - break; - result = result * 10 + d; - - cur++; - }; - - if ( c == '-' ) - result = -result; - - Exit: - *acur = cur; - return result; - } - - - /* first character must be `<' if `delimiters' is non-zero */ - - static FT_Error - ps_tobytes( FT_Byte* *acur, - FT_Byte* limit, - FT_Long max_bytes, - FT_Byte* bytes, - FT_Long* pnum_bytes, - FT_Bool delimiters ) - { - FT_Error error = PSaux_Err_Ok; - - FT_Byte* cur = *acur; - FT_Long n = 0; - - - if ( cur >= limit ) - goto Exit; - - if ( delimiters ) - { - if ( *cur != '<' ) - { - FT_ERROR(( "ps_tobytes: Missing starting delimiter `<'\n" )); - error = PSaux_Err_Invalid_File_Format; - goto Exit; - } - - cur++; - } - - max_bytes = max_bytes * 2; - - for ( n = 0; cur < limit; n++, cur++ ) - { - int d; - - - if ( n >= max_bytes ) - /* buffer is full */ - goto Exit; - - /* All whitespace characters are ignored. */ - skip_spaces( &cur, limit ); - if ( cur >= limit ) - break; - - if ( *cur OP 0x80 ) - break; - - d = ft_char_table[*cur & 0x7F]; - if ( d < 0 || d >= 16 ) - break; - - /* <f> == <f0> != <0f> */ - bytes[n / 2] = (FT_Byte)( ( n % 2 ) ? bytes[n / 2] + d - : d * 16 ); - } - - if ( delimiters ) - { - if ( cur < limit && *cur != '>' ) - { - FT_ERROR(( "ps_tobytes: Missing closing delimiter `>'\n" )); - error = PSaux_Err_Invalid_File_Format; - goto Exit; - } - - cur++; - } - - *acur = cur; - - Exit: - *pnum_bytes = ( n + 1 ) / 2; - - return error; - } - - - /* first character must be already part of the number */ - - static FT_Long - ps_tofixed( FT_Byte* *acur, - FT_Byte* limit, - FT_Long power_ten ) - { - FT_Byte* cur = *acur; - FT_Long num, divider, result; - FT_Int sign = 0; - - - if ( cur >= limit ) - return 0; - - /* first of all, check the sign */ - if ( *cur == '-' && cur + 1 < limit ) - { - sign = 1; - cur++; - } - - /* then, read the integer part, if any */ - if ( *cur != '.' ) - result = ps_toint( &cur, limit ) << 16; - else - result = 0; - - num = 0; - divider = 1; - - if ( cur >= limit ) - goto Exit; - - /* read decimal part, if any */ - if ( *cur == '.' && cur + 1 < limit ) - { - cur++; - - for (;;) - { - int d; - - - if ( *cur OP 0x80 ) - break; - - d = ft_char_table[*cur & 0x7F]; - if ( d < 0 || d >= 10 ) - break; - - if ( divider < 10000000L ) - { - num = num * 10 + d; - divider *= 10; - } - - cur++; - if ( cur >= limit ) - break; - } - } - - /* read exponent, if any */ - if ( cur + 1 < limit && ( *cur == 'e' || *cur == 'E' ) ) - { - cur++; - power_ten += ps_toint( &cur, limit ); - } - - Exit: - /* raise to power of ten if needed */ - while ( power_ten > 0 ) - { - result = result * 10; - num = num * 10; - power_ten--; - } - - while ( power_ten < 0 ) - { - result = result / 10; - divider = divider * 10; - power_ten++; - } - - if ( num ) - result += FT_DivFix( num, divider ); - - if ( sign ) - result = -result; - - *acur = cur; - return result; - } - - /* first character must be a delimiter or a part of a number */ static FT_Int @@ -1003,7 +668,8 @@ break; } - coords[count] = (FT_Short)( ps_tofixed( &cur, limit, 0 ) >> 16 ); + coords[count] = + (FT_Short)( PS_Conv_ToFixed( &cur, limit, 0 ) >> 16 ); count++; if ( !ender ) @@ -1064,7 +730,7 @@ break; } - values[count] = ps_tofixed( &cur, limit, power_ten ); + values[count] = PS_Conv_ToFixed( &cur, limit, power_ten ); count++; if ( !ender ) @@ -1250,15 +916,15 @@ goto Store_Integer; case T1_FIELD_TYPE_FIXED: - val = ps_tofixed( &cur, limit, 0 ); + val = PS_Conv_ToFixed( &cur, limit, 0 ); goto Store_Integer; case T1_FIELD_TYPE_FIXED_1000: - val = ps_tofixed( &cur, limit, 3 ); + val = PS_Conv_ToFixed( &cur, limit, 3 ); goto Store_Integer; case T1_FIELD_TYPE_INTEGER: - val = ps_toint( &cur, limit ); + val = PS_Conv_ToInt( &cur, limit ); /* fall through */ Store_Integer: @@ -1424,10 +1090,12 @@ ps_parser_to_int( PS_Parser parser ) { ps_parser_skip_spaces( parser ); - return ps_toint( &parser->cursor, parser->limit ); + return PS_Conv_ToInt( &parser->cursor, parser->limit ); } + /* first character must be `<' if `delimiters' is non-zero */ + FT_LOCAL_DEF( FT_Error ) ps_parser_to_bytes( PS_Parser parser, FT_Byte* bytes, @@ -1435,13 +1103,49 @@ FT_Long* pnum_bytes, FT_Bool delimiters ) { + FT_Error error = PSaux_Err_Ok; + FT_Byte* cur; + + ps_parser_skip_spaces( parser ); - return ps_tobytes( &parser->cursor, - parser->limit, - max_bytes, - bytes, - pnum_bytes, - delimiters ); + cur = parser->cursor; + + if ( cur >= parser->limit ) + goto Exit; + + if ( delimiters ) + { + if ( *cur != '<' ) + { + FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" )); + error = PSaux_Err_Invalid_File_Format; + goto Exit; + } + + cur++; + } + + *pnum_bytes = PS_Conv_ASCIIHexDecode( &cur, + parser->limit, + bytes, + max_bytes ); + + if ( delimiters ) + { + if ( cur < parser->limit && *cur != '>' ) + { + FT_ERROR(( "ps_tobytes: Missing closing delimiter `>'\n" )); + error = PSaux_Err_Invalid_File_Format; + goto Exit; + } + + cur++; + } + + parser->cursor = cur; + + Exit: + return error; } @@ -1450,7 +1154,7 @@ FT_Int power_ten ) { ps_parser_skip_spaces( parser ); - return ps_tofixed( &parser->cursor, parser->limit, power_ten ); + return PS_Conv_ToFixed( &parser->cursor, parser->limit, power_ten ); } @@ -1623,7 +1327,7 @@ t1_builder_check_points( T1_Builder builder, FT_Int count ) { - return FT_GlyphLoader_CheckPoints( builder->loader, count, 0 ); + return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); } @@ -1689,7 +1393,7 @@ return PSaux_Err_Ok; } - error = FT_GlyphLoader_CheckPoints( builder->loader, 0, 1 ); + error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); if ( !error ) { if ( outline->n_contours > 0 ) @@ -1735,6 +1439,9 @@ FT_Outline* outline = builder->current; + if ( !outline ) + return; + /* XXXX: We must not include the last point in the path if it */ /* is located on the first point. */ if ( outline->n_points > 1 ) @@ -1777,16 +1484,11 @@ FT_Offset length, FT_UShort seed ) { - while ( length > 0 ) - { - FT_Byte plain; - - - plain = (FT_Byte)( *buffer ^ ( seed >> 8 ) ); - seed = (FT_UShort)( ( *buffer + seed ) * 52845U + 22719 ); - *buffer++ = plain; - length--; - } + PS_Conv_EexecDecode( &buffer, + buffer + length, + buffer, + length, + &seed ); } diff --git a/src/libs/freetype2/psaux/rules.mk b/src/libs/freetype2/psaux/rules.mk index 7338d3657a..7a1be37b69 100644 --- a/src/libs/freetype2/psaux/rules.mk +++ b/src/libs/freetype2/psaux/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000, 2002, 2003 by +# Copyright 1996-2000, 2002, 2003, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -28,6 +28,8 @@ PSAUX_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSAUX_DIR)) PSAUX_DRV_SRC := $(PSAUX_DIR)/psobjs.c \ $(PSAUX_DIR)/t1decode.c \ $(PSAUX_DIR)/t1cmap.c \ + $(PSAUX_DIR)/afmparse.c \ + $(PSAUX_DIR)/psconv.c \ $(PSAUX_DIR)/psauxmod.c # PSAUX driver headers diff --git a/src/libs/freetype2/psaux/t1cmap.c b/src/libs/freetype2/psaux/t1cmap.c index dcd99be49f..79e58dde43 100644 --- a/src/libs/freetype2/psaux/t1cmap.c +++ b/src/libs/freetype2/psaux/t1cmap.c @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (body). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -257,194 +257,70 @@ /*************************************************************************/ /*************************************************************************/ - FT_CALLBACK_DEF( FT_Int ) - t1_cmap_uni_pair_compare( const void* pair1, - const void* pair2 ) + FT_CALLBACK_DEF( const char * ) + t1_get_glyph_name( T1_Face face, + FT_UInt idx ) { - FT_UInt32 u1 = ((T1_CMapUniPair)pair1)->unicode; - FT_UInt32 u2 = ((T1_CMapUniPair)pair2)->unicode; - - - if ( u1 < u2 ) - return -1; - - if ( u1 > u2 ) - return +1; - - return 0; + return face->type1.glyph_names[idx]; } FT_CALLBACK_DEF( FT_Error ) - t1_cmap_unicode_init( T1_CMapUnicode cmap ) + t1_cmap_unicode_init( PS_Unicodes unicodes ) { - FT_Error error; - FT_UInt count; - T1_Face face = (T1_Face)FT_CMAP_FACE( cmap ); + T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; - cmap->num_pairs = 0; - cmap->pairs = NULL; - - count = face->type1.num_glyphs; - - if ( !FT_NEW_ARRAY( cmap->pairs, count ) ) - { - FT_UInt n, new_count; - T1_CMapUniPair pair; - FT_UInt32 uni_code; - - - pair = cmap->pairs; - for ( n = 0; n < count; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - /* build unsorted pair table by matching glyph names */ - if ( gname ) - { - uni_code = psnames->unicode_value( gname ); - - if ( uni_code != 0 ) - { - pair->unicode = uni_code; - pair->gindex = n; - pair++; - } - } - } - - new_count = (FT_UInt)( pair - cmap->pairs ); - if ( new_count == 0 ) - { - /* there are no unicode characters in here! */ - FT_FREE( cmap->pairs ); - error = PSaux_Err_Invalid_Argument; - } - else - { - /* re-allocate if the new array is much smaller than the original */ - /* one */ - if ( new_count != count && new_count < count / 2 ) - { - (void)FT_RENEW_ARRAY( cmap->pairs, count, new_count ); - error = 0; - } - - /* sort the pairs table to allow efficient binary searches */ - ft_qsort( cmap->pairs, - new_count, - sizeof ( T1_CMapUniPairRec ), - t1_cmap_uni_pair_compare ); - - cmap->num_pairs = new_count; - } - } - - return error; + return psnames->unicodes_init( memory, + unicodes, + face->type1.num_glyphs, + (PS_Glyph_NameFunc)&t1_get_glyph_name, + (FT_Pointer)face ); } FT_CALLBACK_DEF( void ) - t1_cmap_unicode_done( T1_CMapUnicode cmap ) + t1_cmap_unicode_done( PS_Unicodes unicodes ) { - FT_Face face = FT_CMAP_FACE(cmap); - FT_Memory memory = FT_FACE_MEMORY(face); + FT_Face face = FT_CMAP_FACE( unicodes ); + FT_Memory memory = FT_FACE_MEMORY( face ); - FT_FREE( cmap->pairs ); - cmap->num_pairs = 0; + + FT_FREE( unicodes->maps ); + unicodes->num_maps = 0; } FT_CALLBACK_DEF( FT_UInt ) - t1_cmap_unicode_char_index( T1_CMapUnicode cmap, - FT_UInt32 char_code ) + t1_cmap_unicode_char_index( PS_Unicodes unicodes, + FT_UInt32 char_code ) { - FT_UInt min = 0; - FT_UInt max = cmap->num_pairs; - FT_UInt mid; - T1_CMapUniPair pair; + T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; - while ( min < max ) - { - mid = min + ( max - min ) / 2; - pair = cmap->pairs + mid; - - if ( pair->unicode == char_code ) - return pair->gindex; - - if ( pair->unicode < char_code ) - min = mid + 1; - else - max = mid; - } - return 0; + return psnames->unicodes_char_index( unicodes, char_code ); } FT_CALLBACK_DEF( FT_UInt ) - t1_cmap_unicode_char_next( T1_CMapUnicode cmap, - FT_UInt32 *pchar_code ) + t1_cmap_unicode_char_next( PS_Unicodes unicodes, + FT_UInt32 *pchar_code ) { - FT_UInt result = 0; - FT_UInt32 char_code = *pchar_code + 1; + T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; - Restart: - { - FT_UInt min = 0; - FT_UInt max = cmap->num_pairs; - FT_UInt mid; - T1_CMapUniPair pair; - - - while ( min < max ) - { - mid = min + ( ( max - min ) >> 1 ); - pair = cmap->pairs + mid; - - if ( pair->unicode == char_code ) - { - result = pair->gindex; - if ( result != 0 ) - goto Exit; - - char_code++; - goto Restart; - } - - if ( pair->unicode < char_code ) - min = mid+1; - else - max = mid; - } - - /* we didn't find it, but we have a pair just above it */ - char_code = 0; - - if ( min < cmap->num_pairs ) - { - pair = cmap->pairs + min; - result = pair->gindex; - if ( result != 0 ) - char_code = pair->unicode; - } - } - - Exit: - *pchar_code = char_code; - return result; + return psnames->unicodes_char_next( unicodes, pchar_code ); } FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec t1_cmap_unicode_class_rec = { - sizeof ( T1_CMapUnicodeRec ), + sizeof ( PS_UnicodesRec ), (FT_CMap_InitFunc) t1_cmap_unicode_init, (FT_CMap_DoneFunc) t1_cmap_unicode_done, diff --git a/src/libs/freetype2/psaux/t1cmap.h b/src/libs/freetype2/psaux/t1cmap.h index aa93d746c1..7ae65d2fa1 100644 --- a/src/libs/freetype2/psaux/t1cmap.h +++ b/src/libs/freetype2/psaux/t1cmap.h @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (specification). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -39,13 +39,13 @@ FT_BEGIN_HEADER typedef struct T1_CMapStdRec_ { - FT_CMapRec cmap; + FT_CMapRec cmap; - const FT_UShort* code_to_sid; - PS_Adobe_Std_Strings_Func sid_to_string; + const FT_UShort* code_to_sid; + PS_Adobe_Std_StringsFunc sid_to_string; - FT_UInt num_glyphs; - const char* const* glyph_names; + FT_UInt num_glyphs; + const char* const* glyph_names; } T1_CMapStdRec; @@ -89,25 +89,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /* unicode (syntehtic) cmaps */ - typedef struct T1_CMapUnicodeRec_* T1_CMapUnicode; - - typedef struct T1_CMapUniPairRec_ - { - FT_UInt32 unicode; - FT_UInt gindex; - - } T1_CMapUniPairRec, *T1_CMapUniPair; - - - typedef struct T1_CMapUnicodeRec_ - { - FT_CMapRec cmap; - FT_UInt num_pairs; - T1_CMapUniPair pairs; - - } T1_CMapUnicodeRec; - + /* unicode (synthetic) cmaps */ FT_CALLBACK_TABLE const FT_CMap_ClassRec t1_cmap_unicode_class_rec; diff --git a/src/libs/freetype2/pshinter/descrip.mms b/src/libs/freetype2/pshinter/descrip.mms deleted file mode 100644 index 205d6cfcc0..0000000000 --- a/src/libs/freetype2/pshinter/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 PSHinter driver compilation rules for OpenVMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.psnames]) - -OBJS=pshinter.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/pshinter/module.mk b/src/libs/freetype2/pshinter/module.mk index 63c7e217f1..cd171d0355 100644 --- a/src/libs/freetype2/pshinter/module.mk +++ b/src/libs/freetype2/pshinter/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2001 by +# Copyright 1996-2001, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_pshinter_module +FTMODULE_H_COMMANDS += PSHINTER_MODULE -add_pshinter_module: - $(OPEN_DRIVER)pshinter_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)pshinter $(ECHO_DRIVER_DESC)Postscript hinter module$(ECHO_DRIVER_DONE) +define PSHINTER_MODULE +$(OPEN_DRIVER)pshinter_module_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)pshinter $(ECHO_DRIVER_DESC)Postscript hinter module$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/pshinter/pshglob.c b/src/libs/freetype2/pshinter/pshglob.c index 21d45e92ff..8a69aa1e84 100644 --- a/src/libs/freetype2/pshinter/pshglob.c +++ b/src/libs/freetype2/pshinter/pshglob.c @@ -5,7 +5,7 @@ /* PostScript hinter global hinting management (body). */ /* Inspired by the new auto-hinter module. */ /* */ -/* Copyright 2001, 2002, 2003, 2004 by */ +/* Copyright 2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ @@ -150,7 +150,7 @@ FT_UNUSED( target ); - for ( ; read_count > 0; read_count -= 2 ) + for ( ; read_count > 1; read_count -= 2 ) { FT_Int reference, delta; FT_UInt count; diff --git a/src/libs/freetype2/pshinter/pshrec.h b/src/libs/freetype2/pshinter/pshrec.h index 0159e9cd5d..f7ef9004ea 100644 --- a/src/libs/freetype2/pshinter/pshrec.h +++ b/src/libs/freetype2/pshinter/pshrec.h @@ -4,7 +4,7 @@ /* */ /* Postscript (Type1/Type2) hints recorder (specification). */ /* */ -/* Copyright 2001, 2002, 2003 by */ +/* Copyright 2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,7 +22,7 @@ /* font drivers to record the hints of a given character/glyph. */ /* */ /* The hints are recorded in a unified format, and are later processed */ - /* by the "optimizer" and "fitter" to adjust the outlines to the pixel */ + /* by the `optimizer' and `fitter' to adjust the outlines to the pixel */ /* grid. */ /* */ /**************************************************************************/ diff --git a/src/libs/freetype2/psnames/descrip.mms b/src/libs/freetype2/psnames/descrip.mms deleted file mode 100644 index 6a66b9fa3e..0000000000 --- a/src/libs/freetype2/psnames/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 PSNames driver compilation rules for VMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.psnames]) - -OBJS=psnames.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/psnames/module.mk b/src/libs/freetype2/psnames/module.mk index e1e59c46b6..a93063b928 100644 --- a/src/libs/freetype2/psnames/module.mk +++ b/src/libs/freetype2/psnames/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_psnames_module +FTMODULE_H_COMMANDS += PSNAMES_MODULE -add_psnames_module: - $(OPEN_DRIVER)psnames_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)psnames $(ECHO_DRIVER_DESC)Postscript & Unicode Glyph name handling$(ECHO_DRIVER_DONE) +define PSNAMES_MODULE +$(OPEN_DRIVER)psnames_module_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)psnames $(ECHO_DRIVER_DESC)Postscript & Unicode Glyph name handling$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/psnames/psmodule.c b/src/libs/freetype2/psnames/psmodule.c index ba9deae8aa..631eafd0ec 100644 --- a/src/libs/freetype2/psnames/psmodule.c +++ b/src/libs/freetype2/psnames/psmodule.c @@ -4,7 +4,7 @@ /* */ /* PSNames module implementation (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -32,9 +32,14 @@ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST +#define VARIANT_BIT ( 1L << 31 ) +#define BASE_GLYPH( code ) ( (code) & ~VARIANT_BIT ) + + /* Return the Unicode value corresponding to a given glyph. Note that */ /* we do deal with glyph variants by detecting a non-initial dot in */ - /* the name, as in `A.swash' or `e.final'. */ + /* the name, as in `A.swash' or `e.final'; in this case, the */ + /* VARIANT_BIT is set in the return value. */ /* */ static FT_UInt32 ps_unicode_value( const char* glyph_name ) @@ -72,7 +77,9 @@ d += 10; } - /* exit if a non-uppercase hexadecimal character was found */ + /* Exit if a non-uppercase hexadecimal character was found */ + /* -- this also catches character codes below `0' since such */ + /* negative numbers cast to `unsigned int' are far too big. */ if ( d >= 16 ) break; @@ -80,8 +87,13 @@ } /* there must be exactly four hex digits */ - if ( ( *p == '\0' || *p == '.' ) && count == 0 ) - return value; + if ( count == 0 ) + { + if ( *p == '\0' ) + return value; + if ( *p == '.' ) + return value ^ VARIANT_BIT; + } } /* If the name begins with `u', followed by four to six uppercase */ @@ -115,12 +127,17 @@ value = ( value << 4 ) + d; } - if ( ( *p == '\0' || *p == '.' ) && count <= 2 ) - return value; + if ( count <= 2 ) + { + if ( *p == '\0' ) + return value; + if ( *p == '.' ) + return value ^ VARIANT_BIT; + } } - /* look for a non-initial dot in the glyph name in order to */ - /* sort-out variants like `A.swash', `e.final', etc. */ + /* Look for a non-initial dot in the glyph name in order to */ + /* find variants like `A.swash', `e.final', etc. */ { const char* p = glyph_name; const char* dot = NULL; @@ -128,15 +145,18 @@ for ( ; *p; p++ ) { - if ( *p == '.' && p > glyph_name && !dot ) + if ( *p == '.' && p > glyph_name ) + { dot = p; + break; + } } + /* now look up the glyph in the Adobe Glyph List */ if ( !dot ) - dot = p; - - /* now, look up the glyph in the Adobe Glyph List */ - return ft_get_adobe_glyph_index( glyph_name, dot ); + return ft_get_adobe_glyph_index( glyph_name, p ); + else + return ft_get_adobe_glyph_index( glyph_name, dot ) ^ VARIANT_BIT; } } @@ -148,18 +168,25 @@ { PS_UniMap* map1 = (PS_UniMap*)a; PS_UniMap* map2 = (PS_UniMap*)b; + FT_UInt32 unicode1 = BASE_GLYPH( map1->unicode ); + FT_UInt32 unicode2 = BASE_GLYPH( map2->unicode ); - return ( map1->unicode - map2->unicode ); + /* sort base glyphs before glyph variants */ + if ( unicode1 == unicode2 ) + return map1->unicode - map2->unicode; + else + return unicode1 - unicode2; } - /* Builds a table that maps Unicode values to glyph indices */ + /* Build a table that maps Unicode values to glyph indices. */ static FT_Error - ps_unicodes_init( FT_Memory memory, - FT_UInt num_glyphs, - const char** glyph_names, - PS_Unicodes* table ) + ps_unicodes_init( FT_Memory memory, + PS_Unicodes table, + FT_UInt num_glyphs, + PS_Glyph_NameFunc get_glyph_name, + FT_Pointer glyph_data ) { FT_Error error; @@ -180,39 +207,44 @@ for ( n = 0; n < num_glyphs; n++ ) { - const char* gname = glyph_names[n]; + const char* gname = get_glyph_name( glyph_data, n ); if ( gname ) { uni_char = ps_unicode_value( gname ); - if ( uni_char != 0 && uni_char != 0xFFFFL ) + if ( BASE_GLYPH( uni_char ) != 0 ) { - map->unicode = (FT_UInt)uni_char; + map->unicode = uni_char; map->glyph_index = n; map++; } } } - /* now, compress the table a bit */ + /* now compress the table a bit */ count = (FT_UInt)( map - table->maps ); - if ( count > 0 && FT_REALLOC( table->maps, - num_glyphs * sizeof ( PS_UniMap ), - count * sizeof ( PS_UniMap ) ) ) - count = 0; - if ( count == 0 ) { FT_FREE( table->maps ); if ( !error ) - error = PSnames_Err_Invalid_Argument; /* no unicode chars here! */ + error = PSnames_Err_Invalid_Argument; /* No unicode chars here! */ + } + else { + /* Reallocate if the number of used entries is much smaller. */ + if ( count < num_glyphs / 2 ) + { + (void)FT_RENEW_ARRAY( table->maps, num_glyphs, count ); + error = PSnames_Err_Ok; + } + + /* Sort the table in increasing order of unicode values, */ + /* taking care of glyph variants. */ + ft_qsort( table->maps, count, sizeof ( PS_UniMap ), + compare_uni_maps ); } - else - /* sort the table in increasing order of unicode values */ - ft_qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps ); table->num_maps = count; } @@ -222,75 +254,106 @@ static FT_UInt - ps_unicodes_char_index( PS_Unicodes* table, - FT_ULong unicode ) + ps_unicodes_char_index( PS_Unicodes table, + FT_UInt32 unicode ) { - PS_UniMap *min, *max, *mid; + PS_UniMap *min, *max, *mid, *result = NULL; - /* perform a binary search on the table */ + /* Perform a binary search on the table. */ min = table->maps; max = min + table->num_maps - 1; while ( min <= max ) { - mid = min + ( max - min ) / 2; + FT_UInt32 base_glyph; + + + mid = min + ( ( max - min ) >> 1 ); + if ( mid->unicode == unicode ) - return mid->glyph_index; + { + result = mid; + break; + } + + base_glyph = BASE_GLYPH( mid->unicode ); + + if ( base_glyph == unicode ) + result = mid; /* remember match but continue search for base glyph */ if ( min == max ) break; - if ( mid->unicode < unicode ) + if ( base_glyph < unicode ) min = mid + 1; else max = mid - 1; } - return 0xFFFFU; + if ( result ) + return result->glyph_index; + else + return 0; } static FT_ULong - ps_unicodes_char_next( PS_Unicodes* table, - FT_ULong unicode ) + ps_unicodes_char_next( PS_Unicodes table, + FT_UInt32 *unicode ) { - PS_UniMap *min, *max, *mid; + FT_UInt result = 0; + FT_UInt32 char_code = *unicode + 1; - unicode++; - /* perform a binary search on the table */ - - min = table->maps; - max = min + table->num_maps - 1; - - while ( min <= max ) { - mid = min + ( max - min ) / 2; - if ( mid->unicode == unicode ) - return unicode; + FT_UInt min = 0; + FT_UInt max = table->num_maps; + FT_UInt mid; + PS_UniMap* map; + FT_UInt32 base_glyph; - if ( min == max ) - break; - if ( mid->unicode < unicode ) - min = mid + 1; - else - max = mid - 1; + while ( min < max ) + { + mid = min + ( ( max - min ) >> 1 ); + map = table->maps + mid; + + if ( map->unicode == char_code ) + { + result = map->glyph_index; + goto Exit; + } + + base_glyph = BASE_GLYPH( map->unicode ); + + if ( base_glyph == char_code ) + result = map->glyph_index; + + if ( base_glyph < char_code ) + min = mid + 1; + else + max = mid; + } + + if ( result ) + goto Exit; /* we have a variant glyph */ + + /* we didn't find it; check whether we have a map just above it */ + char_code = 0; + + if ( min < table->num_maps ) + { + map = table->maps + min; + result = map->glyph_index; + char_code = BASE_GLYPH( map->unicode ); + } } - if ( max < table->maps ) - max = table->maps; - - while ( max < table->maps + table->num_maps ) - { - if ( unicode < max->unicode ) - return max->unicode; - max++; - } - - return 0; + Exit: + *unicode = char_code; + return result; } @@ -336,8 +399,8 @@ #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ - (PS_Macintosh_Name_Func) ps_get_macintosh_name, - (PS_Adobe_Std_Strings_Func)ps_get_standard_strings, + (PS_Macintosh_NameFunc) ps_get_macintosh_name, + (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, t1_standard_encoding, t1_expert_encoding diff --git a/src/libs/freetype2/raster/descrip.mms b/src/libs/freetype2/raster/descrip.mms deleted file mode 100644 index d0650ebbf7..0000000000 --- a/src/libs/freetype2/raster/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 renderer module compilation rules for VMS -# - - -# Copyright 2001 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.raster]) - -OBJS=raster.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/raster/ftrend1.c b/src/libs/freetype2/raster/ftrend1.c index ed75fb6055..3cc8d07413 100644 --- a/src/libs/freetype2/raster/ftrend1.c +++ b/src/libs/freetype2/raster/ftrend1.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer interface (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -161,13 +161,13 @@ if ( !( mode & FT_RENDER_MODE_MONO ) ) { /* we pad to 32 bits, only for backwards compatibility with FT 1.x */ - pitch = FT_PAD_CEIL( width, 4 ); + pitch = FT_PAD_CEIL( width, 4 ); bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; } else { - pitch = ( ( width + 15 ) >> 4 ) << 1; + pitch = ( ( width + 15 ) >> 4 ) << 1; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; } @@ -175,7 +175,7 @@ bitmap->rows = height; bitmap->pitch = pitch; - if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) + if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) ) goto Exit; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; diff --git a/src/libs/freetype2/raster/module.mk b/src/libs/freetype2/raster/module.mk index 8a3136413d..59c737b930 100644 --- a/src/libs/freetype2/raster/module.mk +++ b/src/libs/freetype2/raster/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_raster_module +FTMODULE_H_COMMANDS += RASTER_MODULE -add_raster_module: - $(OPEN_DRIVER)ft_raster1_renderer_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)raster $(ECHO_DRIVER_DESC)monochrome bitmap renderer$(ECHO_DRIVER_DONE) +define RASTER_MODULE +$(OPEN_DRIVER)ft_raster1_renderer_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)raster $(ECHO_DRIVER_DESC)monochrome bitmap renderer$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/sfnt/Jamfile b/src/libs/freetype2/sfnt/Jamfile index 441bc81d06..caf0c2cd60 100644 --- a/src/libs/freetype2/sfnt/Jamfile +++ b/src/libs/freetype2/sfnt/Jamfile @@ -13,7 +13,7 @@ UseFreeTypeHeaders ; if $(FT2_MULTI) { - _sources = sfobjs sfdriver ttcmap ttpost ttload ttsbit ttkern ; + _sources = sfobjs sfdriver ttcmap ttpost ttload ttsbit ttkern ttbdf ; } else { diff --git a/src/libs/freetype2/sfnt/descrip.mms b/src/libs/freetype2/sfnt/descrip.mms deleted file mode 100644 index 811c8b3ee5..0000000000 --- a/src/libs/freetype2/sfnt/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 SFNT driver compilation rules for VMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.sfnt]) - -OBJS=sfnt.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/sfnt/module.mk b/src/libs/freetype2/sfnt/module.mk index 52607e2afc..d33913809c 100644 --- a/src/libs/freetype2/sfnt/module.mk +++ b/src/libs/freetype2/sfnt/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_sfnt_module +FTMODULE_H_COMMANDS += SFNT_MODULE -add_sfnt_module: - $(OPEN_DRIVER)sfnt_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)sfnt $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE) +define SFNT_MODULE +$(OPEN_DRIVER)sfnt_module_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)sfnt $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/sfnt/rules.mk b/src/libs/freetype2/sfnt/rules.mk index e15681b21b..c65f8abdd3 100644 --- a/src/libs/freetype2/sfnt/rules.mk +++ b/src/libs/freetype2/sfnt/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000, 2002, 2003, 2004, 2005 by +# Copyright 1996-2000, 2002, 2003, 2004, 2005, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -26,10 +26,12 @@ SFNT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SFNT_DIR)) # SFNT driver sources (i.e., C files) # SFNT_DRV_SRC := $(SFNT_DIR)/ttload.c \ + $(SFNT_DIR)/ttmtx.c \ $(SFNT_DIR)/ttcmap.c \ $(SFNT_DIR)/ttsbit.c \ $(SFNT_DIR)/ttpost.c \ $(SFNT_DIR)/ttkern.c \ + $(SFNT_DIR)/ttbdf.c \ $(SFNT_DIR)/sfobjs.c \ $(SFNT_DIR)/sfdriver.c diff --git a/src/libs/freetype2/sfnt/sfdriver.c b/src/libs/freetype2/sfnt/sfdriver.c index 96a312dfa5..9f4bbcf4b3 100644 --- a/src/libs/freetype2/sfnt/sfdriver.c +++ b/src/libs/freetype2/sfnt/sfdriver.c @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -34,8 +34,14 @@ #include "ttpost.h" #endif +#ifdef TT_CONFIG_OPTION_BDF +#include "ttbdf.h" +#include FT_SERVICE_BDF_H +#endif + #include "ttcmap.h" #include "ttkern.h" +#include "ttmtx.h" #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_POSTSCRIPT_NAME_H @@ -284,20 +290,65 @@ }; - /* - * TT CMAP INFO - * - */ + /* + * TT CMAP INFO + */ static const FT_Service_TTCMapsRec tt_service_get_cmap_info = { (TT_CMap_Info_GetFunc)tt_get_cmap_info }; - /* - * SERVICE LIST - * - */ +#ifdef TT_CONFIG_OPTION_BDF + + static FT_Error + sfnt_get_charset_id( TT_Face face, + const char* *acharset_encoding, + const char* *acharset_registry ) + { + BDF_PropertyRec encoding, registry; + FT_Error error; + + + /* XXX: I don't know whether this is correct, since + * tt_face_find_bdf_prop only returns something correct if we have + * previously selected a size that is listed in the BDF table. + * Should we change the BDF table format to include single offsets + * for `CHARSET_REGISTRY' and `CHARSET_ENCODING'? + */ + error = tt_face_find_bdf_prop( face, "CHARSET_REGISTRY", ®istry ); + if ( !error ) + { + error = tt_face_find_bdf_prop( face, "CHARSET_ENCODING", &encoding ); + if ( !error ) + { + if ( registry.type == BDF_PROPERTY_TYPE_ATOM && + encoding.type == BDF_PROPERTY_TYPE_ATOM ) + { + *acharset_encoding = encoding.u.atom; + *acharset_registry = registry.u.atom; + } + else + error = FT_Err_Invalid_Argument; + } + } + + return error; + } + + + static const FT_Service_BDFRec sfnt_service_bdf = + { + (FT_BDF_GetCharsetIdFunc) sfnt_get_charset_id, + (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop, + }; + +#endif /* TT_CONFIG_OPTION_BDF */ + + + /* + * SERVICE LIST + */ static const FT_ServiceDescRec sfnt_services[] = { @@ -305,6 +356,9 @@ { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name }, #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES { FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict }, +#endif +#ifdef TT_CONFIG_OPTION_BDF + { FT_SERVICE_ID_BDF, &sfnt_service_bdf }, #endif { FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info }, @@ -318,16 +372,138 @@ { FT_UNUSED( module ); - if ( ft_strcmp( module_interface, "get_sfnt" ) == 0 ) - return (FT_Module_Interface)get_sfnt_table; - - if ( ft_strcmp( module_interface, "load_sfnt" ) == 0 ) - return (FT_Module_Interface)tt_face_load_any; - return ft_service_list_lookup( sfnt_services, module_interface ); } +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + + FT_CALLBACK_DEF( FT_Error ) + tt_face_load_sfnt_header_stub( TT_Face face, + FT_Stream stream, + FT_Long face_index, + SFNT_Header header ) + { + FT_UNUSED( face ); + FT_UNUSED( stream ); + FT_UNUSED( face_index ); + FT_UNUSED( header ); + + return FT_Err_Unimplemented_Feature; + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_face_load_directory_stub( TT_Face face, + FT_Stream stream, + SFNT_Header header ) + { + FT_UNUSED( face ); + FT_UNUSED( stream ); + FT_UNUSED( header ); + + return FT_Err_Unimplemented_Feature; + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_face_load_hdmx_stub( TT_Face face, + FT_Stream stream ) + { + FT_UNUSED( face ); + FT_UNUSED( stream ); + + return FT_Err_Unimplemented_Feature; + } + + + FT_CALLBACK_DEF( void ) + tt_face_free_hdmx_stub( TT_Face face ) + { + FT_UNUSED( face ); + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_face_set_sbit_strike_stub( TT_Face face, + FT_UInt x_ppem, + FT_UInt y_ppem, + FT_ULong* astrike_index ) + { + /* + * We simply forge a FT_Size_Request and call the real function + * that does all the work. + * + * This stub might be called by libXfont in the X.Org Xserver, + * compiled against version 2.1.8 or newer. + */ + + FT_Size_RequestRec req; + + + req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; + req.width = (FT_F26Dot6)x_ppem; + req.height = (FT_F26Dot6)y_ppem; + req.horiResolution = 0; + req.vertResolution = 0; + + *astrike_index = 0x7FFFFFFFUL; + + return tt_face_set_sbit_strike( face, &req, astrike_index ); + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_face_load_sbit_stub( TT_Face face, + FT_Stream stream ) + { + FT_UNUSED( face ); + FT_UNUSED( stream ); + + /* + * This function was originally implemented to load the sbit table. + * However, it has been replaced by `tt_face_load_eblc', and this stub + * is only there for some rogue clients which would want to call it + * directly (which doesn't make much sense). + */ + return FT_Err_Unimplemented_Feature; + } + + + FT_CALLBACK_DEF( void ) + tt_face_free_sbit_stub( TT_Face face ) + { + /* nothing to do in this stub */ + FT_UNUSED( face ); + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_face_load_charmap_stub( TT_Face face, + void* cmap, + FT_Stream input ) + { + FT_UNUSED( face ); + FT_UNUSED( cmap ); + FT_UNUSED( input ); + + return FT_Err_Unimplemented_Feature; + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_face_free_charmap_stub( TT_Face face, + void* cmap ) + { + FT_UNUSED( face ); + FT_UNUSED( cmap ); + + return 0; + } + +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ + + static const SFNT_Interface sfnt_interface = { @@ -339,67 +515,94 @@ sfnt_get_interface, tt_face_load_any, - tt_face_load_sfnt_header, - tt_face_load_directory, - tt_face_load_header, - tt_face_load_metrics_header, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + tt_face_load_sfnt_header_stub, + tt_face_load_directory_stub, +#endif + + tt_face_load_head, + tt_face_load_hhea, tt_face_load_cmap, - tt_face_load_max_profile, + tt_face_load_maxp, tt_face_load_os2, - tt_face_load_postscript, + tt_face_load_post, - tt_face_load_names, - tt_face_free_names, + tt_face_load_name, + tt_face_free_name, - tt_face_load_hdmx, - tt_face_free_hdmx, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + tt_face_load_hdmx_stub, + tt_face_free_hdmx_stub, +#endif tt_face_load_kern, tt_face_load_gasp, tt_face_load_pclt, #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /* see `ttload.h' */ - tt_face_load_bitmap_header, + tt_face_load_bhed, +#else + 0, +#endif - /* see `ttsbit.h' and `sfnt.h' */ - tt_face_set_sbit_strike, - tt_face_load_sbit_strikes, - 0 /* tt_find_sbit_image */, - 0 /* tt_load_sbit_metrics */, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + tt_face_set_sbit_strike_stub, + tt_face_load_sbit_stub, + + tt_find_sbit_image, + tt_load_sbit_metrics, +#endif + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS tt_face_load_sbit_image, - tt_face_free_sbit_strikes, +#else + 0, +#endif -#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - - 0, - 0, - 0, - 0, - 0, - 0, - 0, - -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + tt_face_free_sbit_stub, +#endif #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES - - /* see `ttkern.h' */ - tt_face_get_kerning, - /* see `ttpost.h' */ tt_face_get_ps_name, tt_face_free_ps_names, - -#else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ - +#else 0, 0, +#endif -#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + tt_face_load_charmap_stub, + tt_face_free_charmap_stub, +#endif + /* since version 2.1.8 */ + + tt_face_get_kerning, + + /* since version 2.2 */ + + tt_face_load_font_dir, + tt_face_load_hmtx, + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + /* see `ttsbit.h' and `sfnt.h' */ + tt_face_load_eblc, + tt_face_free_eblc, + + tt_face_set_sbit_strike, + tt_face_load_strike_metrics, +#else + 0, + 0, + 0, + 0, +#endif + + tt_face_get_metrics }; diff --git a/src/libs/freetype2/sfnt/sfnt.c b/src/libs/freetype2/sfnt/sfnt.c index 798f923fa8..45a820b718 100644 --- a/src/libs/freetype2/sfnt/sfnt.c +++ b/src/libs/freetype2/sfnt/sfnt.c @@ -4,7 +4,7 @@ /* */ /* Single object library component. */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,6 +20,7 @@ #include <ft2build.h> #include "ttload.c" +#include "ttmtx.c" #include "ttcmap.c" #include "ttkern.c" #include "sfobjs.c" @@ -33,5 +34,8 @@ #include "ttpost.c" #endif +#ifdef TT_CONFIG_OPTION_BDF +#include "ttbdf.c" +#endif /* END */ diff --git a/src/libs/freetype2/sfnt/sfobjs.c b/src/libs/freetype2/sfnt/sfobjs.c index e2d2a17c6d..869269cdd1 100644 --- a/src/libs/freetype2/sfnt/sfobjs.c +++ b/src/libs/freetype2/sfnt/sfobjs.c @@ -4,7 +4,7 @@ /* */ /* SFNT object management (base). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,11 +22,16 @@ #include "ttcmap.h" #include "ttkern.h" #include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_DEBUG_H #include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include "sferrors.h" +#ifdef TT_CONFIG_OPTION_BDF +#include "ttbdf.h" +#endif + /*************************************************************************/ /* */ @@ -47,11 +52,12 @@ FT_String* string; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; + FT_Error error; len = (FT_UInt)entry->stringLength / 2; - if ( FT_MEM_NEW_ARRAY( string, len + 1 ) ) + if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) @@ -77,11 +83,12 @@ FT_String* string; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; + FT_Error error; len = (FT_UInt)entry->stringLength / 4; - if ( FT_MEM_NEW_ARRAY( string, len + 1 ) ) + if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) @@ -107,11 +114,12 @@ FT_String* string; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; + FT_Error error; len = (FT_UInt)entry->stringLength; - if ( FT_MEM_NEW_ARRAY( string, len + 1 ) ) + if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) @@ -338,6 +346,85 @@ } + /* Fill in face->ttc_header. If the font is not a TTC, it is */ + /* synthesized into a TTC with one offset table. */ + static FT_Error + sfnt_open_font( FT_Stream stream, + TT_Face face ) + { + FT_Memory memory = stream->memory; + FT_Error error; + FT_ULong tag, offset; + + static const FT_Frame_Field ttc_header_fields[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE TTC_HeaderRec + + FT_FRAME_START( 8 ), + FT_FRAME_LONG( version ), + FT_FRAME_LONG( count ), + FT_FRAME_END + }; + + + face->ttc_header.tag = 0; + face->ttc_header.version = 0; + face->ttc_header.count = 0; + + offset = FT_STREAM_POS(); + + if ( FT_READ_ULONG( tag ) ) + return error; + + if ( tag != 0x00010000UL && + tag != TTAG_ttcf && + tag != FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) && + tag != TTAG_true && + tag != 0x00020000UL ) + return SFNT_Err_Unknown_File_Format; + + face->ttc_header.tag = TTAG_ttcf; + + if ( tag == TTAG_ttcf ) + { + FT_Int n; + + + FT_TRACE3(( "sfnt_open_font: file is a collection\n" )); + + if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) ) + return error; + + /* now read the offsets of each font in the file */ + if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) ) + return error; + + if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) ) + return error; + + for ( n = 0; n < face->ttc_header.count; n++ ) + face->ttc_header.offsets[n] = FT_GET_ULONG(); + + FT_FRAME_EXIT(); + } + else + { + FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" )); + + face->ttc_header.version = 1 << 16; + face->ttc_header.count = 1; + + if ( FT_NEW( face->ttc_header.offsets) ) + return error; + + face->ttc_header.offsets[0] = offset; + } + + return error; + } + + FT_LOCAL_DEF( FT_Error ) sfnt_init_face( FT_Stream stream, TT_Face face, @@ -345,10 +432,10 @@ FT_Int num_params, FT_Parameter* params ) { - FT_Error error; - FT_Library library = face->root.driver->root.library; - SFNT_Service sfnt; - SFNT_HeaderRec sfnt_header; + FT_Error error; + FT_Library library = face->root.driver->root.library; + SFNT_Service sfnt; + /* for now, parameters are unused */ FT_UNUSED( num_params ); @@ -360,10 +447,7 @@ { sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) - { - error = SFNT_Err_Invalid_File_Format; - goto Exit; - } + return SFNT_Err_Invalid_File_Format; face->sfnt = sfnt; face->goto_table = sfnt->goto_table; @@ -371,31 +455,62 @@ FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS ); + error = sfnt_open_font( stream, face ); + if ( error ) + return error; + + FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_index )); + + if ( face_index < 0 ) + face_index = 0; + + if ( face_index >= face->ttc_header.count ) + return SFNT_Err_Bad_Argument; + + if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) ) + return error; + /* check that we have a valid TrueType file */ - error = sfnt->load_sfnt_header( face, stream, face_index, &sfnt_header ); + error = sfnt->load_font_dir( face, stream ); if ( error ) - goto Exit; - - face->format_tag = sfnt_header.format_tag; - face->num_tables = sfnt_header.num_tables; - - /* Load font directory */ - error = sfnt->load_directory( face, stream, &sfnt_header ); - if ( error ) - goto Exit; + return error; face->root.num_faces = face->ttc_header.count; - if ( face->root.num_faces < 1 ) - face->root.num_faces = 1; - Exit: return error; } -#undef LOAD_ -#define LOAD_( x ) ( ( error = sfnt->load_##x( face, stream ) ) \ - != SFNT_Err_Ok ) +#define LOAD_( x ) \ + do { \ + FT_TRACE2(( "`" #x "' " )); \ + FT_TRACE3(( "-->\n" )); \ + \ + error = sfnt->load_##x( face, stream ); \ + \ + FT_TRACE2(( "%s\n", ( !error ) \ + ? "loaded" \ + : ( error == SFNT_Err_Table_Missing ) \ + ? "missing" \ + : "failed to load" )); \ + FT_TRACE3(( "\n" )); \ + } while ( 0 ) + +#define LOADM_( x, vertical ) \ + do { \ + FT_TRACE2(( "`%s" #x "' ", \ + vertical ? "vertical " : "" )); \ + FT_TRACE3(( "-->\n" )); \ + \ + error = sfnt->load_##x( face, stream, vertical ); \ + \ + FT_TRACE2(( "%s\n", ( !error ) \ + ? "loaded" \ + : ( error == SFNT_Err_Table_Missing ) \ + ? "missing" \ + : "failed to load" )); \ + FT_TRACE3(( "\n" )); \ + } while ( 0 ) FT_LOCAL_DEF( FT_Error ) @@ -433,6 +548,8 @@ /* it doesn't contain outlines. */ /* */ + FT_TRACE2(( "sfnt_load_face: %08p\n\n", face )); + /* do we have outlines in there? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 || @@ -445,74 +562,139 @@ is_apple_sbit = 0; -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /* if this font doesn't contain outlines, we try to load */ /* a `bhed' table */ - if ( !has_outline ) - is_apple_sbit = FT_BOOL( !LOAD_( bitmap_header ) ); - -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + if ( !has_outline && sfnt->load_bhed ) + { + LOAD_( bhed ); + is_apple_sbit = FT_BOOL( !error ); + } /* load the font header (`head' table) if this isn't an Apple */ /* sbit font file */ - if ( !is_apple_sbit && LOAD_( header ) ) + if ( !is_apple_sbit ) + { + LOAD_( head ); + if ( error ) + goto Exit; + } + + if ( face->header.Units_Per_EM == 0 ) + { + error = SFNT_Err_Invalid_Table; + goto Exit; + } /* the following tables are often not present in embedded TrueType */ /* fonts within PDF documents, so don't check for them. */ - (void)LOAD_( max_profile ); - (void)LOAD_( charmaps ); + LOAD_( maxp ); + LOAD_( cmap ); /* the following tables are optional in PCL fonts -- */ /* don't check for errors */ - (void)LOAD_( names ); - psnames_error = LOAD_( psnames ); + LOAD_( name ); + LOAD_( post ); + psnames_error = error; /* do not load the metrics headers and tables if this is an Apple */ /* sbit font file */ if ( !is_apple_sbit ) { - /* load the `hhea' and `hmtx' tables at once */ - error = sfnt->load_metrics( face, stream, 0 ); + /* load the `hhea' and `hmtx' tables */ + LOADM_( hhea, 0 ); + if ( !error ) + { + LOADM_( hmtx, 0 ); + if ( error == SFNT_Err_Table_Missing ) + { + error = SFNT_Err_Hmtx_Table_Missing; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* If this is an incrementally loaded font and there are */ + /* overriding metrics, tolerate a missing `hmtx' table. */ + if ( face->root.internal->incremental_interface && + face->root.internal->incremental_interface->funcs-> + get_glyph_metrics ) + { + face->horizontal.number_Of_HMetrics = 0; + error = SFNT_Err_Ok; + } +#endif + } + } + else if ( error == SFNT_Err_Table_Missing ) + { + /* No `hhea' table necessary for SFNT Mac fonts. */ + if ( face->format_tag == TTAG_true ) + { + FT_TRACE2(( "This is an SFNT Mac font.\n" )); + has_outline = 0; + error = SFNT_Err_Ok; + } + else + error = SFNT_Err_Horiz_Header_Missing; + } + if ( error ) goto Exit; - /* try to load the `vhea' and `vmtx' tables at once */ - error = sfnt->load_metrics( face, stream, 1 ); - if ( error ) + /* try to load the `vhea' and `vmtx' tables */ + LOADM_( hhea, 1 ); + if ( !error ) + { + LOADM_( hmtx, 1 ); + if ( !error ) + face->vertical_info = 1; + } + + if ( error && error != SFNT_Err_Table_Missing ) goto Exit; - if ( LOAD_( os2 ) ) - goto Exit; + LOAD_( os2 ); + if ( error ) + { + if ( error != SFNT_Err_Table_Missing ) + goto Exit; + + face->os2.version = 0xFFFFU; + } + } /* the optional tables */ -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /* embedded bitmap support. */ - if ( sfnt->load_sbits && LOAD_( sbits ) ) + if ( sfnt->load_eblc ) { - /* return an error if this font file has no outlines */ - if ( error == SFNT_Err_Table_Missing && has_outline ) - error = SFNT_Err_Ok; - else - goto Exit; + LOAD_( eblc ); + if ( error ) + { + /* return an error if this font file has no outlines */ + if ( error == SFNT_Err_Table_Missing && has_outline ) + error = SFNT_Err_Ok; + else + goto Exit; + } } -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + LOAD_( pclt ); + if ( error ) + { + if ( error != SFNT_Err_Table_Missing ) + goto Exit; - if ( LOAD_( hdmx ) || - LOAD_( pclt ) ) - goto Exit; + face->pclt.Version = 0; + } /* consider the kerning and gasp tables as optional */ - (void)LOAD_( gasp ); - (void)LOAD_( kerning ); + LOAD_( gasp ); + LOAD_( kern ); error = SFNT_Err_Ok; + face->root.num_glyphs = face->max_profile.numGlyphs; + face->root.family_name = tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY ); if ( !face->root.family_name ) @@ -536,9 +718,11 @@ /* Compute face flags. */ /* */ if ( has_outline == TRUE ) - flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ + flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ - flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ + /* The sfnt driver only supports bitmap fonts natively, thus we */ + /* don't set FT_FACE_FLAG_HINTER. */ + flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES @@ -555,11 +739,9 @@ if ( face->vertical_info ) flags |= FT_FACE_FLAG_VERTICAL; -#if 0 /* kerning available ? */ if ( TT_FACE_HAS_KERNING( face ) ) flags |= FT_FACE_FLAG_KERNING; -#endif #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* Don't bother to load the tables unless somebody asks for them. */ @@ -720,18 +902,80 @@ root->underline_position = face->postscript.underlinePosition; root->underline_thickness = face->postscript.underlineThickness; - - /* root->max_points -- already set up */ - /* root->max_contours -- already set up */ } + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + + /* + * Now allocate the root array of FT_Bitmap_Size records and + * populate them. Unfortunately, it isn't possible to indicate bit + * depths in the FT_Bitmap_Size record. This is a design error. + */ + { + FT_UInt i, count; + + +#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS + count = face->sbit_num_strikes; +#else + count = (FT_UInt)face->num_sbit_strikes; +#endif + + if ( count > 0 ) + { + FT_Memory memory = face->root.stream->memory; + FT_UShort em_size = face->header.Units_Per_EM; + FT_Short avgwidth = face->os2.xAvgCharWidth; + FT_Size_Metrics metrics; + + + if ( em_size == 0 || face->os2.version == 0xFFFFU ) + { + avgwidth = 0; + em_size = 1; + } + + if ( FT_NEW_ARRAY( root->available_sizes, count ) ) + goto Exit; + + for ( i = 0; i < count; i++ ) + { + FT_Bitmap_Size* bsize = root->available_sizes + i; + + + error = sfnt->load_strike_metrics( face, i, &metrics ); + if ( error ) + goto Exit; + + bsize->height = (FT_Short)( metrics.height >> 6 ); + bsize->width = (FT_Short)( + ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size ); + + bsize->x_ppem = metrics.x_ppem << 6; + bsize->y_ppem = metrics.y_ppem << 6; + + /* assume 72dpi */ + bsize->size = metrics.y_ppem << 6; + } + + root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; + root->num_fixed_sizes = (FT_Int)count; + } + } + +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + } Exit: + FT_TRACE2(( "sfnt_load_face: done\n" )); + return error; } #undef LOAD_ +#undef LOADM_ FT_LOCAL_DEF( void ) @@ -748,10 +992,15 @@ sfnt->free_psnames( face ); /* destroy the embedded bitmaps table if it is loaded */ - if ( sfnt->free_sbits ) - sfnt->free_sbits( face ); + if ( sfnt->free_eblc ) + sfnt->free_eblc( face ); } +#ifdef TT_CONFIG_OPTION_BDF + /* freeing the embedded BDF properties */ + tt_face_free_bdf_props( face ); +#endif + /* freeing the kerning table */ tt_face_done_kern( face ); @@ -773,7 +1022,7 @@ } /* freeing the horizontal metrics */ -#ifdef FT_OPTIMIZE_MEMORY +#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS { FT_Stream stream = FT_FACE_STREAM( face ); @@ -801,10 +1050,7 @@ face->gasp.numRanges = 0; /* freeing the name table */ - sfnt->free_names( face ); - - /* freeing the hdmx table */ - sfnt->free_hdmx( face ); + sfnt->free_name( face ); /* freeing family and style name */ FT_FREE( face->root.family_name ); diff --git a/src/libs/freetype2/sfnt/ttbdf.c b/src/libs/freetype2/sfnt/ttbdf.c new file mode 100644 index 0000000000..6c95387adb --- /dev/null +++ b/src/libs/freetype2/sfnt/ttbdf.c @@ -0,0 +1,250 @@ +/***************************************************************************/ +/* */ +/* ttbdf.c */ +/* */ +/* TrueType and OpenType embedded BDF properties (body). */ +/* */ +/* Copyright 2005, 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include "ttbdf.h" + +#include "sferrors.h" + + +#ifdef TT_CONFIG_OPTION_BDF + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_ttbdf + + + FT_LOCAL_DEF( void ) + tt_face_free_bdf_props( TT_Face face ) + { + TT_BDF bdf = &face->bdf; + + + if ( bdf->loaded ) + { + FT_Stream stream = FT_FACE(face)->stream; + + + if ( bdf->table != NULL ) + FT_FRAME_RELEASE( bdf->table ); + + bdf->table_end = NULL; + bdf->strings = NULL; + bdf->strings_size = 0; + } + } + + + static FT_Error + tt_face_load_bdf_props( TT_Face face, + FT_Stream stream ) + { + TT_BDF bdf = &face->bdf; + FT_ULong length; + FT_Error error; + + + FT_ZERO( bdf ); + + error = tt_face_goto_table( face, TTAG_BDF, stream, &length ); + if ( error || + length < 8 || + FT_FRAME_EXTRACT( length, bdf->table ) ) + { + error = FT_Err_Invalid_Table; + goto Exit; + } + + bdf->table_end = bdf->table + length; + + { + FT_Byte* p = bdf->table; + FT_UInt version = FT_NEXT_USHORT( p ); + FT_UInt num_strikes = FT_NEXT_USHORT( p ); + FT_UInt32 strings = FT_NEXT_ULONG ( p ); + FT_UInt count; + FT_Byte* strike; + + + if ( version != 0x0001 || + strings < 8 || + ( strings - 8 ) / 4 < num_strikes || + strings + 1 > length ) + { + goto BadTable; + } + + bdf->num_strikes = num_strikes; + bdf->strings = bdf->table + strings; + bdf->strings_size = length - strings; + + count = bdf->num_strikes; + p = bdf->table + 8; + strike = p + count * 4; + + + for ( ; count > 0; count-- ) + { + FT_UInt num_items = FT_PEEK_USHORT( p + 2 ); + + /* + * We don't need to check the value sets themselves, since this + * is done later. + */ + strike += 10 * num_items; + + p += 4; + } + + if ( strike > bdf->strings ) + goto BadTable; + } + + bdf->loaded = 1; + + Exit: + return error; + + BadTable: + FT_FRAME_RELEASE( bdf->table ); + FT_ZERO( bdf ); + error = FT_Err_Invalid_Table; + goto Exit; + } + + + FT_LOCAL_DEF( FT_Error ) + tt_face_find_bdf_prop( TT_Face face, + const char* property_name, + BDF_PropertyRec *aprop ) + { + TT_BDF bdf = &face->bdf; + FT_Size size = FT_FACE(face)->size; + FT_Error error = 0; + FT_Byte* p; + FT_UInt count; + FT_Byte* strike; + FT_UInt property_len; + + + aprop->type = BDF_PROPERTY_TYPE_NONE; + + if ( bdf->loaded == 0 ) + { + error = tt_face_load_bdf_props( face, FT_FACE( face )->stream ); + if ( error ) + goto Exit; + } + + count = bdf->num_strikes; + p = bdf->table + 8; + strike = p + 4 * count; + + error = FT_Err_Invalid_Argument; + + if ( size == NULL || property_name == NULL ) + goto Exit; + + property_len = ft_strlen( property_name ); + if ( property_len == 0 ) + goto Exit; + + for ( ; count > 0; count-- ) + { + FT_UInt _ppem = FT_NEXT_USHORT( p ); + FT_UInt _count = FT_NEXT_USHORT( p ); + + if ( _ppem == size->metrics.y_ppem ) + { + count = _count; + goto FoundStrike; + } + + strike += 10 * _count; + } + goto Exit; + + FoundStrike: + p = strike; + for ( ; count > 0; count-- ) + { + FT_UInt type = FT_PEEK_USHORT( p + 4 ); + + if ( ( type & 0x10 ) != 0 ) + { + FT_UInt32 name_offset = FT_PEEK_ULONG( p ); + FT_UInt32 value = FT_PEEK_ULONG( p + 6 ); + + /* be a bit paranoid for invalid entries here */ + if ( name_offset < bdf->strings_size && + property_len < bdf->strings_size - name_offset && + ft_strncmp( property_name, + (const char*)bdf->strings + name_offset, + bdf->strings_size - name_offset ) == 0 ) + { + switch ( type & 0x0F ) + { + case 0x00: /* string */ + case 0x01: /* atoms */ + /* check that the content is really 0-terminated */ + if ( value < bdf->strings_size && + ft_memchr( bdf->strings + value, 0, bdf->strings_size ) ) + { + aprop->type = BDF_PROPERTY_TYPE_ATOM; + aprop->u.atom = (const char*)bdf->strings + value; + error = 0; + goto Exit; + } + break; + + case 0x02: + aprop->type = BDF_PROPERTY_TYPE_INTEGER; + aprop->u.integer = (FT_Int32)value; + error = 0; + goto Exit; + + case 0x03: + aprop->type = BDF_PROPERTY_TYPE_CARDINAL; + aprop->u.cardinal = value; + error = 0; + goto Exit; + + default: + ; + } + } + } + p += 10; + } + + Exit: + return error; + } + +#endif /* TT_CONFIG_OPTION_BDF */ + + +/* END */ diff --git a/src/libs/freetype2/sfnt/ttbdf.h b/src/libs/freetype2/sfnt/ttbdf.h new file mode 100644 index 0000000000..48a10d6e9b --- /dev/null +++ b/src/libs/freetype2/sfnt/ttbdf.h @@ -0,0 +1,46 @@ +/***************************************************************************/ +/* */ +/* ttbdf.h */ +/* */ +/* TrueType and OpenType embedded BDF properties (specification). */ +/* */ +/* Copyright 2005 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __TTBDF_H__ +#define __TTBDF_H__ + + +#include <ft2build.h> +#include "ttload.h" +#include FT_BDF_H + + +FT_BEGIN_HEADER + + + FT_LOCAL( void ) + tt_face_free_bdf_props( TT_Face face ); + + + FT_LOCAL( FT_Error ) + tt_face_find_bdf_prop( TT_Face face, + const char* property_name, + BDF_PropertyRec *aprop ); + + +FT_END_HEADER + +#endif /* __TTBDF_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/sfnt/ttcmap.c b/src/libs/freetype2/sfnt/ttcmap.c index 0f3a3241ce..3a43aedc21 100644 --- a/src/libs/freetype2/sfnt/ttcmap.c +++ b/src/libs/freetype2/sfnt/ttcmap.c @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -625,18 +625,12 @@ #ifdef TT_CONFIG_CMAP_FORMAT_4 -#define OPT_CMAP4 - -#ifdef OPT_CMAP4 - typedef struct TT_CMap4Rec_ { TT_CMapRec cmap; - FT_UInt32 old_charcode; /* old charcode */ FT_UInt32 cur_charcode; /* current charcode */ FT_UInt cur_gindex; /* current glyph index */ - FT_UInt table_length; FT_UInt num_ranges; FT_UInt cur_range; FT_UInt cur_start; @@ -656,14 +650,9 @@ cmap->cmap.data = table; - p = table + 2; - cmap->table_length = FT_PEEK_USHORT( p ); - p = table + 6; cmap->num_ranges = FT_PEEK_USHORT( p ) >> 1; - cmap->cur_range = cmap->num_ranges; - cmap->old_charcode = 0xFFFFFFFFUL; - cmap->cur_charcode = 0; + cmap->cur_charcode = 0xFFFFFFFFUL; cmap->cur_gindex = 0; return SFNT_Err_Ok; @@ -707,21 +696,27 @@ range_index++; } - cmap->old_charcode = 0xFFFFFFFFUL; - cmap->cur_charcode = 0; - cmap->cur_gindex = 0; - cmap->cur_range = num_ranges; return -1; } + /* search the index of the charcode next to cmap->cur_charcode; */ + /* caller should call tt_cmap4_set_range with proper range */ + /* before calling this function */ + /* */ static void tt_cmap4_next( TT_CMap4 cmap ) { - FT_UInt charcode = cmap->cur_charcode + 1; + FT_UInt charcode; + + if ( cmap->cur_charcode >= 0xFFFFUL ) + goto Fail; - cmap->old_charcode = cmap->cur_charcode; + charcode = cmap->cur_charcode + 1; + + if ( charcode < cmap->cur_start ) + charcode = cmap->cur_start; for ( ;; ) { @@ -775,27 +770,16 @@ if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 ) break; - charcode = cmap->cur_start; + if ( charcode < cmap->cur_start ) + charcode = cmap->cur_start; } + + Fail: + cmap->cur_charcode = 0xFFFFFFFFUL; + cmap->cur_gindex = 0; } - static void - tt_cmap4_reset( TT_CMap4 cmap, - FT_UInt code, - FT_UInt range_index ) - { - if ( tt_cmap4_set_range( cmap, range_index ) >= 0 ) - { - cmap->cur_charcode = code; - tt_cmap4_next( cmap ); - } - } - -#endif /* OPT_CMAP4 */ - - - FT_CALLBACK_DEF( FT_Error ) tt_cmap4_validate( FT_Byte* table, FT_Validator valid ) @@ -807,11 +791,11 @@ FT_Error error = SFNT_Err_Ok; - /* in certain fonts, the `length' field is invalid and goes */ - /* out of bound. We try to correct this here... */ if ( length < 16 ) FT_INVALID_TOO_SHORT; + /* in certain fonts, the `length' field is invalid and goes */ + /* out of bound. We try to correct this here... */ if ( table + length > valid->limit ) { if ( valid->level >= FT_VALIDATE_TIGHT ) @@ -832,6 +816,9 @@ num_segs /= 2; + if ( length < 16 + num_segs * 2 * 4 ) + FT_INVALID_TOO_SHORT; + /* check the search parameters - even though we never use them */ /* */ if ( valid->level >= FT_VALIDATE_PARANOID ) @@ -863,9 +850,6 @@ offsets = deltas + num_segs * 2; glyph_ids = offsets + num_segs * 2; - if ( glyph_ids > table + length ) - FT_INVALID_TOO_SHORT; - /* check last segment, its end count must be FFFF */ if ( valid->level >= FT_VALIDATE_PARANOID ) { @@ -874,10 +858,9 @@ FT_INVALID_DATA; } - /* check that segments are sorted in increasing order and do not */ - /* overlap; check also the offsets */ { - FT_UInt start, end, last = 0, offset, n; + FT_UInt start, end, offset, n; + FT_UInt last_start = 0, last_end = 0; FT_Int delta; @@ -899,12 +882,20 @@ /* unfortunately, some popular Asian fonts present overlapping */ /* ranges in their charmaps */ /* */ - if ( n > 0 && start <= last ) + if ( start <= last_end && n > 0 ) { if ( valid->level >= FT_VALIDATE_TIGHT ) FT_INVALID_DATA; else - error = SFNT_Err_Invalid_CharMap_Format; + { + /* allow overlapping segments, provided their start points */ + /* and end points, respectively, are in ascending order. */ + /* */ + if ( last_start > start || last_end > end ) + error |= TT_CMAP_FLAG_UNSORTED; + else + error |= TT_CMAP_FLAG_OVERLAPPING; + } } if ( offset && offset != 0xFFFFU ) @@ -955,7 +946,8 @@ FT_INVALID_DATA; } - last = end; + last_start = start; + last_end = end; } } @@ -963,120 +955,305 @@ } + static FT_UInt + tt_cmap4_char_map_linear( TT_CMap cmap, + FT_UInt* pcharcode, + FT_Bool next ) + { + FT_UInt num_segs2, start, end, offset; + FT_Int delta; + FT_UInt i, num_segs; + FT_UInt32 charcode = *pcharcode; + FT_UInt gindex = 0; + FT_Byte* p; + + + p = cmap->data + 6; + num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); + + num_segs = num_segs2 >> 1; + + if ( !num_segs ) + return 0; + + if ( next ) + charcode++; + + /* linear search */ + for ( ; charcode <= 0xFFFFU; charcode++ ) + { + FT_Byte* q; + + + p = cmap->data + 14; /* ends table */ + q = cmap->data + 16 + num_segs2; /* starts table */ + + for ( i = 0; i < num_segs; i++ ) + { + end = TT_NEXT_USHORT( p ); + start = TT_NEXT_USHORT( q ); + + if ( charcode >= start && charcode <= end ) + { + p = q - 2 + num_segs2; + delta = TT_PEEK_SHORT( p ); + p += num_segs2; + offset = TT_PEEK_USHORT( p ); + + if ( offset == 0xFFFFU ) + continue; + + if ( offset ) + { + p += offset + ( charcode - start ) * 2; + gindex = TT_PEEK_USHORT( p ); + if ( gindex != 0 ) + gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU; + } + else + gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU; + + break; + } + } + + if ( !next || gindex ) + break; + } + + if ( next && gindex ) + *pcharcode = charcode; + + return gindex; + } + + + static FT_UInt + tt_cmap4_char_map_binary( TT_CMap cmap, + FT_UInt* pcharcode, + FT_Bool next ) + { + FT_UInt num_segs2, start, end, offset; + FT_Int delta; + FT_UInt max, min, mid, num_segs; + FT_UInt charcode = *pcharcode; + FT_UInt gindex = 0; + FT_Byte* p; + + + p = cmap->data + 6; + num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); + + if ( !num_segs2 ) + return 0; + + num_segs = num_segs2 >> 1; + + /* make compiler happy */ + mid = num_segs; + end = 0xFFFFU; + + if ( next ) + charcode++; + + min = 0; + max = num_segs; + + /* binary search */ + while ( min < max ) + { + mid = ( min + max ) >> 1; + p = cmap->data + 14 + mid * 2; + end = TT_PEEK_USHORT( p ); + p += 2 + num_segs2; + start = TT_PEEK_USHORT( p ); + + if ( charcode < start ) + max = mid; + else if ( charcode > end ) + min = mid + 1; + else + { + p += num_segs2; + delta = TT_PEEK_SHORT( p ); + p += num_segs2; + offset = TT_PEEK_USHORT( p ); + + /* search the first segment containing `charcode' */ + if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPING ) + { + FT_UInt i; + + + /* call the current segment `max' */ + max = mid; + + if ( offset == 0xFFFFU ) + mid = max + 1; + + /* search in segments before the current segment */ + for ( i = max ; i > 0; i-- ) + { + FT_UInt prev_end; + + + p = cmap->data + 14 + ( i - 1 ) * 2; + prev_end = TT_PEEK_USHORT( p ); + + if ( charcode > prev_end ) + break; + + end = prev_end; + p += 2 + num_segs2; + start = TT_PEEK_USHORT( p ); + p += num_segs2; + delta = TT_PEEK_SHORT( p ); + p += num_segs2; + offset = TT_PEEK_USHORT( p ); + + if ( offset != 0xFFFFU ) + mid = i - 1; + } + + /* no luck */ + if ( mid == max + 1 ) + { + if ( i != max ) + { + p = cmap->data + 14 + max * 2; + end = TT_PEEK_USHORT( p ); + p += 2 + num_segs2; + start = TT_PEEK_USHORT( p ); + p += num_segs2; + delta = TT_PEEK_SHORT( p ); + p += num_segs2; + offset = TT_PEEK_USHORT( p ); + } + + mid = max; + + /* search in segments after the current segment */ + for ( i = max + 1; i < num_segs; i++ ) + { + FT_UInt next_end, next_start; + + + p = cmap->data + 14 + i * 2; + next_end = TT_PEEK_USHORT( p ); + p += 2 + num_segs2; + next_start = TT_PEEK_USHORT( p ); + + if ( charcode < next_start ) + break; + + end = next_end; + start = next_start; + p += num_segs2; + delta = TT_PEEK_SHORT( p ); + p += num_segs2; + offset = TT_PEEK_USHORT( p ); + + if ( offset != 0xFFFFU ) + mid = i; + } + i--; + + /* still no luck */ + if ( mid == max ) + { + mid = i; + + break; + } + } + + /* end, start, delta, and offset are for the i'th segment */ + if ( mid != i ) + { + p = cmap->data + 14 + mid * 2; + end = TT_PEEK_USHORT( p ); + p += 2 + num_segs2; + start = TT_PEEK_USHORT( p ); + p += num_segs2; + delta = TT_PEEK_SHORT( p ); + p += num_segs2; + offset = TT_PEEK_USHORT( p ); + } + } + else + { + if ( offset == 0xFFFFU ) + break; + } + + if ( offset ) + { + p += offset + ( charcode - start ) * 2; + gindex = TT_PEEK_USHORT( p ); + if ( gindex != 0 ) + gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU; + } + else + gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU; + + break; + } + } + + if ( next ) + { + TT_CMap4 cmap4 = (TT_CMap4)cmap; + + + /* if `charcode' is not in any segment, then `mid' is */ + /* the segment nearest to `charcode' */ + /* */ + + if ( charcode > end ) + { + mid++; + if ( mid == num_segs ) + return 0; + } + + if ( tt_cmap4_set_range( cmap4, mid ) ) + { + if ( gindex ) + *pcharcode = charcode; + } + else + { + cmap4->cur_charcode = charcode; + + if ( gindex ) + cmap4->cur_gindex = gindex; + else + { + cmap4->cur_charcode = charcode; + tt_cmap4_next( cmap4 ); + gindex = cmap4->cur_gindex; + } + + if ( gindex ) + *pcharcode = cmap4->cur_charcode; + } + } + + return gindex; + } + + FT_CALLBACK_DEF( FT_UInt ) tt_cmap4_char_index( TT_CMap cmap, FT_UInt32 char_code ) { - FT_Byte* table = cmap->data; - FT_UInt result = 0; + if ( char_code >= 0x10000UL ) + return 0; - - if ( char_code < 0x10000UL ) - { - FT_UInt idx, num_segs2; - FT_Int delta; - FT_UInt code = (FT_UInt)char_code; - FT_Byte* p; - - p = table + 6; - num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); /* be paranoid! */ - - if ( !cmap->unsorted ) - { - /* Some fonts have more than 170 segments in their charmaps! */ - /* We changed this function to use a more efficient binary */ - /* search for improving performance */ - FT_UInt min = 0; - FT_UInt max = num_segs2 >> 1; - FT_UInt mid, start, end, offset; - - - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 14 + mid * 2; - end = TT_NEXT_USHORT( p ); - p += num_segs2; - start = TT_PEEK_USHORT( p); - - if ( code < start ) - max = mid; - else if ( code > end ) - min = mid + 1; - else - { - /* we found the segment */ - idx = code; - - p += num_segs2; - delta = TT_PEEK_SHORT( p ); - - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset == 0xFFFFU ) - goto Exit; - - if ( offset != 0 ) - { - p += offset + 2 * ( idx - start ); - idx = TT_PEEK_USHORT( p ); - } - - if ( idx != 0 ) - result = (FT_UInt)( idx + delta ) & 0xFFFFU; - - goto Exit; - } - } - } - else - { - FT_UInt n; - FT_Byte* q; - - - p = table + 14; /* ends table */ - q = table + 16 + num_segs2; /* starts table */ - - - for ( n = 0; n < num_segs2; n += 2 ) - { - FT_UInt end = TT_NEXT_USHORT( p ); - FT_UInt start = TT_NEXT_USHORT( q ); - FT_UInt offset; - - - if ( code < start ) - break; - - if ( code <= end ) - { - idx = code; - - p = q + num_segs2 - 2; - delta = TT_PEEK_SHORT( p ); - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset == 0xFFFFU ) - goto Exit; - - if ( offset != 0 ) - { - p += offset + 2 * ( idx - start ); - idx = TT_PEEK_USHORT( p ); - } - - if ( idx != 0 ) - result = (FT_UInt)( idx + delta ) & 0xFFFFU; - } - } - } - } - - Exit: - return result; + if ( cmap->flags & TT_CMAP_FLAG_UNSORTED ) + return tt_cmap4_char_map_linear( cmap, &char_code, 0 ); + else + return tt_cmap4_char_map_binary( cmap, &char_code, 0 ); } @@ -1084,206 +1261,31 @@ tt_cmap4_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { - FT_Byte* table = cmap->data; - FT_UInt32 result = 0; - FT_UInt gindex = 0; - FT_UInt32 char_code = *pchar_code; - FT_Byte* p; - FT_UInt code, num_segs2; + FT_UInt gindex; - if ( char_code >= 0xFFFFUL ) - goto Exit; + if ( *pchar_code >= 0xFFFFU ) + return 0; -#ifdef OPT_CMAP4 - { - TT_CMap4 cmap4 = (TT_CMap4)cmap; - - - if ( char_code == cmap4->old_charcode ) - { - result = cmap4->cur_charcode; - gindex = cmap4->cur_gindex; - if ( result != 0 ) - { - tt_cmap4_next( cmap4 ); - goto Exit; - } - } - } -#endif /* OPT_CMAP4 */ - - code = (FT_UInt)char_code + 1; - p = table + 6; - num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); /* ensure even-ness */ - - if ( !cmap->unsorted ) - { - for (;;) - { - /* Some fonts have more than 170 segments in their charmaps! */ - /* We changed this function to use a more efficient binary */ - /* search */ - FT_UInt offset; - FT_Int delta; - FT_UInt min = 0; - FT_UInt max = num_segs2 >> 1; - FT_UInt mid, start, end; - FT_UInt hi; - - - /* we begin by finding the segment which end is - closer to our code point */ - hi = max + 1; - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 14 + mid * 2; - end = TT_PEEK_USHORT( p ); - - if ( end < code ) - min = mid + 1; - else - { - hi = mid; - max = mid; - } - } - - if ( hi > max ) - { - /* the point is behind the last segment; - we will exit right now */ - goto Exit; - } - - p = table + 14 + hi * 2; - end = TT_PEEK_USHORT( p ); - - p += 2 + num_segs2; - start = TT_PEEK_USHORT( p ); - - if ( code < start ) - code = start; - - p += num_segs2; - delta = TT_PEEK_USHORT( p ); - - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset != 0 && offset != 0xFFFFU ) - { - /* parse the glyph ids array for non-zero index */ - p += offset + ( code - start ) * 2; - while ( code <= end ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex != 0 ) - { - gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU; - if ( gindex != 0 ) - { - result = code; -#ifdef OPT_CMAP4 - tt_cmap4_reset( (TT_CMap4)cmap, code, hi ); -#endif - goto Exit; - } - } - code++; - } - } - else if ( offset == 0xFFFFU ) - { - /* an offset of 0xFFFF means an empty segment in certain fonts! */ - code = end + 1; - } - else /* offset == 0 */ - { - gindex = (FT_UInt)( code + delta ) & 0xFFFFU; - if ( gindex != 0 ) - { - result = code; -#ifdef OPT_CMAP4 - tt_cmap4_reset( (TT_CMap4)cmap, code, hi ); -#endif - goto Exit; - } - code++; - } - } - } + if ( cmap->flags & TT_CMAP_FLAG_UNSORTED ) + gindex = tt_cmap4_char_map_linear( cmap, pchar_code, 1 ); else { - for ( ;; ) + TT_CMap4 cmap4 = (TT_CMap4)cmap; + + + /* no need to search */ + if ( *pchar_code == cmap4->cur_charcode ) { - FT_UInt offset, n; - FT_Int delta; - FT_Byte* q; - - - p = table + 14; /* ends table */ - q = table + 16 + num_segs2; /* starts table */ - - for ( n = 0; n < num_segs2; n += 2 ) - { - FT_UInt end = TT_NEXT_USHORT( p ); - FT_UInt start = TT_NEXT_USHORT( q ); - - - if ( code < start ) - code = start; - - if ( code <= end ) - { - p = q + num_segs2 - 2; - delta = TT_PEEK_SHORT( p ); - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset != 0 && offset != 0xFFFFU ) - { - /* parse the glyph ids array for non-0 index */ - p += offset + ( code - start ) * 2; - while ( code <= end ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex != 0 ) - { - gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU; - if ( gindex != 0 ) - break; - } - code++; - } - } - else if ( offset == 0xFFFFU ) - { - /* an offset of 0xFFFF means an empty glyph in certain fonts! */ - code = end; - break; - } - else - gindex = (FT_UInt)( code + delta ) & 0xFFFFU; - - if ( gindex == 0 ) - break; - - result = code; - goto Exit; - } - } - /* loop to next trial charcode */ - if ( code >= 0xFFFFU ) - break; - - code++; + tt_cmap4_next( cmap4 ); + gindex = cmap4->cur_gindex; + if ( gindex ) + *pchar_code = cmap4->cur_charcode; } + else + gindex = tt_cmap4_char_map_binary( cmap, pchar_code, 1 ); } - Exit: - *pchar_code = result; return gindex; } @@ -1305,13 +1307,8 @@ const TT_CMap_ClassRec tt_cmap4_class_rec = { { -#ifdef OPT_CMAP4 sizeof ( TT_CMap4Rec ), (FT_CMap_InitFunc) tt_cmap4_init, -#else - sizeof ( TT_CMapRec ), - (FT_CMap_InitFunc) tt_cmap_init, -#endif (FT_CMap_DoneFunc) NULL, (FT_CMap_CharIndexFunc)tt_cmap4_char_index, (FT_CMap_CharNextFunc) tt_cmap4_char_next @@ -1916,6 +1913,33 @@ #ifdef TT_CONFIG_CMAP_FORMAT_12 + typedef struct TT_CMap12Rec_ + { + TT_CMapRec cmap; + FT_Bool valid; + FT_ULong cur_charcode; + FT_UInt cur_gindex; + FT_ULong cur_group; + FT_ULong num_groups; + + } TT_CMap12Rec, *TT_CMap12; + + + FT_CALLBACK_DEF( FT_Error ) + tt_cmap12_init( TT_CMap12 cmap, + FT_Byte* table ) + { + cmap->cmap.data = table; + + table += 12; + cmap->num_groups = FT_PEEK_ULONG( table ); + + cmap->valid = 0; + + return SFNT_Err_Ok; + } + + FT_CALLBACK_DEF( FT_Error ) tt_cmap12_validate( FT_Byte* table, FT_Validator valid ) @@ -1968,33 +1992,146 @@ } + /* search the index of the charcode next to cmap->cur_charcode */ + /* cmap->cur_group should be set up properly by caller */ + /* */ + static void + tt_cmap12_next( TT_CMap12 cmap ) + { + FT_Byte* p; + FT_ULong start, end, start_id, char_code; + FT_ULong n; + FT_UInt gindex; + + + if ( cmap->cur_charcode >= 0xFFFFFFFFUL ) + goto Fail; + + char_code = cmap->cur_charcode + 1; + + n = cmap->cur_group; + + for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) + { + p = cmap->cmap.data + 16 + 12 * n; + start = TT_NEXT_ULONG( p ); + end = TT_NEXT_ULONG( p ); + start_id = TT_PEEK_ULONG( p ); + + if ( char_code < start ) + char_code = start; + + for ( ; char_code <= end; char_code++ ) + { + gindex = (FT_UInt)( start_id + char_code - start ); + + if ( gindex ) + { + cmap->cur_charcode = char_code;; + cmap->cur_gindex = gindex; + cmap->cur_group = n; + + return; + } + } + } + + Fail: + cmap->valid = 0; + } + + + static FT_UInt + tt_cmap12_char_map_binary( TT_CMap cmap, + FT_UInt32* pchar_code, + FT_Bool next ) + { + FT_UInt gindex = 0; + FT_Byte* p = cmap->data + 12; + FT_UInt32 num_groups = TT_PEEK_ULONG( p ); + FT_UInt32 char_code = *pchar_code; + FT_UInt32 start, end, start_id; + FT_UInt32 max, min, mid; + + + if ( !num_groups ) + return 0; + + /* make compiler happy */ + mid = num_groups; + end = 0xFFFFFFFFUL; + + if ( next ) + char_code++; + + min = 0; + max = num_groups; + + /* binary search */ + while ( min < max ) + { + mid = ( min + max ) >> 1; + p = cmap->data + 16 + 12 * mid; + + start = TT_NEXT_ULONG( p ); + end = TT_NEXT_ULONG( p ); + + if ( char_code < start ) + max = mid; + else if ( char_code > end ) + min = mid + 1; + else + { + start_id = TT_PEEK_ULONG( p ); + gindex = (FT_UInt)( start_id + char_code - start ); + + break; + } + } + + if ( next ) + { + TT_CMap12 cmap12 = (TT_CMap12)cmap; + + + /* if `char_code' is not in any group, then `mid' is */ + /* the group nearest to `char_code' */ + /* */ + + if ( char_code > end ) + { + mid++; + if ( mid == num_groups ) + return 0; + } + + cmap12->valid = 1; + cmap12->cur_charcode = char_code; + cmap12->cur_group = mid; + + if ( !gindex ) + { + tt_cmap12_next( cmap12 ); + + if ( cmap12->valid ) + gindex = cmap12->cur_gindex; + } + else + cmap12->cur_gindex = gindex; + + if ( gindex ) + *pchar_code = cmap12->cur_charcode; + } + + return gindex; + } + + FT_CALLBACK_DEF( FT_UInt ) tt_cmap12_char_index( TT_CMap cmap, FT_UInt32 char_code ) { - FT_UInt result = 0; - FT_Byte* table = cmap->data; - FT_Byte* p = table + 12; - FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 start, end, start_id; - - - for ( ; num_groups > 0; num_groups-- ) - { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( char_code < start ) - break; - - if ( char_code <= end ) - { - result = (FT_UInt)( start_id + char_code - start ); - break; - } - } - return result; + return tt_cmap12_char_map_binary( cmap, &char_code, 0 ); } @@ -2002,39 +2139,29 @@ tt_cmap12_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { - FT_Byte* table = cmap->data; - FT_UInt32 result = 0; - FT_UInt32 char_code = *pchar_code + 1; - FT_UInt gindex = 0; - FT_Byte* p = table + 12; - FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 start, end, start_id; + TT_CMap12 cmap12 = (TT_CMap12)cmap; + FT_ULong gindex; - p = table + 16; + if ( cmap12->cur_charcode >= 0xFFFFFFFFUL ) + return 0; - for ( ; num_groups > 0; num_groups-- ) + /* no need to search */ + if ( cmap12->valid && cmap12->cur_charcode == *pchar_code ) { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( char_code < start ) - char_code = start; - - if ( char_code <= end ) + tt_cmap12_next( cmap12 ); + if ( cmap12->valid ) { - gindex = (FT_UInt)(char_code - start + start_id); - if ( gindex != 0 ) - { - result = char_code; - goto Exit; - } + gindex = cmap12->cur_gindex; + if ( gindex ) + *pchar_code = cmap12->cur_charcode; } + else + gindex = 0; } + else + gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 ); - Exit: - *pchar_code = result; return gindex; } @@ -2056,9 +2183,9 @@ const TT_CMap_ClassRec tt_cmap12_class_rec = { { - sizeof ( TT_CMapRec ), + sizeof ( TT_CMap12Rec ), - (FT_CMap_InitFunc) tt_cmap_init, + (FT_CMap_InitFunc) tt_cmap12_init, (FT_CMap_DoneFunc) NULL, (FT_CMap_CharIndexFunc)tt_cmap12_char_index, (FT_CMap_CharNextFunc) tt_cmap12_char_next @@ -2144,14 +2271,12 @@ charmap.encoding = FT_ENCODING_NONE; /* will be filled later */ offset = TT_NEXT_ULONG( p ); - if ( offset && - table + offset + 2 < limit && - table + offset >= table ) + if ( offset && offset <= face->cmap_size - 2 ) { FT_Byte* cmap = table + offset; volatile FT_UInt format = TT_PEEK_USHORT( cmap ); const TT_CMap_Class* volatile pclazz = tt_cmap_classes; - TT_CMap_Class clazz; + TT_CMap_Class volatile clazz; for ( ; *pclazz; pclazz++ ) @@ -2160,13 +2285,13 @@ if ( clazz->format == format ) { volatile TT_ValidatorRec valid; - FT_Error error = SFNT_Err_Ok; + volatile FT_Error error = SFNT_Err_Ok; ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit, FT_VALIDATE_DEFAULT ); - valid.num_glyphs = (FT_UInt)face->root.num_glyphs; + valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs; if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 ) { @@ -2176,13 +2301,16 @@ if ( valid.validator.error == 0 ) { - (void)FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, NULL ); + FT_CMap ttcmap; - /* it is simpler to directly set the `unsorted' flag instead */ - /* of adding a parameter to FT_CMap_New */ - ((TT_CMap)(face->root.charmaps - [face->root.num_charmaps - 1]))->unsorted = - FT_BOOL( error ); + + if ( !FT_CMap_New( (FT_CMap_Class)clazz, + cmap, &charmap, &ttcmap ) ) + { + /* it is simpler to directly set `flags' than adding */ + /* a parameter to FT_CMap_New */ + ((TT_CMap)ttcmap)->flags = (FT_Int)error; + } } else { diff --git a/src/libs/freetype2/sfnt/ttcmap.h b/src/libs/freetype2/sfnt/ttcmap.h index 5f758a46d2..a10a3e2502 100644 --- a/src/libs/freetype2/sfnt/ttcmap.h +++ b/src/libs/freetype2/sfnt/ttcmap.h @@ -27,11 +27,15 @@ FT_BEGIN_HEADER + +#define TT_CMAP_FLAG_UNSORTED 1 +#define TT_CMAP_FLAG_OVERLAPPING 2 + typedef struct TT_CMapRec_ { FT_CMapRec cmap; FT_Byte* data; /* pointer to in-memory cmap table */ - FT_Bool unsorted; /* for format 4 only */ + FT_Int flags; /* for format 4 only */ } TT_CMapRec, *TT_CMap; diff --git a/src/libs/freetype2/sfnt/ttcmap0.c b/src/libs/freetype2/sfnt/ttcmap0.c deleted file mode 100644 index dd1c76aaa7..0000000000 --- a/src/libs/freetype2/sfnt/ttcmap0.c +++ /dev/null @@ -1,1991 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttcmap0.c */ -/* */ -/* TrueType new character mapping table (cmap) support (body). */ -/* */ -/* Copyright 2002, 2003 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_OBJECTS_H -#include FT_INTERNAL_STREAM_H -#include "ttload.h" -#include "ttcmap0.h" - -#include "sferrors.h" - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ -#undef FT_COMPONENT -#define FT_COMPONENT trace_ttcmap - - -#define TT_PEEK_SHORT FT_PEEK_SHORT -#define TT_PEEK_USHORT FT_PEEK_USHORT -#define TT_PEEK_LONG FT_PEEK_LONG -#define TT_PEEK_ULONG FT_PEEK_ULONG - -#define TT_NEXT_SHORT FT_NEXT_SHORT -#define TT_NEXT_USHORT FT_NEXT_USHORT -#define TT_NEXT_LONG FT_NEXT_LONG -#define TT_NEXT_ULONG FT_NEXT_ULONG - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap_init( TT_CMap cmap, - FT_Byte* table ) - { - cmap->data = table; - return 0; - } - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 0 *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 0 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* glyph_ids 6 BYTE[256] array of glyph indices */ - /* 262 */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_0 - - FT_CALLBACK_DEF( void ) - tt_cmap0_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p = table + 2; - FT_UInt length = TT_NEXT_USHORT( p ); - - - if ( table + length > valid->limit || length < 262 ) - FT_INVALID_TOO_SHORT; - - /* check glyph indices whenever necessary */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - FT_UInt n, idx; - - - p = table + 6; - for ( n = 0; n < 256; n++ ) - { - idx = *p++; - if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - } - } - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap0_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_Byte* table = cmap->data; - - - return char_code < 256 ? table[6 + char_code] : 0; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap0_char_next( TT_CMap cmap, - FT_UInt32 *pchar_code ) - { - FT_Byte* table = cmap->data; - FT_UInt32 charcode = *pchar_code; - FT_UInt32 result = 0; - FT_UInt gindex = 0; - - - table += 6; /* go to glyph ids */ - while ( ++charcode < 256 ) - { - gindex = table[charcode]; - if ( gindex != 0 ) - { - result = charcode; - break; - } - } - - *pchar_code = result; - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap0_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 4; - - - cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); - - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap0_class_rec = - { - { - sizeof( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap0_char_index, - (FT_CMap_CharNextFunc) tt_cmap0_char_next - }, - 0, - (TT_CMap_ValidateFunc) tt_cmap0_validate, - (TT_CMap_Info_GetFunc) tt_cmap0_get_info - }; - -#endif /* TT_CONFIG_CMAP_FORMAT_0 */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 2 *****/ - /***** *****/ - /***** This is used for certain CJK encodings that encode text in a *****/ - /***** mixed 8/16 bits encoding along the following lines: *****/ - /***** *****/ - /***** * Certain byte values correspond to an 8-bit character code *****/ - /***** (typically in the range 0..127 for ASCII compatibility). *****/ - /***** *****/ - /***** * Certain byte values signal the first byte of a 2-byte *****/ - /***** character code (but these values are also valid as the *****/ - /***** second byte of a 2-byte character). *****/ - /***** *****/ - /***** The following charmap lookup and iteration functions all *****/ - /***** assume that the value "charcode" correspond to following: *****/ - /***** *****/ - /***** - For one byte characters, "charcode" is simply the *****/ - /***** character code. *****/ - /***** *****/ - /***** - For two byte characters, "charcode" is the 2-byte *****/ - /***** character code in big endian format. More exactly: *****/ - /***** *****/ - /***** (charcode >> 8) is the first byte value *****/ - /***** (charcode & 0xFF) is the second byte value *****/ - /***** *****/ - /***** Note that not all values of "charcode" are valid according *****/ - /***** to these rules, and the function moderately check the *****/ - /***** arguments. *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 2 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* keys 6 USHORT[256] sub-header keys */ - /* subs 518 SUBHEAD[NSUBS] sub-headers array */ - /* glyph_ids 518+NSUB*8 USHORT[] glyph id array */ - /* */ - /* The `keys' table is used to map charcode high-bytes to sub-headers. */ - /* The value of `NSUBS' is the number of sub-headers defined in the */ - /* table and is computed by finding the maximum of the `keys' table. */ - /* */ - /* Note that for any n, `keys[n]' is a byte offset within the `subs' */ - /* table, i.e., it is the corresponding sub-header index multiplied */ - /* by 8. */ - /* */ - /* Each sub-header has the following format: */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* first 0 USHORT first valid low-byte */ - /* count 2 USHORT number of valid low-bytes */ - /* delta 4 SHORT see below */ - /* offset 6 USHORT see below */ - /* */ - /* A sub-header defines, for each high-byte, the range of valid */ - /* low-bytes within the charmap. Note that the range defined by `first' */ - /* and `count' must be completely included in the interval [0..255] */ - /* according to the specification. */ - /* */ - /* If a character code is contained within a given sub-header, then */ - /* mapping it to a glyph index is done as follows: */ - /* */ - /* * The value of `offset' is read. This is a _byte_ distance from the */ - /* location of the `offset' field itself into a slice of the */ - /* `glyph_ids' table. Let's call it `slice' (it's a USHORT[] too). */ - /* */ - /* * The value `slice[char.lo - first]' is read. If it is 0, there is */ - /* no glyph for the charcode. Otherwise, the value of `delta' is */ - /* added to it (modulo 65536) to form a new glyph index. */ - /* */ - /* It is up to the validation routine to check that all offsets fall */ - /* within the glyph ids table (and not within the `subs' table itself or */ - /* outside of the CMap). */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_2 - - FT_CALLBACK_DEF( void ) - tt_cmap2_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p = table + 2; /* skip format */ - FT_UInt length = TT_PEEK_USHORT( p ); - FT_UInt n, max_subs; - FT_Byte* keys; /* keys table */ - FT_Byte* subs; /* sub-headers */ - FT_Byte* glyph_ids; /* glyph id array */ - - - if ( table + length > valid->limit || length < 6 + 512 ) - FT_INVALID_TOO_SHORT; - - keys = table + 6; - - /* parse keys to compute sub-headers count */ - p = keys; - max_subs = 0; - for ( n = 0; n < 256; n++ ) - { - FT_UInt idx = TT_NEXT_USHORT( p ); - - - /* value must be multiple of 8 */ - if ( valid->level >= FT_VALIDATE_PARANOID && ( idx & 7 ) != 0 ) - FT_INVALID_DATA; - - idx >>= 3; - - if ( idx > max_subs ) - max_subs = idx; - } - - FT_ASSERT( p == table + 518 ); - - subs = p; - glyph_ids = subs + (max_subs + 1) * 8; - if ( glyph_ids > valid->limit ) - FT_INVALID_TOO_SHORT; - - /* parse sub-headers */ - for ( n = 0; n <= max_subs; n++ ) - { - FT_UInt first_code, code_count, offset; - FT_Int delta; - FT_Byte* ids; - - - first_code = TT_NEXT_USHORT( p ); - code_count = TT_NEXT_USHORT( p ); - delta = TT_NEXT_SHORT( p ); - offset = TT_NEXT_USHORT( p ); - - /* check range within 0..255 */ - if ( valid->level >= FT_VALIDATE_PARANOID ) - { - if ( first_code >= 256 || first_code + code_count > 256 ) - FT_INVALID_DATA; - } - - /* check offset */ - if ( offset != 0 ) - { - ids = p - 2 + offset; - if ( ids < glyph_ids || ids + code_count*2 > table + length ) - FT_INVALID_OFFSET; - - /* check glyph ids */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - FT_Byte* limit = p + code_count * 2; - FT_UInt idx; - - - for ( ; p < limit; ) - { - idx = TT_NEXT_USHORT( p ); - if ( idx != 0 ) - { - idx = ( idx + delta ) & 0xFFFFU; - if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - } - } - } - } - } - } - - - /* return sub header corresponding to a given character code */ - /* NULL on invalid charcode */ - static FT_Byte* - tt_cmap2_get_subheader( FT_Byte* table, - FT_UInt32 char_code ) - { - FT_Byte* result = NULL; - - - if ( char_code < 0x10000UL ) - { - FT_UInt char_lo = (FT_UInt)( char_code & 0xFF ); - FT_UInt char_hi = (FT_UInt)( char_code >> 8 ); - FT_Byte* p = table + 6; /* keys table */ - FT_Byte* subs = table + 518; /* subheaders table */ - FT_Byte* sub; - - - if ( char_hi == 0 ) - { - /* an 8-bit character code -- we use subHeader 0 in this case */ - /* to test whether the character code is in the charmap */ - /* */ - sub = subs; /* jump to first sub-header */ - - /* check that the sub-header for this byte is 0, which */ - /* indicates that it's really a valid one-byte value */ - /* Otherwise, return 0 */ - /* */ - p += char_lo * 2; - if ( TT_PEEK_USHORT( p ) != 0 ) - goto Exit; - } - else - { - /* a 16-bit character code */ - - /* jump to key entry */ - p += char_hi * 2; - /* jump to sub-header */ - sub = subs + ( FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 8 ) ); - - /* check that the high byte isn't a valid one-byte value */ - if ( sub == subs ) - goto Exit; - } - result = sub; - } - Exit: - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap2_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_Byte* table = cmap->data; - FT_UInt result = 0; - FT_Byte* subheader; - - - subheader = tt_cmap2_get_subheader( table, char_code ); - if ( subheader ) - { - FT_Byte* p = subheader; - FT_UInt idx = (FT_UInt)(char_code & 0xFF); - FT_UInt start, count; - FT_Int delta; - FT_UInt offset; - - - start = TT_NEXT_USHORT( p ); - count = TT_NEXT_USHORT( p ); - delta = TT_NEXT_SHORT ( p ); - offset = TT_PEEK_USHORT( p ); - - idx -= start; - if ( idx < count && offset != 0 ) - { - p += offset + 2 * idx; - idx = TT_PEEK_USHORT( p ); - - if ( idx != 0 ) - result = (FT_UInt)( idx + delta ) & 0xFFFFU; - } - } - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap2_char_next( TT_CMap cmap, - FT_UInt32 *pcharcode ) - { - FT_Byte* table = cmap->data; - FT_UInt gindex = 0; - FT_UInt32 result = 0; - FT_UInt32 charcode = *pcharcode + 1; - FT_Byte* subheader; - - - while ( charcode < 0x10000UL ) - { - subheader = tt_cmap2_get_subheader( table, charcode ); - if ( subheader ) - { - FT_Byte* p = subheader; - FT_UInt start = TT_NEXT_USHORT( p ); - FT_UInt count = TT_NEXT_USHORT( p ); - FT_Int delta = TT_NEXT_SHORT ( p ); - FT_UInt offset = TT_PEEK_USHORT( p ); - FT_UInt char_lo = (FT_UInt)( charcode & 0xFF ); - FT_UInt pos, idx; - - - if ( offset == 0 ) - goto Next_SubHeader; - - if ( char_lo < start ) - { - char_lo = start; - pos = 0; - } - else - pos = (FT_UInt)( char_lo - start ); - - p += offset + pos * 2; - charcode = FT_PAD_FLOOR( charcode, 256 ) + char_lo; - - for ( ; pos < count; pos++, charcode++ ) - { - idx = TT_NEXT_USHORT( p ); - - if ( idx != 0 ) - { - gindex = ( idx + delta ) & 0xFFFFU; - if ( gindex != 0 ) - { - result = charcode; - goto Exit; - } - } - } - } - - /* jump to next sub-header, i.e. higher byte value */ - Next_SubHeader: - charcode = FT_PAD_FLOOR( charcode, 256 ) + 256; - } - - Exit: - *pcharcode = result; - - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap2_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 4; - - - cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); - - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap2_class_rec = - { - { - sizeof( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap2_char_index, - (FT_CMap_CharNextFunc) tt_cmap2_char_next - }, - 2, - (TT_CMap_ValidateFunc) tt_cmap2_validate, - (TT_CMap_Info_GetFunc) tt_cmap2_get_info - }; - -#endif /* TT_CONFIG_CMAP_FORMAT_2 */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 4 *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 4 */ - /* length 2 USHORT table length */ - /* in bytes */ - /* language 4 USHORT Mac language code */ - /* */ - /* segCountX2 6 USHORT 2*NUM_SEGS */ - /* searchRange 8 USHORT 2*(1 << LOG_SEGS) */ - /* entrySelector 10 USHORT LOG_SEGS */ - /* rangeShift 12 USHORT segCountX2 - */ - /* searchRange */ - /* */ - /* endCount 14 USHORT[NUM_SEGS] end charcode for */ - /* each segment; last */ - /* is 0xFFFF */ - /* */ - /* pad 14+NUM_SEGS*2 USHORT padding */ - /* */ - /* startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for */ - /* each segment */ - /* */ - /* idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each */ - /* segment */ - /* idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for */ - /* each segment; can be */ - /* zero */ - /* */ - /* glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph id */ - /* ranges */ - /* */ - /* Character codes are modelled by a series of ordered (increasing) */ - /* intervals called segments. Each segment has start and end codes, */ - /* provided by the `startCount' and `endCount' arrays. Segments must */ - /* not be overlapping and the last segment should always contain the */ - /* `0xFFFF' endCount. */ - /* */ - /* The fields `searchRange', `entrySelector' and `rangeShift' are better */ - /* ignored (they are traces of over-engineering in the TrueType */ - /* specification). */ - /* */ - /* Each segment also has a signed `delta', as well as an optional offset */ - /* within the `glyphIds' table. */ - /* */ - /* If a segment's idOffset is 0, the glyph index corresponding to any */ - /* charcode within the segment is obtained by adding the value of */ - /* `idDelta' directly to the charcode, modulo 65536. */ - /* */ - /* Otherwise, a glyph index is taken from the glyph ids sub-array for */ - /* the segment, and the value of `idDelta' is added to it. */ - /* */ - /* */ - /* Finally, note that certain fonts contain invalid charmaps that */ - /* contain end=0xFFFF, start=0xFFFF, delta=0x0001, offset=0xFFFF at the */ - /* of their charmaps (e.g. opens___.ttf which comes with OpenOffice.org) */ - /* we need special code to deal with them correctly... */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_4 - - FT_CALLBACK_DEF( void ) - tt_cmap4_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p = table + 2; /* skip format */ - FT_UInt length = TT_NEXT_USHORT( p ); - FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids; - FT_UInt num_segs; - - - /* in certain fonts, the `length' field is invalid and goes */ - /* out of bound. We try to correct this here... */ - if ( length < 16 ) - FT_INVALID_TOO_SHORT; - - if ( table + length > valid->limit ) - { - if ( valid->level >= FT_VALIDATE_TIGHT ) - FT_INVALID_TOO_SHORT; - - length = (FT_UInt)( valid->limit - table ); - } - - p = table + 6; - num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */ - - if ( valid->level >= FT_VALIDATE_PARANOID ) - { - /* check that we have an even value here */ - if ( num_segs & 1 ) - FT_INVALID_DATA; - } - - num_segs /= 2; - - /* check the search parameters - even though we never use them */ - /* */ - if ( valid->level >= FT_VALIDATE_PARANOID ) - { - /* check the values of 'searchRange', 'entrySelector', 'rangeShift' */ - FT_UInt search_range = TT_NEXT_USHORT( p ); - FT_UInt entry_selector = TT_NEXT_USHORT( p ); - FT_UInt range_shift = TT_NEXT_USHORT( p ); - - - if ( ( search_range | range_shift ) & 1 ) /* must be even values */ - FT_INVALID_DATA; - - search_range /= 2; - range_shift /= 2; - - /* `search range' is the greatest power of 2 that is <= num_segs */ - - if ( search_range > num_segs || - search_range * 2 < num_segs || - search_range + range_shift != num_segs || - search_range != ( 1U << entry_selector ) ) - FT_INVALID_DATA; - } - - ends = table + 14; - starts = table + 16 + num_segs * 2; - deltas = starts + num_segs * 2; - offsets = deltas + num_segs * 2; - glyph_ids = offsets + num_segs * 2; - - if ( glyph_ids > table + length ) - FT_INVALID_TOO_SHORT; - - /* check last segment, its end count must be FFFF */ - if ( valid->level >= FT_VALIDATE_PARANOID ) - { - p = ends + ( num_segs - 1 ) * 2; - if ( TT_PEEK_USHORT( p ) != 0xFFFFU ) - FT_INVALID_DATA; - } - - /* check that segments are sorted in increasing order and do not */ - /* overlap; check also the offsets */ - { - FT_UInt start, end, last = 0, offset, n; - FT_Int delta; - - - for ( n = 0; n < num_segs; n++ ) - { - p = starts + n * 2; - start = TT_PEEK_USHORT( p ); - p = ends + n * 2; - end = TT_PEEK_USHORT( p ); - p = deltas + n * 2; - delta = TT_PEEK_SHORT( p ); - p = offsets + n * 2; - offset = TT_PEEK_USHORT( p ); - - if ( start > end ) - FT_INVALID_DATA; - - /* this test should be performed at default validation level; */ - /* unfortunately, some popular Asian fonts present overlapping */ - /* ranges in their charmaps */ - /* */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - if ( n > 0 && start <= last ) - FT_INVALID_DATA; - } - - if ( offset && offset != 0xFFFFU ) - { - p += offset; /* start of glyph id array */ - - /* check that we point within the glyph ids table only */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - if ( p < glyph_ids || - p + ( end - start + 1 ) * 2 > table + length ) - FT_INVALID_DATA; - } - else - { - if ( p < glyph_ids || - p + ( end - start + 1 ) * 2 > valid->limit ) - FT_INVALID_DATA; - } - - /* check glyph indices within the segment range */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - FT_UInt i, idx; - - - for ( i = start; i < end; i++ ) - { - idx = FT_NEXT_USHORT( p ); - if ( idx != 0 ) - { - idx = (FT_UInt)( idx + delta ) & 0xFFFFU; - - if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - } - } - } - } - else if ( offset == 0xFFFFU ) - { - /* Some fonts (erroneously?) use a range offset of 0xFFFF */ - /* to mean missing glyph in cmap table */ - /* */ - if ( valid->level >= FT_VALIDATE_PARANOID || - n != num_segs - 1 || - !( start == 0xFFFFU && end == 0xFFFFU && delta == 0x1U ) ) - FT_INVALID_DATA; - } - - last = end; - } - } - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap4_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_Byte* table = cmap->data; - FT_UInt result = 0; - - - if ( char_code < 0x10000UL ) - { - FT_UInt idx, num_segs2; - FT_Int delta; - FT_UInt code = (FT_UInt)char_code; - FT_Byte* p; - - - p = table + 6; - num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); /* be paranoid! */ - -#if 1 - /* Some fonts have more than 170 segments in their charmaps! */ - /* We changed this function to use a more efficient binary */ - /* search for improving performance */ - { - FT_UInt min = 0; - FT_UInt max = num_segs2 >> 1; - FT_UInt mid, start, end, offset; - - - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 14 + mid * 2; - end = TT_NEXT_USHORT( p ); - p += num_segs2; - start = TT_PEEK_USHORT( p); - - if ( code < start ) - max = mid; - else if ( code > end ) - min = mid + 1; - else - { - /* we found the segment */ - idx = code; - - p += num_segs2; - delta = TT_PEEK_SHORT( p ); - - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset == 0xFFFFU ) - goto Exit; - - if ( offset != 0 ) - { - p += offset + 2 * ( idx - start ); - idx = TT_PEEK_USHORT( p ); - } - - if ( idx != 0 ) - result = (FT_UInt)( idx + delta ) & 0xFFFFU; - - goto Exit; - } - } - } - -#else /* 0 - old code */ - - { - FT_UInt n; - FT_Byte* q; - - - p = table + 14; /* ends table */ - q = table + 16 + num_segs2; /* starts table */ - - - for ( n = 0; n < num_segs2; n += 2 ) - { - FT_UInt end = TT_NEXT_USHORT( p ); - FT_UInt start = TT_NEXT_USHORT( q ); - FT_UInt offset; - - - if ( code < start ) - break; - - if ( code <= end ) - { - idx = code; - - p = q + num_segs2 - 2; - delta = TT_PEEK_SHORT( p ); - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset == 0xFFFFU ) - goto Exit; - - if ( offset != 0 ) - { - p += offset + 2 * ( idx - start ); - idx = TT_PEEK_USHORT( p ); - } - - if ( idx != 0 ) - result = (FT_UInt)( idx + delta ) & 0xFFFFU; - } - } - } - -#endif /* 0 */ - - } - - Exit: - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap4_char_next( TT_CMap cmap, - FT_UInt32 *pchar_code ) - { - FT_Byte* table = cmap->data; - FT_UInt32 result = 0; - FT_UInt gindex = 0; - FT_UInt32 char_code = *pchar_code; - FT_Byte* p; - FT_UInt code, num_segs2; - - - if ( char_code >= 0xFFFFUL ) - goto Exit; - - code = (FT_UInt)char_code + 1; - p = table + 6; - num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT(p), 2 ); /* ensure even-ness */ - -#if 1 - - for (;;) - { - /* Some fonts have more than 170 segments in their charmaps! */ - /* We changed this function to use a more efficient binary */ - /* search */ - FT_UInt offset; - FT_Int delta; - FT_UInt min = 0; - FT_UInt max = num_segs2 >> 1; - FT_UInt mid, start, end; - FT_UInt hi; - - - /* we begin by finding the segment which end is - closer to our code point */ - hi = max + 1; - while ( min < max ) - { - mid = ( min + max ) >> 1; - p = table + 14 + mid * 2; - end = TT_PEEK_USHORT( p ); - - if ( end < code ) - min = mid + 1; - else - { - hi = mid; - max = mid; - } - } - - if ( hi > max ) - { - /* the point is behind the last segment; - we will exit right now */ - goto Exit; - } - - p = table + 14 + hi * 2; - end = TT_PEEK_USHORT( p ); - - p += 2 + num_segs2; - start = TT_PEEK_USHORT( p ); - - if ( code < start ) - code = start; - - p += num_segs2; - delta = TT_PEEK_USHORT( p ); - - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset != 0 && offset != 0xFFFFU ) - { - /* parse the glyph ids array for non-zero index */ - p += offset + ( code - start ) * 2; - while ( code <= end ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex != 0 ) - { - gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU; - if ( gindex != 0 ) - { - result = code; - goto Exit; - } - } - code++; - } - } - else if ( offset == 0xFFFFU ) - { - /* an offset of 0xFFFF means an empty glyph in certain fonts! */ - code = end + 1; - } - else /* offset == 0 */ - { - gindex = (FT_UInt)( code + delta ) & 0xFFFFU; - if ( gindex != 0 ) - { - result = code; - goto Exit; - } - code++; - } - } - -#else /* old code -- kept for reference */ - - for ( ;; ) - { - FT_UInt offset, n; - FT_Int delta; - FT_Byte* q; - - - p = table + 14; /* ends table */ - q = table + 16 + num_segs2; /* starts table */ - - for ( n = 0; n < num_segs2; n += 2 ) - { - FT_UInt end = TT_NEXT_USHORT( p ); - FT_UInt start = TT_NEXT_USHORT( q ); - - - if ( code < start ) - code = start; - - if ( code <= end ) - { - p = q + num_segs2 - 2; - delta = TT_PEEK_SHORT( p ); - p += num_segs2; - offset = TT_PEEK_USHORT( p ); - - if ( offset != 0 && offset != 0xFFFFU ) - { - /* parse the glyph ids array for non-0 index */ - p += offset + ( code - start ) * 2; - while ( code <= end ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex != 0 ) - { - gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU; - if ( gindex != 0 ) - break; - } - code++; - } - } - else if ( offset == 0xFFFFU ) - { - /* an offset of 0xFFFF means an empty glyph in certain fonts! */ - code = end; - break; - } - else - gindex = (FT_UInt)( code + delta ) & 0xFFFFU; - - if ( gindex == 0 ) - break; - - result = code; - goto Exit; - } - } - /* loop to next trial charcode */ - if ( code >= 0xFFFFU ) - break; - - code++; - } - -#endif /* !1 */ - - Exit: - *pchar_code = result; - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap4_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 4; - - - cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); - - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap4_class_rec = - { - { - sizeof ( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap4_char_index, - (FT_CMap_CharNextFunc) tt_cmap4_char_next - }, - 4, - (TT_CMap_ValidateFunc) tt_cmap4_validate, - (TT_CMap_Info_GetFunc) tt_cmap4_get_info - }; - -#endif /* TT_CONFIG_CMAP_FORMAT_4 */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 6 *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 4 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* */ - /* first 6 USHORT first segment code */ - /* count 8 USHORT segment size in chars */ - /* glyphIds 10 USHORT[count] glyph ids */ - /* */ - /* A very simplified segment mapping. */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_6 - - FT_CALLBACK_DEF( void ) - tt_cmap6_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p; - FT_UInt length, count; - - - if ( table + 10 > valid->limit ) - FT_INVALID_TOO_SHORT; - - p = table + 2; - length = TT_NEXT_USHORT( p ); - - p = table + 8; /* skip language and start index */ - count = TT_NEXT_USHORT( p ); - - if ( table + length > valid->limit || length < 10 + count * 2 ) - FT_INVALID_TOO_SHORT; - - /* check glyph indices */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - FT_UInt gindex; - - - for ( ; count > 0; count-- ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - } - } - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap6_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_Byte* table = cmap->data; - FT_UInt result = 0; - FT_Byte* p = table + 6; - FT_UInt start = TT_NEXT_USHORT( p ); - FT_UInt count = TT_NEXT_USHORT( p ); - FT_UInt idx = (FT_UInt)( char_code - start ); - - - if ( idx < count ) - { - p += 2 * idx; - result = TT_PEEK_USHORT( p ); - } - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap6_char_next( TT_CMap cmap, - FT_UInt32 *pchar_code ) - { - FT_Byte* table = cmap->data; - FT_UInt32 result = 0; - FT_UInt32 char_code = *pchar_code + 1; - FT_UInt gindex = 0; - - FT_Byte* p = table + 6; - FT_UInt start = TT_NEXT_USHORT( p ); - FT_UInt count = TT_NEXT_USHORT( p ); - FT_UInt idx; - - - if ( char_code >= 0x10000UL ) - goto Exit; - - if ( char_code < start ) - char_code = start; - - idx = (FT_UInt)( char_code - start ); - p += 2 * idx; - - for ( ; idx < count; idx++ ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex != 0 ) - { - result = char_code; - break; - } - char_code++; - } - - Exit: - *pchar_code = result; - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap6_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 4; - - - cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p ); - - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap6_class_rec = - { - { - sizeof ( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap6_char_index, - (FT_CMap_CharNextFunc) tt_cmap6_char_next - }, - 6, - (TT_CMap_ValidateFunc) tt_cmap6_validate, - (TT_CMap_Info_GetFunc) tt_cmap6_get_info - }; - -#endif /* TT_CONFIG_CMAP_FORMAT_6 */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 8 *****/ - /***** *****/ - /***** It's hard to completely understand what the OpenType spec *****/ - /***** says about this format, but here is my conclusion. *****/ - /***** *****/ - /***** The purpose of this format is to easily map UTF-16 text to *****/ - /***** glyph indices. Basically, the `char_code' must be in one of *****/ - /***** the following formats: *****/ - /***** *****/ - /***** - A 16-bit value that isn't part of the Unicode Surrogates *****/ - /***** Area (i.e. U+D800-U+DFFF). *****/ - /***** *****/ - /***** - A 32-bit value, made of two surrogate values, i.e.. if *****/ - /***** `char_code = (char_hi << 16) | char_lo', then both *****/ - /***** `char_hi' and `char_lo' must be in the Surrogates Area. *****/ - /***** Area. *****/ - /***** *****/ - /***** The 'is32' table embedded in the charmap indicates whether a *****/ - /***** given 16-bit value is in the surrogates area or not. *****/ - /***** *****/ - /***** So, for any given `char_code', we can assert the following: *****/ - /***** *****/ - /***** If `char_hi == 0' then we must have `is32[char_lo] == 0'. *****/ - /***** *****/ - /***** If `char_hi != 0' then we must have both *****/ - /***** `is32[char_hi] != 0' and `is32[char_lo] != 0'. *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 8 */ - /* reseved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* is32 12 BYTE[8192] 32-bitness bitmap */ - /* count 8204 ULONG number of groups */ - /* */ - /* This header is followed by 'count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* startId 8 ULONG start glyph id for the group */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_8 - - FT_CALLBACK_DEF( void ) - tt_cmap8_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p = table + 4; - FT_Byte* is32; - FT_UInt32 length; - FT_UInt32 num_groups; - - - if ( table + 16 + 8192 > valid->limit ) - FT_INVALID_TOO_SHORT; - - length = TT_NEXT_ULONG( p ); - if ( table + length > valid->limit || length < 8208 ) - FT_INVALID_TOO_SHORT; - - is32 = table + 12; - p = is32 + 8192; /* skip `is32' array */ - num_groups = TT_NEXT_ULONG( p ); - - if ( p + num_groups * 12 > valid->limit ) - FT_INVALID_TOO_SHORT; - - /* check groups, they must be in increasing order */ - { - FT_UInt32 n, start, end, start_id, count, last = 0; - - - for ( n = 0; n < num_groups; n++ ) - { - FT_UInt hi, lo; - - - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( start > end ) - FT_INVALID_DATA; - - if ( n > 0 && start <= last ) - FT_INVALID_DATA; - - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - - count = (FT_UInt32)( end - start + 1 ); - - if ( start & ~0xFFFFU ) - { - /* start_hi != 0; check that is32[i] is 1 for each i in */ - /* the `hi' and `lo' of the range [start..end] */ - for ( ; count > 0; count--, start++ ) - { - hi = (FT_UInt)( start >> 16 ); - lo = (FT_UInt)( start & 0xFFFFU ); - - if ( (is32[hi >> 3] & ( 0x80 >> ( hi & 7 ) ) ) == 0 ) - FT_INVALID_DATA; - - if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) == 0 ) - FT_INVALID_DATA; - } - } - else - { - /* start_hi == 0; check that is32[i] is 0 for each i in */ - /* the range [start..end] */ - - /* end_hi cannot be != 0! */ - if ( end & ~0xFFFFU ) - FT_INVALID_DATA; - - for ( ; count > 0; count--, start++ ) - { - lo = (FT_UInt)( start & 0xFFFFU ); - - if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 ) - FT_INVALID_DATA; - } - } - } - - last = end; - } - } - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap8_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_Byte* table = cmap->data; - FT_UInt result = 0; - FT_Byte* p = table + 8204; - FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 start, end, start_id; - - - for ( ; num_groups > 0; num_groups-- ) - { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( char_code < start ) - break; - - if ( char_code <= end ) - { - result = (FT_UInt)( start_id + char_code - start ); - break; - } - } - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap8_char_next( TT_CMap cmap, - FT_UInt32 *pchar_code ) - { - FT_UInt32 result = 0; - FT_UInt32 char_code = *pchar_code + 1; - FT_UInt gindex = 0; - FT_Byte* table = cmap->data; - FT_Byte* p = table + 8204; - FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 start, end, start_id; - - - p = table + 8208; - - for ( ; num_groups > 0; num_groups-- ) - { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( char_code < start ) - char_code = start; - - if ( char_code <= end ) - { - gindex = (FT_UInt)( char_code - start + start_id ); - if ( gindex != 0 ) - { - result = char_code; - goto Exit; - } - } - } - - Exit: - *pchar_code = result; - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap8_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 8; - - - cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap8_class_rec = - { - { - sizeof ( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap8_char_index, - (FT_CMap_CharNextFunc) tt_cmap8_char_next - }, - 8, - (TT_CMap_ValidateFunc) tt_cmap8_validate, - (TT_CMap_Info_GetFunc) tt_cmap8_get_info - }; - -#endif /* TT_CONFIG_CMAP_FORMAT_8 */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 10 *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 10 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* */ - /* start 12 ULONG first char in range */ - /* count 16 ULONG number of chars in range */ - /* glyphIds 20 USHORT[count] glyph indices covered */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_10 - - FT_CALLBACK_DEF( void ) - tt_cmap10_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p = table + 4; - FT_ULong length, count; - - - if ( table + 20 > valid->limit ) - FT_INVALID_TOO_SHORT; - - length = TT_NEXT_ULONG( p ); - p = table + 16; - count = TT_NEXT_ULONG( p ); - - if ( table + length > valid->limit || length < 20 + count * 2 ) - FT_INVALID_TOO_SHORT; - - /* check glyph indices */ - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - FT_UInt gindex; - - - for ( ; count > 0; count-- ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - } - } - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap10_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_Byte* table = cmap->data; - FT_UInt result = 0; - FT_Byte* p = table + 12; - FT_UInt32 start = TT_NEXT_ULONG( p ); - FT_UInt32 count = TT_NEXT_ULONG( p ); - FT_UInt32 idx = (FT_ULong)( char_code - start ); - - - if ( idx < count ) - { - p += 2 * idx; - result = TT_PEEK_USHORT( p ); - } - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap10_char_next( TT_CMap cmap, - FT_UInt32 *pchar_code ) - { - FT_Byte* table = cmap->data; - FT_UInt32 char_code = *pchar_code + 1; - FT_UInt gindex = 0; - FT_Byte* p = table + 12; - FT_UInt32 start = TT_NEXT_ULONG( p ); - FT_UInt32 count = TT_NEXT_ULONG( p ); - FT_UInt32 idx; - - - if ( char_code < start ) - char_code = start; - - idx = (FT_UInt32)( char_code - start ); - p += 2 * idx; - - for ( ; idx < count; idx++ ) - { - gindex = TT_NEXT_USHORT( p ); - if ( gindex != 0 ) - break; - char_code++; - } - - *pchar_code = char_code; - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap10_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 8; - - - cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); - - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap10_class_rec = - { - { - sizeof ( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap10_char_index, - (FT_CMap_CharNextFunc) tt_cmap10_char_next - }, - 10, - (TT_CMap_ValidateFunc) tt_cmap10_validate, - (TT_CMap_Info_GetFunc) tt_cmap10_get_info - }; - -#endif /* TT_CONFIG_CMAP_FORMAT_10 */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** FORMAT 12 *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 12 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* count 12 ULONG number of groups */ - /* 16 */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* startId 8 ULONG start glyph id for the group */ - /* */ - -#ifdef TT_CONFIG_CMAP_FORMAT_12 - - FT_CALLBACK_DEF( void ) - tt_cmap12_validate( FT_Byte* table, - FT_Validator valid ) - { - FT_Byte* p; - FT_ULong length; - FT_ULong num_groups; - - - if ( table + 16 > valid->limit ) - FT_INVALID_TOO_SHORT; - - p = table + 4; - length = TT_NEXT_ULONG( p ); - - p = table + 12; - num_groups = TT_NEXT_ULONG( p ); - - if ( table + length > valid->limit || length < 16 + 12 * num_groups ) - FT_INVALID_TOO_SHORT; - - /* check groups, they must be in increasing order */ - { - FT_ULong n, start, end, start_id, last = 0; - - - for ( n = 0; n < num_groups; n++ ) - { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( start > end ) - FT_INVALID_DATA; - - if ( n > 0 && start <= last ) - FT_INVALID_DATA; - - if ( valid->level >= FT_VALIDATE_TIGHT ) - { - if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ) - FT_INVALID_GLYPH_ID; - } - - last = end; - } - } - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap12_char_index( TT_CMap cmap, - FT_UInt32 char_code ) - { - FT_UInt result = 0; - FT_Byte* table = cmap->data; - FT_Byte* p = table + 12; - FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 start, end, start_id; - - - for ( ; num_groups > 0; num_groups-- ) - { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( char_code < start ) - break; - - if ( char_code <= end ) - { - result = (FT_UInt)( start_id + char_code - start ); - break; - } - } - return result; - } - - - FT_CALLBACK_DEF( FT_UInt ) - tt_cmap12_char_next( TT_CMap cmap, - FT_UInt32 *pchar_code ) - { - FT_Byte* table = cmap->data; - FT_UInt32 result = 0; - FT_UInt32 char_code = *pchar_code + 1; - FT_UInt gindex = 0; - FT_Byte* p = table + 12; - FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 start, end, start_id; - - - p = table + 16; - - for ( ; num_groups > 0; num_groups-- ) - { - start = TT_NEXT_ULONG( p ); - end = TT_NEXT_ULONG( p ); - start_id = TT_NEXT_ULONG( p ); - - if ( char_code < start ) - char_code = start; - - if ( char_code <= end ) - { - gindex = (FT_UInt)(char_code - start + start_id); - if ( gindex != 0 ) - { - result = char_code; - goto Exit; - } - } - } - - Exit: - *pchar_code = result; - return gindex; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_cmap12_get_info( TT_CMap cmap, - TT_CMapInfo *cmap_info ) - { - FT_Byte* p = cmap->data + 8; - - - cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p ); - - return FT_Err_Ok; - } - - - FT_CALLBACK_TABLE_DEF - const TT_CMap_ClassRec tt_cmap12_class_rec = - { - { - sizeof ( TT_CMapRec ), - - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap12_char_index, - (FT_CMap_CharNextFunc) tt_cmap12_char_next - }, - 12, - (TT_CMap_ValidateFunc) tt_cmap12_validate, - (TT_CMap_Info_GetFunc) tt_cmap12_get_info - }; - - -#endif /* TT_CONFIG_CMAP_FORMAT_12 */ - - - static const TT_CMap_Class tt_cmap_classes[] = - { -#ifdef TT_CONFIG_CMAP_FORMAT_0 - &tt_cmap0_class_rec, -#endif - -#ifdef TT_CONFIG_CMAP_FORMAT_2 - &tt_cmap2_class_rec, -#endif - -#ifdef TT_CONFIG_CMAP_FORMAT_4 - &tt_cmap4_class_rec, -#endif - -#ifdef TT_CONFIG_CMAP_FORMAT_6 - &tt_cmap6_class_rec, -#endif - -#ifdef TT_CONFIG_CMAP_FORMAT_8 - &tt_cmap8_class_rec, -#endif - -#ifdef TT_CONFIG_CMAP_FORMAT_10 - &tt_cmap10_class_rec, -#endif - -#ifdef TT_CONFIG_CMAP_FORMAT_12 - &tt_cmap12_class_rec, -#endif - - NULL, - }; - - - /* parse the `cmap' table and build the corresponding TT_CMap objects */ - /* in the current face */ - /* */ - FT_LOCAL_DEF( FT_Error ) - tt_face_build_cmaps( TT_Face face ) - { - FT_Byte* table = face->cmap_table; - FT_Byte* limit = table + face->cmap_size; - FT_UInt volatile num_cmaps; - FT_Byte* volatile p = table; - - - if ( p + 4 > limit ) - return SFNT_Err_Invalid_Table; - - /* only recognize format 0 */ - if ( TT_NEXT_USHORT( p ) != 0 ) - { - p -= 2; - FT_ERROR(( "tt_face_build_cmaps: unsupported `cmap' table format = %d\n", - TT_PEEK_USHORT( p ) )); - return SFNT_Err_Invalid_Table; - } - - num_cmaps = TT_NEXT_USHORT( p ); - - for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- ) - { - FT_CharMapRec charmap; - FT_UInt32 offset; - - - charmap.platform_id = TT_NEXT_USHORT( p ); - charmap.encoding_id = TT_NEXT_USHORT( p ); - charmap.face = FT_FACE( face ); - charmap.encoding = FT_ENCODING_NONE; /* will be filled later */ - offset = TT_NEXT_ULONG( p ); - - if ( offset && table + offset + 2 < limit ) - { - FT_Byte* cmap = table + offset; - volatile FT_UInt format = TT_PEEK_USHORT( cmap ); - const TT_CMap_Class* volatile pclazz = tt_cmap_classes; - TT_CMap_Class clazz; - - - for ( ; *pclazz; pclazz++ ) - { - clazz = *pclazz; - if ( clazz->format == format ) - { - volatile TT_ValidatorRec valid; - - - ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit, - FT_VALIDATE_DEFAULT ); - - valid.num_glyphs = (FT_UInt)face->root.num_glyphs; - - if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 ) - { - /* validate this cmap sub-table */ - clazz->validate( cmap, FT_VALIDATOR( &valid ) ); - } - - if ( valid.validator.error == 0 ) - (void)FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, NULL ); - else - { - FT_ERROR(( "tt_face_build_cmaps:" )); - FT_ERROR(( " broken cmap sub-table ignored!\n" )); - } - break; - } - } - } - } - - return 0; - } - - - FT_LOCAL( FT_Error ) - tt_get_cmap_info( FT_CharMap charmap, - TT_CMapInfo *cmap_info ) - { - FT_CMap cmap = (FT_CMap)charmap; - TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz; - - - return clazz->get_cmap_info( charmap, cmap_info ); - } - - -/* END */ diff --git a/src/libs/freetype2/sfnt/ttcmap0.h b/src/libs/freetype2/sfnt/ttcmap0.h deleted file mode 100644 index 6ca9ca1100..0000000000 --- a/src/libs/freetype2/sfnt/ttcmap0.h +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttcmap0.h */ -/* */ -/* TrueType new character mapping table (cmap) support (specification). */ -/* */ -/* Copyright 2002, 2003 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __TTCMAP0_H__ -#define __TTCMAP0_H__ - - -#include <ft2build.h> -#include FT_INTERNAL_TRUETYPE_TYPES_H -#include FT_INTERNAL_OBJECTS_H -#include FT_SERVICE_TT_CMAP_H - -FT_BEGIN_HEADER - - typedef struct TT_CMapRec_ - { - FT_CMapRec cmap; - FT_Byte* data; /* pointer to in-memory cmap table */ - - } TT_CMapRec, *TT_CMap; - - typedef const struct TT_CMap_ClassRec_* TT_CMap_Class; - - - typedef FT_Error - (*TT_CMap_ValidateFunc)( FT_Byte* data, - FT_Validator valid ); - - typedef struct TT_CMap_ClassRec_ - { - FT_CMap_ClassRec clazz; - FT_UInt format; - TT_CMap_ValidateFunc validate; - TT_CMap_Info_GetFunc get_cmap_info; - - } TT_CMap_ClassRec; - - - typedef struct TT_ValidatorRec_ - { - FT_ValidatorRec validator; - FT_UInt num_glyphs; - - } TT_ValidatorRec, *TT_Validator; - - -#define TT_VALIDATOR( x ) ((TT_Validator)( x )) -#define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs - - - FT_LOCAL( FT_Error ) - tt_face_build_cmaps( TT_Face face ); - - /* used in tt-cmaps service */ - FT_LOCAL( FT_Error ) - tt_get_cmap_info( FT_CharMap charmap, - TT_CMapInfo *cmap_info ); - - -FT_END_HEADER - -#endif /* __TTCMAP0_H__ */ - - -/* END */ diff --git a/src/libs/freetype2/sfnt/ttkern.c b/src/libs/freetype2/sfnt/ttkern.c index 805efa5c3b..30f6cdbf12 100644 --- a/src/libs/freetype2/sfnt/ttkern.c +++ b/src/libs/freetype2/sfnt/ttkern.c @@ -5,7 +5,7 @@ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -246,7 +246,10 @@ } else /* linear search */ { - for ( count = num_pairs; count > 0; count-- ) + FT_UInt count2; + + + for ( count2 = num_pairs; count2 > 0; count2-- ) { FT_ULong key = FT_NEXT_ULONG( p ); @@ -263,7 +266,7 @@ break; /* - * We don't support format 2 because we've never seen a single font + * We don't support format 2 because we haven't seen a single font * using it in real life... */ diff --git a/src/libs/freetype2/sfnt/ttload.c b/src/libs/freetype2/sfnt/ttload.c index 0f91984020..c81f80d5e1 100644 --- a/src/libs/freetype2/sfnt/ttload.c +++ b/src/libs/freetype2/sfnt/ttload.c @@ -5,7 +5,7 @@ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -60,7 +60,7 @@ TT_Table limit; - FT_TRACE3(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ", + FT_TRACE4(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ", face, (FT_Char)( tag >> 24 ), (FT_Char)( tag >> 16 ), @@ -76,12 +76,12 @@ /* tables the same as missing tables. */ if ( entry->Tag == tag && entry->Length != 0 ) { - FT_TRACE3(( "found table.\n" )); + FT_TRACE4(( "found table.\n" )); return entry; } } - FT_TRACE3(( "could not find table!\n" )); + FT_TRACE4(( "could not find table!\n" )); return 0; } @@ -134,34 +134,29 @@ } - /* In theory, we should check the values of `search_range', */ - /* `entry_selector', and `range_shift' to detect non-SFNT based files */ - /* whose header might also start with 0x100000L (yes, these exist). */ - /* */ - /* Very unfortunately, many TrueType fonts don't have these fields */ - /* set correctly and we must ignore them to support them. An */ - /* alternative way to check the font file is thus to: */ + /* Here, we */ /* */ /* - check that `num_tables' is valid */ - /* - look for a "head" table, check its size, and parse it to */ - /* see if its "magic" field is correctly set */ + /* - look for a `head' table, check its size, and parse it to check */ + /* whether its `magic' field is correctly set */ /* */ /* When checking directory entries, ignore the tables `glyx' and `locx' */ /* which are hacked-out versions of `glyf' and `loca' in some PostScript */ - /* Type 42 fonts, and will generally be invalid. */ + /* Type 42 fonts, and which are generally invalid. */ /* */ static FT_Error - sfnt_dir_check( FT_Stream stream, - FT_ULong offset, - FT_UInt num_tables ) - { + check_table_dir( SFNT_Header sfnt, + FT_Stream stream ) + { FT_Error error; - FT_UInt nn, has_head = 0; + FT_UInt nn; + FT_UInt has_head = 0, has_sing = 0, has_meta = 0; + FT_ULong offset = sfnt->offset + 12; const FT_ULong glyx_tag = FT_MAKE_TAG( 'g', 'l', 'y', 'x' ); const FT_ULong locx_tag = FT_MAKE_TAG( 'l', 'o', 'c', 'x' ); - static const FT_Frame_Field sfnt_dir_entry_fields[] = + static const FT_Frame_Field table_dir_entry_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_TableRec @@ -175,94 +170,85 @@ }; - /* if 'num_tables' is 0, read the table count from the file */ - if ( num_tables == 0 ) - { - if ( FT_STREAM_SEEK( offset ) || - FT_STREAM_SKIP( 4 ) || - FT_READ_USHORT( num_tables ) || - FT_STREAM_SKIP( 6 ) ) - goto Bad_Format; + if ( sfnt->num_tables == 0 || + offset + sfnt->num_tables * 16 > stream->size ) + return SFNT_Err_Unknown_File_Format; - if ( offset + 12 + num_tables*16 > stream->size ) - goto Bad_Format; - } - else if ( FT_STREAM_SEEK( offset + 12 ) ) - goto Bad_Format; + if ( FT_STREAM_SEEK( offset ) ) + return error; - for ( nn = 0; nn < num_tables; nn++ ) + for ( nn = 0; nn < sfnt->num_tables; nn++ ) { TT_TableRec table; - if ( FT_STREAM_READ_FIELDS( sfnt_dir_entry_fields, &table ) ) - goto Bad_Format; + if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) ) + return error; - if ( table.Offset + table.Length > stream->size && - table.Tag != glyx_tag && table.Tag != locx_tag ) - goto Bad_Format; + if ( table.Offset + table.Length > stream->size && + table.Tag != glyx_tag && + table.Tag != locx_tag ) + return SFNT_Err_Unknown_File_Format; - if ( table.Tag == TTAG_head ) + if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed ) { FT_UInt32 magic; -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - head_retry: -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ +#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + if ( table.Tag == TTAG_head ) +#endif + has_head = 1; - has_head = 1; - - /* The table length should be 0x36, but certain font tools - * make it 0x38, so we will just check that it is greater. + /* + * The table length should be 0x36, but certain font tools make it + * 0x38, so we will just check that it is greater. + * + * Note that according to the specification, the table must be + * padded to 32-bit lengths, but this doesn't apply to the value of + * its `Length' field! * - * Note that according to the specification, - * the table must be padded to 32-bit lengths, but this doesn't - * apply to the value of its "Length" field! */ - if ( table.Length < 0x36 || - FT_STREAM_SEEK( table.Offset + 12 ) || - FT_READ_ULONG( magic ) || - magic != 0x5F0F3CF5UL ) - goto Bad_Format; + if ( table.Length < 0x36 ) + return SFNT_Err_Unknown_File_Format; - if ( FT_STREAM_SEEK( offset + 28 + 16*nn ) ) - goto Bad_Format; + if ( FT_STREAM_SEEK( table.Offset + 12 ) || + FT_READ_ULONG( magic ) ) + return error; + + if ( magic != 0x5F0F3CF5UL ) + return SFNT_Err_Unknown_File_Format; + + if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) ) + return error; } -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - else if ( table.Tag == TTAG_bhed ) - goto head_retry; -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + else if ( table.Tag == TTAG_SING ) + has_sing = 1; + else if ( table.Tag == TTAG_META ) + has_meta = 1; } - if ( has_head == 0 ) - goto Bad_Format; - - Exit: - return error; - - Bad_Format: - error = SFNT_Err_Unknown_File_Format; - goto Exit; + /* if `sing' and `meta' tables are present, there is no `head' table */ + if ( has_head || ( has_sing && has_meta ) ) + return SFNT_Err_Ok; + else + return SFNT_Err_Unknown_File_Format; } /*************************************************************************/ /* */ /* <Function> */ - /* tt_face_load_sfnt_header */ + /* tt_face_load_font_dir */ /* */ /* <Description> */ - /* Loads the header of a SFNT font file. Supports collections. */ + /* Loads the header of a SFNT font file. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* */ /* stream :: The input stream. */ /* */ - /* face_index :: If the font is a collection, the number of the font */ - /* in the collection. Must be zero otherwise. */ - /* */ /* <Output> */ /* sfnt :: The SFNT header. */ /* */ @@ -270,24 +256,19 @@ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ - /* This function recognizes fonts embedded in a `TrueType collection' */ - /* */ - /* The header will be checked whether it is valid by looking at the */ - /* values of `search_range', `entry_selector', and `range_shift'. */ + /* The stream cursor must be at the beginning of the font directory. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_face_load_sfnt_header( TT_Face face, - FT_Stream stream, - FT_Long face_index, - SFNT_Header sfnt ) + tt_face_load_font_dir( TT_Face face, + FT_Stream stream ) { - FT_Error error; - FT_ULong font_format_tag, format_tag, offset; - FT_Memory memory = stream->memory; + SFNT_HeaderRec sfnt; + FT_Error error; + FT_Memory memory = stream->memory; + TT_TableRec* entry; + TT_TableRec* limit; - static const FT_Frame_Field sfnt_header_fields[] = + static const FT_Frame_Field offset_table_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE SFNT_HeaderRec @@ -300,151 +281,53 @@ FT_FRAME_END }; - static const FT_Frame_Field ttc_header_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE TTC_HeaderRec - FT_FRAME_START( 8 ), - FT_FRAME_LONG( version ), - FT_FRAME_LONG( count ), - FT_FRAME_END - }; + FT_TRACE2(( "tt_face_load_font_dir: %08p\n", face )); + /* read the offset table */ - FT_TRACE2(( "tt_face_load_sfnt_header: %08p, %ld\n", - face, face_index )); + sfnt.offset = FT_STREAM_POS(); - face->ttc_header.tag = 0; - face->ttc_header.version = 0; - face->ttc_header.count = 0; + if ( FT_READ_ULONG( sfnt.format_tag ) || + FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) ) + return error; - face->num_tables = 0; + /* many fonts don't have these fields set correctly */ +#if 0 + if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) || + sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 ) + return SFNT_Err_Unknown_File_Format; +#endif - /* First of all, read the first 4 bytes. If it is `ttcf', then the */ - /* file is a TrueType collection, otherwise it is a single-face font. */ - /* */ - offset = FT_STREAM_POS(); + /* load the table directory */ - if ( FT_READ_ULONG( font_format_tag ) ) - goto Exit; + FT_TRACE2(( "-- Tables count: %12u\n", sfnt.num_tables )); + FT_TRACE2(( "-- Format version: %08lx\n", sfnt.format_tag )); - format_tag = font_format_tag; - - if ( font_format_tag == TTAG_ttcf ) - { - FT_Int n; - - - FT_TRACE3(( "tt_face_load_sfnt_header: file is a collection\n" )); - - /* It is a TrueType collection, i.e. a file containing several */ - /* font files. Read the font directory now */ - if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) ) - goto Exit; - - /* now read the offsets of each font in the file */ - if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) || - FT_FRAME_ENTER( face->ttc_header.count * 4L ) ) - goto Exit; - - for ( n = 0; n < face->ttc_header.count; n++ ) - face->ttc_header.offsets[n] = FT_GET_ULONG(); - - FT_FRAME_EXIT(); - - /* check face index */ - if ( face_index >= face->ttc_header.count ) - { - error = SFNT_Err_Bad_Argument; - goto Exit; - } - - /* seek to the appropriate TrueType file, then read tag */ - offset = face->ttc_header.offsets[face_index]; - - if ( FT_STREAM_SEEK( offset ) || - FT_READ_LONG( format_tag ) ) - goto Exit; - } - - /* the format tag was read, now check the rest of the header */ - sfnt->format_tag = format_tag; - sfnt->offset = offset; - - if ( FT_STREAM_READ_FIELDS( sfnt_header_fields, sfnt ) ) - goto Exit; - - /* now check the sfnt directory */ - error = sfnt_dir_check( stream, offset, sfnt->num_tables ); + /* check first */ + error = check_table_dir( &sfnt, stream ); if ( error ) { - FT_TRACE2(( "tt_face_load_sfnt_header: file is not SFNT!\n" )); - error = SFNT_Err_Unknown_File_Format; - goto Exit; + FT_TRACE2(( "tt_face_load_font_dir: invalid table directory!\n" )); + + return error; } - /* disallow face index values > 0 for non-TTC files */ - if ( font_format_tag != TTAG_ttcf && face_index > 0 ) - error = SFNT_Err_Bad_Argument; - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_directory */ - /* */ - /* <Description> */ - /* Loads the table directory into a face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* sfnt :: The SFNT directory header. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - tt_face_load_directory( TT_Face face, - FT_Stream stream, - SFNT_Header sfnt ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - TT_TableRec *entry, *limit; - - - FT_TRACE2(( "tt_face_load_directory: %08p\n", face )); - - FT_TRACE2(( "-- Tables count: %12u\n", sfnt->num_tables )); - FT_TRACE2(( "-- Format version: %08lx\n", sfnt->format_tag )); - - face->num_tables = sfnt->num_tables; + face->num_tables = sfnt.num_tables; + face->format_tag = sfnt.format_tag; if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) ) - goto Exit; + return error; - if ( FT_STREAM_SEEK( sfnt->offset + 12 ) || + if ( FT_STREAM_SEEK( sfnt.offset + 12 ) || FT_FRAME_ENTER( face->num_tables * 16L ) ) - goto Exit; + return error; entry = face->dir_tables; limit = entry + face->num_tables; for ( ; entry < limit; entry++ ) - { /* loop through the tables and get all entries */ + { entry->Tag = FT_GET_TAG4(); entry->CheckSum = FT_GET_ULONG(); entry->Offset = FT_GET_LONG(); @@ -461,9 +344,8 @@ FT_FRAME_EXIT(); - FT_TRACE2(( "Directory loaded\n\n" )); + FT_TRACE2(( "table directory loaded\n\n" )); - Exit: return error; } @@ -611,29 +493,17 @@ }; - FT_TRACE2(( "tt_face_load_generic_header: " - "%08p, looking up font table `%c%c%c%c'.\n", - face, - (FT_Char)( tag >> 24 ), - (FT_Char)( tag >> 16 ), - (FT_Char)( tag >> 8 ), - (FT_Char)( tag ) )); - error = face->goto_table( face, tag, stream, 0 ); if ( error ) - { - FT_TRACE2(( "tt_face_load_generic_header: Font table is missing!\n" )); goto Exit; - } header = &face->header; if ( FT_STREAM_READ_FIELDS( header_fields, header ) ) goto Exit; - FT_TRACE2(( " Units per EM: %8u\n", header->Units_Per_EM )); - FT_TRACE2(( " IndexToLoc: %8d\n", header->Index_To_Loc_Format )); - FT_TRACE2(( "tt_face_load_generic_header: Font table loaded.\n" )); + FT_TRACE3(( "Units per EM: %4u\n", header->Units_Per_EM )); + FT_TRACE3(( "IndexToLoc: %4d\n", header->Index_To_Loc_Format )); Exit: return error; @@ -641,8 +511,8 @@ FT_LOCAL_DEF( FT_Error ) - tt_face_load_header( TT_Face face, - FT_Stream stream ) + tt_face_load_head( TT_Face face, + FT_Stream stream ) { return tt_face_load_generic_header( face, stream, TTAG_head ); } @@ -651,8 +521,8 @@ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_LOCAL_DEF( FT_Error ) - tt_face_load_bitmap_header( TT_Face face, - FT_Stream stream ) + tt_face_load_bhed( TT_Face face, + FT_Stream stream ) { return tt_face_load_generic_header( face, stream, TTAG_bhed ); } @@ -677,8 +547,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_face_load_max_profile( TT_Face face, - FT_Stream stream ) + tt_face_load_maxp( TT_Face face, + FT_Stream stream ) { FT_Error error; TT_MaxProfile* maxProfile = &face->max_profile; @@ -714,8 +584,6 @@ }; - FT_TRACE2(( "Load_TT_MaxProfile: %08p\n", face )); - error = face->goto_table( face, TTAG_maxp, stream, 0 ); if ( error ) goto Exit; @@ -723,8 +591,6 @@ if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) ) goto Exit; - face->root.num_glyphs = maxProfile->numGlyphs; - maxProfile->maxPoints = 0; maxProfile->maxContours = 0; maxProfile->maxCompositePoints = 0; @@ -752,369 +618,9 @@ if ( maxProfile->maxFunctionDefs == 0 ) maxProfile->maxFunctionDefs = 64; - - face->root.internal->max_points = - (FT_UShort)FT_MAX( maxProfile->maxCompositePoints, - maxProfile->maxPoints ); - - face->root.internal->max_contours = - (FT_Short)FT_MAX( maxProfile->maxCompositeContours, - maxProfile->maxContours ); - - face->max_components = (FT_ULong)maxProfile->maxComponentElements + - maxProfile->maxComponentDepth; - - /* XXX: some fonts have maxComponents set to 0; we will */ - /* then use 16 of them by default. */ - if ( face->max_components == 0 ) - face->max_components = 16; - - /* We also increase maxPoints and maxContours in order to support */ - /* some broken fonts. */ - face->root.internal->max_points += (FT_UShort)8; - face->root.internal->max_contours += (FT_Short) 4; } - FT_TRACE2(( "MAXP loaded.\n" )); - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_metrics */ - /* */ - /* <Description> */ - /* Loads the horizontal or vertical metrics table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ -#ifdef FT_OPTIMIZE_MEMORY - - static FT_Error - tt_face_load_metrics( TT_Face face, - FT_Stream stream, - FT_Bool vertical ) - { - FT_Error error; - FT_ULong table_size; - FT_Byte** ptable; - FT_ULong* ptable_size; - - - FT_TRACE2(( "TT_Load_%s_Metrics: %08p\n", vertical ? "Vertical" - : "Horizontal", - face )); - - if ( vertical ) - { - ptable = &face->vert_metrics; - ptable_size = &face->vert_metrics_size; - - /* The table is optional, quit silently if it wasn't found. */ - /* */ - /* XXX: Some fonts have a valid vertical header with a non-null */ - /* `number_of_VMetrics' fields, but no corresponding `vmtx' */ - /* table to get the metrics from (e.g. mingliu). */ - /* */ - /* For safety, we set the field to 0! */ - /* */ - error = face->goto_table( face, TTAG_vmtx, stream, &table_size ); - if ( error ) - { - /* Set number_Of_VMetrics to 0! */ - FT_TRACE2(( " no vertical header in file.\n" )); - error = SFNT_Err_Ok; - goto Exit; - } - } - else - { - ptable = &face->horz_metrics; - ptable_size = &face->horz_metrics_size; - - error = face->goto_table( face, TTAG_hmtx, stream, &table_size ); - if ( error ) - { -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* If this is an incrementally loaded font and there are */ - /* overriding metrics, tolerate a missing `hmtx' table. */ - if ( face->root.internal->incremental_interface && - face->root.internal->incremental_interface->funcs-> - get_glyph_metrics ) - { - face->horizontal.number_Of_HMetrics = 0; - error = SFNT_Err_Ok; - goto Exit; - } -#endif - - FT_ERROR(( " no horizontal metrics in file!\n" )); - error = SFNT_Err_Hmtx_Table_Missing; - goto Exit; - } - } - - if ( FT_FRAME_EXTRACT( table_size, *ptable ) ) - goto Exit; - - *ptable_size = table_size; - - Exit: - return error; - } - -#else /* !OPTIMIZE_MEMORY */ - - static FT_Error - tt_face_load_metrics( TT_Face face, - FT_Stream stream, - FT_Bool vertical ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - FT_ULong table_len; - FT_Long num_shorts, num_longs, num_shorts_checked; - - TT_LongMetrics * longs; - TT_ShortMetrics** shorts; - - - FT_TRACE2(( "TT_Load_%s_Metrics: %08p\n", vertical ? "Vertical" - : "Horizontal", - face )); - - if ( vertical ) - { - /* The table is optional, quit silently if it wasn't found. */ - /* */ - /* XXX: Some fonts have a valid vertical header with a non-null */ - /* `number_of_VMetrics' fields, but no corresponding `vmtx' */ - /* table to get the metrics from (e.g. mingliu). */ - /* */ - /* For safety, we set the field to 0! */ - /* */ - error = face->goto_table( face, TTAG_vmtx, stream, &table_len ); - if ( error ) - { - /* Set number_Of_VMetrics to 0! */ - FT_TRACE2(( " no vertical header in file.\n" )); - face->vertical.number_Of_VMetrics = 0; - error = SFNT_Err_Ok; - goto Exit; - } - - num_longs = face->vertical.number_Of_VMetrics; - longs = (TT_LongMetrics *)&face->vertical.long_metrics; - shorts = (TT_ShortMetrics**)&face->vertical.short_metrics; - } - else - { - error = face->goto_table( face, TTAG_hmtx, stream, &table_len ); - if ( error ) - { - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* If this is an incrementally loaded font and there are */ - /* overriding metrics, tolerate a missing `hmtx' table. */ - if ( face->root.internal->incremental_interface && - face->root.internal->incremental_interface->funcs-> - get_glyph_metrics ) - { - face->horizontal.number_Of_HMetrics = 0; - error = SFNT_Err_Ok; - goto Exit; - } -#endif - - FT_ERROR(( " no horizontal metrics in file!\n" )); - error = SFNT_Err_Hmtx_Table_Missing; - goto Exit; - } - - num_longs = face->horizontal.number_Of_HMetrics; - longs = (TT_LongMetrics *)&face->horizontal.long_metrics; - shorts = (TT_ShortMetrics**)&face->horizontal.short_metrics; - } - - /* never trust derived values */ - - num_shorts = face->max_profile.numGlyphs - num_longs; - num_shorts_checked = ( table_len - num_longs * 4L ) / 2; - - if ( num_shorts < 0 ) - { - FT_ERROR(( "TT_Load_%s_Metrics: more metrics than glyphs!\n", - vertical ? "Vertical" - : "Horizontal" )); - - error = vertical ? SFNT_Err_Invalid_Vert_Metrics - : SFNT_Err_Invalid_Horiz_Metrics; - goto Exit; - } - - if ( FT_QNEW_ARRAY( *longs, num_longs ) || - FT_QNEW_ARRAY( *shorts, num_shorts ) ) - goto Exit; - - if ( FT_FRAME_ENTER( table_len ) ) - goto Exit; - - { - TT_LongMetrics cur = *longs; - TT_LongMetrics limit = cur + num_longs; - - - for ( ; cur < limit; cur++ ) - { - cur->advance = FT_GET_USHORT(); - cur->bearing = FT_GET_SHORT(); - } - } - - /* do we have an inconsistent number of metric values? */ - { - TT_ShortMetrics* cur = *shorts; - TT_ShortMetrics* limit = cur + - FT_MIN( num_shorts, num_shorts_checked ); - - - for ( ; cur < limit; cur++ ) - *cur = FT_GET_SHORT(); - - /* We fill up the missing left side bearings with the */ - /* last valid value. Since this will occur for buggy CJK */ - /* fonts usually only, nothing serious will happen. */ - if ( num_shorts > num_shorts_checked && num_shorts_checked > 0 ) - { - FT_Short val = (*shorts)[num_shorts_checked - 1]; - - - limit = *shorts + num_shorts; - for ( ; cur < limit; cur++ ) - *cur = val; - } - } - - FT_FRAME_EXIT(); - - FT_TRACE2(( "loaded\n" )); - - Exit: - return error; - } - -#endif /* !FT_OPTIMIZE_METRICS */ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_metrics_header */ - /* */ - /* <Description> */ - /* Loads the horizontal or vertical header in a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - tt_face_load_metrics_header( TT_Face face, - FT_Stream stream, - FT_Bool vertical ) - { - FT_Error error; - TT_HoriHeader* header; - - const FT_Frame_Field metrics_header_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE TT_HoriHeader - - FT_FRAME_START( 36 ), - FT_FRAME_ULONG ( Version ), - FT_FRAME_SHORT ( Ascender ), - FT_FRAME_SHORT ( Descender ), - FT_FRAME_SHORT ( Line_Gap ), - FT_FRAME_USHORT( advance_Width_Max ), - FT_FRAME_SHORT ( min_Left_Side_Bearing ), - FT_FRAME_SHORT ( min_Right_Side_Bearing ), - FT_FRAME_SHORT ( xMax_Extent ), - FT_FRAME_SHORT ( caret_Slope_Rise ), - FT_FRAME_SHORT ( caret_Slope_Run ), - FT_FRAME_SHORT ( caret_Offset ), - FT_FRAME_SHORT ( Reserved[0] ), - FT_FRAME_SHORT ( Reserved[1] ), - FT_FRAME_SHORT ( Reserved[2] ), - FT_FRAME_SHORT ( Reserved[3] ), - FT_FRAME_SHORT ( metric_Data_Format ), - FT_FRAME_USHORT( number_Of_HMetrics ), - FT_FRAME_END - }; - - - FT_TRACE2(( vertical ? "Vertical header " : "Horizontal header " )); - - if ( vertical ) - { - face->vertical_info = 0; - - /* The vertical header table is optional, so return quietly if */ - /* we don't find it. */ - error = face->goto_table( face, TTAG_vhea, stream, 0 ); - if ( error ) - { - error = SFNT_Err_Ok; - goto Exit; - } - - face->vertical_info = 1; - header = (TT_HoriHeader*)&face->vertical; - } - else - { - /* The horizontal header is mandatory; return an error if we */ - /* don't find it. */ - error = face->goto_table( face, TTAG_hhea, stream, 0 ); - if ( error ) - { - error = SFNT_Err_Horiz_Header_Missing; - goto Exit; - } - - header = &face->horizontal; - } - - if ( FT_STREAM_READ_FIELDS( metrics_header_fields, header ) ) - goto Exit; - - header->long_metrics = NULL; - header->short_metrics = NULL; - - FT_TRACE2(( "loaded\n" )); - - /* Now try to load the corresponding metrics */ - - error = tt_face_load_metrics( face, stream, vertical ); + FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs )); Exit: return error; @@ -1138,8 +644,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_face_load_names( TT_Face face, - FT_Stream stream ) + tt_face_load_name( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -1179,16 +685,9 @@ table = &face->name_table; table->stream = stream; - FT_TRACE2(( "Names " )); - error = face->goto_table( face, TTAG_name, stream, &table_len ); if ( error ) - { - /* The name table is required so indicate failure. */ - FT_TRACE2(( "is missing!\n" )); - error = SFNT_Err_Name_Table_Missing; goto Exit; - } table_pos = FT_STREAM_POS(); @@ -1208,7 +707,7 @@ if ( storage_start > storage_limit ) { - FT_ERROR(( "tt_face_load_names: invalid `name' table\n" )); + FT_ERROR(( "invalid `name' table\n" )); error = SFNT_Err_Name_Table_Missing; goto Exit; } @@ -1255,8 +754,6 @@ FT_FRAME_EXIT(); - FT_TRACE2(( "loaded\n" )); - /* everything went well, update face->num_names */ face->num_names = (FT_UShort) table->numNameRecords; @@ -1277,7 +774,7 @@ /* face :: A handle to the target face object. */ /* */ FT_LOCAL_DEF( void ) - tt_face_free_names( TT_Face face ) + tt_face_free_name( TT_Face face ) { FT_Memory memory = face->root.driver->root.memory; TT_NameTable table = &face->name_table; @@ -1330,19 +827,10 @@ error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size ); if ( error ) - { - FT_TRACE2(( "No `cmap' table in font !\n" )); - error = SFNT_Err_CMap_Table_Missing; goto Exit; - } - if ( !FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) ) - FT_TRACE2(( "`cmap' table loaded\n" )); - else - { - FT_ERROR(( "`cmap' table is too short!\n" )); + if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) ) face->cmap_size = 0; - } Exit: return error; @@ -1445,19 +933,12 @@ }; - FT_TRACE2(( "OS/2 Table " )); - /* We now support old Mac fonts where the OS/2 table doesn't */ /* exist. Simply put, we set the `version' field to 0xFFFF */ /* and test this value each time we need to access the table. */ error = face->goto_table( face, TTAG_OS2, stream, 0 ); if ( error ) - { - FT_TRACE2(( "is missing!\n" )); - face->os2.version = 0xFFFFU; - error = SFNT_Err_Ok; goto Exit; - } os2 = &face->os2; @@ -1486,7 +967,11 @@ } } - FT_TRACE2(( "loaded\n" )); + FT_TRACE3(( "sTypoAscender: %4d\n", os2->sTypoAscender )); + FT_TRACE3(( "sTypoDescender: %4d\n", os2->sTypoDescender )); + FT_TRACE3(( "usWinAscent: %4u\n", os2->usWinAscent )); + FT_TRACE3(( "usWinDescent: %4u\n", os2->usWinDescent )); + FT_TRACE3(( "fsSelection: 0x%2x\n", os2->fsSelection )); Exit: return error; @@ -1510,8 +995,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_face_load_postscript( TT_Face face, - FT_Stream stream ) + tt_face_load_post( TT_Face face, + FT_Stream stream ) { FT_Error error; TT_Postscript* post = &face->postscript; @@ -1535,18 +1020,19 @@ }; - FT_TRACE2(( "PostScript " )); - error = face->goto_table( face, TTAG_post, stream, 0 ); if ( error ) - return SFNT_Err_Post_Table_Missing; + return error; if ( FT_STREAM_READ_FIELDS( post_fields, post ) ) return error; /* we don't load the glyph names, we do that in another */ /* module (ttpost). */ - FT_TRACE2(( "loaded\n" )); + + FT_TRACE3(( "FormatType: 0x%x\n", post->FormatType )); + FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch + ? " yes" : " no" )); return SFNT_Err_Ok; } @@ -1599,22 +1085,14 @@ TT_PCLT* pclt = &face->pclt; - FT_TRACE2(( "PCLT " )); - /* optional table */ error = face->goto_table( face, TTAG_PCLT, stream, 0 ); if ( error ) - { - FT_TRACE2(( "missing (optional)\n" )); - pclt->Version = 0; - return SFNT_Err_Ok; - } + goto Exit; if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) ) goto Exit; - FT_TRACE2(( "loaded\n" )); - Exit: return error; } @@ -1647,12 +1125,10 @@ TT_GaspRange gaspranges; - FT_TRACE2(( "tt_face_load_gasp: %08p\n", face )); - /* the gasp table is optional */ error = face->goto_table( face, TTAG_gasp, stream, 0 ); if ( error ) - return SFNT_Err_Ok; + goto Exit; if ( FT_FRAME_ENTER( 4L ) ) goto Exit; @@ -1663,7 +1139,7 @@ FT_FRAME_EXIT(); num_ranges = face->gasp.numRanges; - FT_TRACE3(( "number of ranges = %d\n", num_ranges )); + FT_TRACE3(( "numRanges: %u\n", num_ranges )); if ( FT_QNEW_ARRAY( gaspranges, num_ranges ) || FT_FRAME_ENTER( num_ranges * 4L ) ) @@ -1676,201 +1152,17 @@ gaspranges[j].maxPPEM = FT_GET_USHORT(); gaspranges[j].gaspFlag = FT_GET_USHORT(); - FT_TRACE3(( " [max:%d flag:%d]", - gaspranges[j].maxPPEM, - gaspranges[j].gaspFlag )); + FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n", + j, + gaspranges[j].maxPPEM, + gaspranges[j].gaspFlag )); } - FT_TRACE3(( "\n" )); - - FT_FRAME_EXIT(); - FT_TRACE2(( "GASP loaded\n" )); - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hdmx */ - /* */ - /* <Description> */ - /* Loads the horizontal device metrics table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ -#ifdef FT_OPTIMIZE_MEMORY - - FT_LOCAL_DEF( FT_Error ) - tt_face_load_hdmx( TT_Face face, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - FT_UInt version, nn, num_records; - FT_ULong table_size, record_size; - FT_Byte* p; - FT_Byte* limit; - - - /* this table is optional */ - error = face->goto_table( face, TTAG_hdmx, stream, &table_size ); - if ( error || table_size < 8 ) - return SFNT_Err_Ok; - - if ( FT_FRAME_EXTRACT( table_size, face->hdmx_table ) ) - goto Exit; - - p = face->hdmx_table; - limit = p + table_size; - - version = FT_NEXT_USHORT( p ); - num_records = FT_NEXT_USHORT( p ); - record_size = FT_NEXT_ULONG( p ); - - if ( version != 0 || num_records > 255 || record_size > 0x40000 ) - { - error = SFNT_Err_Invalid_File_Format; - goto Fail; - } - - if ( FT_NEW_ARRAY( face->hdmx_record_sizes, num_records ) ) - goto Fail; - - for ( nn = 0; nn < num_records; nn++ ) - { - if ( p + record_size > limit ) - break; - - face->hdmx_record_sizes[nn] = p[0]; - p += record_size; - } - - face->hdmx_record_count = nn; - face->hdmx_table_size = table_size; - - Exit: - return error; - - Fail: - FT_FRAME_RELEASE( face->hdmx_table ); - face->hdmx_table_size = 0; - goto Exit; - } - - - FT_LOCAL_DEF( void ) - tt_face_free_hdmx( TT_Face face ) - { - FT_Stream stream = face->root.stream; - FT_Memory memory = stream->memory; - - - FT_FREE( face->hdmx_record_sizes ); - FT_FRAME_RELEASE( face->hdmx_table ); - } - -#else /* !FT_OPTIMIZE_MEMORY */ - - FT_LOCAL_DEF( FT_Error ) - tt_face_load_hdmx( TT_Face face, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - TT_Hdmx hdmx = &face->hdmx; - FT_Short num_records; - FT_Long num_glyphs; - FT_Long record_size; - - - hdmx->version = 0; - hdmx->num_records = 0; - hdmx->records = 0; - - /* this table is optional */ - error = face->goto_table( face, TTAG_hdmx, stream, 0 ); - if ( error ) - return SFNT_Err_Ok; - - if ( FT_FRAME_ENTER( 8L ) ) - goto Exit; - - hdmx->version = FT_GET_USHORT(); - num_records = FT_GET_SHORT(); - record_size = FT_GET_LONG(); FT_FRAME_EXIT(); - if ( record_size < 0 || num_records < 0 ) - return SFNT_Err_Invalid_File_Format; - - /* Only recognize format 0 */ - if ( hdmx->version != 0 ) - goto Exit; - - /* we can't use FT_QNEW_ARRAY here; otherwise tt_face_free_hdmx */ - /* could fail during deallocation */ - if ( FT_NEW_ARRAY( hdmx->records, num_records ) ) - goto Exit; - - hdmx->num_records = num_records; - num_glyphs = face->root.num_glyphs; - record_size -= num_glyphs + 2; - - { - TT_HdmxEntry cur = hdmx->records; - TT_HdmxEntry limit = cur + hdmx->num_records; - - - for ( ; cur < limit; cur++ ) - { - /* read record */ - if ( FT_READ_BYTE( cur->ppem ) || - FT_READ_BYTE( cur->max_width ) ) - goto Exit; - - if ( FT_QALLOC( cur->widths, num_glyphs ) || - FT_STREAM_READ( cur->widths, num_glyphs ) ) - goto Exit; - - /* skip padding bytes */ - if ( record_size > 0 && FT_STREAM_SKIP( record_size ) ) - goto Exit; - } - } - Exit: return error; } - FT_LOCAL_DEF( void ) - tt_face_free_hdmx( TT_Face face ) - { - if ( face ) - { - FT_Int n; - FT_Memory memory = face->root.driver->root.memory; - - - for ( n = 0; n < face->hdmx.num_records; n++ ) - FT_FREE( face->hdmx.records[n].widths ); - - FT_FREE( face->hdmx.records ); - face->hdmx.num_records = 0; - } - } - -#endif /* !OPTIMIZE_MEMORY */ - - /* END */ diff --git a/src/libs/freetype2/sfnt/ttload.h b/src/libs/freetype2/sfnt/ttload.h index d1a61ca7f1..49a1aee163 100644 --- a/src/libs/freetype2/sfnt/ttload.h +++ b/src/libs/freetype2/sfnt/ttload.h @@ -5,7 +5,7 @@ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2005 by */ +/* Copyright 1996-2001, 2002, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -41,15 +41,9 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - tt_face_load_sfnt_header( TT_Face face, - FT_Stream stream, - FT_Long face_index, - SFNT_Header sfnt ); + tt_face_load_font_dir( TT_Face face, + FT_Stream stream ); - FT_LOCAL( FT_Error ) - tt_face_load_directory( TT_Face face, - FT_Stream stream, - SFNT_Header sfnt ); FT_LOCAL( FT_Error ) tt_face_load_any( TT_Face face, @@ -60,14 +54,8 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - tt_face_load_header( TT_Face face, - FT_Stream stream ); - - - FT_LOCAL( FT_Error ) - tt_face_load_metrics_header( TT_Face face, - FT_Stream stream, - FT_Bool vertical ); + tt_face_load_head( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) @@ -76,13 +64,13 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - tt_face_load_max_profile( TT_Face face, - FT_Stream stream ); + tt_face_load_maxp( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - tt_face_load_names( TT_Face face, - FT_Stream stream ); + tt_face_load_name( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) @@ -91,24 +79,16 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - tt_face_load_postscript( TT_Face face, - FT_Stream stream ); - - - FT_LOCAL( FT_Error ) - tt_face_load_hdmx( TT_Face face, + tt_face_load_post( TT_Face face, FT_Stream stream ); + FT_LOCAL( FT_Error ) tt_face_load_pclt( TT_Face face, FT_Stream stream ); FT_LOCAL( void ) - tt_face_free_names( TT_Face face ); - - - FT_LOCAL( void ) - tt_face_free_hdmx ( TT_Face face ); + tt_face_free_name( TT_Face face ); FT_LOCAL( FT_Error ) @@ -118,8 +98,8 @@ FT_BEGIN_HEADER #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_LOCAL( FT_Error ) - tt_face_load_bitmap_header( TT_Face face, - FT_Stream stream ); + tt_face_load_bhed( TT_Face face, + FT_Stream stream ); #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ diff --git a/src/libs/freetype2/sfnt/ttmtx.c b/src/libs/freetype2/sfnt/ttmtx.c new file mode 100644 index 0000000000..d0140b3a18 --- /dev/null +++ b/src/libs/freetype2/sfnt/ttmtx.c @@ -0,0 +1,440 @@ +/***************************************************************************/ +/* */ +/* ttmtx.c */ +/* */ +/* Load the metrics tables common to TTF and OTF fonts (body). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include "ttmtx.h" + +#include "sferrors.h" + + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_ttmtx + + + /* + * Unfortunately, we can't enable our memory optimizations if + * FT_CONFIG_OPTION_OLD_INTERNALS is defined. This is because at least + * one rogue client (libXfont in the X.Org XServer) is directly accessing + * the metrics. + */ + + /*************************************************************************/ + /* */ + /* <Function> */ + /* tt_face_load_hmtx */ + /* */ + /* <Description> */ + /* Load the `hmtx' or `vmtx' table into a face object. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* stream :: The input stream. */ + /* */ + /* vertical :: A boolean flag. If set, load `vmtx'. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ +#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_hmtx( TT_Face face, + FT_Stream stream, + FT_Bool vertical ) + { + FT_Error error; + FT_ULong table_size; + FT_Byte** ptable; + FT_ULong* ptable_size; + + + if ( vertical ) + { + error = face->goto_table( face, TTAG_vmtx, stream, &table_size ); + if ( error ) + goto Fail; + + ptable = &face->vert_metrics; + ptable_size = &face->vert_metrics_size; + } + else + { + error = face->goto_table( face, TTAG_hmtx, stream, &table_size ); + if ( error ) + goto Fail; + + ptable = &face->horz_metrics; + ptable_size = &face->horz_metrics_size; + } + + if ( FT_FRAME_EXTRACT( table_size, *ptable ) ) + goto Fail; + + *ptable_size = table_size; + + Fail: + return error; + } + +#else /* !OPTIMIZE_MEMORY || OLD_INTERNALS */ + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_hmtx( TT_Face face, + FT_Stream stream, + FT_Bool vertical ) + { + FT_Error error; + FT_Memory memory = stream->memory; + + FT_ULong table_len; + FT_Long num_shorts, num_longs, num_shorts_checked; + + TT_LongMetrics * longs; + TT_ShortMetrics** shorts; + + + if ( vertical ) + { + error = face->goto_table( face, TTAG_vmtx, stream, &table_len ); + if ( error ) + goto Fail; + + num_longs = face->vertical.number_Of_VMetrics; + if ( (FT_ULong)num_longs > table_len / 4 ) + num_longs = (FT_Long)(table_len / 4); + + face->vertical.number_Of_VMetrics = 0; + + longs = (TT_LongMetrics *)&face->vertical.long_metrics; + shorts = (TT_ShortMetrics**)&face->vertical.short_metrics; + } + else + { + error = face->goto_table( face, TTAG_hmtx, stream, &table_len ); + if ( error ) + goto Fail; + + num_longs = face->horizontal.number_Of_HMetrics; + if ( (FT_ULong)num_longs > table_len / 4 ) + num_longs = (FT_Long)(table_len / 4); + + face->horizontal.number_Of_HMetrics = 0; + + longs = (TT_LongMetrics *)&face->horizontal.long_metrics; + shorts = (TT_ShortMetrics**)&face->horizontal.short_metrics; + } + + /* never trust derived values */ + + num_shorts = face->max_profile.numGlyphs - num_longs; + num_shorts_checked = ( table_len - num_longs * 4L ) / 2; + + if ( num_shorts < 0 ) + { + FT_ERROR(( "%cmtx has more metrics than glyphs.\n" )); + + /* Adobe simply ignores this problem. So we shall do the same. */ +#if 0 + error = vertical ? SFNT_Err_Invalid_Vert_Metrics + : SFNT_Err_Invalid_Horiz_Metrics; + goto Exit; +#else + num_shorts = 0; +#endif + } + + if ( FT_QNEW_ARRAY( *longs, num_longs ) || + FT_QNEW_ARRAY( *shorts, num_shorts ) ) + goto Fail; + + if ( FT_FRAME_ENTER( table_len ) ) + goto Fail; + + { + TT_LongMetrics cur = *longs; + TT_LongMetrics limit = cur + num_longs; + + + for ( ; cur < limit; cur++ ) + { + cur->advance = FT_GET_USHORT(); + cur->bearing = FT_GET_SHORT(); + } + } + + /* do we have an inconsistent number of metric values? */ + { + TT_ShortMetrics* cur = *shorts; + TT_ShortMetrics* limit = cur + + FT_MIN( num_shorts, num_shorts_checked ); + + + for ( ; cur < limit; cur++ ) + *cur = FT_GET_SHORT(); + + /* We fill up the missing left side bearings with the */ + /* last valid value. Since this will occur for buggy CJK */ + /* fonts usually only, nothing serious will happen. */ + if ( num_shorts > num_shorts_checked && num_shorts_checked > 0 ) + { + FT_Short val = (*shorts)[num_shorts_checked - 1]; + + + limit = *shorts + num_shorts; + for ( ; cur < limit; cur++ ) + *cur = val; + } + } + + FT_FRAME_EXIT(); + + if ( vertical ) + face->vertical.number_Of_VMetrics = (FT_UShort)num_longs; + else + face->horizontal.number_Of_HMetrics = (FT_UShort)num_longs; + + Fail: + return error; + } + +#endif /* !OPTIMIZE_MEMORY || OLD_INTERNALS */ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* tt_face_load_hhea */ + /* */ + /* <Description> */ + /* Load the `hhea' or 'vhea' table into a face object. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* stream :: The input stream. */ + /* */ + /* vertical :: A boolean flag. If set, load `vhea'. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + tt_face_load_hhea( TT_Face face, + FT_Stream stream, + FT_Bool vertical ) + { + FT_Error error; + TT_HoriHeader* header; + + const FT_Frame_Field metrics_header_fields[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE TT_HoriHeader + + FT_FRAME_START( 36 ), + FT_FRAME_ULONG ( Version ), + FT_FRAME_SHORT ( Ascender ), + FT_FRAME_SHORT ( Descender ), + FT_FRAME_SHORT ( Line_Gap ), + FT_FRAME_USHORT( advance_Width_Max ), + FT_FRAME_SHORT ( min_Left_Side_Bearing ), + FT_FRAME_SHORT ( min_Right_Side_Bearing ), + FT_FRAME_SHORT ( xMax_Extent ), + FT_FRAME_SHORT ( caret_Slope_Rise ), + FT_FRAME_SHORT ( caret_Slope_Run ), + FT_FRAME_SHORT ( caret_Offset ), + FT_FRAME_SHORT ( Reserved[0] ), + FT_FRAME_SHORT ( Reserved[1] ), + FT_FRAME_SHORT ( Reserved[2] ), + FT_FRAME_SHORT ( Reserved[3] ), + FT_FRAME_SHORT ( metric_Data_Format ), + FT_FRAME_USHORT( number_Of_HMetrics ), + FT_FRAME_END + }; + + + if ( vertical ) + { + error = face->goto_table( face, TTAG_vhea, stream, 0 ); + if ( error ) + goto Fail; + + header = (TT_HoriHeader*)&face->vertical; + } + else + { + error = face->goto_table( face, TTAG_hhea, stream, 0 ); + if ( error ) + goto Fail; + + header = &face->horizontal; + } + + if ( FT_STREAM_READ_FIELDS( metrics_header_fields, header ) ) + goto Fail; + + FT_TRACE3(( "Ascender: %5d\n", header->Ascender )); + FT_TRACE3(( "Descender: %5d\n", header->Descender )); + FT_TRACE3(( "number_Of_Metrics: %5u\n", header->number_Of_HMetrics )); + + header->long_metrics = NULL; + header->short_metrics = NULL; + + Fail: + return error; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* tt_face_get_metrics */ + /* */ + /* <Description> */ + /* Returns the horizontal or vertical metrics in font units for a */ + /* given glyph. The metrics are the left side bearing (resp. top */ + /* side bearing) and advance width (resp. advance height). */ + /* */ + /* <Input> */ + /* header :: A pointer to either the horizontal or vertical metrics */ + /* structure. */ + /* */ + /* idx :: The glyph index. */ + /* */ + /* <Output> */ + /* bearing :: The bearing, either left side or top side. */ + /* */ + /* advance :: The advance width resp. advance height. */ + /* */ +#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS + + FT_LOCAL_DEF( FT_Error ) + tt_face_get_metrics( TT_Face face, + FT_Bool vertical, + FT_UInt gindex, + FT_Short *abearing, + FT_UShort *aadvance ) + { + TT_HoriHeader* header; + FT_Byte* p; + FT_Byte* limit; + FT_UShort k; + + + if ( vertical ) + { + header = (TT_HoriHeader*)&face->vertical; + p = face->vert_metrics; + limit = p + face->vert_metrics_size; + } + else + { + header = &face->horizontal; + p = face->horz_metrics; + limit = p + face->horz_metrics_size; + } + + k = header->number_Of_HMetrics; + + if ( k > 0 ) + { + if ( gindex < (FT_UInt)k ) + { + p += 4 * gindex; + if ( p + 4 > limit ) + goto NoData; + + *aadvance = FT_NEXT_USHORT( p ); + *abearing = FT_NEXT_SHORT( p ); + } + else + { + p += 4 * ( k - 1 ); + if ( p + 4 > limit ) + goto NoData; + + *aadvance = FT_NEXT_USHORT( p ); + p += 2 + 2 * ( gindex - k ); + if ( p + 2 > limit ) + *abearing = 0; + else + *abearing = FT_PEEK_SHORT( p ); + } + } + else + { + NoData: + *abearing = 0; + *aadvance = 0; + } + + return SFNT_Err_Ok; + } + +#else /* !OPTIMIZE_MEMORY || OLD_INTERNALS */ + + FT_LOCAL_DEF( FT_Error ) + tt_face_get_metrics( TT_Face face, + FT_Bool vertical, + FT_UInt gindex, + FT_Short* abearing, + FT_UShort* aadvance ) + { + TT_HoriHeader* header = vertical ? (TT_HoriHeader*)&face->vertical + : &face->horizontal; + TT_LongMetrics longs_m; + FT_UShort k = header->number_Of_HMetrics; + + + if ( k == 0 || + !header->long_metrics || + gindex >= (FT_UInt)face->max_profile.numGlyphs ) + { + *abearing = *aadvance = 0; + return SFNT_Err_Ok; + } + + if ( gindex < (FT_UInt)k ) + { + longs_m = (TT_LongMetrics)header->long_metrics + gindex; + *abearing = longs_m->bearing; + *aadvance = longs_m->advance; + } + else + { + *abearing = ((TT_ShortMetrics*)header->short_metrics)[gindex - k]; + *aadvance = ((TT_LongMetrics)header->long_metrics)[k - 1].advance; + } + + return SFNT_Err_Ok; + } + +#endif /* !OPTIMIZE_MEMORY || OLD_INTERNALS */ + + +/* END */ diff --git a/src/libs/freetype2/sfnt/ttmtx.h b/src/libs/freetype2/sfnt/ttmtx.h new file mode 100644 index 0000000000..8b91a113d8 --- /dev/null +++ b/src/libs/freetype2/sfnt/ttmtx.h @@ -0,0 +1,55 @@ +/***************************************************************************/ +/* */ +/* ttmtx.h */ +/* */ +/* Load the metrics tables common to TTF and OTF fonts (specification). */ +/* */ +/* Copyright 2006 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __TTMTX_H__ +#define __TTMTX_H__ + + +#include <ft2build.h> +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TRUETYPE_TYPES_H + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + tt_face_load_hhea( TT_Face face, + FT_Stream stream, + FT_Bool vertical ); + + + FT_LOCAL( FT_Error ) + tt_face_load_hmtx( TT_Face face, + FT_Stream stream, + FT_Bool vertical ); + + + FT_LOCAL( FT_Error ) + tt_face_get_metrics( TT_Face face, + FT_Bool vertical, + FT_UInt gindex, + FT_Short* abearing, + FT_UShort* aadvance ); + +FT_END_HEADER + +#endif /* __TTMTX_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/sfnt/ttpost.c b/src/libs/freetype2/sfnt/ttpost.c index 3d526db4cf..511288e34a 100644 --- a/src/libs/freetype2/sfnt/ttpost.c +++ b/src/libs/freetype2/sfnt/ttpost.c @@ -5,7 +5,7 @@ /* Postcript name table processing for TrueType and OpenType fonts */ /* (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -175,7 +175,7 @@ /* There already exist fonts which have more than 32768 glyph names */ /* in this table, so the test for this threshold has been dropped. */ - if ( num_glyphs > face->root.num_glyphs ) + if ( num_glyphs > face->max_profile.numGlyphs ) { error = SFNT_Err_Invalid_File_Format; goto Exit; @@ -286,13 +286,13 @@ goto Exit; /* check the number of glyphs */ - if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 ) + if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } - if ( FT_ALLOC( offset_table, num_glyphs ) || + if ( FT_NEW_ARRAY( offset_table, num_glyphs ) || FT_STREAM_READ( offset_table, num_glyphs ) ) goto Fail; @@ -448,7 +448,7 @@ if ( !face ) return SFNT_Err_Invalid_Face_Handle; - if ( idx >= (FT_UInt)face->root.num_glyphs ) + if ( idx >= (FT_UInt)face->max_profile.numGlyphs ) return SFNT_Err_Invalid_Glyph_Index; #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES diff --git a/src/libs/freetype2/sfnt/ttsbit.c b/src/libs/freetype2/sfnt/ttsbit.c index 610b63bcc0..21f30efdd4 100644 --- a/src/libs/freetype2/sfnt/ttsbit.c +++ b/src/libs/freetype2/sfnt/ttsbit.c @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded bitmap support (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,9 +20,15 @@ #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H -#ifdef FT_OPTIMIZE_MEMORY + /* + * Alas, the memory-optimized sbit loader can't be used when implementing + * the `old internals' hack + */ +#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS + #include "ttsbit0.c" -#else /* !OPTIMIZE_MEMORY */ + +#else /* !OPTIMIZE_MEMORY || OLD_INTERNALS */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H @@ -406,8 +412,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_face_load_sbit_strikes( TT_Face face, - FT_Stream stream ) + tt_face_load_eblc( TT_Face face, + FT_Stream stream ) { FT_Error error = 0; FT_Memory memory = stream->memory; @@ -584,41 +590,6 @@ } } - /* now set up the root fields to indicate the strikes */ - if ( face->num_sbit_strikes ) - { - FT_ULong n; - FT_Face root = FT_FACE( face ); - - - if ( FT_NEW_ARRAY( root->available_sizes, face->num_sbit_strikes ) ) - goto Exit; - - for ( n = 0 ; n < face->num_sbit_strikes ; n++ ) - { - FT_Bitmap_Size* bsize = root->available_sizes + n; - TT_SBit_Strike strike = face->sbit_strikes + n; - FT_UShort fupem = face->header.Units_Per_EM; - FT_Short height = (FT_Short)( face->horizontal.Ascender - - face->horizontal.Descender + - face->horizontal.Line_Gap ); - FT_Short avg = face->os2.xAvgCharWidth; - - - /* assume 72dpi */ - bsize->height = - (FT_Short)( ( height * strike->y_ppem + fupem / 2 ) / fupem ); - bsize->width = - (FT_Short)( ( avg * strike->y_ppem + fupem / 2 ) / fupem ); - bsize->size = strike->y_ppem << 6; - bsize->x_ppem = strike->x_ppem << 6; - bsize->y_ppem = strike->y_ppem << 6; - } - - root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; - root->num_fixed_sizes = (FT_Int)face->num_sbit_strikes; - } - Exit: return error; } @@ -636,7 +607,7 @@ /* face :: The target face object. */ /* */ FT_LOCAL_DEF( void ) - tt_face_free_sbit_strikes( TT_Face face ) + tt_face_free_eblc( TT_Face face ) { FT_Memory memory = face->root.memory; TT_SBit_Strike strike = face->sbit_strikes; @@ -671,30 +642,41 @@ FT_LOCAL_DEF( FT_Error ) - tt_face_set_sbit_strike( TT_Face face, - FT_UInt x_ppem, - FT_UInt y_ppem, - FT_ULong *astrike_index ) + tt_face_set_sbit_strike( TT_Face face, + FT_Size_Request req, + FT_ULong* astrike_index ) { - FT_ULong i; + return FT_Match_Size( (FT_Face)face, req, 0, astrike_index ); + } - if ( x_ppem > 255 || - y_ppem < 1 || y_ppem > 255 ) - return SFNT_Err_Invalid_PPem; + FT_LOCAL_DEF( FT_Error ) + tt_face_load_strike_metrics( TT_Face face, + FT_ULong strike_index, + FT_Size_Metrics* metrics ) + { + TT_SBit_Strike strike; - for ( i = 0; i < face->num_sbit_strikes; i++ ) - { - if ( ( (FT_UInt)face->sbit_strikes[i].y_ppem == y_ppem ) && - ( ( x_ppem == 0 ) || - ( (FT_UInt)face->sbit_strikes[i].x_ppem == x_ppem ) ) ) - { - *astrike_index = i; - return SFNT_Err_Ok; - } - } - return SFNT_Err_Invalid_PPem; + if ( strike_index >= face->num_sbit_strikes ) + return SFNT_Err_Invalid_Argument; + + strike = face->sbit_strikes + strike_index; + + metrics->x_ppem = strike->x_ppem; + metrics->y_ppem = strike->y_ppem; + + metrics->ascender = strike->hori.ascender << 6; + metrics->descender = strike->hori.descender << 6; + + /* XXX: Is this correct? */ + metrics->max_advance = ( strike->hori.min_origin_SB + + strike->hori.max_width + + strike->hori.min_advance_SB ) << 6; + + metrics->height = metrics->ascender - metrics->descender; + + return SFNT_Err_Ok; } @@ -910,7 +892,7 @@ { TT_SBit_SmallMetricsRec smetrics; - const FT_Frame_Field sbit_small_metrics_fields[] = + static const FT_Frame_Field sbit_small_metrics_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_SmallMetricsRec @@ -1501,7 +1483,7 @@ /* some heuristic values */ metrics->vertBearingX = (FT_Char)(-metrics->width / 2 ); - metrics->vertBearingY = (FT_Char)( advance / 10 ); + metrics->vertBearingY = (FT_Char)( ( advance - metrics->height ) / 2 ); metrics->vertAdvance = (FT_Char)( advance * 12 / 10 ); } @@ -1513,7 +1495,7 @@ return error; } -#endif /* !OPTIMIZE_MEMORY */ +#endif /* !OPTIMIZE_MEMORY || OLD_INTERNALS */ /* END */ diff --git a/src/libs/freetype2/sfnt/ttsbit.h b/src/libs/freetype2/sfnt/ttsbit.h index d2734dd810..af52742de4 100644 --- a/src/libs/freetype2/sfnt/ttsbit.h +++ b/src/libs/freetype2/sfnt/ttsbit.h @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded bitmap support (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,20 +28,24 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - tt_face_load_sbit_strikes( TT_Face face, - FT_Stream stream ); + tt_face_load_eblc( TT_Face face, + FT_Stream stream ); FT_LOCAL( void ) - tt_face_free_sbit_strikes( TT_Face face ); + tt_face_free_eblc( TT_Face face ); FT_LOCAL( FT_Error ) - tt_face_set_sbit_strike( TT_Face face, - FT_UInt x_ppem, - FT_UInt y_ppem, - FT_ULong *astrike_index ); + tt_face_set_sbit_strike( TT_Face face, + FT_Size_Request req, + FT_ULong* astrike_index ); -#ifndef FT_OPTIMIZE_MEMORY + FT_LOCAL( FT_Error ) + tt_face_load_strike_metrics( TT_Face face, + FT_ULong strike_index, + FT_Size_Metrics* metrics ); + +#if !defined FT_OPTIMIZE_MEMORY || defined FT_CONFIG_OPTION_OLD_INTERNALS FT_LOCAL( FT_Error ) tt_find_sbit_image( TT_Face face, FT_UInt glyph_index, @@ -54,7 +58,8 @@ FT_BEGIN_HEADER tt_load_sbit_metrics( FT_Stream stream, TT_SBit_Range range, TT_SBit_Metrics metrics ); -#endif /* !FT_OPTIMIZE_MEMORY */ + +#endif /* !FT_OPTIMIZE_MEMORY || FT_CONFIG_OPTION_OLD_INTERNALS */ FT_LOCAL( FT_Error ) tt_face_load_sbit_image( TT_Face face, diff --git a/src/libs/freetype2/sfnt/ttsbit0.c b/src/libs/freetype2/sfnt/ttsbit0.c index 31c77856f3..56ab236c0b 100644 --- a/src/libs/freetype2/sfnt/ttsbit0.c +++ b/src/libs/freetype2/sfnt/ttsbit0.c @@ -5,7 +5,7 @@ /* TrueType and OpenType embedded bitmap support (body). */ /* This is a heap-optimized version. */ /* */ -/* Copyright 2005 by */ +/* Copyright 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -86,15 +86,15 @@ FT_LOCAL_DEF( FT_Error ) - tt_face_load_sbit_strikes( TT_Face face, - FT_Stream stream ) + tt_face_load_eblc( TT_Face face, + FT_Stream stream ) { FT_Error error = SFNT_Err_Ok; FT_Fixed version; FT_ULong num_strikes, table_size; FT_Byte* p; FT_Byte* p_limit; - FT_UInt nn, count; + FT_UInt count; face->sbit_num_strikes = 0; @@ -142,47 +142,7 @@ face->sbit_num_strikes = count; - /* - * Now allocate the root array of FT_Bitmap_Size records and - * populate them. Unfortunately, it isn't possible to indicate bit - * depths in the FT_Bitmap_Size record. This is a design error. - */ - { - FT_Memory memory = face->root.stream->memory; - FT_UInt em_size = (FT_UInt) face->header.Units_Per_EM; - FT_Short height = (FT_Short)( face->horizontal.Ascender - - face->horizontal.Descender + - face->horizontal.Line_Gap ); - - FT_Short avgwidth = face->os2.xAvgCharWidth; - - - if ( FT_NEW_ARRAY( face->root.available_sizes, count ) ) - goto Fail; - - for ( nn = 0; nn < count; nn++ ) - { - FT_Bitmap_Size* bsize = face->root.available_sizes + nn; - FT_UInt x_ppem, y_ppem; - - - x_ppem = p[44]; - y_ppem = p[45]; - - bsize->x_ppem = (FT_Pos)(x_ppem << 6); - bsize->y_ppem = (FT_Pos)(y_ppem << 6); - - bsize->height = (FT_Short)( height*y_ppem + em_size / 2 ) / em_size; - bsize->width = (FT_Short)( avgwidth*y_ppem + em_size / 2 ) / em_size; - bsize->size = bsize->y_ppem; - - p += 48; - } - - face->root.face_flags |= FT_FACE_FLAG_FIXED_SIZES; - face->root.num_fixed_sizes = count; - } - + FT_TRACE3(( "sbit_num_strikes: %u\n", count )); Exit: return error; @@ -194,7 +154,7 @@ FT_LOCAL_DEF( void ) - tt_face_free_sbit_strikes( TT_Face face ) + tt_face_free_eblc( TT_Face face ) { FT_Stream stream = face->root.stream; @@ -206,35 +166,41 @@ FT_LOCAL_DEF( FT_Error ) - tt_face_set_sbit_strike( TT_Face face, - FT_UInt x_ppem, - FT_UInt y_ppem, - FT_ULong *astrike_index ) + tt_face_set_sbit_strike( TT_Face face, + FT_Size_Request req, + FT_ULong* astrike_index ) { - FT_UInt nn, count; - FT_Byte* p; - FT_Byte* p_limit; + return FT_Match_Size( (FT_Face)face, req, 0, astrike_index ); + } - if ( x_ppem > 255 || - y_ppem < 1 || y_ppem > 255 ) - return SFNT_Err_Invalid_PPem; + FT_LOCAL_DEF( FT_Error ) + tt_face_load_strike_metrics( TT_Face face, + FT_ULong strike_index, + FT_Size_Metrics* metrics ) + { + FT_Byte* strike; + - p = face->sbit_table + 8; - p_limit = p + face->sbit_table_size; - count = face->sbit_num_strikes; + if ( strike_index >= (FT_ULong)face->sbit_num_strikes ) + return SFNT_Err_Invalid_Argument; - for ( nn = 0; nn < count; nn++ ) - { - if ( x_ppem == (FT_UInt)p[44] && y_ppem == (FT_UInt)p[45] ) - { - *astrike_index = (FT_ULong)nn; - return SFNT_Err_Ok; - } - p += 48; - } + strike = face->sbit_table + 8 + strike_index * 48; - return SFNT_Err_Invalid_PPem; + metrics->x_ppem = (FT_UShort)strike[44]; + metrics->y_ppem = (FT_UShort)strike[45]; + + metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */ + metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */ + metrics->height = metrics->ascender - metrics->descender; + + /* XXX: Is this correct? */ + metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */ + strike[18] + /* max_width */ + (FT_Char)strike[23] /* min_advance_SB */ + ) << 6; + + return SFNT_Err_Ok; } @@ -523,9 +489,18 @@ } if ( w > 0 ) - wval = (FT_UInt)(wval | ( *p++ & ( 0xFF00U >> w ) ) ); + wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) ); + + /* all bits read and there are ( x_pos + w ) bits to be written */ write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) ); + + if ( x_pos + w > 8 ) + { + write++; + wval <<= 8; + write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) ); + } } } @@ -543,9 +518,9 @@ { FT_Error error = SFNT_Err_Ok; FT_Byte* line; - FT_Int bit_height, bit_width, pitch, width, height, h; + FT_Int bit_height, bit_width, pitch, width, height, h, nbits; FT_Bitmap* bitmap; - FT_UInt32 rval; + FT_UShort rval; if ( !decoder->bitmap_allocated ) @@ -572,7 +547,7 @@ goto Exit; } - if ( p + ( ( width + 7 ) >> 3 ) * height > limit ) + if ( p + ( ( width * height + 7 ) >> 3 ) > limit ) { error = SFNT_Err_Invalid_File_Format; goto Exit; @@ -581,39 +556,61 @@ /* now do the blit */ line += y_pos * pitch + ( x_pos >> 3 ); x_pos &= 7; - rval = 0x10000UL; + + /* the higher byte of `rval' is used as a buffer */ + rval = 0; + nbits = 0; for ( h = height; h > 0; h--, line += pitch ) { - FT_Byte* write = line; - FT_UInt32 wval = 0x100 << x_pos; - FT_Int w; + FT_Byte* write = line; + FT_Int w = width; - for ( w = width; w >= 8; w -= 8 ) + if ( x_pos ) { - if ( rval & 0x10000UL ) - rval = 0x100 | *p++; + w = ( width < 8 - x_pos ) ? width : 8 - x_pos; - wval |= rval & 0x80; - - wval <<= 1; - rval <<= 1; - - if ( wval & 0x10000UL ) + if ( nbits < w ) { - write[0] = (FT_Byte)( write[0] | ( wval >> 8 ) ); - write += 1; - wval = 0x100; + rval |= *p++; + nbits += 8 - w; } + else + { + rval >>= 8; + nbits -= w; + } + + *write++ |= ( ( rval >> nbits ) & 0xFF ) & ~( 0xFF << w ); + rval <<= 8; + + w = width - w; } - if ( wval != 0x100 ) + for ( ; w >= 8; w -= 8 ) { - while ( wval > 0x1FF ) - wval >>= 1; + rval |= *p++; + *write++ |= ( rval >> nbits ) & 0xFF; - write[0] = (FT_Byte)( write[0] | wval ); + rval <<= 8; + } + + if ( w > 0 ) + { + if ( nbits < w ) + { + rval |= *p++; + *write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w ); + nbits += 8 - w; + + rval <<= 8; + } + else + { + *write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w ); + nbits -= w; + } } } @@ -830,7 +827,7 @@ if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) ) goto NoBitmap; - image_start = image_offset + image_size * ( glyph_index - start ); + image_start = image_size * ( glyph_index - start ); image_end = image_start + image_size; } break; @@ -910,7 +907,7 @@ if ( mm >= num_glyphs ) goto NoBitmap; - image_start = image_offset + image_size*mm; + image_start = image_size*mm; image_end = image_start + image_size; } break; diff --git a/src/libs/freetype2/smooth/descrip.mms b/src/libs/freetype2/smooth/descrip.mms deleted file mode 100644 index 9ebc7ff221..0000000000 --- a/src/libs/freetype2/smooth/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 smooth renderer module compilation rules for VMS -# - - -# Copyright 2001 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.smooth]) - -OBJS=smooth.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/smooth/ftgrays.c b/src/libs/freetype2/smooth/ftgrays.c index 99119159db..3d61d79360 100644 --- a/src/libs/freetype2/smooth/ftgrays.c +++ b/src/libs/freetype2/smooth/ftgrays.c @@ -4,7 +4,7 @@ /* */ /* A new `perfect' anti-aliasing renderer (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2005 by */ +/* Copyright 2000-2001, 2002, 2003, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1959,7 +1959,7 @@ } - extern int + static int gray_raster_render( PRaster raster, const FT_Raster_Params* params ) { diff --git a/src/libs/freetype2/smooth/module.mk b/src/libs/freetype2/smooth/module.mk index ead77cf30b..05ad4ba0a8 100644 --- a/src/libs/freetype2/smooth/module.mk +++ b/src/libs/freetype2/smooth/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,15 @@ # fully. -make_module_list: add_smooth_renderer +FTMODULE_H_COMMANDS += SMOOTH_RENDERER -add_smooth_renderer: - $(OPEN_DRIVER)ft_smooth_renderer_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer$(ECHO_DRIVER_DONE) +define SMOOTH_RENDERER +$(OPEN_DRIVER)ft_smooth_renderer_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer$(ECHO_DRIVER_DONE) +$(OPEN_DRIVER)ft_smooth_lcd_renderer_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for LCDs$(ECHO_DRIVER_DONE) +$(OPEN_DRIVER)ft_smooth_lcdv_renderer_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for vertical LCDs$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/tools/cordic.py b/src/libs/freetype2/tools/cordic.py deleted file mode 100755 index 1906b6b1f8..0000000000 --- a/src/libs/freetype2/tools/cordic.py +++ /dev/null @@ -1,79 +0,0 @@ -# compute arctangent table for CORDIC computations in fttrigon.c -import sys, math - -#units = 64*65536.0 # don't change !! -units = 256 -scale = units/math.pi -shrink = 1.0 -comma = "" - -def calc_val( x ): - global units, shrink - angle = math.atan(x) - shrink = shrink * math.cos(angle) - return angle/math.pi * units - -def print_val( n, x ): - global comma - - lo = int(x) - hi = lo + 1 - alo = math.atan(lo) - ahi = math.atan(hi) - ax = math.atan(2.0**n) - - errlo = abs( alo - ax ) - errhi = abs( ahi - ax ) - - if ( errlo < errhi ): - hi = lo - - sys.stdout.write( comma + repr( int(hi) ) ) - comma = ", " - - -print "" -print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units" - -# compute range of "i" -r = [-1] -r = r + range(32) - -for n in r: - - if n >= 0: - x = 1.0/(2.0**n) # tangent value - else: - x = 2.0**(-n) - - angle = math.atan(x) # arctangent - angle2 = angle*scale # arctangent in FT_Angle units - - # determine which integer value for angle gives the best tangent - lo = int(angle2) - hi = lo + 1 - tlo = math.tan(lo/scale) - thi = math.tan(hi/scale) - - errlo = abs( tlo - x ) - errhi = abs( thi - x ) - - angle2 = hi - if errlo < errhi: - angle2 = lo - - if angle2 <= 0: - break - - sys.stdout.write( comma + repr( int(angle2) ) ) - comma = ", " - - shrink = shrink * math.cos( angle2/scale) - - -print -print "shrink factor = " + repr( shrink ) -print "shrink factor 2 = " + repr( shrink * (2.0**32) ) -print "expansion factor = " + repr(1/shrink) -print "" - \ No newline at end of file diff --git a/src/libs/freetype2/tools/docmaker/content.py b/src/libs/freetype2/tools/docmaker/content.py deleted file mode 100644 index ebfeb8bf48..0000000000 --- a/src/libs/freetype2/tools/docmaker/content.py +++ /dev/null @@ -1,585 +0,0 @@ -# -# this file contains routines used to parse the content of documentation -# comment block and build a more structured objects out of them -# - -from sources import * -from utils import * -import string, re - - -# this regular expresion is used to detect code sequences. these -# are simply code fragments embedded in '{' and '}' like in: -# -# { -# x = y + z; -# if ( zookoo == 2 ) -# { -# foobar(); -# } -# } -# -# note that identation of the starting and ending accolades must be -# exactly the same. the code sequence can contain accolades at greater -# indentation -# -re_code_start = re.compile( r"(\s*){\s*$" ) -re_code_end = re.compile( r"(\s*)}\s*$" ) - - -# this regular expression is used to isolate identifiers from -# other text -# -re_identifier = re.compile( r'(\w*)' ) - - -############################################################################# -# -# The DocCode class is used to store source code lines. -# -# 'self.lines' contains a set of source code lines that will be dumped as -# HTML in a <PRE> tag. -# -# The object is filled line by line by the parser; it strips the leading -# "margin" space from each input line before storing it in 'self.lines'. -# -class DocCode: - - def __init__( self, margin, lines ): - self.lines = [] - self.words = None - - # remove margin spaces - for l in lines: - if string.strip( l[:margin] ) == "": - l = l[margin:] - self.lines.append( l ) - - def dump( self, prefix = "", width=60 ): - lines = self.dump_lines( 0, width ) - for l in lines: - print prefix + l - - def dump_lines( self, margin=0, width=60 ): - result = [] - for l in self.lines: - result.append( " "*margin + l ) - return result - - - -############################################################################# -# -# The DocPara class is used to store "normal" text paragraph. -# -# 'self.words' contains the list of words that make up the paragraph -# -class DocPara: - - def __init__( self, lines ): - self.lines = None - self.words = [] - for l in lines: - l = string.strip(l) - self.words.extend( string.split( l ) ) - - def dump( self, prefix = "", width = 60 ): - lines = self.dump_lines( 0, width ) - for l in lines: - print prefix + l - - def dump_lines( self, margin=0, width = 60 ): - cur = "" # current line - col = 0 # current width - result = [] - - for word in self.words: - ln = len(word) - if col > 0: - ln = ln+1 - - if col + ln > width: - result.append( " "*margin + cur ) - cur = word - col = len(word) - else: - if col > 0: - cur = cur + " " - cur = cur + word - col = col + ln - - if col > 0: - result.append( " "*margin + cur ) - - return result - - - - -############################################################################# -# -# The DocField class is used to store a list containing either DocPara or -# DocCode objects. Each DocField also has an optional "name" which is used -# when the object corresponds to a field of value definition -# -class DocField: - - def __init__( self, name, lines ): - - self.name = name # can be None for normal paragraphs/sources - self.items = [] # list of items - - mode_none = 0 # start parsing mode - mode_code = 1 # parsing code sequences - mode_para = 3 # parsing normal paragraph - - margin = -1 # current code sequence indentation - cur_lines = [] - - # now analyze the markup lines to see if they contain paragraphs, - # code sequences or fields definitions - # - start = 0 - mode = mode_none - for l in lines: - - # are we parsing a code sequence ? - if mode == mode_code: - - m = re_code_end.match( l ) - if m and len(m.group(1)) <= margin: - # that's it, we finised the code sequence - code = DocCode( 0, cur_lines ) - self.items.append( code ) - margin = -1 - cur_lines = [] - mode = mode_none - else: - # nope, continue the code sequence - cur_lines.append( l[margin:] ) - else: - # start of code sequence ? - m = re_code_start.match( l ) - if m: - # save current lines - if cur_lines: - para = DocPara( cur_lines ) - self.items.append( para ) - cur_lines = [] - - # switch to code extraction mode - margin = len(m.group(1)) - mode = mode_code - - else: - if not string.split( l ) and cur_lines: - # if the line is empty, we end the current paragraph, - # if any - para = DocPara( cur_lines ) - self.items.append( para ) - cur_lines = [] - else: - # otherwise, simply add the line to the current - # paragraph - cur_lines.append( l ) - - if mode == mode_code: - # unexpected end of code sequence - code = DocCode( margin, cur_lines ) - self.items.append( code ) - - elif cur_lines: - para = DocPara( cur_lines ) - self.items.append( para ) - - def dump( self, prefix = "" ): - if self.field: - print prefix + self.field + " ::" - prefix = prefix + "----" - - first = 1 - for p in self.items: - if not first: - print "" - p.dump( prefix ) - first = 0 - - def dump_lines( self, margin=0, width=60 ): - result = [] - nl = None - for p in self.items: - if nl: - result.append( "" ) - - result.extend( p.dump_lines( margin, width ) ) - nl = 1 - - return result - -# this regular expression is used to detect field definitions -# -re_field = re.compile( r"\s*(\w*)\s*::" ) - - - -class DocMarkup: - - def __init__( self, tag, lines ): - self.tag = string.lower(tag) - self.fields = [] - - cur_lines = [] - field = None - mode = 0 - - for l in lines: - m = re_field.match( l ) - if m: - # we detected the start of a new field definition - - # first, save the current one - if cur_lines: - f = DocField( field, cur_lines ) - self.fields.append( f ) - cur_lines = [] - field = None - - field = m.group(1) # record field name - ln = len(m.group(0)) - l = " "*ln + l[ln:] - cur_lines = [ l ] - else: - cur_lines.append( l ) - - if field or cur_lines: - f = DocField( field, cur_lines ) - self.fields.append( f ) - - def get_name( self ): - try: - return self.fields[0].items[0].words[0] - - except: - return None - - def get_start( self ): - try: - result = "" - for word in self.fields[0].items[0].words: - result = result + " " + word - return result[1:] - - except: - return "ERROR" - - def dump( self, margin ): - print " "*margin + "<" + self.tag + ">" - for f in self.fields: - f.dump( " " ) - print " "*margin + "</" + self.tag + ">" - - - - -class DocChapter: - - def __init__( self, block ): - self.block = block - self.sections = [] - if block: - self.name = block.name - self.title = block.get_markup_words( "title" ) - self.order = block.get_markup_words( "sections" ) - else: - self.name = "Other" - self.title = string.split( "Miscellaneous" ) - self.order = [] - - - -class DocSection: - - def __init__( self, name = "Other" ): - self.name = name - self.blocks = {} - self.block_names = [] # ordered block names in section - self.defs = [] - self.abstract = "" - self.description = "" - self.order = [] - self.title = "ERROR" - self.chapter = None - - def add_def( self, block ): - self.defs.append( block ) - - def add_block( self, block ): - self.block_names.append( block.name ) - self.blocks[ block.name ] = block - - def process( self ): - # lookup one block that contains a valid section description - for block in self.defs: - title = block.get_markup_text( "Title" ) - if title: - self.title = title - self.abstract = block.get_markup_words( "abstract" ) - self.description = block.get_markup_items( "description" ) - self.order = block.get_markup_words( "order" ) - return - - def reorder( self ): - - self.block_names = sort_order_list( self.block_names, self.order ) - - -class ContentProcessor: - - def __init__( self ): - """initialize a block content processor""" - self.reset() - - self.sections = {} # dictionary of documentation sections - self.section = None # current documentation section - - self.chapters = [] # list of chapters - - def set_section( self, section_name ): - """set current section during parsing""" - if not self.sections.has_key( section_name ): - section = DocSection( section_name ) - self.sections[ section_name ] = section - self.section = section - else: - self.section = self.sections[ section_name ] - - def add_chapter( self, block ): - chapter = DocChapter( block ) - self.chapters.append( chapter ) - - - def reset( self ): - """reset the content processor for a new block""" - self.markups = [] - self.markup = None - self.markup_lines = [] - - def add_markup( self ): - """add a new markup section""" - if self.markup and self.markup_lines: - - # get rid of last line of markup if it's empty - marks = self.markup_lines - if len(marks) > 0 and not string.strip(marks[-1]): - self.markup_lines = marks[:-1] - - m = DocMarkup( self.markup, self.markup_lines ) - - self.markups.append( m ) - - self.markup = None - self.markup_lines = [] - - - def process_content( self, content ): - """process a block content and return a list of DocMarkup objects - corresponding to it""" - markup = None - markup_lines = [] - first = 1 - - for line in content: - found = None - for t in re_markup_tags: - m = t.match( line ) - if m: - found = string.lower(m.group(1)) - prefix = len(m.group(0)) - line = " "*prefix + line[prefix:] # remove markup from line - break - - # is it the start of a new markup section ? - if found: - first = 0 - self.add_markup() # add current markup content - self.markup = found - if len(string.strip( line )) > 0: - self.markup_lines.append( line ) - elif first == 0: - self.markup_lines.append( line ) - - self.add_markup() - - return self.markups - - - def parse_sources( self, source_processor ): - blocks = source_processor.blocks - count = len(blocks) - for n in range(count): - - source = blocks[n] - if source.content: - # this is a documentation comment, we need to catch - # all following normal blocks in the "follow" list - # - follow = [] - m = n+1 - while m < count and not blocks[m].content: - follow.append( blocks[m] ) - m = m+1 - - doc_block = DocBlock( source, follow, self ) - - - def finish( self ): - - # process all sections to extract their abstract, description - # and ordered list of items - # - for sec in self.sections.values(): - sec.process() - - # process chapters to check that all sections are correctly - # listed there - for chap in self.chapters: - for sec in chap.order: - if self.sections.has_key(sec): - section = self.sections[ sec ] - section.chapter = chap - section.reorder() - chap.sections.append( section ) - else: - sys.stderr.write( "WARNING: chapter '" + - chap.name + "' in " + chap.block.location() + \ - " lists unknown section '" + sec + "'\n" ) - - # check that all sections are in a chapter - # - others = [] - for sec in self.sections.values(): - if not sec.chapter: - others.append(sec) - - # create a new special chapter for all remaining sections - # when necessary - # - if others: - chap = DocChapter( None ) - chap.sections = others - self.chapters.append( chap ) - - - -class DocBlock: - - def __init__( self, source, follow, processor ): - - processor.reset() - - self.source = source - self.code = [] - self.type = "ERRTYPE" - self.name = "ERRNAME" - self.section = processor.section - self.markups = processor.process_content( source.content ) - - # compute block type from first markup tag - try: - self.type = self.markups[0].tag - except: - pass - - - # compute block name from first markup paragraph - try: - markup = self.markups[0] - para = markup.fields[0].items[0] - name = para.words[0] - m = re_identifier.match( name ) - if m: - name = m.group(1) - self.name = name - except: - pass - - # detect new section starts - if self.type == "section": - processor.set_section( self.name ) - processor.section.add_def( self ) - - # detect new chapter - elif self.type == "chapter": - processor.add_chapter( self ) - - else: - processor.section.add_block( self ) - - # now, compute the source lines relevant to this documentation - # block. We keep normal comments in for obvious reasons (??) - source = [] - for b in follow: - if b.format: - break - for l in b.lines: - # we use "/* */" as a separator - if re_source_sep.match( l ): - break - source.append( l ) - - # now strip the leading and trailing empty lines from the sources - start = 0 - end = len( source )-1 - - while start < end and not string.strip( source[start] ): - start = start + 1 - - while start < end and not string.strip( source[end] ): - end = end - 1 - - source = source[start:end+1] - - self.code = source - - - def location( self ): - return self.source.location() - - - - def get_markup( self, tag_name ): - """return the DocMarkup corresponding to a given tag in a block""" - for m in self.markups: - if m.tag == string.lower(tag_name): - return m - return None - - - def get_markup_name( self, tag_name ): - """return the name of a given primary markup in a block""" - try: - m = self.get_markup( tag_name ) - return m.get_name() - except: - return None - - - def get_markup_words( self, tag_name ): - try: - m = self.get_markup( tag_name ) - return m.fields[0].items[0].words - except: - return [] - - - def get_markup_text( self, tag_name ): - result = self.get_markup_words( tag_name ) - return string.join( result ) - - - def get_markup_items( self, tag_name ): - try: - m = self.get_markup( tag_name ) - return m.fields[0].items - except: - return None diff --git a/src/libs/freetype2/tools/docmaker/docbeauty.py b/src/libs/freetype2/tools/docmaker/docbeauty.py deleted file mode 100644 index 94b266b6d1..0000000000 --- a/src/libs/freetype2/tools/docmaker/docbeauty.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python -# -# DocBeauty (c) 2003, 2004 David Turner <david@freetype.org> -# -# This program is used to beautify the documentation comments used -# in the FreeType 2 public headers. -# - -from sources import * -from content import * -from utils import * - -import utils - -import sys, os, time, string, getopt - -content_processor = ContentProcessor() - - -def beautify_block( block ): - if block.content: - content_processor.reset() - - markups = content_processor.process_content( block.content ) - text = [] - first = 1 - - for markup in markups: - text.extend( markup.beautify( first ) ) - first = 0 - - # now beautify the documentation "borders" themselves - lines = [ " /*************************************************************************" ] - for l in text: - lines.append( " *" + l ) - lines.append( " */" ) - - block.lines = lines - - -def usage(): - print "\nDocBeauty 0.1 Usage information\n" - print " docbeauty [options] file1 [ file2 ... ]\n" - print "using the following options:\n" - print " -h : print this page" - print " -b : backup original files with the 'orig' extension" - print "" - print " --backup : same as -b" - - -def main( argv ): - """main program loop""" - - global output_dir - - try: - opts, args = getopt.getopt( sys.argv[1:], - "hb", - [ "help", "backup" ] ) - - except getopt.GetoptError: - usage() - sys.exit( 2 ) - - if args == []: - usage() - sys.exit( 1 ) - - # process options - # - output_dir = None - do_backup = None - - for opt in opts: - if opt[0] in ( "-h", "--help" ): - usage() - sys.exit( 0 ) - - if opt[0] in ( "-b", "--backup" ): - do_backup = 1 - - # create context and processor - source_processor = SourceProcessor() - - # retrieve the list of files to process - file_list = make_file_list( args ) - for filename in file_list: - source_processor.parse_file( filename ) - for block in source_processor.blocks: - beautify_block( block ) - new_name = filename + ".new" - ok = None - try: - file = open( new_name, "wt" ) - for block in source_processor.blocks: - for line in block.lines: - file.write( line ) - file.write( "\n" ) - file.close() - except: - ok = 0 - -# if called from the command line -# -if __name__ == '__main__': - main( sys.argv ) - - -# eof diff --git a/src/libs/freetype2/tools/docmaker/docmaker.py b/src/libs/freetype2/tools/docmaker/docmaker.py deleted file mode 100644 index 9da4bbf8ea..0000000000 --- a/src/libs/freetype2/tools/docmaker/docmaker.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python -# -# DocMaker (c) 2002, 2004 David Turner <david@freetype.org> -# -# This program is a re-write of the original DocMaker took used -# to generate the API Reference of the FreeType font engine -# by converting in-source comments into structured HTML. -# -# This new version is capable of outputting XML data, as well -# as accepts more liberal formatting options. -# -# It also uses regular expression matching and substitution -# to speed things significantly. -# - -from sources import * -from content import * -from utils import * -from formatter import * -from tohtml import * - -import utils - -import sys, os, time, string, glob, getopt - - -def usage(): - print "\nDocMaker Usage information\n" - print " docmaker [options] file1 [ file2 ... ]\n" - print "using the following options:\n" - print " -h : print this page" - print " -t : set project title, as in '-t \"My Project\"'" - print " -o : set output directory, as in '-o mydir'" - print " -p : set documentation prefix, as in '-p ft2'" - print "" - print " --title : same as -t, as in '--title=\"My Project\"'" - print " --output : same as -o, as in '--output=mydir'" - print " --prefix : same as -p, as in '--prefix=ft2'" - - -def main( argv ): - """main program loop""" - - global output_dir - - try: - opts, args = getopt.getopt( sys.argv[1:], - "ht:o:p:", - [ "help", "title=", "output=", "prefix=" ] ) - - except getopt.GetoptError: - usage() - sys.exit( 2 ) - - if args == []: - usage() - sys.exit( 1 ) - - # process options - # - project_title = "Project" - project_prefix = None - output_dir = None - - for opt in opts: - if opt[0] in ( "-h", "--help" ): - usage() - sys.exit( 0 ) - - if opt[0] in ( "-t", "--title" ): - project_title = opt[1] - - if opt[0] in ( "-o", "--output" ): - utils.output_dir = opt[1] - - if opt[0] in ( "-p", "--prefix" ): - project_prefix = opt[1] - - check_output( ) - - # create context and processor - source_processor = SourceProcessor() - content_processor = ContentProcessor() - - # retrieve the list of files to process - file_list = make_file_list( args ) - for filename in file_list: - source_processor.parse_file( filename ) - content_processor.parse_sources( source_processor ) - - # process sections - content_processor.finish() - - formatter = HtmlFormatter( content_processor, project_title, project_prefix ) - - formatter.toc_dump() - formatter.index_dump() - formatter.section_dump_all() - - -# if called from the command line -# -if __name__ == '__main__': - main( sys.argv ) - - -# eof diff --git a/src/libs/freetype2/tools/docmaker/formatter.py b/src/libs/freetype2/tools/docmaker/formatter.py deleted file mode 100644 index 63ecddc973..0000000000 --- a/src/libs/freetype2/tools/docmaker/formatter.py +++ /dev/null @@ -1,203 +0,0 @@ -from sources import * -from content import * -from utils import * - -# This is the base Formatter class. its purpose is to convert -# a content processor's data into specific documents (i.e. table of -# contents, global index, and individual API reference indices). -# -# You'll need to sub-class it to output anything sensible. For example, -# the file tohtml.py contains the definition of the HtmlFormatter sub-class -# used to output, you guessed it, HTML. -# - -class Formatter: - - def __init__( self, processor ): - - self.processor = processor - self.identifiers = {} - self.chapters = processor.chapters - self.sections = processor.sections.values() - self.block_index = [] - - # store all blocks in a dictionary - self.blocks = [] - for section in self.sections: - for block in section.blocks.values(): - self.add_identifier( block.name, block ) - - # add enumeration values to the index, since this is useful - for markup in block.markups: - if markup.tag == 'values': - for field in markup.fields: - self.add_identifier( field.name, block ) - - - self.block_index = self.identifiers.keys() - self.block_index.sort( index_sort ) - - - def add_identifier( self, name, block ): - if self.identifiers.has_key( name ): - # duplicate name !! - sys.stderr.write( \ - "WARNING: duplicate definition for '" + name + "' in " + \ - block.location() + ", previous definition in " + \ - self.identifiers[ name ].location() + "\n" ) - else: - self.identifiers[name] = block - - - # - # Formatting the table of contents - # - - def toc_enter( self ): - pass - - def toc_chapter_enter( self, chapter ): - pass - - def toc_section_enter( self, section ): - pass - - def toc_section_exit( self, section ): - pass - - def toc_chapter_exit( self, chapter ): - pass - - def toc_index( self, index_filename ): - pass - - def toc_exit( self ): - pass - - def toc_dump( self, toc_filename = None, index_filename = None ): - - output = None - if toc_filename: - output = open_output( toc_filename ) - - self.toc_enter() - - for chap in self.processor.chapters: - - self.toc_chapter_enter( chap ) - - for section in chap.sections: - self.toc_section_enter( section ) - self.toc_section_exit( section ) - - self.toc_chapter_exit ( chap ) - - self.toc_index( index_filename ) - - self.toc_exit() - - if output: - close_output( output ) - - # - # Formatting the index - # - - def index_enter( self ): - pass - - def index_name_enter( self, name ): - pass - - def index_name_exit( self, name ): - pass - - def index_exit( self ): - pass - - def index_dump( self, index_filename = None ): - - output = None - if index_filename: - output = open_output( index_filename ) - - self.index_enter() - - for name in self.block_index: - self.index_name_enter( name ) - self.index_name_exit ( name ) - - self.index_exit() - - if output: - close_output( output ) - - # - # Formatting a section - # - def section_enter( self, section ): - pass - - def block_enter( self, block ): - pass - - def markup_enter( self, markup, block = None ): - pass - - def field_enter( self, field, markup = None, block = None ): - pass - - def field_exit( self, field, markup = None, block = None ): - pass - - def markup_exit( self, markup, block = None ): - pass - - def block_exit( self, block ): - pass - - def section_exit( self, section ): - pass - - - def section_dump( self, section, section_filename = None ): - - output = None - if section_filename: - output = open_output( section_filename ) - - self.section_enter( section ) - - for name in section.block_names: - block = self.identifiers[ name ] - self.block_enter( block ) - - for markup in block.markups[1:]: # always ignore first markup !! - self.markup_enter( markup, block ) - - for field in markup.fields: - self.field_enter( field, markup, block ) - - self.field_exit ( field, markup, block ) - - self.markup_exit( markup, block ) - - self.block_exit( block ) - - self.section_exit ( section ) - - if output: - close_output( output ) - - - def section_dump_all( self ): - for section in self.sections: - self.section_dump( section ) - - # - # Formatting a block - # - - - - diff --git a/src/libs/freetype2/tools/docmaker/sources.py b/src/libs/freetype2/tools/docmaker/sources.py deleted file mode 100644 index 1928ae1fed..0000000000 --- a/src/libs/freetype2/tools/docmaker/sources.py +++ /dev/null @@ -1,355 +0,0 @@ -# -# this file contains definitions of classes needed to decompose -# C sources files into a series of multi-line "blocks". There are -# two kinds of blocks: -# -# - normal blocks, which contain source code or ordinary comments -# -# - documentation blocks, which have restricted formatting, and -# whose text always start with a documentation markup tag like -# "<Function>", "<Type>", etc.. -# -# the routines used to process the content of documentation blocks -# are not contained here, but in "content.py" -# -# the classes and methods found here only deal with text parsing -# and basic documentation block extraction -# -import fileinput, re, sys, os, string - - - - - - -################################################################ -## -## BLOCK FORMAT PATTERN -## -## A simple class containing compiled regular expressions used -## to detect potential documentation format block comments within -## C source code -## -## note that the 'column' pattern must contain a group that will -## be used to "unbox" the content of documentation comment blocks -## -class SourceBlockFormat: - - def __init__( self, id, start, column, end ): - """create a block pattern, used to recognize special documentation blocks""" - - self.id = id - self.start = re.compile( start, re.VERBOSE ) - self.column = re.compile( column, re.VERBOSE ) - self.end = re.compile( end, re.VERBOSE ) - - - -# -# format 1 documentation comment blocks look like the following: -# -# /************************************/ -# /* */ -# /* */ -# /* */ -# /************************************/ -# -# we define a few regular expressions here to detect them -# - -start = r''' - \s* # any number of whitespace - /\*{2,}/ # followed by '/' and at least two asterisks then '/' - \s*$ # eventually followed by whitespace -''' - -column = r''' - \s* # any number of whitespace - /\*{1} # followed by '/' and precisely one asterisk - ([^*].*) # followed by anything (group 1) - \*{1}/ # followed by one asterisk and a '/' - \s*$ # enventually followed by whitespace -''' - -re_source_block_format1 = SourceBlockFormat( 1, start, column, start ) - -# -# format 2 documentation comment blocks look like the following: -# -# /************************************ (at least 2 asterisks) -# * -# * -# * -# * -# **/ (1 or more asterisks at the end) -# -# we define a few regular expressions here to detect them -# -start = r''' - \s* # any number of whitespace - /\*{2,} # followed by '/' and at least two asterisks - \s*$ # eventually followed by whitespace -''' - -column = r''' - \s* # any number of whitespace - \*{1}(?!/) # followed by precisely one asterisk not followed by `/' - (.*) # then anything (group1) -''' - -end = r''' - \s* # any number of whitespace - \*+/ # followed by at least one asterisk, then '/' -''' - -re_source_block_format2 = SourceBlockFormat( 2, start, column, end ) - -# -# the list of supported documentation block formats, we could add new ones -# relatively easily -# -re_source_block_formats = [ re_source_block_format1, re_source_block_format2 ] - - -# -# the following regular expressions corresponds to markup tags -# within the documentation comment blocks. they're equivalent -# despite their different syntax -# -# notice how each markup tag _must_ begin a new line -# -re_markup_tag1 = re.compile( r'''\s*<(\w*)>''' ) # <xxxx> format -re_markup_tag2 = re.compile( r'''\s*@(\w*):''' ) # @xxxx: format - -# -# the list of supported markup tags, we could add new ones relatively -# easily -# -re_markup_tags = [ re_markup_tag1, re_markup_tag2 ] - -# -# used to detect a cross-reference, after markup tags have been stripped -# -re_crossref = re.compile( r'@(\w*)(.*)' ) - -# -# used to detect italic and bold styles in paragraph text -# -re_italic = re.compile( r'_(\w+)_' ) -re_bold = re.compile( r'\*(\w+)\*' ) - -# -# used to detect the end of commented source lines -# -re_source_sep = re.compile( r'\s*/\*\s*\*/' ) - -# -# used to perform cross-reference within source output -# -re_source_crossref = re.compile( r'(\W*)(\w*)' ) - -# -# a list of reserved source keywords -# -re_source_keywords = re.compile( '''( typedef | - struct | - enum | - union | - const | - char | - int | - short | - long | - void | - signed | - unsigned | - \#include | - \#define | - \#undef | - \#if | - \#ifdef | - \#ifndef | - \#else | - \#endif )''', re.VERBOSE ) - -################################################################ -## -## SOURCE BLOCK CLASS -## -## A SourceProcessor is in charge or reading a C source file -## and decomposing it into a series of different "SourceBlocks". -## each one of these blocks can be made of the following data: -## -## - A documentation comment block that starts with "/**" and -## whose exact format will be discussed later -## -## - normal sources lines, include comments -## -## the important fields in a text block are the following ones: -## -## self.lines : a list of text lines for the corresponding block -## -## self.content : for documentation comment blocks only, this is the -## block content that has been "unboxed" from its -## decoration. This is None for all other blocks -## (i.e. sources or ordinary comments with no starting -## markup tag) -## -class SourceBlock: - def __init__( self, processor, filename, lineno, lines ): - self.processor = processor - self.filename = filename - self.lineno = lineno - self.lines = lines[:] - self.format = processor.format - self.content = [] - - if self.format == None: - return - - words = [] - - # extract comment lines - lines = [] - - for line0 in self.lines: - m = self.format.column.match( line0 ) - if m: - lines.append( m.group(1) ) - - # now, look for a markup tag - for l in lines: - l = string.strip(l) - if len(l) > 0: - for tag in re_markup_tags: - if tag.match( l ): - self.content = lines - return - - def location( self ): - return "(" + self.filename + ":" + repr(self.lineno) + ")" - - - # debugging only - not used in normal operations - def dump( self ): - - if self.content: - print "{{{content start---" - for l in self.content: - print l - print "---content end}}}" - return - - fmt = "" - if self.format: - fmt = repr(self.format.id) + " " - - for line in self.lines: - print line - - -################################################################ -## -## SOURCE PROCESSOR CLASS -## -## The SourceProcessor is in charge or reading a C source file -## and decomposing it into a series of different "SourceBlock" -## objects. -## -## each one of these blocks can be made of the following data: -## -## - A documentation comment block that starts with "/**" and -## whose exact format will be discussed later -## -## - normal sources lines, include comments -## -## -class SourceProcessor: - - def __init__( self ): - """initialize a source processor""" - self.blocks = [] - self.filename = None - self.format = None - self.lines = [] - - def reset( self ): - """reset a block processor, clean all its blocks""" - self.blocks = [] - self.format = None - - - def parse_file( self, filename ): - """parse a C source file, and adds its blocks to the processor's list""" - - self.reset() - - self.filename = filename - - fileinput.close() - self.format = None - self.lineno = 0 - self.lines = [] - - for line in fileinput.input( filename ): - - # strip trailing newlines, important on Windows machines !! - if line[-1] == '\012': - line = line[0:-1] - - if self.format == None: - self.process_normal_line( line ) - - else: - if self.format.end.match( line ): - # that's a normal block end, add it to lines and - # create a new block - self.lines.append( line ) - self.add_block_lines() - - elif self.format.column.match( line ): - # that's a normal column line, add it to 'lines' - self.lines.append( line ) - - else: - # humm.. this is an unexcepted block end, - # create a new block, but don't process the line - self.add_block_lines() - - # we need to process the line again - self.process_normal_line( line ) - - # record the last lines - self.add_block_lines() - - - - def process_normal_line( self, line ): - """process a normal line and check if it's the start of a new block""" - for f in re_source_block_formats: - if f.start.match( line ): - self.add_block_lines() - self.format = f - self.lineno = fileinput.filelineno() - - self.lines.append( line ) - - - - def add_block_lines( self ): - """add the current accumulated lines, and create a new block""" - if self.lines != []: - block = SourceBlock( self, self.filename, self.lineno, self.lines ) - - self.blocks.append( block ) - self.format = None - self.lines = [] - - - # debugging only, not used in normal operations - def dump( self ): - """print all blocks in a processor""" - for b in self.blocks: - b.dump() - -# eof diff --git a/src/libs/freetype2/tools/docmaker/tohtml.py b/src/libs/freetype2/tools/docmaker/tohtml.py deleted file mode 100644 index 2a3cf239b4..0000000000 --- a/src/libs/freetype2/tools/docmaker/tohtml.py +++ /dev/null @@ -1,489 +0,0 @@ -from sources import * -from content import * -from formatter import * - -import time - -# The following defines the HTML header used by all generated pages. -# -html_header_1 = """\ -<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" -"http://www.w3.org/TR/html4/loose.dtd"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<title>""" - -html_header_2= """ API Reference - - - -

""" - -html_header_3=""" API Reference

-""" - - - -# The HTML footer used by all generated pages. -# -html_footer = """\ - -""" - -# The header and footer used for each section. -# -section_title_header = "

" -section_title_footer = "

" - -# The header and footer used for code segments. -# -code_header = '
'
-code_footer = '
' - -# Paragraph header and footer. -# -para_header = "

" -para_footer = "

" - -# Block header and footer. -# -block_header = '
' -block_footer = '

' - -# Description header/footer. -# -description_header = '
' -description_footer = "

" - -# Marker header/inter/footer combination. -# -marker_header = '
' -marker_inter = "
" -marker_footer = "
" - -# Source code extracts header/footer. -# -source_header = '
\n'
-source_footer = "\n

" - -# Chapter header/inter/footer. -# -chapter_header = '

' -chapter_inter = '

  • ' -chapter_footer = '
' - - -# source language keyword coloration/styling -# -keyword_prefix = '' -keyword_suffix = '' - -section_synopsis_header = '

Synopsis

' -section_synopsis_footer = '' - -# Translate a single line of source to HTML. This will convert -# a "<" into "<.", ">" into ">.", etc. -# -def html_quote( line ): - result = string.replace( line, "&", "&" ) - result = string.replace( result, "<", "<" ) - result = string.replace( result, ">", ">" ) - return result - - -# same as 'html_quote', but ignores left and right brackets -# -def html_quote0( line ): - return string.replace( line, "&", "&" ) - - -def dump_html_code( lines, prefix = "" ): - # clean the last empty lines - # - l = len( self.lines ) - while l > 0 and string.strip( self.lines[l - 1] ) == "": - l = l - 1 - - # The code footer should be directly appended to the last code - # line to avoid an additional blank line. - # - print prefix + code_header, - for line in self.lines[0 : l+1]: - print '\n' + prefix + html_quote(line), - print prefix + code_footer, - - - -class HtmlFormatter(Formatter): - - def __init__( self, processor, project_title, file_prefix ): - - Formatter.__init__( self, processor ) - - global html_header_1, html_header_2, html_header_3, html_footer - - if file_prefix: - file_prefix = file_prefix + "-" - else: - file_prefix = "" - - self.project_title = project_title - self.file_prefix = file_prefix - self.html_header = html_header_1 + project_title + html_header_2 + \ - project_title + html_header_3 - - self.html_footer = "
generated on " + \ - time.asctime( time.localtime( time.time() ) ) + \ - "
" + html_footer - - self.columns = 3 - - def make_section_url( self, section ): - return self.file_prefix + section.name + ".html" - - - def make_block_url( self, block ): - return self.make_section_url( block.section ) + "#" + block.name - - - def make_html_words( self, words ): - """ convert a series of simple words into some HTML text """ - line = "" - if words: - line = html_quote( words[0] ) - for w in words[1:]: - line = line + " " + html_quote( w ) - - return line - - - def make_html_word( self, word ): - """analyze a simple word to detect cross-references and styling""" - # look for cross-references - # - m = re_crossref.match( word ) - if m: - try: - name = m.group(1) - rest = m.group(2) - block = self.identifiers[ name ] - url = self.make_block_url( block ) - return '' + name + '' + rest - except: - return '?' + name + '?' + rest - - # look for italics and bolds - m = re_italic.match( word ) - if m: - name = m.group(1) - return ''+name+'' - - m = re_bold.match( word ) - if m: - name = m.group(1) - return ''+name+'' - - return html_quote(word) - - - def make_html_para( self, words ): - """ convert a paragraph's words into tagged HTML text, handle xrefs """ - line = "" - if words: - line = self.make_html_word( words[0] ) - for word in words[1:]: - line = line + " " + self.make_html_word( word ) - - return "

" + line + "

" - - - def make_html_code( self, lines ): - """ convert a code sequence to HTML """ - line = code_header + '\n' - for l in lines: - line = line + html_quote( l ) + '\n' - - return line + code_footer - - - def make_html_items( self, items ): - """ convert a field's content into some valid HTML """ - lines = [] - for item in items: - if item.lines: - lines.append( self.make_html_code( item.lines ) ) - else: - lines.append( self.make_html_para( item.words ) ) - - return string.join( lines, '\n' ) - - - def print_html_items( self, items ): - print self.make_html_items( items ) - - - def print_html_field( self, field ): - if field.name: - print "
"+field.name+"" - - print self.make_html_items( field.items ) - - if field.name: - print "
" - - - def html_source_quote( self, line, block_name = None ): - result = "" - while line: - m = re_source_crossref.match( line ) - if m: - name = m.group(2) - prefix = html_quote( m.group(1) ) - length = len( m.group(0) ) - - if name == block_name: - # this is the current block name, if any - result = result + prefix + '' + name + '' - - elif re_source_keywords.match(name): - # this is a C keyword - result = result + prefix + keyword_prefix + name + keyword_suffix - - elif self.identifiers.has_key(name): - # this is a known identifier - block = self.identifiers[name] - result = result + prefix + '' + name + '' - else: - result = result + html_quote(line[ : length ]) - - line = line[ length : ] - else: - result = result + html_quote(line) - line = [] - - return result - - - def print_html_field_list( self, fields ): - print "" - for field in fields: - print "" - print "
" + field.name + "" - self.print_html_items( field.items ) - print "
" - - - def print_html_markup( self, markup ): - table_fields = [] - for field in markup.fields: - if field.name: - # we begin a new series of field or value definitions, we - # will record them in the 'table_fields' list before outputting - # all of them as a single table - # - table_fields.append( field ) - - else: - if table_fields: - self.print_html_field_list( table_fields ) - table_fields = [] - - self.print_html_items( field.items ) - - if table_fields: - self.print_html_field_list( table_fields ) - - # - # Formatting the index - # - - def index_enter( self ): - print self.html_header - self.index_items = {} - - def index_name_enter( self, name ): - block = self.identifiers[ name ] - url = self.make_block_url( block ) - self.index_items[ name ] = url - - def index_exit( self ): - - # block_index already contains the sorted list of index names - count = len( self.block_index ) - rows = (count + self.columns - 1)/self.columns - - print "" - for r in range(rows): - line = "" - for c in range(self.columns): - i = r + c*rows - if i < count: - bname = self.block_index[ r + c*rows ] - url = self.index_items[ bname ] - line = line + '' - else: - line = line + '' - line = line + "" - print line - - print "
' + bname + '
" - print self.html_footer - self.index_items = {} - - def index_dump( self, index_filename = None ): - - if index_filename == None: - index_filename = self.file_prefix + "index.html" - - Formatter.index_dump( self, index_filename ) - - # - # Formatting the table of content - # - def toc_enter( self ): - print self.html_header - print "

Table of Contents

" - - def toc_chapter_enter( self, chapter ): - print chapter_header + string.join(chapter.title) + chapter_inter - print "" - - def toc_section_enter( self, section ): - print "" - - def toc_chapter_exit( self, chapter ): - print "
" - print '' + \ - section.title + '' - - print self.make_html_para( section.abstract ) - - def toc_section_exit( self, section ): - print "
" - print chapter_footer - - def toc_index( self, index_filename ): - print chapter_header + 'Global Index' + chapter_inter + chapter_footer - - def toc_exit( self ): - print self.html_footer - - def toc_dump( self, toc_filename = None, index_filename = None ): - if toc_filename == None: - toc_filename = self.file_prefix + "toc.html" - - if index_filename == None: - index_filename = self.file_prefix + "index.html" - - Formatter.toc_dump( self, toc_filename, index_filename ) - - # - # Formatting sections - # - def section_enter( self, section ): - print self.html_header - - print section_title_header - print section.title - print section_title_footer - - # print section synopsys - print section_synopsis_header - print "" - - maxwidth = 0 - for b in section.blocks.values(): - if len(b.name) > maxwidth: - maxwidth = len(b.name) - - width = 70 # XXX magic number - columns = width / maxwidth - if columns < 1: - columns = 1 - - count = len(section.block_names) - rows = (count + columns-1)/columns - for r in range(rows): - line = "" - for c in range(columns): - i = r + c*rows - line = line + '' - line = line + "" - print line - - print "
' - if i < count: - name = section.block_names[i] - line = line + '' + name + '' - - line = line + '


" - print section_synopsis_footer - - print description_header - print self.make_html_items( section.description ) - print description_footer - - def block_enter( self, block ): - print block_header - - # place html anchor if needed - if block.name: - print '

' + block.name + '

' - - # dump the block C source lines now - if block.code: - print source_header - for l in block.code: - print self.html_source_quote( l, block.name ) - print source_footer - - - def markup_enter( self, markup, block ): - if markup.tag == "description": - print description_header - else: - print marker_header + markup.tag + marker_inter - - self.print_html_markup( markup ) - - def markup_exit( self, markup, block ): - if markup.tag == "description": - print description_footer - else: - print marker_footer - - def block_exit( self, block ): - print block_footer - - - def section_exit( self, section ): - print html_footer - - - def section_dump_all( self ): - for section in self.sections: - self.section_dump( section, self.file_prefix + section.name + '.html' ) - diff --git a/src/libs/freetype2/tools/docmaker/utils.py b/src/libs/freetype2/tools/docmaker/utils.py deleted file mode 100644 index c3e9e2700f..0000000000 --- a/src/libs/freetype2/tools/docmaker/utils.py +++ /dev/null @@ -1,128 +0,0 @@ -import string, sys, os, glob - -# current output directory -# -output_dir = None - - -# This function is used to sort the index. It is a simple lexicographical -# sort, except that it places capital letters before lowercase ones. -# -def index_sort( s1, s2 ): - if not s1: - return -1 - - if not s2: - return 1 - - l1 = len( s1 ) - l2 = len( s2 ) - m1 = string.lower( s1 ) - m2 = string.lower( s2 ) - - for i in range( l1 ): - if i >= l2 or m1[i] > m2[i]: - return 1 - - if m1[i] < m2[i]: - return -1 - - if s1[i] < s2[i]: - return -1 - - if s1[i] > s2[i]: - return 1 - - if l2 > l1: - return -1 - - return 0 - -# Sort input_list, placing the elements of order_list in front. -# -def sort_order_list( input_list, order_list ): - new_list = order_list[:] - for id in input_list: - if not id in order_list: - new_list.append( id ) - return new_list - - - -# Open the standard output to a given project documentation file. Use -# "output_dir" to determine the filename location if necessary and save the -# old stdout in a tuple that is returned by this function. -# -def open_output( filename ): - global output_dir - - if output_dir and output_dir != "": - filename = output_dir + os.sep + filename - - old_stdout = sys.stdout - new_file = open( filename, "w" ) - sys.stdout = new_file - - return ( new_file, old_stdout ) - - -# Close the output that was returned by "close_output". -# -def close_output( output ): - output[0].close() - sys.stdout = output[1] - - -# Check output directory. -# -def check_output( ): - global output_dir - if output_dir: - if output_dir != "": - if not os.path.isdir( output_dir ): - sys.stderr.write( "argument" + " '" + output_dir + "' " + - "is not a valid directory" ) - sys.exit( 2 ) - else: - output_dir = None - -def file_exists( pathname ): - """checks that a given file exists""" - result = 1 - try: - file = open( pathname, "r" ) - file.close() - except: - result = None - sys.stderr.write( pathname + " couldn't be accessed\n" ) - - return result - - -def make_file_list( args = None ): - """builds a list of input files from command-line arguments""" - - file_list = [] - # sys.stderr.write( repr( sys.argv[1 :] ) + '\n' ) - - if not args: - args = sys.argv[1 :] - - for pathname in args: - if string.find( pathname, '*' ) >= 0: - newpath = glob.glob( pathname ) - newpath.sort() # sort files -- this is important because - # of the order of files - else: - newpath = [pathname] - - file_list.extend( newpath ) - - if len( file_list ) == 0: - file_list = None - else: - # now filter the file list to remove non-existing ones - file_list = filter( file_exists, file_list ) - - return file_list - diff --git a/src/libs/freetype2/tools/glnames.py b/src/libs/freetype2/tools/glnames.py deleted file mode 100755 index 6131098e12..0000000000 --- a/src/libs/freetype2/tools/glnames.py +++ /dev/null @@ -1,5282 +0,0 @@ -#!/usr/bin/env python -# - -# -# FreeType 2 glyph name builder -# - - -# Copyright 1996-2000, 2003, 2005 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -"""\ - -usage: %s - - This python script generates the glyph names tables defined in the - PSNames module. - - Its single argument is the name of the header file to be created. -""" - - -import sys, string, struct, re, os.path - - -# This table lists the glyphs according to the Macintosh specification. -# It is used by the TrueType Postscript names table. -# -# See -# -# http://fonts.apple.com/TTRefMan/RM06/Chap6post.html -# -# for the official list. -# -mac_standard_names = \ -[ - # 0 - ".notdef", ".null", "nonmarkingreturn", "space", "exclam", - "quotedbl", "numbersign", "dollar", "percent", "ampersand", - - # 10 - "quotesingle", "parenleft", "parenright", "asterisk", "plus", - "comma", "hyphen", "period", "slash", "zero", - - # 20 - "one", "two", "three", "four", "five", - "six", "seven", "eight", "nine", "colon", - - # 30 - "semicolon", "less", "equal", "greater", "question", - "at", "A", "B", "C", "D", - - # 40 - "E", "F", "G", "H", "I", - "J", "K", "L", "M", "N", - - # 50 - "O", "P", "Q", "R", "S", - "T", "U", "V", "W", "X", - - # 60 - "Y", "Z", "bracketleft", "backslash", "bracketright", - "asciicircum", "underscore", "grave", "a", "b", - - # 70 - "c", "d", "e", "f", "g", - "h", "i", "j", "k", "l", - - # 80 - "m", "n", "o", "p", "q", - "r", "s", "t", "u", "v", - - # 90 - "w", "x", "y", "z", "braceleft", - "bar", "braceright", "asciitilde", "Adieresis", "Aring", - - # 100 - "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", - "aacute", "agrave", "acircumflex", "adieresis", "atilde", - - # 110 - "aring", "ccedilla", "eacute", "egrave", "ecircumflex", - "edieresis", "iacute", "igrave", "icircumflex", "idieresis", - - # 120 - "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", - "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", - - # 130 - "dagger", "degree", "cent", "sterling", "section", - "bullet", "paragraph", "germandbls", "registered", "copyright", - - # 140 - "trademark", "acute", "dieresis", "notequal", "AE", - "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", - - # 150 - "yen", "mu", "partialdiff", "summation", "product", - "pi", "integral", "ordfeminine", "ordmasculine", "Omega", - - # 160 - "ae", "oslash", "questiondown", "exclamdown", "logicalnot", - "radical", "florin", "approxequal", "Delta", "guillemotleft", - - # 170 - "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", - "Otilde", "OE", "oe", "endash", "emdash", - - # 180 - "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", - "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", - - # 190 - "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", - "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", - "Acircumflex", - - # 200 - "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", - "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", - - # 210 - "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", - "dotlessi", "circumflex", "tilde", "macron", "breve", - - # 220 - "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", - "caron", "Lslash", "lslash", "Scaron", "scaron", - - # 230 - "Zcaron", "zcaron", "brokenbar", "Eth", "eth", - "Yacute", "yacute", "Thorn", "thorn", "minus", - - # 240 - "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", - "onequarter", "threequarters", "franc", "Gbreve", "gbreve", - - # 250 - "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", - "Ccaron", "ccaron", "dcroat" -] - - -# The list of standard `SID' glyph names. For the official list, -# see Annex A of document at -# -# http://partners.adobe.com/asn/developer/pdfs/tn/5176.CFF.pdf. -# -sid_standard_names = \ -[ - # 0 - ".notdef", "space", "exclam", "quotedbl", "numbersign", - "dollar", "percent", "ampersand", "quoteright", "parenleft", - - # 10 - "parenright", "asterisk", "plus", "comma", "hyphen", - "period", "slash", "zero", "one", "two", - - # 20 - "three", "four", "five", "six", "seven", - "eight", "nine", "colon", "semicolon", "less", - - # 30 - "equal", "greater", "question", "at", "A", - "B", "C", "D", "E", "F", - - # 40 - "G", "H", "I", "J", "K", - "L", "M", "N", "O", "P", - - # 50 - "Q", "R", "S", "T", "U", - "V", "W", "X", "Y", "Z", - - # 60 - "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", - "quoteleft", "a", "b", "c", "d", - - # 70 - "e", "f", "g", "h", "i", - "j", "k", "l", "m", "n", - - # 80 - "o", "p", "q", "r", "s", - "t", "u", "v", "w", "x", - - # 90 - "y", "z", "braceleft", "bar", "braceright", - "asciitilde", "exclamdown", "cent", "sterling", "fraction", - - # 100 - "yen", "florin", "section", "currency", "quotesingle", - "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", - - # 110 - "fl", "endash", "dagger", "daggerdbl", "periodcentered", - "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", - - # 120 - "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", - "acute", "circumflex", "tilde", "macron", "breve", - - # 130 - "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", - "ogonek", "caron", "emdash", "AE", "ordfeminine", - - # 140 - "Lslash", "Oslash", "OE", "ordmasculine", "ae", - "dotlessi", "lslash", "oslash", "oe", "germandbls", - - # 150 - "onesuperior", "logicalnot", "mu", "trademark", "Eth", - "onehalf", "plusminus", "Thorn", "onequarter", "divide", - - # 160 - "brokenbar", "degree", "thorn", "threequarters", "twosuperior", - "registered", "minus", "eth", "multiply", "threesuperior", - - # 170 - "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", - "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", - - # 180 - "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", - "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", - - # 190 - "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", - "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", - - # 200 - "aacute", "acircumflex", "adieresis", "agrave", "aring", - "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", - - # 210 - "egrave", "iacute", "icircumflex", "idieresis", "igrave", - "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", - - # 220 - "otilde", "scaron", "uacute", "ucircumflex", "udieresis", - "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", - - # 230 - "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", - "Acutesmall", - "parenleftsuperior", "parenrightsuperior", "twodotenleader", - "onedotenleader", "zerooldstyle", - - # 240 - "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", - "fiveoldstyle", - "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", - "commasuperior", - - # 250 - "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", - "bsuperior", - "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", - - # 260 - "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", - "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", - - # 270 - "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", - "Asmall", - "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", - - # 280 - "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", - "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", - - # 290 - "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", - "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", - - # 300 - "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", - "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", - "Dieresissmall", - - # 310 - "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", - "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", - "questiondownsmall", - - # 320 - "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", - "twothirds", "zerosuperior", "foursuperior", "fivesuperior", - "sixsuperior", - - # 330 - "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", - "oneinferior", - "twoinferior", "threeinferior", "fourinferior", "fiveinferior", - "sixinferior", - - # 340 - "seveninferior", "eightinferior", "nineinferior", "centinferior", - "dollarinferior", - "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", - "Acircumflexsmall", - - # 350 - "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", - "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", - "Igravesmall", - - # 360 - "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", - "Ntildesmall", - "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", - "Odieresissmall", - - # 370 - "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", - "Ucircumflexsmall", - "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", - "001.000", - - # 380 - "001.001", "001.002", "001.003", "Black", "Bold", - "Book", "Light", "Medium", "Regular", "Roman", - - # 390 - "Semibold" -] - - -# This table maps character codes of the Adobe Standard Type 1 -# encoding to glyph indices in the sid_standard_names table. -# -t1_standard_encoding = \ -[ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 0, 111, 112, 113, - 114, 0, 115, 116, 117, 118, 119, 120, 121, 122, - 0, 123, 0, 124, 125, 126, 127, 128, 129, 130, - - 131, 0, 132, 133, 0, 134, 135, 136, 137, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 138, 0, 139, 0, 0, - 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, - 0, 144, 0, 0, 0, 145, 0, 0, 146, 147, - - 148, 149, 0, 0, 0, 0 -] - - -# This table maps character codes of the Adobe Expert Type 1 -# encoding to glyph indices in the sid_standard_names table. -# -t1_expert_encoding = \ -[ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 229, 230, 0, 231, 232, 233, 234, - 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, - - 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, - 249, 250, 251, 252, 0, 253, 254, 255, 256, 257, - 0, 0, 0, 258, 0, 0, 259, 260, 261, 262, - 0, 0, 263, 264, 265, 0, 266, 109, 110, 267, - 268, 269, 0, 270, 271, 272, 273, 274, 275, 276, - - 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, 300, 301, 302, 303, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 304, 305, 306, 0, 0, 307, 308, 309, 310, - 311, 0, 312, 0, 0, 313, 0, 0, 314, 315, - 0, 0, 316, 317, 318, 0, 0, 0, 158, 155, - 163, 319, 320, 321, 322, 323, 324, 325, 0, 0, - - 326, 150, 164, 169, 327, 328, 329, 330, 331, 332, - 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, - 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, - 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, - - 373, 374, 375, 376, 377, 378 -] - - -# This data has been taken literally from the file `glyphlist.txt', -# version 2.0, 22 Sept 2002. It is available from -# -# http://partners.adobe.com/asn/developer/typeforum/unicodegn.html -# http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt -# -adobe_glyph_list = """\ -A;0041 -AE;00C6 -AEacute;01FC -AEmacron;01E2 -AEsmall;F7E6 -Aacute;00C1 -Aacutesmall;F7E1 -Abreve;0102 -Abreveacute;1EAE -Abrevecyrillic;04D0 -Abrevedotbelow;1EB6 -Abrevegrave;1EB0 -Abrevehookabove;1EB2 -Abrevetilde;1EB4 -Acaron;01CD -Acircle;24B6 -Acircumflex;00C2 -Acircumflexacute;1EA4 -Acircumflexdotbelow;1EAC -Acircumflexgrave;1EA6 -Acircumflexhookabove;1EA8 -Acircumflexsmall;F7E2 -Acircumflextilde;1EAA -Acute;F6C9 -Acutesmall;F7B4 -Acyrillic;0410 -Adblgrave;0200 -Adieresis;00C4 -Adieresiscyrillic;04D2 -Adieresismacron;01DE -Adieresissmall;F7E4 -Adotbelow;1EA0 -Adotmacron;01E0 -Agrave;00C0 -Agravesmall;F7E0 -Ahookabove;1EA2 -Aiecyrillic;04D4 -Ainvertedbreve;0202 -Alpha;0391 -Alphatonos;0386 -Amacron;0100 -Amonospace;FF21 -Aogonek;0104 -Aring;00C5 -Aringacute;01FA -Aringbelow;1E00 -Aringsmall;F7E5 -Asmall;F761 -Atilde;00C3 -Atildesmall;F7E3 -Aybarmenian;0531 -B;0042 -Bcircle;24B7 -Bdotaccent;1E02 -Bdotbelow;1E04 -Becyrillic;0411 -Benarmenian;0532 -Beta;0392 -Bhook;0181 -Blinebelow;1E06 -Bmonospace;FF22 -Brevesmall;F6F4 -Bsmall;F762 -Btopbar;0182 -C;0043 -Caarmenian;053E -Cacute;0106 -Caron;F6CA -Caronsmall;F6F5 -Ccaron;010C -Ccedilla;00C7 -Ccedillaacute;1E08 -Ccedillasmall;F7E7 -Ccircle;24B8 -Ccircumflex;0108 -Cdot;010A -Cdotaccent;010A -Cedillasmall;F7B8 -Chaarmenian;0549 -Cheabkhasiancyrillic;04BC -Checyrillic;0427 -Chedescenderabkhasiancyrillic;04BE -Chedescendercyrillic;04B6 -Chedieresiscyrillic;04F4 -Cheharmenian;0543 -Chekhakassiancyrillic;04CB -Cheverticalstrokecyrillic;04B8 -Chi;03A7 -Chook;0187 -Circumflexsmall;F6F6 -Cmonospace;FF23 -Coarmenian;0551 -Csmall;F763 -D;0044 -DZ;01F1 -DZcaron;01C4 -Daarmenian;0534 -Dafrican;0189 -Dcaron;010E -Dcedilla;1E10 -Dcircle;24B9 -Dcircumflexbelow;1E12 -Dcroat;0110 -Ddotaccent;1E0A -Ddotbelow;1E0C -Decyrillic;0414 -Deicoptic;03EE -Delta;2206 -Deltagreek;0394 -Dhook;018A -Dieresis;F6CB -DieresisAcute;F6CC -DieresisGrave;F6CD -Dieresissmall;F7A8 -Digammagreek;03DC -Djecyrillic;0402 -Dlinebelow;1E0E -Dmonospace;FF24 -Dotaccentsmall;F6F7 -Dslash;0110 -Dsmall;F764 -Dtopbar;018B -Dz;01F2 -Dzcaron;01C5 -Dzeabkhasiancyrillic;04E0 -Dzecyrillic;0405 -Dzhecyrillic;040F -E;0045 -Eacute;00C9 -Eacutesmall;F7E9 -Ebreve;0114 -Ecaron;011A -Ecedillabreve;1E1C -Echarmenian;0535 -Ecircle;24BA -Ecircumflex;00CA -Ecircumflexacute;1EBE -Ecircumflexbelow;1E18 -Ecircumflexdotbelow;1EC6 -Ecircumflexgrave;1EC0 -Ecircumflexhookabove;1EC2 -Ecircumflexsmall;F7EA -Ecircumflextilde;1EC4 -Ecyrillic;0404 -Edblgrave;0204 -Edieresis;00CB -Edieresissmall;F7EB -Edot;0116 -Edotaccent;0116 -Edotbelow;1EB8 -Efcyrillic;0424 -Egrave;00C8 -Egravesmall;F7E8 -Eharmenian;0537 -Ehookabove;1EBA -Eightroman;2167 -Einvertedbreve;0206 -Eiotifiedcyrillic;0464 -Elcyrillic;041B -Elevenroman;216A -Emacron;0112 -Emacronacute;1E16 -Emacrongrave;1E14 -Emcyrillic;041C -Emonospace;FF25 -Encyrillic;041D -Endescendercyrillic;04A2 -Eng;014A -Enghecyrillic;04A4 -Enhookcyrillic;04C7 -Eogonek;0118 -Eopen;0190 -Epsilon;0395 -Epsilontonos;0388 -Ercyrillic;0420 -Ereversed;018E -Ereversedcyrillic;042D -Escyrillic;0421 -Esdescendercyrillic;04AA -Esh;01A9 -Esmall;F765 -Eta;0397 -Etarmenian;0538 -Etatonos;0389 -Eth;00D0 -Ethsmall;F7F0 -Etilde;1EBC -Etildebelow;1E1A -Euro;20AC -Ezh;01B7 -Ezhcaron;01EE -Ezhreversed;01B8 -F;0046 -Fcircle;24BB -Fdotaccent;1E1E -Feharmenian;0556 -Feicoptic;03E4 -Fhook;0191 -Fitacyrillic;0472 -Fiveroman;2164 -Fmonospace;FF26 -Fourroman;2163 -Fsmall;F766 -G;0047 -GBsquare;3387 -Gacute;01F4 -Gamma;0393 -Gammaafrican;0194 -Gangiacoptic;03EA -Gbreve;011E -Gcaron;01E6 -Gcedilla;0122 -Gcircle;24BC -Gcircumflex;011C -Gcommaaccent;0122 -Gdot;0120 -Gdotaccent;0120 -Gecyrillic;0413 -Ghadarmenian;0542 -Ghemiddlehookcyrillic;0494 -Ghestrokecyrillic;0492 -Gheupturncyrillic;0490 -Ghook;0193 -Gimarmenian;0533 -Gjecyrillic;0403 -Gmacron;1E20 -Gmonospace;FF27 -Grave;F6CE -Gravesmall;F760 -Gsmall;F767 -Gsmallhook;029B -Gstroke;01E4 -H;0048 -H18533;25CF -H18543;25AA -H18551;25AB -H22073;25A1 -HPsquare;33CB -Haabkhasiancyrillic;04A8 -Hadescendercyrillic;04B2 -Hardsigncyrillic;042A -Hbar;0126 -Hbrevebelow;1E2A -Hcedilla;1E28 -Hcircle;24BD -Hcircumflex;0124 -Hdieresis;1E26 -Hdotaccent;1E22 -Hdotbelow;1E24 -Hmonospace;FF28 -Hoarmenian;0540 -Horicoptic;03E8 -Hsmall;F768 -Hungarumlaut;F6CF -Hungarumlautsmall;F6F8 -Hzsquare;3390 -I;0049 -IAcyrillic;042F -IJ;0132 -IUcyrillic;042E -Iacute;00CD -Iacutesmall;F7ED -Ibreve;012C -Icaron;01CF -Icircle;24BE -Icircumflex;00CE -Icircumflexsmall;F7EE -Icyrillic;0406 -Idblgrave;0208 -Idieresis;00CF -Idieresisacute;1E2E -Idieresiscyrillic;04E4 -Idieresissmall;F7EF -Idot;0130 -Idotaccent;0130 -Idotbelow;1ECA -Iebrevecyrillic;04D6 -Iecyrillic;0415 -Ifraktur;2111 -Igrave;00CC -Igravesmall;F7EC -Ihookabove;1EC8 -Iicyrillic;0418 -Iinvertedbreve;020A -Iishortcyrillic;0419 -Imacron;012A -Imacroncyrillic;04E2 -Imonospace;FF29 -Iniarmenian;053B -Iocyrillic;0401 -Iogonek;012E -Iota;0399 -Iotaafrican;0196 -Iotadieresis;03AA -Iotatonos;038A -Ismall;F769 -Istroke;0197 -Itilde;0128 -Itildebelow;1E2C -Izhitsacyrillic;0474 -Izhitsadblgravecyrillic;0476 -J;004A -Jaarmenian;0541 -Jcircle;24BF -Jcircumflex;0134 -Jecyrillic;0408 -Jheharmenian;054B -Jmonospace;FF2A -Jsmall;F76A -K;004B -KBsquare;3385 -KKsquare;33CD -Kabashkircyrillic;04A0 -Kacute;1E30 -Kacyrillic;041A -Kadescendercyrillic;049A -Kahookcyrillic;04C3 -Kappa;039A -Kastrokecyrillic;049E -Kaverticalstrokecyrillic;049C -Kcaron;01E8 -Kcedilla;0136 -Kcircle;24C0 -Kcommaaccent;0136 -Kdotbelow;1E32 -Keharmenian;0554 -Kenarmenian;053F -Khacyrillic;0425 -Kheicoptic;03E6 -Khook;0198 -Kjecyrillic;040C -Klinebelow;1E34 -Kmonospace;FF2B -Koppacyrillic;0480 -Koppagreek;03DE -Ksicyrillic;046E -Ksmall;F76B -L;004C -LJ;01C7 -LL;F6BF -Lacute;0139 -Lambda;039B -Lcaron;013D -Lcedilla;013B -Lcircle;24C1 -Lcircumflexbelow;1E3C -Lcommaaccent;013B -Ldot;013F -Ldotaccent;013F -Ldotbelow;1E36 -Ldotbelowmacron;1E38 -Liwnarmenian;053C -Lj;01C8 -Ljecyrillic;0409 -Llinebelow;1E3A -Lmonospace;FF2C -Lslash;0141 -Lslashsmall;F6F9 -Lsmall;F76C -M;004D -MBsquare;3386 -Macron;F6D0 -Macronsmall;F7AF -Macute;1E3E -Mcircle;24C2 -Mdotaccent;1E40 -Mdotbelow;1E42 -Menarmenian;0544 -Mmonospace;FF2D -Msmall;F76D -Mturned;019C -Mu;039C -N;004E -NJ;01CA -Nacute;0143 -Ncaron;0147 -Ncedilla;0145 -Ncircle;24C3 -Ncircumflexbelow;1E4A -Ncommaaccent;0145 -Ndotaccent;1E44 -Ndotbelow;1E46 -Nhookleft;019D -Nineroman;2168 -Nj;01CB -Njecyrillic;040A -Nlinebelow;1E48 -Nmonospace;FF2E -Nowarmenian;0546 -Nsmall;F76E -Ntilde;00D1 -Ntildesmall;F7F1 -Nu;039D -O;004F -OE;0152 -OEsmall;F6FA -Oacute;00D3 -Oacutesmall;F7F3 -Obarredcyrillic;04E8 -Obarreddieresiscyrillic;04EA -Obreve;014E -Ocaron;01D1 -Ocenteredtilde;019F -Ocircle;24C4 -Ocircumflex;00D4 -Ocircumflexacute;1ED0 -Ocircumflexdotbelow;1ED8 -Ocircumflexgrave;1ED2 -Ocircumflexhookabove;1ED4 -Ocircumflexsmall;F7F4 -Ocircumflextilde;1ED6 -Ocyrillic;041E -Odblacute;0150 -Odblgrave;020C -Odieresis;00D6 -Odieresiscyrillic;04E6 -Odieresissmall;F7F6 -Odotbelow;1ECC -Ogoneksmall;F6FB -Ograve;00D2 -Ogravesmall;F7F2 -Oharmenian;0555 -Ohm;2126 -Ohookabove;1ECE -Ohorn;01A0 -Ohornacute;1EDA -Ohorndotbelow;1EE2 -Ohorngrave;1EDC -Ohornhookabove;1EDE -Ohorntilde;1EE0 -Ohungarumlaut;0150 -Oi;01A2 -Oinvertedbreve;020E -Omacron;014C -Omacronacute;1E52 -Omacrongrave;1E50 -Omega;2126 -Omegacyrillic;0460 -Omegagreek;03A9 -Omegaroundcyrillic;047A -Omegatitlocyrillic;047C -Omegatonos;038F -Omicron;039F -Omicrontonos;038C -Omonospace;FF2F -Oneroman;2160 -Oogonek;01EA -Oogonekmacron;01EC -Oopen;0186 -Oslash;00D8 -Oslashacute;01FE -Oslashsmall;F7F8 -Osmall;F76F -Ostrokeacute;01FE -Otcyrillic;047E -Otilde;00D5 -Otildeacute;1E4C -Otildedieresis;1E4E -Otildesmall;F7F5 -P;0050 -Pacute;1E54 -Pcircle;24C5 -Pdotaccent;1E56 -Pecyrillic;041F -Peharmenian;054A -Pemiddlehookcyrillic;04A6 -Phi;03A6 -Phook;01A4 -Pi;03A0 -Piwrarmenian;0553 -Pmonospace;FF30 -Psi;03A8 -Psicyrillic;0470 -Psmall;F770 -Q;0051 -Qcircle;24C6 -Qmonospace;FF31 -Qsmall;F771 -R;0052 -Raarmenian;054C -Racute;0154 -Rcaron;0158 -Rcedilla;0156 -Rcircle;24C7 -Rcommaaccent;0156 -Rdblgrave;0210 -Rdotaccent;1E58 -Rdotbelow;1E5A -Rdotbelowmacron;1E5C -Reharmenian;0550 -Rfraktur;211C -Rho;03A1 -Ringsmall;F6FC -Rinvertedbreve;0212 -Rlinebelow;1E5E -Rmonospace;FF32 -Rsmall;F772 -Rsmallinverted;0281 -Rsmallinvertedsuperior;02B6 -S;0053 -SF010000;250C -SF020000;2514 -SF030000;2510 -SF040000;2518 -SF050000;253C -SF060000;252C -SF070000;2534 -SF080000;251C -SF090000;2524 -SF100000;2500 -SF110000;2502 -SF190000;2561 -SF200000;2562 -SF210000;2556 -SF220000;2555 -SF230000;2563 -SF240000;2551 -SF250000;2557 -SF260000;255D -SF270000;255C -SF280000;255B -SF360000;255E -SF370000;255F -SF380000;255A -SF390000;2554 -SF400000;2569 -SF410000;2566 -SF420000;2560 -SF430000;2550 -SF440000;256C -SF450000;2567 -SF460000;2568 -SF470000;2564 -SF480000;2565 -SF490000;2559 -SF500000;2558 -SF510000;2552 -SF520000;2553 -SF530000;256B -SF540000;256A -Sacute;015A -Sacutedotaccent;1E64 -Sampigreek;03E0 -Scaron;0160 -Scarondotaccent;1E66 -Scaronsmall;F6FD -Scedilla;015E -Schwa;018F -Schwacyrillic;04D8 -Schwadieresiscyrillic;04DA -Scircle;24C8 -Scircumflex;015C -Scommaaccent;0218 -Sdotaccent;1E60 -Sdotbelow;1E62 -Sdotbelowdotaccent;1E68 -Seharmenian;054D -Sevenroman;2166 -Shaarmenian;0547 -Shacyrillic;0428 -Shchacyrillic;0429 -Sheicoptic;03E2 -Shhacyrillic;04BA -Shimacoptic;03EC -Sigma;03A3 -Sixroman;2165 -Smonospace;FF33 -Softsigncyrillic;042C -Ssmall;F773 -Stigmagreek;03DA -T;0054 -Tau;03A4 -Tbar;0166 -Tcaron;0164 -Tcedilla;0162 -Tcircle;24C9 -Tcircumflexbelow;1E70 -Tcommaaccent;0162 -Tdotaccent;1E6A -Tdotbelow;1E6C -Tecyrillic;0422 -Tedescendercyrillic;04AC -Tenroman;2169 -Tetsecyrillic;04B4 -Theta;0398 -Thook;01AC -Thorn;00DE -Thornsmall;F7FE -Threeroman;2162 -Tildesmall;F6FE -Tiwnarmenian;054F -Tlinebelow;1E6E -Tmonospace;FF34 -Toarmenian;0539 -Tonefive;01BC -Tonesix;0184 -Tonetwo;01A7 -Tretroflexhook;01AE -Tsecyrillic;0426 -Tshecyrillic;040B -Tsmall;F774 -Twelveroman;216B -Tworoman;2161 -U;0055 -Uacute;00DA -Uacutesmall;F7FA -Ubreve;016C -Ucaron;01D3 -Ucircle;24CA -Ucircumflex;00DB -Ucircumflexbelow;1E76 -Ucircumflexsmall;F7FB -Ucyrillic;0423 -Udblacute;0170 -Udblgrave;0214 -Udieresis;00DC -Udieresisacute;01D7 -Udieresisbelow;1E72 -Udieresiscaron;01D9 -Udieresiscyrillic;04F0 -Udieresisgrave;01DB -Udieresismacron;01D5 -Udieresissmall;F7FC -Udotbelow;1EE4 -Ugrave;00D9 -Ugravesmall;F7F9 -Uhookabove;1EE6 -Uhorn;01AF -Uhornacute;1EE8 -Uhorndotbelow;1EF0 -Uhorngrave;1EEA -Uhornhookabove;1EEC -Uhorntilde;1EEE -Uhungarumlaut;0170 -Uhungarumlautcyrillic;04F2 -Uinvertedbreve;0216 -Ukcyrillic;0478 -Umacron;016A -Umacroncyrillic;04EE -Umacrondieresis;1E7A -Umonospace;FF35 -Uogonek;0172 -Upsilon;03A5 -Upsilon1;03D2 -Upsilonacutehooksymbolgreek;03D3 -Upsilonafrican;01B1 -Upsilondieresis;03AB -Upsilondieresishooksymbolgreek;03D4 -Upsilonhooksymbol;03D2 -Upsilontonos;038E -Uring;016E -Ushortcyrillic;040E -Usmall;F775 -Ustraightcyrillic;04AE -Ustraightstrokecyrillic;04B0 -Utilde;0168 -Utildeacute;1E78 -Utildebelow;1E74 -V;0056 -Vcircle;24CB -Vdotbelow;1E7E -Vecyrillic;0412 -Vewarmenian;054E -Vhook;01B2 -Vmonospace;FF36 -Voarmenian;0548 -Vsmall;F776 -Vtilde;1E7C -W;0057 -Wacute;1E82 -Wcircle;24CC -Wcircumflex;0174 -Wdieresis;1E84 -Wdotaccent;1E86 -Wdotbelow;1E88 -Wgrave;1E80 -Wmonospace;FF37 -Wsmall;F777 -X;0058 -Xcircle;24CD -Xdieresis;1E8C -Xdotaccent;1E8A -Xeharmenian;053D -Xi;039E -Xmonospace;FF38 -Xsmall;F778 -Y;0059 -Yacute;00DD -Yacutesmall;F7FD -Yatcyrillic;0462 -Ycircle;24CE -Ycircumflex;0176 -Ydieresis;0178 -Ydieresissmall;F7FF -Ydotaccent;1E8E -Ydotbelow;1EF4 -Yericyrillic;042B -Yerudieresiscyrillic;04F8 -Ygrave;1EF2 -Yhook;01B3 -Yhookabove;1EF6 -Yiarmenian;0545 -Yicyrillic;0407 -Yiwnarmenian;0552 -Ymonospace;FF39 -Ysmall;F779 -Ytilde;1EF8 -Yusbigcyrillic;046A -Yusbigiotifiedcyrillic;046C -Yuslittlecyrillic;0466 -Yuslittleiotifiedcyrillic;0468 -Z;005A -Zaarmenian;0536 -Zacute;0179 -Zcaron;017D -Zcaronsmall;F6FF -Zcircle;24CF -Zcircumflex;1E90 -Zdot;017B -Zdotaccent;017B -Zdotbelow;1E92 -Zecyrillic;0417 -Zedescendercyrillic;0498 -Zedieresiscyrillic;04DE -Zeta;0396 -Zhearmenian;053A -Zhebrevecyrillic;04C1 -Zhecyrillic;0416 -Zhedescendercyrillic;0496 -Zhedieresiscyrillic;04DC -Zlinebelow;1E94 -Zmonospace;FF3A -Zsmall;F77A -Zstroke;01B5 -a;0061 -aabengali;0986 -aacute;00E1 -aadeva;0906 -aagujarati;0A86 -aagurmukhi;0A06 -aamatragurmukhi;0A3E -aarusquare;3303 -aavowelsignbengali;09BE -aavowelsigndeva;093E -aavowelsigngujarati;0ABE -abbreviationmarkarmenian;055F -abbreviationsigndeva;0970 -abengali;0985 -abopomofo;311A -abreve;0103 -abreveacute;1EAF -abrevecyrillic;04D1 -abrevedotbelow;1EB7 -abrevegrave;1EB1 -abrevehookabove;1EB3 -abrevetilde;1EB5 -acaron;01CE -acircle;24D0 -acircumflex;00E2 -acircumflexacute;1EA5 -acircumflexdotbelow;1EAD -acircumflexgrave;1EA7 -acircumflexhookabove;1EA9 -acircumflextilde;1EAB -acute;00B4 -acutebelowcmb;0317 -acutecmb;0301 -acutecomb;0301 -acutedeva;0954 -acutelowmod;02CF -acutetonecmb;0341 -acyrillic;0430 -adblgrave;0201 -addakgurmukhi;0A71 -adeva;0905 -adieresis;00E4 -adieresiscyrillic;04D3 -adieresismacron;01DF -adotbelow;1EA1 -adotmacron;01E1 -ae;00E6 -aeacute;01FD -aekorean;3150 -aemacron;01E3 -afii00208;2015 -afii08941;20A4 -afii10017;0410 -afii10018;0411 -afii10019;0412 -afii10020;0413 -afii10021;0414 -afii10022;0415 -afii10023;0401 -afii10024;0416 -afii10025;0417 -afii10026;0418 -afii10027;0419 -afii10028;041A -afii10029;041B -afii10030;041C -afii10031;041D -afii10032;041E -afii10033;041F -afii10034;0420 -afii10035;0421 -afii10036;0422 -afii10037;0423 -afii10038;0424 -afii10039;0425 -afii10040;0426 -afii10041;0427 -afii10042;0428 -afii10043;0429 -afii10044;042A -afii10045;042B -afii10046;042C -afii10047;042D -afii10048;042E -afii10049;042F -afii10050;0490 -afii10051;0402 -afii10052;0403 -afii10053;0404 -afii10054;0405 -afii10055;0406 -afii10056;0407 -afii10057;0408 -afii10058;0409 -afii10059;040A -afii10060;040B -afii10061;040C -afii10062;040E -afii10063;F6C4 -afii10064;F6C5 -afii10065;0430 -afii10066;0431 -afii10067;0432 -afii10068;0433 -afii10069;0434 -afii10070;0435 -afii10071;0451 -afii10072;0436 -afii10073;0437 -afii10074;0438 -afii10075;0439 -afii10076;043A -afii10077;043B -afii10078;043C -afii10079;043D -afii10080;043E -afii10081;043F -afii10082;0440 -afii10083;0441 -afii10084;0442 -afii10085;0443 -afii10086;0444 -afii10087;0445 -afii10088;0446 -afii10089;0447 -afii10090;0448 -afii10091;0449 -afii10092;044A -afii10093;044B -afii10094;044C -afii10095;044D -afii10096;044E -afii10097;044F -afii10098;0491 -afii10099;0452 -afii10100;0453 -afii10101;0454 -afii10102;0455 -afii10103;0456 -afii10104;0457 -afii10105;0458 -afii10106;0459 -afii10107;045A -afii10108;045B -afii10109;045C -afii10110;045E -afii10145;040F -afii10146;0462 -afii10147;0472 -afii10148;0474 -afii10192;F6C6 -afii10193;045F -afii10194;0463 -afii10195;0473 -afii10196;0475 -afii10831;F6C7 -afii10832;F6C8 -afii10846;04D9 -afii299;200E -afii300;200F -afii301;200D -afii57381;066A -afii57388;060C -afii57392;0660 -afii57393;0661 -afii57394;0662 -afii57395;0663 -afii57396;0664 -afii57397;0665 -afii57398;0666 -afii57399;0667 -afii57400;0668 -afii57401;0669 -afii57403;061B -afii57407;061F -afii57409;0621 -afii57410;0622 -afii57411;0623 -afii57412;0624 -afii57413;0625 -afii57414;0626 -afii57415;0627 -afii57416;0628 -afii57417;0629 -afii57418;062A -afii57419;062B -afii57420;062C -afii57421;062D -afii57422;062E -afii57423;062F -afii57424;0630 -afii57425;0631 -afii57426;0632 -afii57427;0633 -afii57428;0634 -afii57429;0635 -afii57430;0636 -afii57431;0637 -afii57432;0638 -afii57433;0639 -afii57434;063A -afii57440;0640 -afii57441;0641 -afii57442;0642 -afii57443;0643 -afii57444;0644 -afii57445;0645 -afii57446;0646 -afii57448;0648 -afii57449;0649 -afii57450;064A -afii57451;064B -afii57452;064C -afii57453;064D -afii57454;064E -afii57455;064F -afii57456;0650 -afii57457;0651 -afii57458;0652 -afii57470;0647 -afii57505;06A4 -afii57506;067E -afii57507;0686 -afii57508;0698 -afii57509;06AF -afii57511;0679 -afii57512;0688 -afii57513;0691 -afii57514;06BA -afii57519;06D2 -afii57534;06D5 -afii57636;20AA -afii57645;05BE -afii57658;05C3 -afii57664;05D0 -afii57665;05D1 -afii57666;05D2 -afii57667;05D3 -afii57668;05D4 -afii57669;05D5 -afii57670;05D6 -afii57671;05D7 -afii57672;05D8 -afii57673;05D9 -afii57674;05DA -afii57675;05DB -afii57676;05DC -afii57677;05DD -afii57678;05DE -afii57679;05DF -afii57680;05E0 -afii57681;05E1 -afii57682;05E2 -afii57683;05E3 -afii57684;05E4 -afii57685;05E5 -afii57686;05E6 -afii57687;05E7 -afii57688;05E8 -afii57689;05E9 -afii57690;05EA -afii57694;FB2A -afii57695;FB2B -afii57700;FB4B -afii57705;FB1F -afii57716;05F0 -afii57717;05F1 -afii57718;05F2 -afii57723;FB35 -afii57793;05B4 -afii57794;05B5 -afii57795;05B6 -afii57796;05BB -afii57797;05B8 -afii57798;05B7 -afii57799;05B0 -afii57800;05B2 -afii57801;05B1 -afii57802;05B3 -afii57803;05C2 -afii57804;05C1 -afii57806;05B9 -afii57807;05BC -afii57839;05BD -afii57841;05BF -afii57842;05C0 -afii57929;02BC -afii61248;2105 -afii61289;2113 -afii61352;2116 -afii61573;202C -afii61574;202D -afii61575;202E -afii61664;200C -afii63167;066D -afii64937;02BD -agrave;00E0 -agujarati;0A85 -agurmukhi;0A05 -ahiragana;3042 -ahookabove;1EA3 -aibengali;0990 -aibopomofo;311E -aideva;0910 -aiecyrillic;04D5 -aigujarati;0A90 -aigurmukhi;0A10 -aimatragurmukhi;0A48 -ainarabic;0639 -ainfinalarabic;FECA -aininitialarabic;FECB -ainmedialarabic;FECC -ainvertedbreve;0203 -aivowelsignbengali;09C8 -aivowelsigndeva;0948 -aivowelsigngujarati;0AC8 -akatakana;30A2 -akatakanahalfwidth;FF71 -akorean;314F -alef;05D0 -alefarabic;0627 -alefdageshhebrew;FB30 -aleffinalarabic;FE8E -alefhamzaabovearabic;0623 -alefhamzaabovefinalarabic;FE84 -alefhamzabelowarabic;0625 -alefhamzabelowfinalarabic;FE88 -alefhebrew;05D0 -aleflamedhebrew;FB4F -alefmaddaabovearabic;0622 -alefmaddaabovefinalarabic;FE82 -alefmaksuraarabic;0649 -alefmaksurafinalarabic;FEF0 -alefmaksurainitialarabic;FEF3 -alefmaksuramedialarabic;FEF4 -alefpatahhebrew;FB2E -alefqamatshebrew;FB2F -aleph;2135 -allequal;224C -alpha;03B1 -alphatonos;03AC -amacron;0101 -amonospace;FF41 -ampersand;0026 -ampersandmonospace;FF06 -ampersandsmall;F726 -amsquare;33C2 -anbopomofo;3122 -angbopomofo;3124 -angkhankhuthai;0E5A -angle;2220 -anglebracketleft;3008 -anglebracketleftvertical;FE3F -anglebracketright;3009 -anglebracketrightvertical;FE40 -angleleft;2329 -angleright;232A -angstrom;212B -anoteleia;0387 -anudattadeva;0952 -anusvarabengali;0982 -anusvaradeva;0902 -anusvaragujarati;0A82 -aogonek;0105 -apaatosquare;3300 -aparen;249C -apostrophearmenian;055A -apostrophemod;02BC -apple;F8FF -approaches;2250 -approxequal;2248 -approxequalorimage;2252 -approximatelyequal;2245 -araeaekorean;318E -araeakorean;318D -arc;2312 -arighthalfring;1E9A -aring;00E5 -aringacute;01FB -aringbelow;1E01 -arrowboth;2194 -arrowdashdown;21E3 -arrowdashleft;21E0 -arrowdashright;21E2 -arrowdashup;21E1 -arrowdblboth;21D4 -arrowdbldown;21D3 -arrowdblleft;21D0 -arrowdblright;21D2 -arrowdblup;21D1 -arrowdown;2193 -arrowdownleft;2199 -arrowdownright;2198 -arrowdownwhite;21E9 -arrowheaddownmod;02C5 -arrowheadleftmod;02C2 -arrowheadrightmod;02C3 -arrowheadupmod;02C4 -arrowhorizex;F8E7 -arrowleft;2190 -arrowleftdbl;21D0 -arrowleftdblstroke;21CD -arrowleftoverright;21C6 -arrowleftwhite;21E6 -arrowright;2192 -arrowrightdblstroke;21CF -arrowrightheavy;279E -arrowrightoverleft;21C4 -arrowrightwhite;21E8 -arrowtableft;21E4 -arrowtabright;21E5 -arrowup;2191 -arrowupdn;2195 -arrowupdnbse;21A8 -arrowupdownbase;21A8 -arrowupleft;2196 -arrowupleftofdown;21C5 -arrowupright;2197 -arrowupwhite;21E7 -arrowvertex;F8E6 -asciicircum;005E -asciicircummonospace;FF3E -asciitilde;007E -asciitildemonospace;FF5E -ascript;0251 -ascriptturned;0252 -asmallhiragana;3041 -asmallkatakana;30A1 -asmallkatakanahalfwidth;FF67 -asterisk;002A -asteriskaltonearabic;066D -asteriskarabic;066D -asteriskmath;2217 -asteriskmonospace;FF0A -asterisksmall;FE61 -asterism;2042 -asuperior;F6E9 -asymptoticallyequal;2243 -at;0040 -atilde;00E3 -atmonospace;FF20 -atsmall;FE6B -aturned;0250 -aubengali;0994 -aubopomofo;3120 -audeva;0914 -augujarati;0A94 -augurmukhi;0A14 -aulengthmarkbengali;09D7 -aumatragurmukhi;0A4C -auvowelsignbengali;09CC -auvowelsigndeva;094C -auvowelsigngujarati;0ACC -avagrahadeva;093D -aybarmenian;0561 -ayin;05E2 -ayinaltonehebrew;FB20 -ayinhebrew;05E2 -b;0062 -babengali;09AC -backslash;005C -backslashmonospace;FF3C -badeva;092C -bagujarati;0AAC -bagurmukhi;0A2C -bahiragana;3070 -bahtthai;0E3F -bakatakana;30D0 -bar;007C -barmonospace;FF5C -bbopomofo;3105 -bcircle;24D1 -bdotaccent;1E03 -bdotbelow;1E05 -beamedsixteenthnotes;266C -because;2235 -becyrillic;0431 -beharabic;0628 -behfinalarabic;FE90 -behinitialarabic;FE91 -behiragana;3079 -behmedialarabic;FE92 -behmeeminitialarabic;FC9F -behmeemisolatedarabic;FC08 -behnoonfinalarabic;FC6D -bekatakana;30D9 -benarmenian;0562 -bet;05D1 -beta;03B2 -betasymbolgreek;03D0 -betdagesh;FB31 -betdageshhebrew;FB31 -bethebrew;05D1 -betrafehebrew;FB4C -bhabengali;09AD -bhadeva;092D -bhagujarati;0AAD -bhagurmukhi;0A2D -bhook;0253 -bihiragana;3073 -bikatakana;30D3 -bilabialclick;0298 -bindigurmukhi;0A02 -birusquare;3331 -blackcircle;25CF -blackdiamond;25C6 -blackdownpointingtriangle;25BC -blackleftpointingpointer;25C4 -blackleftpointingtriangle;25C0 -blacklenticularbracketleft;3010 -blacklenticularbracketleftvertical;FE3B -blacklenticularbracketright;3011 -blacklenticularbracketrightvertical;FE3C -blacklowerlefttriangle;25E3 -blacklowerrighttriangle;25E2 -blackrectangle;25AC -blackrightpointingpointer;25BA -blackrightpointingtriangle;25B6 -blacksmallsquare;25AA -blacksmilingface;263B -blacksquare;25A0 -blackstar;2605 -blackupperlefttriangle;25E4 -blackupperrighttriangle;25E5 -blackuppointingsmalltriangle;25B4 -blackuppointingtriangle;25B2 -blank;2423 -blinebelow;1E07 -block;2588 -bmonospace;FF42 -bobaimaithai;0E1A -bohiragana;307C -bokatakana;30DC -bparen;249D -bqsquare;33C3 -braceex;F8F4 -braceleft;007B -braceleftbt;F8F3 -braceleftmid;F8F2 -braceleftmonospace;FF5B -braceleftsmall;FE5B -bracelefttp;F8F1 -braceleftvertical;FE37 -braceright;007D -bracerightbt;F8FE -bracerightmid;F8FD -bracerightmonospace;FF5D -bracerightsmall;FE5C -bracerighttp;F8FC -bracerightvertical;FE38 -bracketleft;005B -bracketleftbt;F8F0 -bracketleftex;F8EF -bracketleftmonospace;FF3B -bracketlefttp;F8EE -bracketright;005D -bracketrightbt;F8FB -bracketrightex;F8FA -bracketrightmonospace;FF3D -bracketrighttp;F8F9 -breve;02D8 -brevebelowcmb;032E -brevecmb;0306 -breveinvertedbelowcmb;032F -breveinvertedcmb;0311 -breveinverteddoublecmb;0361 -bridgebelowcmb;032A -bridgeinvertedbelowcmb;033A -brokenbar;00A6 -bstroke;0180 -bsuperior;F6EA -btopbar;0183 -buhiragana;3076 -bukatakana;30D6 -bullet;2022 -bulletinverse;25D8 -bulletoperator;2219 -bullseye;25CE -c;0063 -caarmenian;056E -cabengali;099A -cacute;0107 -cadeva;091A -cagujarati;0A9A -cagurmukhi;0A1A -calsquare;3388 -candrabindubengali;0981 -candrabinducmb;0310 -candrabindudeva;0901 -candrabindugujarati;0A81 -capslock;21EA -careof;2105 -caron;02C7 -caronbelowcmb;032C -caroncmb;030C -carriagereturn;21B5 -cbopomofo;3118 -ccaron;010D -ccedilla;00E7 -ccedillaacute;1E09 -ccircle;24D2 -ccircumflex;0109 -ccurl;0255 -cdot;010B -cdotaccent;010B -cdsquare;33C5 -cedilla;00B8 -cedillacmb;0327 -cent;00A2 -centigrade;2103 -centinferior;F6DF -centmonospace;FFE0 -centoldstyle;F7A2 -centsuperior;F6E0 -chaarmenian;0579 -chabengali;099B -chadeva;091B -chagujarati;0A9B -chagurmukhi;0A1B -chbopomofo;3114 -cheabkhasiancyrillic;04BD -checkmark;2713 -checyrillic;0447 -chedescenderabkhasiancyrillic;04BF -chedescendercyrillic;04B7 -chedieresiscyrillic;04F5 -cheharmenian;0573 -chekhakassiancyrillic;04CC -cheverticalstrokecyrillic;04B9 -chi;03C7 -chieuchacirclekorean;3277 -chieuchaparenkorean;3217 -chieuchcirclekorean;3269 -chieuchkorean;314A -chieuchparenkorean;3209 -chochangthai;0E0A -chochanthai;0E08 -chochingthai;0E09 -chochoethai;0E0C -chook;0188 -cieucacirclekorean;3276 -cieucaparenkorean;3216 -cieuccirclekorean;3268 -cieuckorean;3148 -cieucparenkorean;3208 -cieucuparenkorean;321C -circle;25CB -circlemultiply;2297 -circleot;2299 -circleplus;2295 -circlepostalmark;3036 -circlewithlefthalfblack;25D0 -circlewithrighthalfblack;25D1 -circumflex;02C6 -circumflexbelowcmb;032D -circumflexcmb;0302 -clear;2327 -clickalveolar;01C2 -clickdental;01C0 -clicklateral;01C1 -clickretroflex;01C3 -club;2663 -clubsuitblack;2663 -clubsuitwhite;2667 -cmcubedsquare;33A4 -cmonospace;FF43 -cmsquaredsquare;33A0 -coarmenian;0581 -colon;003A -colonmonetary;20A1 -colonmonospace;FF1A -colonsign;20A1 -colonsmall;FE55 -colontriangularhalfmod;02D1 -colontriangularmod;02D0 -comma;002C -commaabovecmb;0313 -commaaboverightcmb;0315 -commaaccent;F6C3 -commaarabic;060C -commaarmenian;055D -commainferior;F6E1 -commamonospace;FF0C -commareversedabovecmb;0314 -commareversedmod;02BD -commasmall;FE50 -commasuperior;F6E2 -commaturnedabovecmb;0312 -commaturnedmod;02BB -compass;263C -congruent;2245 -contourintegral;222E -control;2303 -controlACK;0006 -controlBEL;0007 -controlBS;0008 -controlCAN;0018 -controlCR;000D -controlDC1;0011 -controlDC2;0012 -controlDC3;0013 -controlDC4;0014 -controlDEL;007F -controlDLE;0010 -controlEM;0019 -controlENQ;0005 -controlEOT;0004 -controlESC;001B -controlETB;0017 -controlETX;0003 -controlFF;000C -controlFS;001C -controlGS;001D -controlHT;0009 -controlLF;000A -controlNAK;0015 -controlRS;001E -controlSI;000F -controlSO;000E -controlSOT;0002 -controlSTX;0001 -controlSUB;001A -controlSYN;0016 -controlUS;001F -controlVT;000B -copyright;00A9 -copyrightsans;F8E9 -copyrightserif;F6D9 -cornerbracketleft;300C -cornerbracketlefthalfwidth;FF62 -cornerbracketleftvertical;FE41 -cornerbracketright;300D -cornerbracketrighthalfwidth;FF63 -cornerbracketrightvertical;FE42 -corporationsquare;337F -cosquare;33C7 -coverkgsquare;33C6 -cparen;249E -cruzeiro;20A2 -cstretched;0297 -curlyand;22CF -curlyor;22CE -currency;00A4 -cyrBreve;F6D1 -cyrFlex;F6D2 -cyrbreve;F6D4 -cyrflex;F6D5 -d;0064 -daarmenian;0564 -dabengali;09A6 -dadarabic;0636 -dadeva;0926 -dadfinalarabic;FEBE -dadinitialarabic;FEBF -dadmedialarabic;FEC0 -dagesh;05BC -dageshhebrew;05BC -dagger;2020 -daggerdbl;2021 -dagujarati;0AA6 -dagurmukhi;0A26 -dahiragana;3060 -dakatakana;30C0 -dalarabic;062F -dalet;05D3 -daletdagesh;FB33 -daletdageshhebrew;FB33 -dalethatafpatah;05D3 05B2 -dalethatafpatahhebrew;05D3 05B2 -dalethatafsegol;05D3 05B1 -dalethatafsegolhebrew;05D3 05B1 -dalethebrew;05D3 -dalethiriq;05D3 05B4 -dalethiriqhebrew;05D3 05B4 -daletholam;05D3 05B9 -daletholamhebrew;05D3 05B9 -daletpatah;05D3 05B7 -daletpatahhebrew;05D3 05B7 -daletqamats;05D3 05B8 -daletqamatshebrew;05D3 05B8 -daletqubuts;05D3 05BB -daletqubutshebrew;05D3 05BB -daletsegol;05D3 05B6 -daletsegolhebrew;05D3 05B6 -daletsheva;05D3 05B0 -daletshevahebrew;05D3 05B0 -dalettsere;05D3 05B5 -dalettserehebrew;05D3 05B5 -dalfinalarabic;FEAA -dammaarabic;064F -dammalowarabic;064F -dammatanaltonearabic;064C -dammatanarabic;064C -danda;0964 -dargahebrew;05A7 -dargalefthebrew;05A7 -dasiapneumatacyrilliccmb;0485 -dblGrave;F6D3 -dblanglebracketleft;300A -dblanglebracketleftvertical;FE3D -dblanglebracketright;300B -dblanglebracketrightvertical;FE3E -dblarchinvertedbelowcmb;032B -dblarrowleft;21D4 -dblarrowright;21D2 -dbldanda;0965 -dblgrave;F6D6 -dblgravecmb;030F -dblintegral;222C -dbllowline;2017 -dbllowlinecmb;0333 -dbloverlinecmb;033F -dblprimemod;02BA -dblverticalbar;2016 -dblverticallineabovecmb;030E -dbopomofo;3109 -dbsquare;33C8 -dcaron;010F -dcedilla;1E11 -dcircle;24D3 -dcircumflexbelow;1E13 -dcroat;0111 -ddabengali;09A1 -ddadeva;0921 -ddagujarati;0AA1 -ddagurmukhi;0A21 -ddalarabic;0688 -ddalfinalarabic;FB89 -dddhadeva;095C -ddhabengali;09A2 -ddhadeva;0922 -ddhagujarati;0AA2 -ddhagurmukhi;0A22 -ddotaccent;1E0B -ddotbelow;1E0D -decimalseparatorarabic;066B -decimalseparatorpersian;066B -decyrillic;0434 -degree;00B0 -dehihebrew;05AD -dehiragana;3067 -deicoptic;03EF -dekatakana;30C7 -deleteleft;232B -deleteright;2326 -delta;03B4 -deltaturned;018D -denominatorminusonenumeratorbengali;09F8 -dezh;02A4 -dhabengali;09A7 -dhadeva;0927 -dhagujarati;0AA7 -dhagurmukhi;0A27 -dhook;0257 -dialytikatonos;0385 -dialytikatonoscmb;0344 -diamond;2666 -diamondsuitwhite;2662 -dieresis;00A8 -dieresisacute;F6D7 -dieresisbelowcmb;0324 -dieresiscmb;0308 -dieresisgrave;F6D8 -dieresistonos;0385 -dihiragana;3062 -dikatakana;30C2 -dittomark;3003 -divide;00F7 -divides;2223 -divisionslash;2215 -djecyrillic;0452 -dkshade;2593 -dlinebelow;1E0F -dlsquare;3397 -dmacron;0111 -dmonospace;FF44 -dnblock;2584 -dochadathai;0E0E -dodekthai;0E14 -dohiragana;3069 -dokatakana;30C9 -dollar;0024 -dollarinferior;F6E3 -dollarmonospace;FF04 -dollaroldstyle;F724 -dollarsmall;FE69 -dollarsuperior;F6E4 -dong;20AB -dorusquare;3326 -dotaccent;02D9 -dotaccentcmb;0307 -dotbelowcmb;0323 -dotbelowcomb;0323 -dotkatakana;30FB -dotlessi;0131 -dotlessj;F6BE -dotlessjstrokehook;0284 -dotmath;22C5 -dottedcircle;25CC -doubleyodpatah;FB1F -doubleyodpatahhebrew;FB1F -downtackbelowcmb;031E -downtackmod;02D5 -dparen;249F -dsuperior;F6EB -dtail;0256 -dtopbar;018C -duhiragana;3065 -dukatakana;30C5 -dz;01F3 -dzaltone;02A3 -dzcaron;01C6 -dzcurl;02A5 -dzeabkhasiancyrillic;04E1 -dzecyrillic;0455 -dzhecyrillic;045F -e;0065 -eacute;00E9 -earth;2641 -ebengali;098F -ebopomofo;311C -ebreve;0115 -ecandradeva;090D -ecandragujarati;0A8D -ecandravowelsigndeva;0945 -ecandravowelsigngujarati;0AC5 -ecaron;011B -ecedillabreve;1E1D -echarmenian;0565 -echyiwnarmenian;0587 -ecircle;24D4 -ecircumflex;00EA -ecircumflexacute;1EBF -ecircumflexbelow;1E19 -ecircumflexdotbelow;1EC7 -ecircumflexgrave;1EC1 -ecircumflexhookabove;1EC3 -ecircumflextilde;1EC5 -ecyrillic;0454 -edblgrave;0205 -edeva;090F -edieresis;00EB -edot;0117 -edotaccent;0117 -edotbelow;1EB9 -eegurmukhi;0A0F -eematragurmukhi;0A47 -efcyrillic;0444 -egrave;00E8 -egujarati;0A8F -eharmenian;0567 -ehbopomofo;311D -ehiragana;3048 -ehookabove;1EBB -eibopomofo;311F -eight;0038 -eightarabic;0668 -eightbengali;09EE -eightcircle;2467 -eightcircleinversesansserif;2791 -eightdeva;096E -eighteencircle;2471 -eighteenparen;2485 -eighteenperiod;2499 -eightgujarati;0AEE -eightgurmukhi;0A6E -eighthackarabic;0668 -eighthangzhou;3028 -eighthnotebeamed;266B -eightideographicparen;3227 -eightinferior;2088 -eightmonospace;FF18 -eightoldstyle;F738 -eightparen;247B -eightperiod;248F -eightpersian;06F8 -eightroman;2177 -eightsuperior;2078 -eightthai;0E58 -einvertedbreve;0207 -eiotifiedcyrillic;0465 -ekatakana;30A8 -ekatakanahalfwidth;FF74 -ekonkargurmukhi;0A74 -ekorean;3154 -elcyrillic;043B -element;2208 -elevencircle;246A -elevenparen;247E -elevenperiod;2492 -elevenroman;217A -ellipsis;2026 -ellipsisvertical;22EE -emacron;0113 -emacronacute;1E17 -emacrongrave;1E15 -emcyrillic;043C -emdash;2014 -emdashvertical;FE31 -emonospace;FF45 -emphasismarkarmenian;055B -emptyset;2205 -enbopomofo;3123 -encyrillic;043D -endash;2013 -endashvertical;FE32 -endescendercyrillic;04A3 -eng;014B -engbopomofo;3125 -enghecyrillic;04A5 -enhookcyrillic;04C8 -enspace;2002 -eogonek;0119 -eokorean;3153 -eopen;025B -eopenclosed;029A -eopenreversed;025C -eopenreversedclosed;025E -eopenreversedhook;025D -eparen;24A0 -epsilon;03B5 -epsilontonos;03AD -equal;003D -equalmonospace;FF1D -equalsmall;FE66 -equalsuperior;207C -equivalence;2261 -erbopomofo;3126 -ercyrillic;0440 -ereversed;0258 -ereversedcyrillic;044D -escyrillic;0441 -esdescendercyrillic;04AB -esh;0283 -eshcurl;0286 -eshortdeva;090E -eshortvowelsigndeva;0946 -eshreversedloop;01AA -eshsquatreversed;0285 -esmallhiragana;3047 -esmallkatakana;30A7 -esmallkatakanahalfwidth;FF6A -estimated;212E -esuperior;F6EC -eta;03B7 -etarmenian;0568 -etatonos;03AE -eth;00F0 -etilde;1EBD -etildebelow;1E1B -etnahtafoukhhebrew;0591 -etnahtafoukhlefthebrew;0591 -etnahtahebrew;0591 -etnahtalefthebrew;0591 -eturned;01DD -eukorean;3161 -euro;20AC -evowelsignbengali;09C7 -evowelsigndeva;0947 -evowelsigngujarati;0AC7 -exclam;0021 -exclamarmenian;055C -exclamdbl;203C -exclamdown;00A1 -exclamdownsmall;F7A1 -exclammonospace;FF01 -exclamsmall;F721 -existential;2203 -ezh;0292 -ezhcaron;01EF -ezhcurl;0293 -ezhreversed;01B9 -ezhtail;01BA -f;0066 -fadeva;095E -fagurmukhi;0A5E -fahrenheit;2109 -fathaarabic;064E -fathalowarabic;064E -fathatanarabic;064B -fbopomofo;3108 -fcircle;24D5 -fdotaccent;1E1F -feharabic;0641 -feharmenian;0586 -fehfinalarabic;FED2 -fehinitialarabic;FED3 -fehmedialarabic;FED4 -feicoptic;03E5 -female;2640 -ff;FB00 -ffi;FB03 -ffl;FB04 -fi;FB01 -fifteencircle;246E -fifteenparen;2482 -fifteenperiod;2496 -figuredash;2012 -filledbox;25A0 -filledrect;25AC -finalkaf;05DA -finalkafdagesh;FB3A -finalkafdageshhebrew;FB3A -finalkafhebrew;05DA -finalkafqamats;05DA 05B8 -finalkafqamatshebrew;05DA 05B8 -finalkafsheva;05DA 05B0 -finalkafshevahebrew;05DA 05B0 -finalmem;05DD -finalmemhebrew;05DD -finalnun;05DF -finalnunhebrew;05DF -finalpe;05E3 -finalpehebrew;05E3 -finaltsadi;05E5 -finaltsadihebrew;05E5 -firsttonechinese;02C9 -fisheye;25C9 -fitacyrillic;0473 -five;0035 -fivearabic;0665 -fivebengali;09EB -fivecircle;2464 -fivecircleinversesansserif;278E -fivedeva;096B -fiveeighths;215D -fivegujarati;0AEB -fivegurmukhi;0A6B -fivehackarabic;0665 -fivehangzhou;3025 -fiveideographicparen;3224 -fiveinferior;2085 -fivemonospace;FF15 -fiveoldstyle;F735 -fiveparen;2478 -fiveperiod;248C -fivepersian;06F5 -fiveroman;2174 -fivesuperior;2075 -fivethai;0E55 -fl;FB02 -florin;0192 -fmonospace;FF46 -fmsquare;3399 -fofanthai;0E1F -fofathai;0E1D -fongmanthai;0E4F -forall;2200 -four;0034 -fourarabic;0664 -fourbengali;09EA -fourcircle;2463 -fourcircleinversesansserif;278D -fourdeva;096A -fourgujarati;0AEA -fourgurmukhi;0A6A -fourhackarabic;0664 -fourhangzhou;3024 -fourideographicparen;3223 -fourinferior;2084 -fourmonospace;FF14 -fournumeratorbengali;09F7 -fouroldstyle;F734 -fourparen;2477 -fourperiod;248B -fourpersian;06F4 -fourroman;2173 -foursuperior;2074 -fourteencircle;246D -fourteenparen;2481 -fourteenperiod;2495 -fourthai;0E54 -fourthtonechinese;02CB -fparen;24A1 -fraction;2044 -franc;20A3 -g;0067 -gabengali;0997 -gacute;01F5 -gadeva;0917 -gafarabic;06AF -gaffinalarabic;FB93 -gafinitialarabic;FB94 -gafmedialarabic;FB95 -gagujarati;0A97 -gagurmukhi;0A17 -gahiragana;304C -gakatakana;30AC -gamma;03B3 -gammalatinsmall;0263 -gammasuperior;02E0 -gangiacoptic;03EB -gbopomofo;310D -gbreve;011F -gcaron;01E7 -gcedilla;0123 -gcircle;24D6 -gcircumflex;011D -gcommaaccent;0123 -gdot;0121 -gdotaccent;0121 -gecyrillic;0433 -gehiragana;3052 -gekatakana;30B2 -geometricallyequal;2251 -gereshaccenthebrew;059C -gereshhebrew;05F3 -gereshmuqdamhebrew;059D -germandbls;00DF -gershayimaccenthebrew;059E -gershayimhebrew;05F4 -getamark;3013 -ghabengali;0998 -ghadarmenian;0572 -ghadeva;0918 -ghagujarati;0A98 -ghagurmukhi;0A18 -ghainarabic;063A -ghainfinalarabic;FECE -ghaininitialarabic;FECF -ghainmedialarabic;FED0 -ghemiddlehookcyrillic;0495 -ghestrokecyrillic;0493 -gheupturncyrillic;0491 -ghhadeva;095A -ghhagurmukhi;0A5A -ghook;0260 -ghzsquare;3393 -gihiragana;304E -gikatakana;30AE -gimarmenian;0563 -gimel;05D2 -gimeldagesh;FB32 -gimeldageshhebrew;FB32 -gimelhebrew;05D2 -gjecyrillic;0453 -glottalinvertedstroke;01BE -glottalstop;0294 -glottalstopinverted;0296 -glottalstopmod;02C0 -glottalstopreversed;0295 -glottalstopreversedmod;02C1 -glottalstopreversedsuperior;02E4 -glottalstopstroke;02A1 -glottalstopstrokereversed;02A2 -gmacron;1E21 -gmonospace;FF47 -gohiragana;3054 -gokatakana;30B4 -gparen;24A2 -gpasquare;33AC -gradient;2207 -grave;0060 -gravebelowcmb;0316 -gravecmb;0300 -gravecomb;0300 -gravedeva;0953 -gravelowmod;02CE -gravemonospace;FF40 -gravetonecmb;0340 -greater;003E -greaterequal;2265 -greaterequalorless;22DB -greatermonospace;FF1E -greaterorequivalent;2273 -greaterorless;2277 -greateroverequal;2267 -greatersmall;FE65 -gscript;0261 -gstroke;01E5 -guhiragana;3050 -guillemotleft;00AB -guillemotright;00BB -guilsinglleft;2039 -guilsinglright;203A -gukatakana;30B0 -guramusquare;3318 -gysquare;33C9 -h;0068 -haabkhasiancyrillic;04A9 -haaltonearabic;06C1 -habengali;09B9 -hadescendercyrillic;04B3 -hadeva;0939 -hagujarati;0AB9 -hagurmukhi;0A39 -haharabic;062D -hahfinalarabic;FEA2 -hahinitialarabic;FEA3 -hahiragana;306F -hahmedialarabic;FEA4 -haitusquare;332A -hakatakana;30CF -hakatakanahalfwidth;FF8A -halantgurmukhi;0A4D -hamzaarabic;0621 -hamzadammaarabic;0621 064F -hamzadammatanarabic;0621 064C -hamzafathaarabic;0621 064E -hamzafathatanarabic;0621 064B -hamzalowarabic;0621 -hamzalowkasraarabic;0621 0650 -hamzalowkasratanarabic;0621 064D -hamzasukunarabic;0621 0652 -hangulfiller;3164 -hardsigncyrillic;044A -harpoonleftbarbup;21BC -harpoonrightbarbup;21C0 -hasquare;33CA -hatafpatah;05B2 -hatafpatah16;05B2 -hatafpatah23;05B2 -hatafpatah2f;05B2 -hatafpatahhebrew;05B2 -hatafpatahnarrowhebrew;05B2 -hatafpatahquarterhebrew;05B2 -hatafpatahwidehebrew;05B2 -hatafqamats;05B3 -hatafqamats1b;05B3 -hatafqamats28;05B3 -hatafqamats34;05B3 -hatafqamatshebrew;05B3 -hatafqamatsnarrowhebrew;05B3 -hatafqamatsquarterhebrew;05B3 -hatafqamatswidehebrew;05B3 -hatafsegol;05B1 -hatafsegol17;05B1 -hatafsegol24;05B1 -hatafsegol30;05B1 -hatafsegolhebrew;05B1 -hatafsegolnarrowhebrew;05B1 -hatafsegolquarterhebrew;05B1 -hatafsegolwidehebrew;05B1 -hbar;0127 -hbopomofo;310F -hbrevebelow;1E2B -hcedilla;1E29 -hcircle;24D7 -hcircumflex;0125 -hdieresis;1E27 -hdotaccent;1E23 -hdotbelow;1E25 -he;05D4 -heart;2665 -heartsuitblack;2665 -heartsuitwhite;2661 -hedagesh;FB34 -hedageshhebrew;FB34 -hehaltonearabic;06C1 -heharabic;0647 -hehebrew;05D4 -hehfinalaltonearabic;FBA7 -hehfinalalttwoarabic;FEEA -hehfinalarabic;FEEA -hehhamzaabovefinalarabic;FBA5 -hehhamzaaboveisolatedarabic;FBA4 -hehinitialaltonearabic;FBA8 -hehinitialarabic;FEEB -hehiragana;3078 -hehmedialaltonearabic;FBA9 -hehmedialarabic;FEEC -heiseierasquare;337B -hekatakana;30D8 -hekatakanahalfwidth;FF8D -hekutaarusquare;3336 -henghook;0267 -herutusquare;3339 -het;05D7 -hethebrew;05D7 -hhook;0266 -hhooksuperior;02B1 -hieuhacirclekorean;327B -hieuhaparenkorean;321B -hieuhcirclekorean;326D -hieuhkorean;314E -hieuhparenkorean;320D -hihiragana;3072 -hikatakana;30D2 -hikatakanahalfwidth;FF8B -hiriq;05B4 -hiriq14;05B4 -hiriq21;05B4 -hiriq2d;05B4 -hiriqhebrew;05B4 -hiriqnarrowhebrew;05B4 -hiriqquarterhebrew;05B4 -hiriqwidehebrew;05B4 -hlinebelow;1E96 -hmonospace;FF48 -hoarmenian;0570 -hohipthai;0E2B -hohiragana;307B -hokatakana;30DB -hokatakanahalfwidth;FF8E -holam;05B9 -holam19;05B9 -holam26;05B9 -holam32;05B9 -holamhebrew;05B9 -holamnarrowhebrew;05B9 -holamquarterhebrew;05B9 -holamwidehebrew;05B9 -honokhukthai;0E2E -hookabovecomb;0309 -hookcmb;0309 -hookpalatalizedbelowcmb;0321 -hookretroflexbelowcmb;0322 -hoonsquare;3342 -horicoptic;03E9 -horizontalbar;2015 -horncmb;031B -hotsprings;2668 -house;2302 -hparen;24A3 -hsuperior;02B0 -hturned;0265 -huhiragana;3075 -huiitosquare;3333 -hukatakana;30D5 -hukatakanahalfwidth;FF8C -hungarumlaut;02DD -hungarumlautcmb;030B -hv;0195 -hyphen;002D -hypheninferior;F6E5 -hyphenmonospace;FF0D -hyphensmall;FE63 -hyphensuperior;F6E6 -hyphentwo;2010 -i;0069 -iacute;00ED -iacyrillic;044F -ibengali;0987 -ibopomofo;3127 -ibreve;012D -icaron;01D0 -icircle;24D8 -icircumflex;00EE -icyrillic;0456 -idblgrave;0209 -ideographearthcircle;328F -ideographfirecircle;328B -ideographicallianceparen;323F -ideographiccallparen;323A -ideographiccentrecircle;32A5 -ideographicclose;3006 -ideographiccomma;3001 -ideographiccommaleft;FF64 -ideographiccongratulationparen;3237 -ideographiccorrectcircle;32A3 -ideographicearthparen;322F -ideographicenterpriseparen;323D -ideographicexcellentcircle;329D -ideographicfestivalparen;3240 -ideographicfinancialcircle;3296 -ideographicfinancialparen;3236 -ideographicfireparen;322B -ideographichaveparen;3232 -ideographichighcircle;32A4 -ideographiciterationmark;3005 -ideographiclaborcircle;3298 -ideographiclaborparen;3238 -ideographicleftcircle;32A7 -ideographiclowcircle;32A6 -ideographicmedicinecircle;32A9 -ideographicmetalparen;322E -ideographicmoonparen;322A -ideographicnameparen;3234 -ideographicperiod;3002 -ideographicprintcircle;329E -ideographicreachparen;3243 -ideographicrepresentparen;3239 -ideographicresourceparen;323E -ideographicrightcircle;32A8 -ideographicsecretcircle;3299 -ideographicselfparen;3242 -ideographicsocietyparen;3233 -ideographicspace;3000 -ideographicspecialparen;3235 -ideographicstockparen;3231 -ideographicstudyparen;323B -ideographicsunparen;3230 -ideographicsuperviseparen;323C -ideographicwaterparen;322C -ideographicwoodparen;322D -ideographiczero;3007 -ideographmetalcircle;328E -ideographmooncircle;328A -ideographnamecircle;3294 -ideographsuncircle;3290 -ideographwatercircle;328C -ideographwoodcircle;328D -ideva;0907 -idieresis;00EF -idieresisacute;1E2F -idieresiscyrillic;04E5 -idotbelow;1ECB -iebrevecyrillic;04D7 -iecyrillic;0435 -ieungacirclekorean;3275 -ieungaparenkorean;3215 -ieungcirclekorean;3267 -ieungkorean;3147 -ieungparenkorean;3207 -igrave;00EC -igujarati;0A87 -igurmukhi;0A07 -ihiragana;3044 -ihookabove;1EC9 -iibengali;0988 -iicyrillic;0438 -iideva;0908 -iigujarati;0A88 -iigurmukhi;0A08 -iimatragurmukhi;0A40 -iinvertedbreve;020B -iishortcyrillic;0439 -iivowelsignbengali;09C0 -iivowelsigndeva;0940 -iivowelsigngujarati;0AC0 -ij;0133 -ikatakana;30A4 -ikatakanahalfwidth;FF72 -ikorean;3163 -ilde;02DC -iluyhebrew;05AC -imacron;012B -imacroncyrillic;04E3 -imageorapproximatelyequal;2253 -imatragurmukhi;0A3F -imonospace;FF49 -increment;2206 -infinity;221E -iniarmenian;056B -integral;222B -integralbottom;2321 -integralbt;2321 -integralex;F8F5 -integraltop;2320 -integraltp;2320 -intersection;2229 -intisquare;3305 -invbullet;25D8 -invcircle;25D9 -invsmileface;263B -iocyrillic;0451 -iogonek;012F -iota;03B9 -iotadieresis;03CA -iotadieresistonos;0390 -iotalatin;0269 -iotatonos;03AF -iparen;24A4 -irigurmukhi;0A72 -ismallhiragana;3043 -ismallkatakana;30A3 -ismallkatakanahalfwidth;FF68 -issharbengali;09FA -istroke;0268 -isuperior;F6ED -iterationhiragana;309D -iterationkatakana;30FD -itilde;0129 -itildebelow;1E2D -iubopomofo;3129 -iucyrillic;044E -ivowelsignbengali;09BF -ivowelsigndeva;093F -ivowelsigngujarati;0ABF -izhitsacyrillic;0475 -izhitsadblgravecyrillic;0477 -j;006A -jaarmenian;0571 -jabengali;099C -jadeva;091C -jagujarati;0A9C -jagurmukhi;0A1C -jbopomofo;3110 -jcaron;01F0 -jcircle;24D9 -jcircumflex;0135 -jcrossedtail;029D -jdotlessstroke;025F -jecyrillic;0458 -jeemarabic;062C -jeemfinalarabic;FE9E -jeeminitialarabic;FE9F -jeemmedialarabic;FEA0 -jeharabic;0698 -jehfinalarabic;FB8B -jhabengali;099D -jhadeva;091D -jhagujarati;0A9D -jhagurmukhi;0A1D -jheharmenian;057B -jis;3004 -jmonospace;FF4A -jparen;24A5 -jsuperior;02B2 -k;006B -kabashkircyrillic;04A1 -kabengali;0995 -kacute;1E31 -kacyrillic;043A -kadescendercyrillic;049B -kadeva;0915 -kaf;05DB -kafarabic;0643 -kafdagesh;FB3B -kafdageshhebrew;FB3B -kaffinalarabic;FEDA -kafhebrew;05DB -kafinitialarabic;FEDB -kafmedialarabic;FEDC -kafrafehebrew;FB4D -kagujarati;0A95 -kagurmukhi;0A15 -kahiragana;304B -kahookcyrillic;04C4 -kakatakana;30AB -kakatakanahalfwidth;FF76 -kappa;03BA -kappasymbolgreek;03F0 -kapyeounmieumkorean;3171 -kapyeounphieuphkorean;3184 -kapyeounpieupkorean;3178 -kapyeounssangpieupkorean;3179 -karoriisquare;330D -kashidaautoarabic;0640 -kashidaautonosidebearingarabic;0640 -kasmallkatakana;30F5 -kasquare;3384 -kasraarabic;0650 -kasratanarabic;064D -kastrokecyrillic;049F -katahiraprolongmarkhalfwidth;FF70 -kaverticalstrokecyrillic;049D -kbopomofo;310E -kcalsquare;3389 -kcaron;01E9 -kcedilla;0137 -kcircle;24DA -kcommaaccent;0137 -kdotbelow;1E33 -keharmenian;0584 -kehiragana;3051 -kekatakana;30B1 -kekatakanahalfwidth;FF79 -kenarmenian;056F -kesmallkatakana;30F6 -kgreenlandic;0138 -khabengali;0996 -khacyrillic;0445 -khadeva;0916 -khagujarati;0A96 -khagurmukhi;0A16 -khaharabic;062E -khahfinalarabic;FEA6 -khahinitialarabic;FEA7 -khahmedialarabic;FEA8 -kheicoptic;03E7 -khhadeva;0959 -khhagurmukhi;0A59 -khieukhacirclekorean;3278 -khieukhaparenkorean;3218 -khieukhcirclekorean;326A -khieukhkorean;314B -khieukhparenkorean;320A -khokhaithai;0E02 -khokhonthai;0E05 -khokhuatthai;0E03 -khokhwaithai;0E04 -khomutthai;0E5B -khook;0199 -khorakhangthai;0E06 -khzsquare;3391 -kihiragana;304D -kikatakana;30AD -kikatakanahalfwidth;FF77 -kiroguramusquare;3315 -kiromeetorusquare;3316 -kirosquare;3314 -kiyeokacirclekorean;326E -kiyeokaparenkorean;320E -kiyeokcirclekorean;3260 -kiyeokkorean;3131 -kiyeokparenkorean;3200 -kiyeoksioskorean;3133 -kjecyrillic;045C -klinebelow;1E35 -klsquare;3398 -kmcubedsquare;33A6 -kmonospace;FF4B -kmsquaredsquare;33A2 -kohiragana;3053 -kohmsquare;33C0 -kokaithai;0E01 -kokatakana;30B3 -kokatakanahalfwidth;FF7A -kooposquare;331E -koppacyrillic;0481 -koreanstandardsymbol;327F -koroniscmb;0343 -kparen;24A6 -kpasquare;33AA -ksicyrillic;046F -ktsquare;33CF -kturned;029E -kuhiragana;304F -kukatakana;30AF -kukatakanahalfwidth;FF78 -kvsquare;33B8 -kwsquare;33BE -l;006C -labengali;09B2 -lacute;013A -ladeva;0932 -lagujarati;0AB2 -lagurmukhi;0A32 -lakkhangyaothai;0E45 -lamaleffinalarabic;FEFC -lamalefhamzaabovefinalarabic;FEF8 -lamalefhamzaaboveisolatedarabic;FEF7 -lamalefhamzabelowfinalarabic;FEFA -lamalefhamzabelowisolatedarabic;FEF9 -lamalefisolatedarabic;FEFB -lamalefmaddaabovefinalarabic;FEF6 -lamalefmaddaaboveisolatedarabic;FEF5 -lamarabic;0644 -lambda;03BB -lambdastroke;019B -lamed;05DC -lameddagesh;FB3C -lameddageshhebrew;FB3C -lamedhebrew;05DC -lamedholam;05DC 05B9 -lamedholamdagesh;05DC 05B9 05BC -lamedholamdageshhebrew;05DC 05B9 05BC -lamedholamhebrew;05DC 05B9 -lamfinalarabic;FEDE -lamhahinitialarabic;FCCA -laminitialarabic;FEDF -lamjeeminitialarabic;FCC9 -lamkhahinitialarabic;FCCB -lamlamhehisolatedarabic;FDF2 -lammedialarabic;FEE0 -lammeemhahinitialarabic;FD88 -lammeeminitialarabic;FCCC -lammeemjeeminitialarabic;FEDF FEE4 FEA0 -lammeemkhahinitialarabic;FEDF FEE4 FEA8 -largecircle;25EF -lbar;019A -lbelt;026C -lbopomofo;310C -lcaron;013E -lcedilla;013C -lcircle;24DB -lcircumflexbelow;1E3D -lcommaaccent;013C -ldot;0140 -ldotaccent;0140 -ldotbelow;1E37 -ldotbelowmacron;1E39 -leftangleabovecmb;031A -lefttackbelowcmb;0318 -less;003C -lessequal;2264 -lessequalorgreater;22DA -lessmonospace;FF1C -lessorequivalent;2272 -lessorgreater;2276 -lessoverequal;2266 -lesssmall;FE64 -lezh;026E -lfblock;258C -lhookretroflex;026D -lira;20A4 -liwnarmenian;056C -lj;01C9 -ljecyrillic;0459 -ll;F6C0 -lladeva;0933 -llagujarati;0AB3 -llinebelow;1E3B -llladeva;0934 -llvocalicbengali;09E1 -llvocalicdeva;0961 -llvocalicvowelsignbengali;09E3 -llvocalicvowelsigndeva;0963 -lmiddletilde;026B -lmonospace;FF4C -lmsquare;33D0 -lochulathai;0E2C -logicaland;2227 -logicalnot;00AC -logicalnotreversed;2310 -logicalor;2228 -lolingthai;0E25 -longs;017F -lowlinecenterline;FE4E -lowlinecmb;0332 -lowlinedashed;FE4D -lozenge;25CA -lparen;24A7 -lslash;0142 -lsquare;2113 -lsuperior;F6EE -ltshade;2591 -luthai;0E26 -lvocalicbengali;098C -lvocalicdeva;090C -lvocalicvowelsignbengali;09E2 -lvocalicvowelsigndeva;0962 -lxsquare;33D3 -m;006D -mabengali;09AE -macron;00AF -macronbelowcmb;0331 -macroncmb;0304 -macronlowmod;02CD -macronmonospace;FFE3 -macute;1E3F -madeva;092E -magujarati;0AAE -magurmukhi;0A2E -mahapakhhebrew;05A4 -mahapakhlefthebrew;05A4 -mahiragana;307E -maichattawalowleftthai;F895 -maichattawalowrightthai;F894 -maichattawathai;0E4B -maichattawaupperleftthai;F893 -maieklowleftthai;F88C -maieklowrightthai;F88B -maiekthai;0E48 -maiekupperleftthai;F88A -maihanakatleftthai;F884 -maihanakatthai;0E31 -maitaikhuleftthai;F889 -maitaikhuthai;0E47 -maitholowleftthai;F88F -maitholowrightthai;F88E -maithothai;0E49 -maithoupperleftthai;F88D -maitrilowleftthai;F892 -maitrilowrightthai;F891 -maitrithai;0E4A -maitriupperleftthai;F890 -maiyamokthai;0E46 -makatakana;30DE -makatakanahalfwidth;FF8F -male;2642 -mansyonsquare;3347 -maqafhebrew;05BE -mars;2642 -masoracirclehebrew;05AF -masquare;3383 -mbopomofo;3107 -mbsquare;33D4 -mcircle;24DC -mcubedsquare;33A5 -mdotaccent;1E41 -mdotbelow;1E43 -meemarabic;0645 -meemfinalarabic;FEE2 -meeminitialarabic;FEE3 -meemmedialarabic;FEE4 -meemmeeminitialarabic;FCD1 -meemmeemisolatedarabic;FC48 -meetorusquare;334D -mehiragana;3081 -meizierasquare;337E -mekatakana;30E1 -mekatakanahalfwidth;FF92 -mem;05DE -memdagesh;FB3E -memdageshhebrew;FB3E -memhebrew;05DE -menarmenian;0574 -merkhahebrew;05A5 -merkhakefulahebrew;05A6 -merkhakefulalefthebrew;05A6 -merkhalefthebrew;05A5 -mhook;0271 -mhzsquare;3392 -middledotkatakanahalfwidth;FF65 -middot;00B7 -mieumacirclekorean;3272 -mieumaparenkorean;3212 -mieumcirclekorean;3264 -mieumkorean;3141 -mieumpansioskorean;3170 -mieumparenkorean;3204 -mieumpieupkorean;316E -mieumsioskorean;316F -mihiragana;307F -mikatakana;30DF -mikatakanahalfwidth;FF90 -minus;2212 -minusbelowcmb;0320 -minuscircle;2296 -minusmod;02D7 -minusplus;2213 -minute;2032 -miribaarusquare;334A -mirisquare;3349 -mlonglegturned;0270 -mlsquare;3396 -mmcubedsquare;33A3 -mmonospace;FF4D -mmsquaredsquare;339F -mohiragana;3082 -mohmsquare;33C1 -mokatakana;30E2 -mokatakanahalfwidth;FF93 -molsquare;33D6 -momathai;0E21 -moverssquare;33A7 -moverssquaredsquare;33A8 -mparen;24A8 -mpasquare;33AB -mssquare;33B3 -msuperior;F6EF -mturned;026F -mu;00B5 -mu1;00B5 -muasquare;3382 -muchgreater;226B -muchless;226A -mufsquare;338C -mugreek;03BC -mugsquare;338D -muhiragana;3080 -mukatakana;30E0 -mukatakanahalfwidth;FF91 -mulsquare;3395 -multiply;00D7 -mumsquare;339B -munahhebrew;05A3 -munahlefthebrew;05A3 -musicalnote;266A -musicalnotedbl;266B -musicflatsign;266D -musicsharpsign;266F -mussquare;33B2 -muvsquare;33B6 -muwsquare;33BC -mvmegasquare;33B9 -mvsquare;33B7 -mwmegasquare;33BF -mwsquare;33BD -n;006E -nabengali;09A8 -nabla;2207 -nacute;0144 -nadeva;0928 -nagujarati;0AA8 -nagurmukhi;0A28 -nahiragana;306A -nakatakana;30CA -nakatakanahalfwidth;FF85 -napostrophe;0149 -nasquare;3381 -nbopomofo;310B -nbspace;00A0 -ncaron;0148 -ncedilla;0146 -ncircle;24DD -ncircumflexbelow;1E4B -ncommaaccent;0146 -ndotaccent;1E45 -ndotbelow;1E47 -nehiragana;306D -nekatakana;30CD -nekatakanahalfwidth;FF88 -newsheqelsign;20AA -nfsquare;338B -ngabengali;0999 -ngadeva;0919 -ngagujarati;0A99 -ngagurmukhi;0A19 -ngonguthai;0E07 -nhiragana;3093 -nhookleft;0272 -nhookretroflex;0273 -nieunacirclekorean;326F -nieunaparenkorean;320F -nieuncieuckorean;3135 -nieuncirclekorean;3261 -nieunhieuhkorean;3136 -nieunkorean;3134 -nieunpansioskorean;3168 -nieunparenkorean;3201 -nieunsioskorean;3167 -nieuntikeutkorean;3166 -nihiragana;306B -nikatakana;30CB -nikatakanahalfwidth;FF86 -nikhahitleftthai;F899 -nikhahitthai;0E4D -nine;0039 -ninearabic;0669 -ninebengali;09EF -ninecircle;2468 -ninecircleinversesansserif;2792 -ninedeva;096F -ninegujarati;0AEF -ninegurmukhi;0A6F -ninehackarabic;0669 -ninehangzhou;3029 -nineideographicparen;3228 -nineinferior;2089 -ninemonospace;FF19 -nineoldstyle;F739 -nineparen;247C -nineperiod;2490 -ninepersian;06F9 -nineroman;2178 -ninesuperior;2079 -nineteencircle;2472 -nineteenparen;2486 -nineteenperiod;249A -ninethai;0E59 -nj;01CC -njecyrillic;045A -nkatakana;30F3 -nkatakanahalfwidth;FF9D -nlegrightlong;019E -nlinebelow;1E49 -nmonospace;FF4E -nmsquare;339A -nnabengali;09A3 -nnadeva;0923 -nnagujarati;0AA3 -nnagurmukhi;0A23 -nnnadeva;0929 -nohiragana;306E -nokatakana;30CE -nokatakanahalfwidth;FF89 -nonbreakingspace;00A0 -nonenthai;0E13 -nonuthai;0E19 -noonarabic;0646 -noonfinalarabic;FEE6 -noonghunnaarabic;06BA -noonghunnafinalarabic;FB9F -noonhehinitialarabic;FEE7 FEEC -nooninitialarabic;FEE7 -noonjeeminitialarabic;FCD2 -noonjeemisolatedarabic;FC4B -noonmedialarabic;FEE8 -noonmeeminitialarabic;FCD5 -noonmeemisolatedarabic;FC4E -noonnoonfinalarabic;FC8D -notcontains;220C -notelement;2209 -notelementof;2209 -notequal;2260 -notgreater;226F -notgreaternorequal;2271 -notgreaternorless;2279 -notidentical;2262 -notless;226E -notlessnorequal;2270 -notparallel;2226 -notprecedes;2280 -notsubset;2284 -notsucceeds;2281 -notsuperset;2285 -nowarmenian;0576 -nparen;24A9 -nssquare;33B1 -nsuperior;207F -ntilde;00F1 -nu;03BD -nuhiragana;306C -nukatakana;30CC -nukatakanahalfwidth;FF87 -nuktabengali;09BC -nuktadeva;093C -nuktagujarati;0ABC -nuktagurmukhi;0A3C -numbersign;0023 -numbersignmonospace;FF03 -numbersignsmall;FE5F -numeralsigngreek;0374 -numeralsignlowergreek;0375 -numero;2116 -nun;05E0 -nundagesh;FB40 -nundageshhebrew;FB40 -nunhebrew;05E0 -nvsquare;33B5 -nwsquare;33BB -nyabengali;099E -nyadeva;091E -nyagujarati;0A9E -nyagurmukhi;0A1E -o;006F -oacute;00F3 -oangthai;0E2D -obarred;0275 -obarredcyrillic;04E9 -obarreddieresiscyrillic;04EB -obengali;0993 -obopomofo;311B -obreve;014F -ocandradeva;0911 -ocandragujarati;0A91 -ocandravowelsigndeva;0949 -ocandravowelsigngujarati;0AC9 -ocaron;01D2 -ocircle;24DE -ocircumflex;00F4 -ocircumflexacute;1ED1 -ocircumflexdotbelow;1ED9 -ocircumflexgrave;1ED3 -ocircumflexhookabove;1ED5 -ocircumflextilde;1ED7 -ocyrillic;043E -odblacute;0151 -odblgrave;020D -odeva;0913 -odieresis;00F6 -odieresiscyrillic;04E7 -odotbelow;1ECD -oe;0153 -oekorean;315A -ogonek;02DB -ogonekcmb;0328 -ograve;00F2 -ogujarati;0A93 -oharmenian;0585 -ohiragana;304A -ohookabove;1ECF -ohorn;01A1 -ohornacute;1EDB -ohorndotbelow;1EE3 -ohorngrave;1EDD -ohornhookabove;1EDF -ohorntilde;1EE1 -ohungarumlaut;0151 -oi;01A3 -oinvertedbreve;020F -okatakana;30AA -okatakanahalfwidth;FF75 -okorean;3157 -olehebrew;05AB -omacron;014D -omacronacute;1E53 -omacrongrave;1E51 -omdeva;0950 -omega;03C9 -omega1;03D6 -omegacyrillic;0461 -omegalatinclosed;0277 -omegaroundcyrillic;047B -omegatitlocyrillic;047D -omegatonos;03CE -omgujarati;0AD0 -omicron;03BF -omicrontonos;03CC -omonospace;FF4F -one;0031 -onearabic;0661 -onebengali;09E7 -onecircle;2460 -onecircleinversesansserif;278A -onedeva;0967 -onedotenleader;2024 -oneeighth;215B -onefitted;F6DC -onegujarati;0AE7 -onegurmukhi;0A67 -onehackarabic;0661 -onehalf;00BD -onehangzhou;3021 -oneideographicparen;3220 -oneinferior;2081 -onemonospace;FF11 -onenumeratorbengali;09F4 -oneoldstyle;F731 -oneparen;2474 -oneperiod;2488 -onepersian;06F1 -onequarter;00BC -oneroman;2170 -onesuperior;00B9 -onethai;0E51 -onethird;2153 -oogonek;01EB -oogonekmacron;01ED -oogurmukhi;0A13 -oomatragurmukhi;0A4B -oopen;0254 -oparen;24AA -openbullet;25E6 -option;2325 -ordfeminine;00AA -ordmasculine;00BA -orthogonal;221F -oshortdeva;0912 -oshortvowelsigndeva;094A -oslash;00F8 -oslashacute;01FF -osmallhiragana;3049 -osmallkatakana;30A9 -osmallkatakanahalfwidth;FF6B -ostrokeacute;01FF -osuperior;F6F0 -otcyrillic;047F -otilde;00F5 -otildeacute;1E4D -otildedieresis;1E4F -oubopomofo;3121 -overline;203E -overlinecenterline;FE4A -overlinecmb;0305 -overlinedashed;FE49 -overlinedblwavy;FE4C -overlinewavy;FE4B -overscore;00AF -ovowelsignbengali;09CB -ovowelsigndeva;094B -ovowelsigngujarati;0ACB -p;0070 -paampssquare;3380 -paasentosquare;332B -pabengali;09AA -pacute;1E55 -padeva;092A -pagedown;21DF -pageup;21DE -pagujarati;0AAA -pagurmukhi;0A2A -pahiragana;3071 -paiyannoithai;0E2F -pakatakana;30D1 -palatalizationcyrilliccmb;0484 -palochkacyrillic;04C0 -pansioskorean;317F -paragraph;00B6 -parallel;2225 -parenleft;0028 -parenleftaltonearabic;FD3E -parenleftbt;F8ED -parenleftex;F8EC -parenleftinferior;208D -parenleftmonospace;FF08 -parenleftsmall;FE59 -parenleftsuperior;207D -parenlefttp;F8EB -parenleftvertical;FE35 -parenright;0029 -parenrightaltonearabic;FD3F -parenrightbt;F8F8 -parenrightex;F8F7 -parenrightinferior;208E -parenrightmonospace;FF09 -parenrightsmall;FE5A -parenrightsuperior;207E -parenrighttp;F8F6 -parenrightvertical;FE36 -partialdiff;2202 -paseqhebrew;05C0 -pashtahebrew;0599 -pasquare;33A9 -patah;05B7 -patah11;05B7 -patah1d;05B7 -patah2a;05B7 -patahhebrew;05B7 -patahnarrowhebrew;05B7 -patahquarterhebrew;05B7 -patahwidehebrew;05B7 -pazerhebrew;05A1 -pbopomofo;3106 -pcircle;24DF -pdotaccent;1E57 -pe;05E4 -pecyrillic;043F -pedagesh;FB44 -pedageshhebrew;FB44 -peezisquare;333B -pefinaldageshhebrew;FB43 -peharabic;067E -peharmenian;057A -pehebrew;05E4 -pehfinalarabic;FB57 -pehinitialarabic;FB58 -pehiragana;307A -pehmedialarabic;FB59 -pekatakana;30DA -pemiddlehookcyrillic;04A7 -perafehebrew;FB4E -percent;0025 -percentarabic;066A -percentmonospace;FF05 -percentsmall;FE6A -period;002E -periodarmenian;0589 -periodcentered;00B7 -periodhalfwidth;FF61 -periodinferior;F6E7 -periodmonospace;FF0E -periodsmall;FE52 -periodsuperior;F6E8 -perispomenigreekcmb;0342 -perpendicular;22A5 -perthousand;2030 -peseta;20A7 -pfsquare;338A -phabengali;09AB -phadeva;092B -phagujarati;0AAB -phagurmukhi;0A2B -phi;03C6 -phi1;03D5 -phieuphacirclekorean;327A -phieuphaparenkorean;321A -phieuphcirclekorean;326C -phieuphkorean;314D -phieuphparenkorean;320C -philatin;0278 -phinthuthai;0E3A -phisymbolgreek;03D5 -phook;01A5 -phophanthai;0E1E -phophungthai;0E1C -phosamphaothai;0E20 -pi;03C0 -pieupacirclekorean;3273 -pieupaparenkorean;3213 -pieupcieuckorean;3176 -pieupcirclekorean;3265 -pieupkiyeokkorean;3172 -pieupkorean;3142 -pieupparenkorean;3205 -pieupsioskiyeokkorean;3174 -pieupsioskorean;3144 -pieupsiostikeutkorean;3175 -pieupthieuthkorean;3177 -pieuptikeutkorean;3173 -pihiragana;3074 -pikatakana;30D4 -pisymbolgreek;03D6 -piwrarmenian;0583 -plus;002B -plusbelowcmb;031F -pluscircle;2295 -plusminus;00B1 -plusmod;02D6 -plusmonospace;FF0B -plussmall;FE62 -plussuperior;207A -pmonospace;FF50 -pmsquare;33D8 -pohiragana;307D -pointingindexdownwhite;261F -pointingindexleftwhite;261C -pointingindexrightwhite;261E -pointingindexupwhite;261D -pokatakana;30DD -poplathai;0E1B -postalmark;3012 -postalmarkface;3020 -pparen;24AB -precedes;227A -prescription;211E -primemod;02B9 -primereversed;2035 -product;220F -projective;2305 -prolongedkana;30FC -propellor;2318 -propersubset;2282 -propersuperset;2283 -proportion;2237 -proportional;221D -psi;03C8 -psicyrillic;0471 -psilipneumatacyrilliccmb;0486 -pssquare;33B0 -puhiragana;3077 -pukatakana;30D7 -pvsquare;33B4 -pwsquare;33BA -q;0071 -qadeva;0958 -qadmahebrew;05A8 -qafarabic;0642 -qaffinalarabic;FED6 -qafinitialarabic;FED7 -qafmedialarabic;FED8 -qamats;05B8 -qamats10;05B8 -qamats1a;05B8 -qamats1c;05B8 -qamats27;05B8 -qamats29;05B8 -qamats33;05B8 -qamatsde;05B8 -qamatshebrew;05B8 -qamatsnarrowhebrew;05B8 -qamatsqatanhebrew;05B8 -qamatsqatannarrowhebrew;05B8 -qamatsqatanquarterhebrew;05B8 -qamatsqatanwidehebrew;05B8 -qamatsquarterhebrew;05B8 -qamatswidehebrew;05B8 -qarneyparahebrew;059F -qbopomofo;3111 -qcircle;24E0 -qhook;02A0 -qmonospace;FF51 -qof;05E7 -qofdagesh;FB47 -qofdageshhebrew;FB47 -qofhatafpatah;05E7 05B2 -qofhatafpatahhebrew;05E7 05B2 -qofhatafsegol;05E7 05B1 -qofhatafsegolhebrew;05E7 05B1 -qofhebrew;05E7 -qofhiriq;05E7 05B4 -qofhiriqhebrew;05E7 05B4 -qofholam;05E7 05B9 -qofholamhebrew;05E7 05B9 -qofpatah;05E7 05B7 -qofpatahhebrew;05E7 05B7 -qofqamats;05E7 05B8 -qofqamatshebrew;05E7 05B8 -qofqubuts;05E7 05BB -qofqubutshebrew;05E7 05BB -qofsegol;05E7 05B6 -qofsegolhebrew;05E7 05B6 -qofsheva;05E7 05B0 -qofshevahebrew;05E7 05B0 -qoftsere;05E7 05B5 -qoftserehebrew;05E7 05B5 -qparen;24AC -quarternote;2669 -qubuts;05BB -qubuts18;05BB -qubuts25;05BB -qubuts31;05BB -qubutshebrew;05BB -qubutsnarrowhebrew;05BB -qubutsquarterhebrew;05BB -qubutswidehebrew;05BB -question;003F -questionarabic;061F -questionarmenian;055E -questiondown;00BF -questiondownsmall;F7BF -questiongreek;037E -questionmonospace;FF1F -questionsmall;F73F -quotedbl;0022 -quotedblbase;201E -quotedblleft;201C -quotedblmonospace;FF02 -quotedblprime;301E -quotedblprimereversed;301D -quotedblright;201D -quoteleft;2018 -quoteleftreversed;201B -quotereversed;201B -quoteright;2019 -quoterightn;0149 -quotesinglbase;201A -quotesingle;0027 -quotesinglemonospace;FF07 -r;0072 -raarmenian;057C -rabengali;09B0 -racute;0155 -radeva;0930 -radical;221A -radicalex;F8E5 -radoverssquare;33AE -radoverssquaredsquare;33AF -radsquare;33AD -rafe;05BF -rafehebrew;05BF -ragujarati;0AB0 -ragurmukhi;0A30 -rahiragana;3089 -rakatakana;30E9 -rakatakanahalfwidth;FF97 -ralowerdiagonalbengali;09F1 -ramiddlediagonalbengali;09F0 -ramshorn;0264 -ratio;2236 -rbopomofo;3116 -rcaron;0159 -rcedilla;0157 -rcircle;24E1 -rcommaaccent;0157 -rdblgrave;0211 -rdotaccent;1E59 -rdotbelow;1E5B -rdotbelowmacron;1E5D -referencemark;203B -reflexsubset;2286 -reflexsuperset;2287 -registered;00AE -registersans;F8E8 -registerserif;F6DA -reharabic;0631 -reharmenian;0580 -rehfinalarabic;FEAE -rehiragana;308C -rehyehaleflamarabic;0631 FEF3 FE8E 0644 -rekatakana;30EC -rekatakanahalfwidth;FF9A -resh;05E8 -reshdageshhebrew;FB48 -reshhatafpatah;05E8 05B2 -reshhatafpatahhebrew;05E8 05B2 -reshhatafsegol;05E8 05B1 -reshhatafsegolhebrew;05E8 05B1 -reshhebrew;05E8 -reshhiriq;05E8 05B4 -reshhiriqhebrew;05E8 05B4 -reshholam;05E8 05B9 -reshholamhebrew;05E8 05B9 -reshpatah;05E8 05B7 -reshpatahhebrew;05E8 05B7 -reshqamats;05E8 05B8 -reshqamatshebrew;05E8 05B8 -reshqubuts;05E8 05BB -reshqubutshebrew;05E8 05BB -reshsegol;05E8 05B6 -reshsegolhebrew;05E8 05B6 -reshsheva;05E8 05B0 -reshshevahebrew;05E8 05B0 -reshtsere;05E8 05B5 -reshtserehebrew;05E8 05B5 -reversedtilde;223D -reviahebrew;0597 -reviamugrashhebrew;0597 -revlogicalnot;2310 -rfishhook;027E -rfishhookreversed;027F -rhabengali;09DD -rhadeva;095D -rho;03C1 -rhook;027D -rhookturned;027B -rhookturnedsuperior;02B5 -rhosymbolgreek;03F1 -rhotichookmod;02DE -rieulacirclekorean;3271 -rieulaparenkorean;3211 -rieulcirclekorean;3263 -rieulhieuhkorean;3140 -rieulkiyeokkorean;313A -rieulkiyeoksioskorean;3169 -rieulkorean;3139 -rieulmieumkorean;313B -rieulpansioskorean;316C -rieulparenkorean;3203 -rieulphieuphkorean;313F -rieulpieupkorean;313C -rieulpieupsioskorean;316B -rieulsioskorean;313D -rieulthieuthkorean;313E -rieultikeutkorean;316A -rieulyeorinhieuhkorean;316D -rightangle;221F -righttackbelowcmb;0319 -righttriangle;22BF -rihiragana;308A -rikatakana;30EA -rikatakanahalfwidth;FF98 -ring;02DA -ringbelowcmb;0325 -ringcmb;030A -ringhalfleft;02BF -ringhalfleftarmenian;0559 -ringhalfleftbelowcmb;031C -ringhalfleftcentered;02D3 -ringhalfright;02BE -ringhalfrightbelowcmb;0339 -ringhalfrightcentered;02D2 -rinvertedbreve;0213 -rittorusquare;3351 -rlinebelow;1E5F -rlongleg;027C -rlonglegturned;027A -rmonospace;FF52 -rohiragana;308D -rokatakana;30ED -rokatakanahalfwidth;FF9B -roruathai;0E23 -rparen;24AD -rrabengali;09DC -rradeva;0931 -rragurmukhi;0A5C -rreharabic;0691 -rrehfinalarabic;FB8D -rrvocalicbengali;09E0 -rrvocalicdeva;0960 -rrvocalicgujarati;0AE0 -rrvocalicvowelsignbengali;09C4 -rrvocalicvowelsigndeva;0944 -rrvocalicvowelsigngujarati;0AC4 -rsuperior;F6F1 -rtblock;2590 -rturned;0279 -rturnedsuperior;02B4 -ruhiragana;308B -rukatakana;30EB -rukatakanahalfwidth;FF99 -rupeemarkbengali;09F2 -rupeesignbengali;09F3 -rupiah;F6DD -ruthai;0E24 -rvocalicbengali;098B -rvocalicdeva;090B -rvocalicgujarati;0A8B -rvocalicvowelsignbengali;09C3 -rvocalicvowelsigndeva;0943 -rvocalicvowelsigngujarati;0AC3 -s;0073 -sabengali;09B8 -sacute;015B -sacutedotaccent;1E65 -sadarabic;0635 -sadeva;0938 -sadfinalarabic;FEBA -sadinitialarabic;FEBB -sadmedialarabic;FEBC -sagujarati;0AB8 -sagurmukhi;0A38 -sahiragana;3055 -sakatakana;30B5 -sakatakanahalfwidth;FF7B -sallallahoualayhewasallamarabic;FDFA -samekh;05E1 -samekhdagesh;FB41 -samekhdageshhebrew;FB41 -samekhhebrew;05E1 -saraaathai;0E32 -saraaethai;0E41 -saraaimaimalaithai;0E44 -saraaimaimuanthai;0E43 -saraamthai;0E33 -saraathai;0E30 -saraethai;0E40 -saraiileftthai;F886 -saraiithai;0E35 -saraileftthai;F885 -saraithai;0E34 -saraothai;0E42 -saraueeleftthai;F888 -saraueethai;0E37 -saraueleftthai;F887 -sarauethai;0E36 -sarauthai;0E38 -sarauuthai;0E39 -sbopomofo;3119 -scaron;0161 -scarondotaccent;1E67 -scedilla;015F -schwa;0259 -schwacyrillic;04D9 -schwadieresiscyrillic;04DB -schwahook;025A -scircle;24E2 -scircumflex;015D -scommaaccent;0219 -sdotaccent;1E61 -sdotbelow;1E63 -sdotbelowdotaccent;1E69 -seagullbelowcmb;033C -second;2033 -secondtonechinese;02CA -section;00A7 -seenarabic;0633 -seenfinalarabic;FEB2 -seeninitialarabic;FEB3 -seenmedialarabic;FEB4 -segol;05B6 -segol13;05B6 -segol1f;05B6 -segol2c;05B6 -segolhebrew;05B6 -segolnarrowhebrew;05B6 -segolquarterhebrew;05B6 -segoltahebrew;0592 -segolwidehebrew;05B6 -seharmenian;057D -sehiragana;305B -sekatakana;30BB -sekatakanahalfwidth;FF7E -semicolon;003B -semicolonarabic;061B -semicolonmonospace;FF1B -semicolonsmall;FE54 -semivoicedmarkkana;309C -semivoicedmarkkanahalfwidth;FF9F -sentisquare;3322 -sentosquare;3323 -seven;0037 -sevenarabic;0667 -sevenbengali;09ED -sevencircle;2466 -sevencircleinversesansserif;2790 -sevendeva;096D -seveneighths;215E -sevengujarati;0AED -sevengurmukhi;0A6D -sevenhackarabic;0667 -sevenhangzhou;3027 -sevenideographicparen;3226 -seveninferior;2087 -sevenmonospace;FF17 -sevenoldstyle;F737 -sevenparen;247A -sevenperiod;248E -sevenpersian;06F7 -sevenroman;2176 -sevensuperior;2077 -seventeencircle;2470 -seventeenparen;2484 -seventeenperiod;2498 -seventhai;0E57 -sfthyphen;00AD -shaarmenian;0577 -shabengali;09B6 -shacyrillic;0448 -shaddaarabic;0651 -shaddadammaarabic;FC61 -shaddadammatanarabic;FC5E -shaddafathaarabic;FC60 -shaddafathatanarabic;0651 064B -shaddakasraarabic;FC62 -shaddakasratanarabic;FC5F -shade;2592 -shadedark;2593 -shadelight;2591 -shademedium;2592 -shadeva;0936 -shagujarati;0AB6 -shagurmukhi;0A36 -shalshelethebrew;0593 -shbopomofo;3115 -shchacyrillic;0449 -sheenarabic;0634 -sheenfinalarabic;FEB6 -sheeninitialarabic;FEB7 -sheenmedialarabic;FEB8 -sheicoptic;03E3 -sheqel;20AA -sheqelhebrew;20AA -sheva;05B0 -sheva115;05B0 -sheva15;05B0 -sheva22;05B0 -sheva2e;05B0 -shevahebrew;05B0 -shevanarrowhebrew;05B0 -shevaquarterhebrew;05B0 -shevawidehebrew;05B0 -shhacyrillic;04BB -shimacoptic;03ED -shin;05E9 -shindagesh;FB49 -shindageshhebrew;FB49 -shindageshshindot;FB2C -shindageshshindothebrew;FB2C -shindageshsindot;FB2D -shindageshsindothebrew;FB2D -shindothebrew;05C1 -shinhebrew;05E9 -shinshindot;FB2A -shinshindothebrew;FB2A -shinsindot;FB2B -shinsindothebrew;FB2B -shook;0282 -sigma;03C3 -sigma1;03C2 -sigmafinal;03C2 -sigmalunatesymbolgreek;03F2 -sihiragana;3057 -sikatakana;30B7 -sikatakanahalfwidth;FF7C -siluqhebrew;05BD -siluqlefthebrew;05BD -similar;223C -sindothebrew;05C2 -siosacirclekorean;3274 -siosaparenkorean;3214 -sioscieuckorean;317E -sioscirclekorean;3266 -sioskiyeokkorean;317A -sioskorean;3145 -siosnieunkorean;317B -siosparenkorean;3206 -siospieupkorean;317D -siostikeutkorean;317C -six;0036 -sixarabic;0666 -sixbengali;09EC -sixcircle;2465 -sixcircleinversesansserif;278F -sixdeva;096C -sixgujarati;0AEC -sixgurmukhi;0A6C -sixhackarabic;0666 -sixhangzhou;3026 -sixideographicparen;3225 -sixinferior;2086 -sixmonospace;FF16 -sixoldstyle;F736 -sixparen;2479 -sixperiod;248D -sixpersian;06F6 -sixroman;2175 -sixsuperior;2076 -sixteencircle;246F -sixteencurrencydenominatorbengali;09F9 -sixteenparen;2483 -sixteenperiod;2497 -sixthai;0E56 -slash;002F -slashmonospace;FF0F -slong;017F -slongdotaccent;1E9B -smileface;263A -smonospace;FF53 -sofpasuqhebrew;05C3 -softhyphen;00AD -softsigncyrillic;044C -sohiragana;305D -sokatakana;30BD -sokatakanahalfwidth;FF7F -soliduslongoverlaycmb;0338 -solidusshortoverlaycmb;0337 -sorusithai;0E29 -sosalathai;0E28 -sosothai;0E0B -sosuathai;0E2A -space;0020 -spacehackarabic;0020 -spade;2660 -spadesuitblack;2660 -spadesuitwhite;2664 -sparen;24AE -squarebelowcmb;033B -squarecc;33C4 -squarecm;339D -squarediagonalcrosshatchfill;25A9 -squarehorizontalfill;25A4 -squarekg;338F -squarekm;339E -squarekmcapital;33CE -squareln;33D1 -squarelog;33D2 -squaremg;338E -squaremil;33D5 -squaremm;339C -squaremsquared;33A1 -squareorthogonalcrosshatchfill;25A6 -squareupperlefttolowerrightfill;25A7 -squareupperrighttolowerleftfill;25A8 -squareverticalfill;25A5 -squarewhitewithsmallblack;25A3 -srsquare;33DB -ssabengali;09B7 -ssadeva;0937 -ssagujarati;0AB7 -ssangcieuckorean;3149 -ssanghieuhkorean;3185 -ssangieungkorean;3180 -ssangkiyeokkorean;3132 -ssangnieunkorean;3165 -ssangpieupkorean;3143 -ssangsioskorean;3146 -ssangtikeutkorean;3138 -ssuperior;F6F2 -sterling;00A3 -sterlingmonospace;FFE1 -strokelongoverlaycmb;0336 -strokeshortoverlaycmb;0335 -subset;2282 -subsetnotequal;228A -subsetorequal;2286 -succeeds;227B -suchthat;220B -suhiragana;3059 -sukatakana;30B9 -sukatakanahalfwidth;FF7D -sukunarabic;0652 -summation;2211 -sun;263C -superset;2283 -supersetnotequal;228B -supersetorequal;2287 -svsquare;33DC -syouwaerasquare;337C -t;0074 -tabengali;09A4 -tackdown;22A4 -tackleft;22A3 -tadeva;0924 -tagujarati;0AA4 -tagurmukhi;0A24 -taharabic;0637 -tahfinalarabic;FEC2 -tahinitialarabic;FEC3 -tahiragana;305F -tahmedialarabic;FEC4 -taisyouerasquare;337D -takatakana;30BF -takatakanahalfwidth;FF80 -tatweelarabic;0640 -tau;03C4 -tav;05EA -tavdages;FB4A -tavdagesh;FB4A -tavdageshhebrew;FB4A -tavhebrew;05EA -tbar;0167 -tbopomofo;310A -tcaron;0165 -tccurl;02A8 -tcedilla;0163 -tcheharabic;0686 -tchehfinalarabic;FB7B -tchehinitialarabic;FB7C -tchehmedialarabic;FB7D -tchehmeeminitialarabic;FB7C FEE4 -tcircle;24E3 -tcircumflexbelow;1E71 -tcommaaccent;0163 -tdieresis;1E97 -tdotaccent;1E6B -tdotbelow;1E6D -tecyrillic;0442 -tedescendercyrillic;04AD -teharabic;062A -tehfinalarabic;FE96 -tehhahinitialarabic;FCA2 -tehhahisolatedarabic;FC0C -tehinitialarabic;FE97 -tehiragana;3066 -tehjeeminitialarabic;FCA1 -tehjeemisolatedarabic;FC0B -tehmarbutaarabic;0629 -tehmarbutafinalarabic;FE94 -tehmedialarabic;FE98 -tehmeeminitialarabic;FCA4 -tehmeemisolatedarabic;FC0E -tehnoonfinalarabic;FC73 -tekatakana;30C6 -tekatakanahalfwidth;FF83 -telephone;2121 -telephoneblack;260E -telishagedolahebrew;05A0 -telishaqetanahebrew;05A9 -tencircle;2469 -tenideographicparen;3229 -tenparen;247D -tenperiod;2491 -tenroman;2179 -tesh;02A7 -tet;05D8 -tetdagesh;FB38 -tetdageshhebrew;FB38 -tethebrew;05D8 -tetsecyrillic;04B5 -tevirhebrew;059B -tevirlefthebrew;059B -thabengali;09A5 -thadeva;0925 -thagujarati;0AA5 -thagurmukhi;0A25 -thalarabic;0630 -thalfinalarabic;FEAC -thanthakhatlowleftthai;F898 -thanthakhatlowrightthai;F897 -thanthakhatthai;0E4C -thanthakhatupperleftthai;F896 -theharabic;062B -thehfinalarabic;FE9A -thehinitialarabic;FE9B -thehmedialarabic;FE9C -thereexists;2203 -therefore;2234 -theta;03B8 -theta1;03D1 -thetasymbolgreek;03D1 -thieuthacirclekorean;3279 -thieuthaparenkorean;3219 -thieuthcirclekorean;326B -thieuthkorean;314C -thieuthparenkorean;320B -thirteencircle;246C -thirteenparen;2480 -thirteenperiod;2494 -thonangmonthothai;0E11 -thook;01AD -thophuthaothai;0E12 -thorn;00FE -thothahanthai;0E17 -thothanthai;0E10 -thothongthai;0E18 -thothungthai;0E16 -thousandcyrillic;0482 -thousandsseparatorarabic;066C -thousandsseparatorpersian;066C -three;0033 -threearabic;0663 -threebengali;09E9 -threecircle;2462 -threecircleinversesansserif;278C -threedeva;0969 -threeeighths;215C -threegujarati;0AE9 -threegurmukhi;0A69 -threehackarabic;0663 -threehangzhou;3023 -threeideographicparen;3222 -threeinferior;2083 -threemonospace;FF13 -threenumeratorbengali;09F6 -threeoldstyle;F733 -threeparen;2476 -threeperiod;248A -threepersian;06F3 -threequarters;00BE -threequartersemdash;F6DE -threeroman;2172 -threesuperior;00B3 -threethai;0E53 -thzsquare;3394 -tihiragana;3061 -tikatakana;30C1 -tikatakanahalfwidth;FF81 -tikeutacirclekorean;3270 -tikeutaparenkorean;3210 -tikeutcirclekorean;3262 -tikeutkorean;3137 -tikeutparenkorean;3202 -tilde;02DC -tildebelowcmb;0330 -tildecmb;0303 -tildecomb;0303 -tildedoublecmb;0360 -tildeoperator;223C -tildeoverlaycmb;0334 -tildeverticalcmb;033E -timescircle;2297 -tipehahebrew;0596 -tipehalefthebrew;0596 -tippigurmukhi;0A70 -titlocyrilliccmb;0483 -tiwnarmenian;057F -tlinebelow;1E6F -tmonospace;FF54 -toarmenian;0569 -tohiragana;3068 -tokatakana;30C8 -tokatakanahalfwidth;FF84 -tonebarextrahighmod;02E5 -tonebarextralowmod;02E9 -tonebarhighmod;02E6 -tonebarlowmod;02E8 -tonebarmidmod;02E7 -tonefive;01BD -tonesix;0185 -tonetwo;01A8 -tonos;0384 -tonsquare;3327 -topatakthai;0E0F -tortoiseshellbracketleft;3014 -tortoiseshellbracketleftsmall;FE5D -tortoiseshellbracketleftvertical;FE39 -tortoiseshellbracketright;3015 -tortoiseshellbracketrightsmall;FE5E -tortoiseshellbracketrightvertical;FE3A -totaothai;0E15 -tpalatalhook;01AB -tparen;24AF -trademark;2122 -trademarksans;F8EA -trademarkserif;F6DB -tretroflexhook;0288 -triagdn;25BC -triaglf;25C4 -triagrt;25BA -triagup;25B2 -ts;02A6 -tsadi;05E6 -tsadidagesh;FB46 -tsadidageshhebrew;FB46 -tsadihebrew;05E6 -tsecyrillic;0446 -tsere;05B5 -tsere12;05B5 -tsere1e;05B5 -tsere2b;05B5 -tserehebrew;05B5 -tserenarrowhebrew;05B5 -tserequarterhebrew;05B5 -tserewidehebrew;05B5 -tshecyrillic;045B -tsuperior;F6F3 -ttabengali;099F -ttadeva;091F -ttagujarati;0A9F -ttagurmukhi;0A1F -tteharabic;0679 -ttehfinalarabic;FB67 -ttehinitialarabic;FB68 -ttehmedialarabic;FB69 -tthabengali;09A0 -tthadeva;0920 -tthagujarati;0AA0 -tthagurmukhi;0A20 -tturned;0287 -tuhiragana;3064 -tukatakana;30C4 -tukatakanahalfwidth;FF82 -tusmallhiragana;3063 -tusmallkatakana;30C3 -tusmallkatakanahalfwidth;FF6F -twelvecircle;246B -twelveparen;247F -twelveperiod;2493 -twelveroman;217B -twentycircle;2473 -twentyhangzhou;5344 -twentyparen;2487 -twentyperiod;249B -two;0032 -twoarabic;0662 -twobengali;09E8 -twocircle;2461 -twocircleinversesansserif;278B -twodeva;0968 -twodotenleader;2025 -twodotleader;2025 -twodotleadervertical;FE30 -twogujarati;0AE8 -twogurmukhi;0A68 -twohackarabic;0662 -twohangzhou;3022 -twoideographicparen;3221 -twoinferior;2082 -twomonospace;FF12 -twonumeratorbengali;09F5 -twooldstyle;F732 -twoparen;2475 -twoperiod;2489 -twopersian;06F2 -tworoman;2171 -twostroke;01BB -twosuperior;00B2 -twothai;0E52 -twothirds;2154 -u;0075 -uacute;00FA -ubar;0289 -ubengali;0989 -ubopomofo;3128 -ubreve;016D -ucaron;01D4 -ucircle;24E4 -ucircumflex;00FB -ucircumflexbelow;1E77 -ucyrillic;0443 -udattadeva;0951 -udblacute;0171 -udblgrave;0215 -udeva;0909 -udieresis;00FC -udieresisacute;01D8 -udieresisbelow;1E73 -udieresiscaron;01DA -udieresiscyrillic;04F1 -udieresisgrave;01DC -udieresismacron;01D6 -udotbelow;1EE5 -ugrave;00F9 -ugujarati;0A89 -ugurmukhi;0A09 -uhiragana;3046 -uhookabove;1EE7 -uhorn;01B0 -uhornacute;1EE9 -uhorndotbelow;1EF1 -uhorngrave;1EEB -uhornhookabove;1EED -uhorntilde;1EEF -uhungarumlaut;0171 -uhungarumlautcyrillic;04F3 -uinvertedbreve;0217 -ukatakana;30A6 -ukatakanahalfwidth;FF73 -ukcyrillic;0479 -ukorean;315C -umacron;016B -umacroncyrillic;04EF -umacrondieresis;1E7B -umatragurmukhi;0A41 -umonospace;FF55 -underscore;005F -underscoredbl;2017 -underscoremonospace;FF3F -underscorevertical;FE33 -underscorewavy;FE4F -union;222A -universal;2200 -uogonek;0173 -uparen;24B0 -upblock;2580 -upperdothebrew;05C4 -upsilon;03C5 -upsilondieresis;03CB -upsilondieresistonos;03B0 -upsilonlatin;028A -upsilontonos;03CD -uptackbelowcmb;031D -uptackmod;02D4 -uragurmukhi;0A73 -uring;016F -ushortcyrillic;045E -usmallhiragana;3045 -usmallkatakana;30A5 -usmallkatakanahalfwidth;FF69 -ustraightcyrillic;04AF -ustraightstrokecyrillic;04B1 -utilde;0169 -utildeacute;1E79 -utildebelow;1E75 -uubengali;098A -uudeva;090A -uugujarati;0A8A -uugurmukhi;0A0A -uumatragurmukhi;0A42 -uuvowelsignbengali;09C2 -uuvowelsigndeva;0942 -uuvowelsigngujarati;0AC2 -uvowelsignbengali;09C1 -uvowelsigndeva;0941 -uvowelsigngujarati;0AC1 -v;0076 -vadeva;0935 -vagujarati;0AB5 -vagurmukhi;0A35 -vakatakana;30F7 -vav;05D5 -vavdagesh;FB35 -vavdagesh65;FB35 -vavdageshhebrew;FB35 -vavhebrew;05D5 -vavholam;FB4B -vavholamhebrew;FB4B -vavvavhebrew;05F0 -vavyodhebrew;05F1 -vcircle;24E5 -vdotbelow;1E7F -vecyrillic;0432 -veharabic;06A4 -vehfinalarabic;FB6B -vehinitialarabic;FB6C -vehmedialarabic;FB6D -vekatakana;30F9 -venus;2640 -verticalbar;007C -verticallineabovecmb;030D -verticallinebelowcmb;0329 -verticallinelowmod;02CC -verticallinemod;02C8 -vewarmenian;057E -vhook;028B -vikatakana;30F8 -viramabengali;09CD -viramadeva;094D -viramagujarati;0ACD -visargabengali;0983 -visargadeva;0903 -visargagujarati;0A83 -vmonospace;FF56 -voarmenian;0578 -voicediterationhiragana;309E -voicediterationkatakana;30FE -voicedmarkkana;309B -voicedmarkkanahalfwidth;FF9E -vokatakana;30FA -vparen;24B1 -vtilde;1E7D -vturned;028C -vuhiragana;3094 -vukatakana;30F4 -w;0077 -wacute;1E83 -waekorean;3159 -wahiragana;308F -wakatakana;30EF -wakatakanahalfwidth;FF9C -wakorean;3158 -wasmallhiragana;308E -wasmallkatakana;30EE -wattosquare;3357 -wavedash;301C -wavyunderscorevertical;FE34 -wawarabic;0648 -wawfinalarabic;FEEE -wawhamzaabovearabic;0624 -wawhamzaabovefinalarabic;FE86 -wbsquare;33DD -wcircle;24E6 -wcircumflex;0175 -wdieresis;1E85 -wdotaccent;1E87 -wdotbelow;1E89 -wehiragana;3091 -weierstrass;2118 -wekatakana;30F1 -wekorean;315E -weokorean;315D -wgrave;1E81 -whitebullet;25E6 -whitecircle;25CB -whitecircleinverse;25D9 -whitecornerbracketleft;300E -whitecornerbracketleftvertical;FE43 -whitecornerbracketright;300F -whitecornerbracketrightvertical;FE44 -whitediamond;25C7 -whitediamondcontainingblacksmalldiamond;25C8 -whitedownpointingsmalltriangle;25BF -whitedownpointingtriangle;25BD -whiteleftpointingsmalltriangle;25C3 -whiteleftpointingtriangle;25C1 -whitelenticularbracketleft;3016 -whitelenticularbracketright;3017 -whiterightpointingsmalltriangle;25B9 -whiterightpointingtriangle;25B7 -whitesmallsquare;25AB -whitesmilingface;263A -whitesquare;25A1 -whitestar;2606 -whitetelephone;260F -whitetortoiseshellbracketleft;3018 -whitetortoiseshellbracketright;3019 -whiteuppointingsmalltriangle;25B5 -whiteuppointingtriangle;25B3 -wihiragana;3090 -wikatakana;30F0 -wikorean;315F -wmonospace;FF57 -wohiragana;3092 -wokatakana;30F2 -wokatakanahalfwidth;FF66 -won;20A9 -wonmonospace;FFE6 -wowaenthai;0E27 -wparen;24B2 -wring;1E98 -wsuperior;02B7 -wturned;028D -wynn;01BF -x;0078 -xabovecmb;033D -xbopomofo;3112 -xcircle;24E7 -xdieresis;1E8D -xdotaccent;1E8B -xeharmenian;056D -xi;03BE -xmonospace;FF58 -xparen;24B3 -xsuperior;02E3 -y;0079 -yaadosquare;334E -yabengali;09AF -yacute;00FD -yadeva;092F -yaekorean;3152 -yagujarati;0AAF -yagurmukhi;0A2F -yahiragana;3084 -yakatakana;30E4 -yakatakanahalfwidth;FF94 -yakorean;3151 -yamakkanthai;0E4E -yasmallhiragana;3083 -yasmallkatakana;30E3 -yasmallkatakanahalfwidth;FF6C -yatcyrillic;0463 -ycircle;24E8 -ycircumflex;0177 -ydieresis;00FF -ydotaccent;1E8F -ydotbelow;1EF5 -yeharabic;064A -yehbarreearabic;06D2 -yehbarreefinalarabic;FBAF -yehfinalarabic;FEF2 -yehhamzaabovearabic;0626 -yehhamzaabovefinalarabic;FE8A -yehhamzaaboveinitialarabic;FE8B -yehhamzaabovemedialarabic;FE8C -yehinitialarabic;FEF3 -yehmedialarabic;FEF4 -yehmeeminitialarabic;FCDD -yehmeemisolatedarabic;FC58 -yehnoonfinalarabic;FC94 -yehthreedotsbelowarabic;06D1 -yekorean;3156 -yen;00A5 -yenmonospace;FFE5 -yeokorean;3155 -yeorinhieuhkorean;3186 -yerahbenyomohebrew;05AA -yerahbenyomolefthebrew;05AA -yericyrillic;044B -yerudieresiscyrillic;04F9 -yesieungkorean;3181 -yesieungpansioskorean;3183 -yesieungsioskorean;3182 -yetivhebrew;059A -ygrave;1EF3 -yhook;01B4 -yhookabove;1EF7 -yiarmenian;0575 -yicyrillic;0457 -yikorean;3162 -yinyang;262F -yiwnarmenian;0582 -ymonospace;FF59 -yod;05D9 -yoddagesh;FB39 -yoddageshhebrew;FB39 -yodhebrew;05D9 -yodyodhebrew;05F2 -yodyodpatahhebrew;FB1F -yohiragana;3088 -yoikorean;3189 -yokatakana;30E8 -yokatakanahalfwidth;FF96 -yokorean;315B -yosmallhiragana;3087 -yosmallkatakana;30E7 -yosmallkatakanahalfwidth;FF6E -yotgreek;03F3 -yoyaekorean;3188 -yoyakorean;3187 -yoyakthai;0E22 -yoyingthai;0E0D -yparen;24B4 -ypogegrammeni;037A -ypogegrammenigreekcmb;0345 -yr;01A6 -yring;1E99 -ysuperior;02B8 -ytilde;1EF9 -yturned;028E -yuhiragana;3086 -yuikorean;318C -yukatakana;30E6 -yukatakanahalfwidth;FF95 -yukorean;3160 -yusbigcyrillic;046B -yusbigiotifiedcyrillic;046D -yuslittlecyrillic;0467 -yuslittleiotifiedcyrillic;0469 -yusmallhiragana;3085 -yusmallkatakana;30E5 -yusmallkatakanahalfwidth;FF6D -yuyekorean;318B -yuyeokorean;318A -yyabengali;09DF -yyadeva;095F -z;007A -zaarmenian;0566 -zacute;017A -zadeva;095B -zagurmukhi;0A5B -zaharabic;0638 -zahfinalarabic;FEC6 -zahinitialarabic;FEC7 -zahiragana;3056 -zahmedialarabic;FEC8 -zainarabic;0632 -zainfinalarabic;FEB0 -zakatakana;30B6 -zaqefgadolhebrew;0595 -zaqefqatanhebrew;0594 -zarqahebrew;0598 -zayin;05D6 -zayindagesh;FB36 -zayindageshhebrew;FB36 -zayinhebrew;05D6 -zbopomofo;3117 -zcaron;017E -zcircle;24E9 -zcircumflex;1E91 -zcurl;0291 -zdot;017C -zdotaccent;017C -zdotbelow;1E93 -zecyrillic;0437 -zedescendercyrillic;0499 -zedieresiscyrillic;04DF -zehiragana;305C -zekatakana;30BC -zero;0030 -zeroarabic;0660 -zerobengali;09E6 -zerodeva;0966 -zerogujarati;0AE6 -zerogurmukhi;0A66 -zerohackarabic;0660 -zeroinferior;2080 -zeromonospace;FF10 -zerooldstyle;F730 -zeropersian;06F0 -zerosuperior;2070 -zerothai;0E50 -zerowidthjoiner;FEFF -zerowidthnonjoiner;200C -zerowidthspace;200B -zeta;03B6 -zhbopomofo;3113 -zhearmenian;056A -zhebrevecyrillic;04C2 -zhecyrillic;0436 -zhedescendercyrillic;0497 -zhedieresiscyrillic;04DD -zihiragana;3058 -zikatakana;30B8 -zinorhebrew;05AE -zlinebelow;1E95 -zmonospace;FF5A -zohiragana;305E -zokatakana;30BE -zparen;24B5 -zretroflexhook;0290 -zstroke;01B6 -zuhiragana;305A -zukatakana;30BA -""" - - -# string table management -# -class StringTable: - def __init__( self, name_list, master_table_name ): - self.names = name_list - self.master_table = master_table_name - self.indices = {} - index = 0 - - for name in name_list: - self.indices[name] = index - index += len( name ) + 1 - - self.total = index - - def dump( self, file ): - write = file.write - write( " static const char " + self.master_table + - "[" + repr( self.total ) + "] =\n" ) - write( " {\n" ) - - line = "" - for name in self.names: - line += " '" - line += string.join( ( re.findall( ".", name ) ), "','" ) - line += "', 0,\n" - - write( line + " };\n\n\n" ) - - def dump_sublist( self, file, table_name, macro_name, sublist ): - write = file.write - write( "#define " + macro_name + " " + repr( len( sublist ) ) + "\n\n" ) - - write( " /* Values are offsets into the `" + - self.master_table + "' table */\n\n" ) - write( " static const short " + table_name + - "[" + macro_name + "] =\n" ) - write( " {\n" ) - - line = " " - comma = "" - col = 0 - - for name in sublist: - line += comma - line += "%4d" % self.indices[name] - col += 1 - comma = "," - if col == 14: - col = 0 - comma = ",\n " - - write( line + "\n };\n\n\n" ) - - -# We now store the Adobe Glyph List in compressed form. The list is put -# into a data structure called `trie' (because it has a tree-like -# appearance). Consider, for example, that you want to store the -# following name mapping: -# -# A => 1 -# Aacute => 6 -# Abalon => 2 -# Abstract => 4 -# -# It is possible to store the entries as follows. -# -# A => 1 -# | -# +-acute => 6 -# | -# +-b -# | -# +-alon => 2 -# | -# +-stract => 4 -# -# We see that each node in the trie has: -# -# - one or more `letters' -# - an optional value -# - zero or more child nodes -# -# The first step is to call -# -# root = StringNode( "", 0 ) -# for word in map.values(): -# root.add( word, map[word] ) -# -# which creates a large trie where each node has only one children. -# -# Executing -# -# root = root.optimize() -# -# optimizes the trie by merging the letters of successive nodes whenever -# possible. -# -# Each node of the trie is stored as follows. -# -# - First the node's letter, according to the following scheme. We -# use the fact that in the AGL no name contains character codes > 127. -# -# name bitsize description -# ---------------------------------------------------------------- -# notlast 1 Set to 1 if this is not the last letter -# in the word. -# ascii 7 The letter's ASCII value. -# -# - The letter is followed by a children count and the value of the -# current key (if any). Again we can do some optimization because all -# AGL entries are from the BMP; this means that 16 bits are sufficient -# to store its Unicode values. Additionally, no node has more than -# 127 children. -# -# name bitsize description -# ----------------------------------------- -# hasvalue 1 Set to 1 if a 16-bit Unicode value follows. -# num_children 7 Number of childrens. Can be 0 only if -# `hasvalue' is set to 1. -# value 16 Optional Unicode value. -# -# - A node is finished by a list of 16bit absolute offsets to the -# children, which must be sorted in increasing order of their first -# letter. -# -# For simplicity, all 16bit quantities are stored in big-endian order. -# -# The root node has first letter = 0, and no value. -# -class StringNode: - def __init__( self, letter, value ): - self.letter = letter - self.value = value - self.children = {} - - def __cmp__( self, other ): - return ord( self.letter[0] ) - ord( other.letter[0] ) - - def add( self, word, value ): - if len( word ) == 0: - self.value = value - return - - letter = word[0] - word = word[1:] - - if self.children.has_key( letter ): - child = self.children[letter] - else: - child = StringNode( letter, 0 ) - self.children[letter] = child - - child.add( word, value ) - - def optimize( self ): - # optimize all children first - children = self.children.values() - self.children = {} - - for child in children: - self.children[child.letter[0]] = child.optimize() - - # don't optimize if there's a value, - # if we don't have any child or if we - # have more than one child - if ( self.value != 0 ) or ( not children ) or len( children ) > 1: - return self - - child = children[0] - - self.letter += child.letter - self.value = child.value - self.children = child.children - - return self - - def dump_debug( self, write, margin ): - # this is used during debugging - line = margin + "+-" - if len( self.letter ) == 0: - line += "" - else: - line += self.letter - - if self.value: - line += " => " + repr( self.value ) - - write( line + "\n" ) - - if self.children: - margin += "| " - for child in self.children.values(): - child.dump_debug( write, margin ) - - def locate( self, index ): - self.index = index - if len( self.letter ) > 0: - index += len( self.letter ) + 1 - else: - index += 2 - - if self.value != 0: - index += 2 - - children = self.children.values() - children.sort() - - index += 2 * len( children ) - for child in children: - index = child.locate( index ) - - return index - - def store( self, storage ): - # write the letters - l = len( self.letter ) - if l == 0: - storage += struct.pack( "B", 0 ) - else: - for n in range( l ): - val = ord( self.letter[n] ) - if n < l - 1: - val += 128 - storage += struct.pack( "B", val ) - - # write the count - children = self.children.values() - children.sort() - - count = len( children ) - - if self.value != 0: - storage += struct.pack( "!BH", count + 128, self.value ) - else: - storage += struct.pack( "B", count ) - - for child in children: - storage += struct.pack( "!H", child.index ) - - for child in children: - storage = child.store( storage ) - - return storage - - -def adobe_glyph_values(): - """return the list of glyph names and their unicode values""" - - lines = string.split( adobe_glyph_list, '\n' ) - glyphs = [] - values = [] - - for line in lines: - if line: - fields = string.split( line, ';' ) -# print fields[1] + ' - ' + fields[0] - subfields = string.split( fields[1], ' ' ) - if len( subfields ) == 1: - glyphs.append( fields[0] ) - values.append( fields[1] ) - - return glyphs, values - - -def filter_glyph_names( alist, filter ): - """filter `alist' by taking _out_ all glyph names that are in `filter'""" - - count = 0 - extras = [] - - for name in alist: - try: - filtered_index = filter.index( name ) - except: - extras.append( name ) - - return extras - - -def dump_encoding( file, encoding_name, encoding_list ): - """dump a given encoding""" - - write = file.write - write( " /* the following are indices into the SID name table */\n" ) - write( " static const unsigned short " + encoding_name + - "[" + repr( len( encoding_list ) ) + "] =\n" ) - write( " {\n" ) - - line = " " - comma = "" - col = 0 - for value in encoding_list: - line += comma - line += "%3d" % value - comma = "," - col += 1 - if col == 16: - col = 0 - comma = ",\n " - - write( line + "\n };\n\n\n" ) - - -def dump_array( the_array, write, array_name ): - """dumps a given encoding""" - - write( " static const unsigned char " + array_name + - "[" + repr( len( the_array ) ) + "] =\n" ) - write( " {\n" ) - - line = "" - comma = " " - col = 0 - - for value in the_array: - line += comma - line += "%3d" % ord( value ) - comma = "," - col += 1 - - if col == 16: - col = 0 - comma = ",\n " - - if len( line ) > 1024: - write( line ) - line = "" - - write( line + "\n };\n\n\n" ) - - -def main(): - """main program body""" - - if len( sys.argv ) != 2: - print __doc__ % sys.argv[0] - sys.exit( 1 ) - - file = open( sys.argv[1], "w\n" ) - write = file.write - - count_sid = len( sid_standard_names ) - - # `mac_extras' contains the list of glyph names in the Macintosh standard - # encoding which are not in the SID Standard Names. - # - mac_extras = filter_glyph_names( mac_standard_names, sid_standard_names ) - - # `base_list' contains the names of our final glyph names table. - # It consists of the `mac_extras' glyph names, followed by the SID - # standard names. - # - mac_extras_count = len( mac_extras ) - base_list = mac_extras + sid_standard_names - - write( "/***************************************************************************/\n" ) - write( "/* */\n" ) - - write( "/* %-71s*/\n" % os.path.basename( sys.argv[1] ) ) - - write( "/* */\n" ) - write( "/* PostScript glyph names. */\n" ) - write( "/* */\n" ) - write( "/* Copyright 2005 by */\n" ) - write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" ) - write( "/* */\n" ) - write( "/* This file is part of the FreeType project, and may only be used, */\n" ) - write( "/* modified, and distributed under the terms of the FreeType project */\n" ) - write( "/* license, LICENSE.TXT. By continuing to use, modify, or distribute */\n" ) - write( "/* this file you indicate that you have read the license and */\n" ) - write( "/* understand and accept it fully. */\n" ) - write( "/* */\n" ) - write( "/***************************************************************************/\n" ) - write( "\n" ) - write( "\n" ) - write( " /* This file has been generated automatically -- do not edit! */\n" ) - write( "\n" ) - write( "\n" ) - - # dump final glyph list (mac extras + sid standard names) - # - st = StringTable( base_list, "ft_standard_glyph_names" ) - - st.dump( file ) - st.dump_sublist( file, "ft_mac_names", - "FT_NUM_MAC_NAMES", mac_standard_names ) - st.dump_sublist( file, "ft_sid_names", - "FT_NUM_SID_NAMES", sid_standard_names ) - - dump_encoding( file, "t1_standard_encoding", t1_standard_encoding ) - dump_encoding( file, "t1_expert_encoding", t1_expert_encoding ) - - # dump the AGL in its compressed form - # - agl_glyphs, agl_values = adobe_glyph_values() - dict = StringNode( "", 0 ) - - for g in range( len( agl_glyphs ) ): - dict.add( agl_glyphs[g], eval( "0x" + agl_values[g] ) ) - - dict = dict.optimize() - dict_len = dict.locate( 0 ) - dict_array = dict.store( "" ) - - write( """\ - /* - * This table is a compressed version of the Adobe Glyph List (AGL), - * optimized for efficient searching. It has been generated by the - * `glnames.py' python script located in the `src/tools' directory. - * - * The lookup function to get the Unicode value for a given string - * is defined below the table. - */ -""" ) - - dump_array( dict_array, write, "ft_adobe_glyph_list" ) - - # write the lookup routine now - # - write( """\ - /* - * This function searches the compressed table efficiently. - */ - static unsigned long - ft_get_adobe_glyph_index( const char* name, - const char* limit ) - { - int c = 0; - int count, min, max; - const unsigned char* p = ft_adobe_glyph_list; - - - if ( name == 0 || name >= limit ) - goto NotFound; - - c = *name++; - count = p[1]; - p += 2; - - min = 0; - max = count; - - while ( min < max ) - { - int mid = ( min + max ) >> 1; - const unsigned char* q = p + mid * 2; - int c2; - - - q = ft_adobe_glyph_list + ( ( (int)q[0] << 8 ) | q[1] ); - - c2 = q[0] & 127; - if ( c2 == c ) - { - p = q; - goto Found; - } - if ( c2 < c ) - min = mid + 1; - else - max = mid; - } - goto NotFound; - - Found: - for (;;) - { - /* assert (*p & 127) == c */ - - if ( name >= limit ) - { - if ( (p[0] & 128) == 0 && - (p[1] & 128) != 0 ) - return (unsigned long)( ( (int)p[2] << 8 ) | p[3] ); - - goto NotFound; - } - c = *name++; - if ( p[0] & 128 ) - { - p++; - if ( c != (p[0] & 127) ) - goto NotFound; - - continue; - } - - p++; - count = p[0] & 127; - if ( p[0] & 128 ) - p += 2; - - p++; - - for ( ; count > 0; count--, p += 2 ) - { - int offset = ( (int)p[0] << 8 ) | p[1]; - const unsigned char* q = ft_adobe_glyph_list + offset; - - if ( c == ( q[0] & 127 ) ) - { - p = q; - goto NextIter; - } - } - goto NotFound; - - NextIter: - ; - } - - NotFound: - return 0; - } - -""" ) - - if 0: # generate unit test, or don't - # - # now write the unit test to check that everything works OK - # - write( "#ifdef TEST\n\n" ) - - write( "static const char* const the_names[] = {\n" ) - for name in agl_glyphs: - write( ' "' + name + '",\n' ) - write( " 0\n};\n" ) - - write( "static const unsigned long the_values[] = {\n" ) - for val in agl_values: - write( ' 0x' + val + ',\n' ) - write( " 0\n};\n" ) - - write( """ -#include -#include - - int - main( void ) - { - int result = 0; - const char* const* names = the_names; - const unsigned long* values = the_values; - - - for ( ; *names; names++, values++ ) - { - const char* name = *names; - unsigned long reference = *values; - unsigned long value; - - - value = ft_get_adobe_glyph_index( name, name + strlen( name ) ); - if ( value != reference ) - { - result = 1; - fprintf( stderr, "name '%s' => %04x instead of %04x\\n", - name, value, reference ); - } - } - - return result; - } -""" ) - - write( "#endif /* TEST */\n" ) - - write("\n/* END */\n") - - -# Now run the main routine -# -main() - - -# END diff --git a/src/libs/freetype2/tools/test_bbox.c b/src/libs/freetype2/tools/test_bbox.c deleted file mode 100644 index e085c5b3d6..0000000000 --- a/src/libs/freetype2/tools/test_bbox.c +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include FT_FREETYPE_H -#include FT_BBOX_H - - -#include /* for clock() */ - -/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include */ -/* to get the HZ macro which is the equivalent. */ -#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4) -#include -#define CLOCKS_PER_SEC HZ -#endif - - static long - get_time( void ) - { - return clock() * 10000L / CLOCKS_PER_SEC; - } - - - - - /* test bbox computations */ - -#define XSCALE 65536 -#define XX(x) ((FT_Pos)(x*XSCALE)) -#define XVEC(x,y) { XX(x), XX(y) } -#define XVAL(x) ((x)/(1.0*XSCALE)) - - /* dummy outline #1 */ - static FT_Vector dummy_vec_1[4] = - { -#if 1 - XVEC( 408.9111, 535.3164 ), - XVEC( 455.8887, 634.396 ), - XVEC( -37.8765, 786.2207 ), - XVEC( 164.6074, 535.3164 ) -#else - { (FT_Int32)0x0198E93DL , (FT_Int32)0x021750FFL }, /* 408.9111, 535.3164 */ - { (FT_Int32)0x01C7E312L , (FT_Int32)0x027A6560L }, /* 455.8887, 634.3960 */ - { (FT_Int32)0xFFDA1F9EL , (FT_Int32)0x0312387FL }, /* -37.8765, 786.2207 */ - { (FT_Int32)0x00A49B7EL , (FT_Int32)0x021750FFL } /* 164.6074, 535.3164 */ -#endif - }; - - static char dummy_tag_1[4] = - { - FT_CURVE_TAG_ON, - FT_CURVE_TAG_CUBIC, - FT_CURVE_TAG_CUBIC, - FT_CURVE_TAG_ON - }; - - static short dummy_contour_1[1] = - { - 3 - }; - - static FT_Outline dummy_outline_1 = - { - 1, - 4, - dummy_vec_1, - dummy_tag_1, - dummy_contour_1, - 0 - }; - - - /* dummy outline #2 */ - static FT_Vector dummy_vec_2[4] = - { - XVEC( 100.0, 100.0 ), - XVEC( 100.0, 200.0 ), - XVEC( 200.0, 200.0 ), - XVEC( 200.0, 133.0 ) - }; - - static FT_Outline dummy_outline_2 = - { - 1, - 4, - dummy_vec_2, - dummy_tag_1, - dummy_contour_1, - 0 - }; - - - static void - dump_outline( FT_Outline* outline ) - { - FT_BBox bbox; - - /* compute and display cbox */ - FT_Outline_Get_CBox( outline, &bbox ); - printf( "cbox = [%.2f %.2f %.2f %.2f]\n", - XVAL( bbox.xMin ), - XVAL( bbox.yMin ), - XVAL( bbox.xMax ), - XVAL( bbox.yMax ) ); - - /* compute and display bbox */ - FT_Outline_Get_BBox( outline, &bbox ); - printf( "bbox = [%.2f %.2f %.2f %.2f]\n", - XVAL( bbox.xMin ), - XVAL( bbox.yMin ), - XVAL( bbox.xMax ), - XVAL( bbox.yMax ) ); - } - - - - static void - profile_outline( FT_Outline* outline, - long repeat ) - { - FT_BBox bbox; - long count; - long time0; - - time0 = get_time(); - for ( count = repeat; count > 0; count-- ) - FT_Outline_Get_CBox( outline, &bbox ); - - time0 = get_time() - time0; - printf( "time = %5.2f cbox = [%.2f %.2f %.2f %.2f]\n", - ((double)time0/10000.0), - XVAL( bbox.xMin ), - XVAL( bbox.yMin ), - XVAL( bbox.xMax ), - XVAL( bbox.yMax ) ); - - - time0 = get_time(); - for ( count = repeat; count > 0; count-- ) - FT_Outline_Get_BBox( outline, &bbox ); - - time0 = get_time() - time0; - printf( "time = %5.2f bbox = [%.2f %.2f %.2f %.2f]\n", - ((double)time0/10000.0), - XVAL( bbox.xMin ), - XVAL( bbox.yMin ), - XVAL( bbox.xMax ), - XVAL( bbox.yMax ) ); - } - -#define REPEAT 100000L - - int main( int argc, char** argv ) - { - printf( "outline #1\n" ); - profile_outline( &dummy_outline_1, REPEAT ); - - printf( "outline #2\n" ); - profile_outline( &dummy_outline_2, REPEAT ); - return 0; - } - diff --git a/src/libs/freetype2/tools/test_trig.c b/src/libs/freetype2/tools/test_trig.c deleted file mode 100644 index 8c8a544aa9..0000000000 --- a/src/libs/freetype2/tools/test_trig.c +++ /dev/null @@ -1,236 +0,0 @@ -#include -#include FT_FREETYPE_H -#include FT_TRIGONOMETRY_H - -#include -#include - -#define PI 3.14159265358979323846 -#define SPI (PI/FT_ANGLE_PI) - -/* the precision in 16.16 fixed float points of the checks. Expect */ -/* between 2 and 5 noise LSB bits during operations, due to */ -/* rounding errors.. */ -#define THRESHOLD 64 - - static error = 0; - - static void - test_cos( void ) - { - FT_Fixed f1, f2; - double d1, d2; - int i; - - for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) - { - f1 = FT_Cos(i); - d1 = f1/65536.0; - d2 = cos( i*SPI ); - f2 = (FT_Fixed)(d2*65536.0); - - if ( abs( f2-f1 ) > THRESHOLD ) - { - error = 1; - printf( "FT_Cos[%3d] = %.7f cos[%3d] = %.7f\n", - (i >> 16), f1/65536.0, (i >> 16), d2 ); - } - } - } - - - - static void - test_sin( void ) - { - FT_Fixed f1, f2; - double d1, d2; - int i; - - for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) - { - f1 = FT_Sin(i); - d1 = f1/65536.0; - d2 = sin( i*SPI ); - f2 = (FT_Fixed)(d2*65536.0); - - if ( abs( f2-f1 ) > THRESHOLD ) - { - error = 1; - printf( "FT_Sin[%3d] = %.7f sin[%3d] = %.7f\n", - (i >> 16), f1/65536.0, (i >> 16), d2 ); - } - } - } - - - static void - test_tan( void ) - { - FT_Fixed f1, f2; - double d1, d2; - int i; - - for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 ) - { - f1 = FT_Tan(i); - d1 = f1/65536.0; - d2 = tan( i*SPI ); - f2 = (FT_Fixed)(d2*65536.0); - - if ( abs( f2-f1 ) > THRESHOLD ) - { - error = 1; - printf( "FT_Tan[%3d] = %.7f tan[%3d] = %.7f\n", - (i >> 16), f1/65536.0, (i >> 16), d2 ); - } - } - } - - - static void - test_atan2( void ) - { - FT_Fixed c2, s2; - double l, a, c1, s1; - int i, j; - - for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) - { - l = 5.0; - a = i*SPI; - - c1 = l * cos(a); - s1 = l * sin(a); - - c2 = (FT_Fixed)(c1*65536.0); - s2 = (FT_Fixed)(s1*65536.0); - - j = FT_Atan2( c2, s2 ); - if ( j < 0 ) - j += FT_ANGLE_2PI; - - if ( abs( i - j ) > 1 ) - { - printf( "FT_Atan2( %.7f, %.7f ) = %.5f, atan = %.5f\n", - c2/65536.0, s2/65536.0, j/65536.0, i/65536.0 ); - } - } - } - - static void - test_unit( void ) - { - FT_Vector v; - double a, c1, s1; - FT_Fixed c2, s2; - int i; - - for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) - { - FT_Vector_Unit( &v, i ); - a = ( i*SPI ); - c1 = cos(a); - s1 = sin(a); - c2 = (FT_Fixed)(c1*65536.0); - s2 = (FT_Fixed)(s1*65536.0); - - if ( abs( v.x-c2 ) > THRESHOLD || - abs( v.y-s2 ) > THRESHOLD ) - { - error = 1; - printf( "FT_Vector_Unit[%3d] = ( %.7f, %.7f ) vec = ( %.7f, %.7f )\n", - (i >> 16), - v.x/65536.0, v.y/65536.0, - c1, s1 ); - } - } - } - - - static void - test_length( void ) - { - FT_Vector v; - FT_Fixed l, l2; - int i; - - for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) - { - l = (FT_Fixed)(500.0*65536.0); - v.x = (FT_Fixed)( l * cos( i*SPI ) ); - v.y = (FT_Fixed)( l * sin( i*SPI ) ); - l2 = FT_Vector_Length( &v ); - - if ( abs( l2-l ) > THRESHOLD ) - { - error = 1; - printf( "FT_Length( %.7f, %.7f ) = %.5f, length = %.5f\n", - v.x/65536.0, v.y/65536.0, l2/65536.0, l/65536.0 ); - } - } - } - - - static void - test_rotate( void ) - { - FT_Fixed c2, s2, c4, s4; - FT_Vector v; - double l, ra, a, c1, s1, cra, sra, c3, s3; - int i, j, rotate; - - for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 ) - { - ra = rotate*SPI; - cra = cos( ra ); - sra = sin( ra ); - - for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) - { - l = 500.0; - a = i*SPI; - - c1 = l * cos(a); - s1 = l * sin(a); - - v.x = c2 = (FT_Fixed)(c1*65536.0); - v.y = s2 = (FT_Fixed)(s1*65536.0); - - FT_Vector_Rotate( &v, rotate ); - - c3 = c1 * cra - s1 * sra; - s3 = c1 * sra + s1 * cra; - - c4 = (FT_Fixed)(c3*65536.0); - s4 = (FT_Fixed)(s3*65536.0); - - if ( abs( c4 - v.x ) > THRESHOLD || - abs( s4 - v.y ) > THRESHOLD ) - { - error = 1; - printf( "FT_Rotate( (%.7f,%.7f), %.5f ) = ( %.7f, %.7f ), rot = ( %.7f, %.7f )\n", - c1, s1, ra, - c2/65536.0, s2/65536.0, - c4/65536.0, s4/65536.0 ); - } - } - } - } - - - int main( void ) - { - test_cos(); - test_sin(); - test_tan(); - test_atan2(); - test_unit(); - test_length(); - test_rotate(); - - if (!error) - printf( "trigonometry test ok !\n" ); - - return !error; - } diff --git a/src/libs/freetype2/truetype/descrip.mms b/src/libs/freetype2/truetype/descrip.mms deleted file mode 100644 index e30ee1b3f8..0000000000 --- a/src/libs/freetype2/truetype/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 TrueType driver compilation rules for VMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.truetype]) - -OBJS=truetype.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/truetype/module.mk b/src/libs/freetype2/truetype/module.mk index bb042beae1..3b05afc7fd 100644 --- a/src/libs/freetype2/truetype/module.mk +++ b/src/libs/freetype2/truetype/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_truetype_driver +FTMODULE_H_COMMANDS += TRUETYPE_DRIVER -add_truetype_driver: - $(OPEN_DRIVER)tt_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)truetype $(ECHO_DRIVER_DESC)Windows/Mac font files with extension *.ttf or *.ttc$(ECHO_DRIVER_DONE) +define TRUETYPE_DRIVER +$(OPEN_DRIVER)tt_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)truetype $(ECHO_DRIVER_DESC)Windows/Mac font files with extension *.ttf or *.ttc$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/truetype/ttdriver.c b/src/libs/freetype2/truetype/ttdriver.c index c981dfdec9..fa25c25ede 100644 --- a/src/libs/freetype2/truetype/ttdriver.c +++ b/src/libs/freetype2/truetype/ttdriver.c @@ -4,7 +4,7 @@ /* */ /* TrueType font driver implementation (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,6 +28,8 @@ #include FT_SERVICE_MULTIPLE_MASTERS_H #endif +#include FT_SERVICE_TRUETYPE_ENGINE_H + #include "ttdriver.h" #include "ttgload.h" @@ -113,7 +115,7 @@ if ( sfnt ) kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph ); - + return 0; } @@ -134,118 +136,76 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* */ - /* Set_Char_Sizes */ - /* */ - /* */ - /* A driver method used to reset a size's character sizes (horizontal */ - /* and vertical) expressed in fractional points. */ - /* */ - /* */ - /* char_width :: The character width expressed in 26.6 */ - /* fractional points. */ - /* */ - /* char_height :: The character height expressed in 26.6 */ - /* fractional points. */ - /* */ - /* horz_resolution :: The horizontal resolution of the output device. */ - /* */ - /* vert_resolution :: The vertical resolution of the output device. */ - /* */ - /* */ - /* size :: A handle to the target size object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + static FT_Error - Set_Char_Sizes( FT_Size ttsize, /* TT_Size */ - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) + tt_size_select( FT_Size size, + FT_ULong strike_index ) { - TT_Size size = (TT_Size)ttsize; - FT_Size_Metrics* metrics = &size->root.metrics; - FT_Size_Metrics* metrics2 = &size->metrics; - TT_Face face = (TT_Face)size->root.face; - FT_Long dim_x, dim_y; + TT_Face ttface = (TT_Face)size->face; + TT_Size ttsize = (TT_Size)size; + FT_Error error = TT_Err_Ok; - *metrics2 = *metrics; + ttsize->strike_index = strike_index; - /* This bit flag, when set, indicates that the pixel size must be */ - /* truncated to an integer. Nearly all TrueType fonts have this */ - /* bit set, as hinting won't work really well otherwise. */ - /* */ - if ( ( face->header.Flags & 8 ) != 0 ) + if ( FT_IS_SCALABLE( size->face ) ) { - /* we need to use rounding in the following computations. Otherwise, - * the resulting hinted outlines will be very slightly distorted - */ - dim_x = ( ( char_width * horz_resolution + (36+32*72) ) / 72 ) & ~63; - dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & ~63; + /* use the scaled metrics, even when tt_size_reset fails */ + FT_Select_Metrics( size->face, strike_index ); + + tt_size_reset( ttsize ); } else { - dim_x = ( ( char_width * horz_resolution + 36 ) / 72 ); - dim_y = ( ( char_height * vert_resolution + 36 ) / 72 ); + SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; + FT_Size_Metrics* metrics = &size->metrics; + + + error = sfnt->load_strike_metrics( ttface, strike_index, metrics ); + if ( error ) + ttsize->strike_index = 0xFFFFFFFFUL; } - /* we only modify "metrics2", not "metrics", so these changes have */ - /* no effect on the result of the auto-hinter when it is used */ - /* */ - metrics2->x_ppem = (FT_UShort)( dim_x >> 6 ); - metrics2->y_ppem = (FT_UShort)( dim_y >> 6 ); - metrics2->x_scale = FT_DivFix( dim_x, face->root.units_per_EM ); - metrics2->y_scale = FT_DivFix( dim_y, face->root.units_per_EM ); - - size->ttmetrics.valid = FALSE; -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - size->strike_index = 0xFFFFU; -#endif - - return tt_size_reset( size ); + return error; } +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + - /*************************************************************************/ - /* */ - /* */ - /* Set_Pixel_Sizes */ - /* */ - /* */ - /* A driver method used to reset a size's character sizes (horizontal */ - /* and vertical) expressed in integer pixels. */ - /* */ - /* */ - /* size :: A handle to the target size object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ static FT_Error - Set_Pixel_Sizes( FT_Size ttsize, /* TT_Size */ - FT_UInt pixel_width, - FT_UInt pixel_height ) + tt_size_request( FT_Size size, + FT_Size_Request req ) { - TT_Size size = (TT_Size)ttsize; - - FT_UNUSED( pixel_width ); - FT_UNUSED( pixel_height ); + TT_Size ttsize = (TT_Size)size; + FT_Error error = TT_Err_Ok; - /* many things have been pre-computed by the base layer */ - - size->metrics = size->root.metrics; - size->ttmetrics.valid = FALSE; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - size->strike_index = 0xFFFFU; -#endif - return tt_size_reset( size ); + if ( FT_HAS_FIXED_SIZES( size->face ) ) + { + TT_Face ttface = (TT_Face)size->face; + SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; + FT_ULong index; + + + error = sfnt->set_sbit_strike( ttface, req, &index ); + + if ( error ) + ttsize->strike_index = 0xFFFFFFFFUL; + else + return tt_size_select( size, index ); + } + +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + + FT_Request_Metrics( size->face, req ); + + if ( FT_IS_SCALABLE( size->face ) ) + error = tt_size_reset( ttsize ); + + return error; } @@ -289,25 +249,14 @@ if ( !slot ) return TT_Err_Invalid_Slot_Handle; - /* check whether we want a scaled outline or bitmap */ if ( !size ) - load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; + return TT_Err_Invalid_Size_Handle; - if ( load_flags & FT_LOAD_NO_SCALE ) - size = NULL; - - /* reset the size object if necessary */ - if ( size ) + if ( load_flags & ( FT_LOAD_NO_RECURSE | FT_LOAD_NO_SCALE ) ) { - /* these two object must have the same parent */ - if ( size->root.face != slot->face ) - return TT_Err_Invalid_Face_Handle; - - if ( !size->ttmetrics.valid ) - { - if ( FT_SET_ERROR( tt_size_reset( size ) ) ) - return error; - } + load_flags |= FT_LOAD_NO_HINTING | + FT_LOAD_NO_BITMAP | + FT_LOAD_NO_SCALE; } /* now load the glyph outline if necessary */ @@ -343,13 +292,30 @@ }; #endif + static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine = + { +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + +#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING + FT_TRUETYPE_ENGINE_TYPE_UNPATENTED +#else + FT_TRUETYPE_ENGINE_TYPE_PATENTED +#endif + +#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + + FT_TRUETYPE_ENGINE_TYPE_NONE + +#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + }; static const FT_ServiceDescRec tt_services[] = { - { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE }, + { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE }, #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - { FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters }, + { FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters }, #endif + { FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine }, { NULL, NULL } }; @@ -415,16 +381,25 @@ tt_face_done, tt_size_init, tt_size_done, - 0, /* FT_Slot_InitFunc */ - 0, /* FT_Slot_DoneFunc */ + tt_slot_init, + 0, /* FT_Slot_DoneFunc */ - Set_Char_Sizes, - Set_Pixel_Sizes, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif Load_Glyph, tt_get_kerning, 0, /* FT_Face_AttachFunc */ - 0 /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_GetAdvancesFunc */ + + tt_size_request, +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + tt_size_select +#else + 0 /* FT_Size_SelectFunc */ +#endif }; diff --git a/src/libs/freetype2/truetype/ttgload.c b/src/libs/freetype2/truetype/ttgload.c index d1ad181b87..158111384e 100644 --- a/src/libs/freetype2/truetype/ttgload.c +++ b/src/libs/freetype2/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -63,140 +63,6 @@ #define UNSCALED_COMPONENT_OFFSET 0x1000 -/* Maximum recursion depth we allow for composite glyphs. - * The TrueType spec doesn't say anything about recursion, - * so it isn't clear that recursion is allowed at all. But - * we'll be generous. - */ -#define TT_MAX_COMPOSITE_RECURSE 5 - - - - /*************************************************************************/ - /* */ - /* */ - /* tt_face_get_metrics */ - /* */ - /* */ - /* Returns the horizontal or vertical metrics in font units for a */ - /* given glyph. The metrics are the left side bearing (resp. top */ - /* side bearing) and advance width (resp. advance height). */ - /* */ - /* */ - /* header :: A pointer to either the horizontal or vertical metrics */ - /* structure. */ - /* */ - /* idx :: The glyph index. */ - /* */ - /* */ - /* bearing :: The bearing, either left side or top side. */ - /* */ - /* advance :: The advance width resp. advance height. */ - /* */ - /* */ - /* This function will much probably move to another component in the */ - /* near future, but I haven't decided which yet. */ - /* */ -#ifdef FT_OPTIMIZE_MEMORY - - static void - tt_face_get_metrics( TT_Face face, - FT_Bool vertical, - FT_UInt idx, - FT_Short *abearing, - FT_UShort *aadvance ) - { - TT_HoriHeader* header; - FT_Byte* p; - FT_Byte* limit; - FT_UShort k; - - - if ( vertical ) - { - header = (TT_HoriHeader*)&face->vertical; - p = face->vert_metrics; - limit = p + face->vert_metrics_size; - } - else - { - header = &face->horizontal; - p = face->horz_metrics; - limit = p + face->horz_metrics_size; - } - - k = header->number_Of_HMetrics; - - if ( k > 0 ) - { - if ( idx < (FT_UInt)k ) - { - p += 4 * idx; - if ( p + 4 > limit ) - goto NoData; - - *aadvance = FT_NEXT_USHORT( p ); - *abearing = FT_NEXT_SHORT( p ); - } - else - { - p += 4 * ( k - 1 ); - if ( p + 4 > limit ) - goto NoData; - - *aadvance = FT_NEXT_USHORT( p ); - p += 2 + 2 * ( idx - k ); - if ( p + 2 > limit ) - *abearing = 0; - else - *abearing = FT_PEEK_SHORT( p ); - } - } - else - { - NoData: - *abearing = 0; - *aadvance = 0; - } - } - -#else /* !FT_OPTIMIZE_MEMORY */ - - static void - tt_face_get_metrics( TT_Face face, - FT_Bool vertical, - FT_UInt idx, - FT_Short *abearing, - FT_UShort *aadvance ) - { - TT_HoriHeader* header = vertical ? (TT_HoriHeader*)&face->vertical - : &face->horizontal; - TT_LongMetrics longs_m; - FT_UShort k = header->number_Of_HMetrics; - - - if ( k == 0 ) - { - *abearing = *aadvance = 0; - return; - } - - if ( idx < (FT_UInt)k ) - { - longs_m = (TT_LongMetrics)header->long_metrics + idx; - *abearing = longs_m->bearing; - *aadvance = longs_m->advance; - } - else - { - *abearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k]; - *aadvance = ((TT_LongMetrics)header->long_metrics)[k - 1].advance; - } - } - -#endif /* !FT_OPTIMIZE_MEMORY */ - - /*************************************************************************/ /* */ /* Returns the horizontal metrics in font units for a given glyph. If */ @@ -210,57 +76,13 @@ FT_Short* lsb, FT_UShort* aw ) { - tt_face_get_metrics( face, 0, idx, lsb, aw ); + ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw ); if ( check && face->postscript.isFixedPitch ) *aw = face->horizontal.advance_Width_Max; } - /*************************************************************************/ - /* */ - /* Returns the advance width table for a given pixel size if it is found */ - /* in the font's `hdmx' table (if any). */ - /* */ - static FT_Byte* - Get_Advance_WidthPtr( TT_Face face, - FT_Int ppem, - FT_UInt gindex ) - { -#ifdef FT_OPTIMIZE_MEMORY - - FT_UInt nn; - FT_Byte* result = NULL; - FT_ULong record_size = face->hdmx_record_size; - FT_Byte* record = face->hdmx_table + 8; - - - for ( nn = 0; nn < face->hdmx_record_count; nn++ ) - if ( face->hdmx_record_sizes[nn] == ppem ) - { - gindex += 2; - if ( gindex < record_size ) - result = record + gindex; - break; - } - - return result; - -#else - - FT_UShort n; - - - for ( n = 0; n < face->hdmx.num_records; n++ ) - if ( face->hdmx.records[n].ppem == ppem ) - return &face->hdmx.records[n].widths[gindex]; - - return NULL; - -#endif - } - - /*************************************************************************/ /* */ /* Returns the vertical metrics in font units for a given glyph. */ @@ -284,7 +106,7 @@ FT_UNUSED( check ); if ( face->vertical_info ) - tt_face_get_metrics( face, 1, idx, tsb, ah ); + ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah ); #if 1 /* Emperically determined, at variance with what MS said */ @@ -312,13 +134,6 @@ } -#define cur_to_org( n, zone ) \ - FT_ARRAY_COPY( (zone)->org, (zone)->cur, (n) ) - -#define org_to_cur( n, zone ) \ - FT_ARRAY_COPY( (zone)->cur, (zone)->org, (n) ) - - /*************************************************************************/ /* */ /* Translates an array of coordinates. */ @@ -342,21 +157,6 @@ } - static void - tt_prepare_zone( TT_GlyphZone zone, - FT_GlyphLoad load, - FT_UInt start_point, - FT_UInt start_contour ) - { - zone->n_points = (FT_UShort)( load->outline.n_points - start_point ); - zone->n_contours = (FT_Short) ( load->outline.n_contours - start_contour ); - zone->org = load->extra_points + start_point; - zone->cur = load->outline.points + start_point; - zone->tags = (FT_Byte*)load->outline.tags + start_point; - zone->contours = (FT_UShort*)load->outline.contours + start_contour; - } - - #undef IS_HINTED #define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 ) @@ -439,7 +239,6 @@ FT_Int n_contours = load->n_contours; FT_Outline* outline; TT_Face face = (TT_Face)load->face; - TT_GlyphSlot slot = (TT_GlyphSlot)load->glyph; FT_UShort n_ins; FT_Int n, n_points; FT_Int byte_len = load->byte_len; @@ -451,6 +250,11 @@ FT_Short *cont, *cont_limit; + /* check that we can add the contours to the glyph */ + error = FT_GLYPHLOADER_CHECK_POINTS( gloader, 0, n_contours ); + if ( error ) + goto Fail; + /* reading the contours' endpoints & number of points */ cont = gloader->current.outline.contours; cont_limit = cont + n_contours; @@ -467,7 +271,8 @@ if ( n_contours > 0 ) n_points = cont[-1] + 1; - error = FT_GlyphLoader_CheckPoints( gloader, n_points + 4, 0 ); + /* note that we will add four phantom points later */ + error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 ); if ( error ) goto Fail; @@ -479,8 +284,8 @@ goto Invalid_Outline; /* reading the bytecode instructions */ - slot->control_len = 0; - slot->control_data = 0; + load->glyph->control_len = 0; + load->glyph->control_data = 0; n_ins = FT_GET_USHORT(); @@ -503,14 +308,12 @@ #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - if ( ( load->load_flags & - ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0 && - load->instructions ) + if ( IS_HINTED( load->load_flags ) ) { - slot->control_len = n_ins; - slot->control_data = load->instructions; + load->glyph->control_len = n_ins; + load->glyph->control_data = load->exec->glyphIns; - FT_MEM_COPY( load->instructions, stream->cursor, (FT_Long)n_ins ); + FT_MEM_COPY( load->exec->glyphIns, stream->cursor, (FT_Long)n_ins ); } #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ @@ -723,6 +526,7 @@ gloader->current.num_subglyphs = num_subglyphs; #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + { /* we must undo the FT_FRAME_ENTER in order to point to the */ /* composite instructions, if we find some. */ @@ -731,6 +535,7 @@ loader->ins_pos = (FT_ULong)( FT_STREAM_POS() + stream->cursor - stream->limit ); } + #endif loader->byte_len = byte_len; @@ -755,6 +560,107 @@ } + static void + tt_prepare_zone( TT_GlyphZone zone, + FT_GlyphLoad load, + FT_UInt start_point, + FT_UInt start_contour ) + { + zone->n_points = (FT_UShort)( load->outline.n_points - start_point ); + zone->n_contours = (FT_Short) ( load->outline.n_contours - start_contour ); + zone->org = load->extra_points + start_point; + zone->cur = load->outline.points + start_point; + zone->tags = (FT_Byte*)load->outline.tags + start_point; + zone->contours = (FT_UShort*)load->outline.contours + start_contour; + } + + + /*************************************************************************/ + /* */ + /* */ + /* TT_Hint_Glyph */ + /* */ + /* */ + /* Hint the glyph using the zone prepared by the caller. Note that */ + /* the zone is supposed to include four phantom points. */ + /* */ +#define cur_to_org( n, zone ) \ + FT_ARRAY_COPY( (zone)->org, (zone)->cur, (n) ) + + static FT_Error + TT_Hint_Glyph( TT_Loader loader, + FT_Bool is_composite ) + { + TT_GlyphZone zone = &loader->zone; + FT_Pos origin; + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + FT_UInt n_ins; +#else + FT_UNUSED( is_composite ); +#endif + + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + n_ins = loader->glyph->control_len; +#endif + + origin = zone->cur[zone->n_points - 4].x; + origin = FT_PIX_ROUND( origin ) - origin; + if ( origin ) + translate_array( zone->n_points, zone->cur, origin, 0 ); + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + /* save original point positioin in org */ + if ( n_ins > 0 ) + cur_to_org( zone->n_points, zone ); +#endif + + /* round pp2 and pp4 */ + zone->cur[zone->n_points - 3].x = + FT_PIX_ROUND( zone->cur[zone->n_points - 3].x ); + zone->cur[zone->n_points - 1].y = + FT_PIX_ROUND( zone->cur[zone->n_points - 1].y ); + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + if ( n_ins > 0 ) + { + FT_Bool debug; + FT_Error error; + + + error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph, + loader->exec->glyphIns, n_ins ); + if ( error ) + return error; + + loader->exec->is_composite = is_composite; + loader->exec->pts = *zone; + + debug = !( loader->load_flags & FT_LOAD_NO_SCALE ) && + ( (TT_Size)loader->size )->debug; + + error = TT_Run_Context( loader->exec, debug ); + if ( error && loader->exec->pedantic_hinting ) + return error; + } + +#endif + + /* save glyph phantom points */ + if ( !loader->preserve_pps ) + { + loader->pp1 = zone->cur[zone->n_points - 4]; + loader->pp2 = zone->cur[zone->n_points - 3]; + loader->pp3 = zone->cur[zone->n_points - 2]; + loader->pp4 = zone->cur[zone->n_points - 1]; + } + + return TT_Err_Ok; + } + + /*************************************************************************/ /* */ /* */ @@ -766,95 +672,47 @@ /* interpretation. */ /* */ static FT_Error - TT_Process_Simple_Glyph( TT_Loader load, - FT_Bool debug ) + TT_Process_Simple_Glyph( TT_Loader loader ) { - FT_GlyphLoader gloader = load->gloader; - FT_Outline* outline = &gloader->current.outline; - FT_UInt n_points = outline->n_points; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - FT_UInt n_ins; -#endif - TT_GlyphZone zone = &load->zone; - FT_Error error = TT_Err_Ok; - - FT_UNUSED( debug ); /* used by truetype interpreter only */ + FT_GlyphLoader gloader = loader->gloader; + FT_Error error = TT_Err_Ok; + FT_Outline* outline; + FT_UInt n_points; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - n_ins = load->glyph->control_len; -#endif + outline = &gloader->current.outline; + n_points = outline->n_points; - /* add shadow points */ + /* set phantom points */ - /* Add two horizontal shadow points at n and n+1. */ - /* We need the left side bearing and advance width. */ - /* Add two vertical shadow points at n+2 and n+3. */ - /* We need the top side bearing and advance height. */ + outline->points[n_points ] = loader->pp1; + outline->points[n_points + 1] = loader->pp2; + outline->points[n_points + 2] = loader->pp3; + outline->points[n_points + 3] = loader->pp4; - { - FT_Vector* pp1; - FT_Vector* pp2; - FT_Vector* pp3; - FT_Vector* pp4; - - - /* pp1 = xMin - lsb */ - pp1 = outline->points + n_points; - pp1->x = load->bbox.xMin - load->left_bearing; - pp1->y = 0; - - /* pp2 = pp1 + aw */ - pp2 = pp1 + 1; - pp2->x = pp1->x + load->advance; - pp2->y = 0; - - /* pp3 = top side bearing */ - pp3 = pp1 + 2; - pp3->x = 0; - pp3->y = load->top_bearing + load->bbox.yMax; - - /* pp4 = pp3 - ah */ - pp4 = pp1 + 3; - pp4->x = 0; - pp4->y = pp3->y - load->vadvance; - - outline->tags[n_points ] = 0; - outline->tags[n_points + 1] = 0; - outline->tags[n_points + 2] = 0; - outline->tags[n_points + 3] = 0; - } - - /* Note that we return four more points that are not */ - /* part of the glyph outline. */ + outline->tags[n_points ] = 0; + outline->tags[n_points + 1] = 0; + outline->tags[n_points + 2] = 0; + outline->tags[n_points + 3] = 0; n_points += 4; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( ((TT_Face)load->face)->doblend ) + if ( ((TT_Face)loader->face)->doblend ) { /* Deltas apply to the unscaled data. */ - FT_Vector* deltas; - FT_Memory memory = load->face->memory; - FT_StreamRec saved_stream = *(load->stream); - FT_UInt i; + FT_Vector* deltas; + FT_Memory memory = loader->face->memory; + FT_UInt i; - /* TT_Vary_Get_Glyph_Deltas uses a frame, thus we have to save */ - /* (and restore) the current one */ - load->stream->cursor = 0; - load->stream->limit = 0; - - error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(load->face), - load->glyph_index, + error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face), + loader->glyph_index, &deltas, n_points ); - - *(load->stream) = saved_stream; - if ( error ) - goto Exit; + return error; for ( i = 0; i < n_points; ++i ) { @@ -867,84 +725,292 @@ #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ - /* set up zone for hinting */ - tt_prepare_zone( zone, &gloader->current, 0, 0 ); - - /* eventually scale the glyph */ - if ( !( load->load_flags & FT_LOAD_NO_SCALE ) ) + /* scale the glyph */ + if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { - FT_Vector* vec = zone->cur; - FT_Vector* limit = vec + n_points; - FT_Fixed x_scale = ((TT_Size)load->size)->metrics.x_scale; - FT_Fixed y_scale = ((TT_Size)load->size)->metrics.y_scale; + FT_Vector* vec = outline->points; + FT_Vector* limit = outline->points + n_points; + FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale; + FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale; + - /* first scale the glyph points */ for ( ; vec < limit; vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } + + loader->pp1 = outline->points[n_points - 4]; + loader->pp2 = outline->points[n_points - 3]; + loader->pp3 = outline->points[n_points - 2]; + loader->pp4 = outline->points[n_points - 1]; } - cur_to_org( n_points, zone ); - - /* eventually hint the glyph */ - if ( IS_HINTED( load->load_flags ) ) + if ( IS_HINTED( loader->load_flags ) ) { - FT_Pos x = zone->org[n_points-4].x; - - - x = FT_PIX_ROUND( x ) - x; - translate_array( n_points, zone->org, x, 0 ); - - org_to_cur( n_points, zone ); - - zone->cur[n_points - 3].x = FT_PIX_ROUND( zone->cur[n_points - 3].x ); - zone->cur[n_points - 1].y = FT_PIX_ROUND( zone->cur[n_points - 1].y ); - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - /* now consider hinting */ - if ( n_ins > 0 ) - { - error = TT_Set_CodeRange( load->exec, tt_coderange_glyph, - load->exec->glyphIns, n_ins ); - if ( error ) - goto Exit; - - load->exec->is_composite = FALSE; - load->exec->pts = *zone; - load->exec->pts.n_points += 4; - - error = TT_Run_Context( load->exec, debug ); - if ( error && load->exec->pedantic_hinting ) - goto Exit; - - error = TT_Err_Ok; /* ignore bytecode errors in non-pedantic mode */ - } - -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 ); + loader->zone.n_points += 4; + error = TT_Hint_Glyph( loader, 0 ); } - /* save glyph phantom points */ - if ( !load->preserve_pps ) - { - load->pp1 = zone->cur[n_points - 4]; - load->pp2 = zone->cur[n_points - 3]; - load->pp3 = zone->cur[n_points - 2]; - load->pp4 = zone->cur[n_points - 1]; - } - -#if defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER ) || \ - defined( TT_CONFIG_OPTION_GX_VAR_SUPPORT ) - Exit: -#endif - return error; } + /*************************************************************************/ + /* */ + /* */ + /* TT_Process_Composite_Component */ + /* */ + /* */ + /* Once a composite component has been loaded, it needs to be */ + /* processed. Usually, this means transforming and translating. */ + /* */ + static FT_Error + TT_Process_Composite_Component( TT_Loader loader, + FT_SubGlyph subglyph, + FT_UInt start_point, + FT_UInt num_base_points ) + { + FT_GlyphLoader gloader = loader->gloader; + FT_Vector* base_vec = gloader->base.outline.points; + FT_UInt num_points = gloader->base.outline.n_points; + FT_Bool have_scale; + FT_Pos x, y; + + + have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE | + WE_HAVE_AN_XY_SCALE | + WE_HAVE_A_2X2 ) ); + + /* perform the transform required for this subglyph */ + if ( have_scale ) + { + FT_UInt i; + + + for ( i = num_base_points; i < num_points; i++ ) + FT_Vector_Transform( base_vec + i, &subglyph->transform ); + } + + /* get offset */ + if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) ) + { + FT_UInt k = subglyph->arg1; + FT_UInt l = subglyph->arg2; + FT_Vector* p1; + FT_Vector* p2; + + + /* match l-th point of the newly loaded component to the k-th point */ + /* of the previously loaded components. */ + + /* change to the point numbers used by our outline */ + k += start_point; + l += num_base_points; + if ( k >= num_base_points || + l >= num_points ) + return TT_Err_Invalid_Composite; + + p1 = gloader->base.outline.points + k; + p2 = gloader->base.outline.points + l; + + x = p1->x - p2->x; + y = p1->y - p2->y; + } + else + { + x = subglyph->arg1; + y = subglyph->arg2; + + if ( !x && !y ) + return TT_Err_Ok; + + /* Use a default value dependent on */ + /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */ + /* fonts which don't set the xxx_COMPONENT_OFFSET bit. */ + + if ( have_scale && +#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + !( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) ) +#else + ( subglyph->flags & SCALED_COMPONENT_OFFSET ) ) +#endif + { + +#if 0 + + /*************************************************************************/ + /* */ + /* This algorithm is what Apple documents. But it doesn't work. */ + /* */ + int a = subglyph->transform.xx > 0 ? subglyph->transform.xx + : -subglyph->transform.xx; + int b = subglyph->transform.yx > 0 ? subglyph->transform.yx + : -subglyph->transform.yx; + int c = subglyph->transform.xy > 0 ? subglyph->transform.xy + : -subglyph->transform.xy; + int d = subglyph->transform.yy > 0 ? subglyph->transform.yy + : -subglyph->transform.yy; + int m = a > b ? a : b; + int n = c > d ? c : d; + + + if ( a - b <= 33 && a - b >= -33 ) + m *= 2; + if ( c - d <= 33 && c - d >= -33 ) + n *= 2; + x = FT_MulFix( x, m ); + y = FT_MulFix( y, n ); + +#else /* 0 */ + + /*************************************************************************/ + /* */ + /* This algorithm is a guess and works much better than the above. */ + /* */ + FT_Fixed mac_xscale = FT_SqrtFixed( + FT_MulFix( subglyph->transform.xx, + subglyph->transform.xx ) + + FT_MulFix( subglyph->transform.xy, + subglyph->transform.xy ) ); + FT_Fixed mac_yscale = FT_SqrtFixed( + FT_MulFix( subglyph->transform.yy, + subglyph->transform.yy ) + + FT_MulFix( subglyph->transform.yx, + subglyph->transform.yx ) ); + + + x = FT_MulFix( x, mac_xscale ); + y = FT_MulFix( y, mac_yscale ); + +#endif /* 0 */ + + } + + if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) + { + FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale; + FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale; + + + x = FT_MulFix( x, x_scale ); + y = FT_MulFix( y, y_scale ); + + if ( subglyph->flags & ROUND_XY_TO_GRID ) + { + x = FT_PIX_ROUND( x ); + y = FT_PIX_ROUND( y ); + } + } + } + + if ( x || y ) + translate_array( num_points - num_base_points, + base_vec + num_base_points, + x, y ); + + return TT_Err_Ok; + } + + + /*************************************************************************/ + /* */ + /* */ + /* TT_Process_Composite_Glyph */ + /* */ + /* */ + /* This is slightly different from TT_Process_Simple_Glyph, in that */ + /* it's sole purpose is to hint the glyph. Thus this function is */ + /* only available when bytecode interpreter is enabled. */ + /* */ + static FT_Error + TT_Process_Composite_Glyph( TT_Loader loader, + FT_UInt start_point, + FT_UInt start_contour ) + { + FT_Error error; + FT_Outline* outline; + + + outline = &loader->gloader->base.outline; + + /* make room for phantom points */ + error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader, + outline->n_points + 4, + 0 ); + if ( error ) + return error; + + outline->points[outline->n_points ] = loader->pp1; + outline->points[outline->n_points + 1] = loader->pp2; + outline->points[outline->n_points + 2] = loader->pp3; + outline->points[outline->n_points + 3] = loader->pp4; + + outline->tags[outline->n_points ] = 0; + outline->tags[outline->n_points + 1] = 0; + outline->tags[outline->n_points + 2] = 0; + outline->tags[outline->n_points + 3] = 0; + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + { + FT_Stream stream = loader->stream; + FT_UShort n_ins; + + + /* TT_Load_Composite_Glyph only gives us the offset of instructions */ + /* so we read them here */ + if ( FT_STREAM_SEEK( loader->ins_pos ) || + FT_READ_USHORT( n_ins ) ) + return error; + + FT_TRACE5(( " Instructions size = %d\n", n_ins )); + + /* check it */ + if ( n_ins > ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions ) + { + FT_TRACE0(( "Too many instructions (%d)\n", n_ins )); + + return TT_Err_Too_Many_Hints; + } + else if ( n_ins == 0 ) + return TT_Err_Ok; + + if ( FT_STREAM_READ( loader->exec->glyphIns, n_ins ) ) + return error; + + loader->glyph->control_data = loader->exec->glyphIns; + loader->glyph->control_len = n_ins; + } + +#endif + + tt_prepare_zone( &loader->zone, &loader->gloader->base, + start_point, start_contour ); + loader->zone.n_points += 4; + + return TT_Hint_Glyph( loader, 1 ); + } + + + /* Calculate the four phantom points. */ + /* The first two stand for horizontal origin and advance. */ + /* The last two stand for vertical origin and advance. */ +#define TT_LOADER_SET_PP( loader ) \ + do { \ + (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \ + (loader)->pp1.y = 0; \ + (loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \ + (loader)->pp2.y = 0; \ + (loader)->pp3.x = 0; \ + (loader)->pp3.y = (loader)->top_bearing + (loader)->bbox.yMax; \ + (loader)->pp4.x = 0; \ + (loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \ + } while ( 0 ) + + /*************************************************************************/ /* */ /* */ @@ -959,32 +1025,25 @@ FT_UInt glyph_index, FT_UInt recurse_count ) { - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - FT_Stream stream = loader->stream; -#endif - FT_Error error; - TT_Face face = (TT_Face)loader->face; - FT_ULong offset; - FT_Int contours_count; - FT_UInt num_points, count; FT_Fixed x_scale, y_scale; - FT_GlyphLoader gloader = loader->gloader; + FT_ULong offset; + TT_Face face = (TT_Face)loader->face; + FT_GlyphLoader gloader = loader->gloader; FT_Bool opened_frame = 0; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Vector* deltas = NULL; +#endif + #ifdef FT_CONFIG_OPTION_INCREMENTAL FT_StreamRec inc_stream; FT_Data glyph_data; FT_Bool glyph_data_loaded = 0; #endif -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Vector *deltas; -#endif - - if ( recurse_count >= TT_MAX_COMPOSITE_RECURSE ) + if ( recurse_count > face->max_profile.maxComponentDepth ) { error = TT_Err_Invalid_Composite; goto Exit; @@ -998,15 +1057,17 @@ } loader->glyph_index = glyph_index; - num_points = 0; - x_scale = 0x10000L; - y_scale = 0x10000L; if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { x_scale = ((TT_Size)loader->size)->metrics.x_scale; y_scale = ((TT_Size)loader->size)->metrics.y_scale; } + else + { + x_scale = 0x10000L; + y_scale = 0x10000L; + } /* get metrics, horizontal and vertical */ { @@ -1045,16 +1106,10 @@ goto Exit; left_bearing = (FT_Short)metrics.bearing_x; advance_width = (FT_UShort)metrics.advance; - } - -# if 0 - /* GWW: Do I do the same for vertical metrics ??? */ - if ( face->root.internal->incremental_interface && - face->root.internal->incremental_interface->funcs->get_glyph_metrics ) - { - FT_Incremental_MetricsRec metrics; +#if 0 + /* GWW: Do I do the same for vertical metrics? */ metrics.bearing_x = 0; metrics.bearing_y = top_bearing; metrics.advance = advance_height; @@ -1065,8 +1120,10 @@ goto Exit; top_bearing = (FT_Short)metrics.bearing_y; advance_height = (FT_UShort)metrics.advance; + +#endif /* 0 */ + } -# endif #endif /* FT_CONFIG_OPTION_INCREMENTAL */ @@ -1082,16 +1139,15 @@ } } + /* Set `offset' to the start of the glyph relative to the start of */ + /* the `glyf' table, and `byte_len' to the length of the glyph in */ + /* bytes. */ + #ifdef FT_CONFIG_OPTION_INCREMENTAL - /* Set `offset' to the start of the glyph program relative to the */ - /* start of the 'glyf' table, and `count' to the length of the */ - /* glyph program in bytes. */ - /* */ /* If we are loading glyph data via the incremental interface, set */ /* the loader stream to a memory stream reading the data returned */ /* by the interface. */ - if ( face->root.internal->incremental_interface ) { error = face->root.internal->incremental_interface->funcs->get_glyph_data( @@ -1102,7 +1158,7 @@ glyph_data_loaded = 1; offset = 0; - count = glyph_data.length; + loader->byte_len = glyph_data.length; FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) ); FT_Stream_OpenMemory( &inc_stream, @@ -1114,23 +1170,22 @@ #endif /* FT_CONFIG_OPTION_INCREMENTAL */ - offset = tt_face_get_location( face, glyph_index, &count ); + offset = tt_face_get_location( face, glyph_index, + (FT_UInt*)&loader->byte_len ); - if ( count == 0 ) + if ( loader->byte_len == 0 ) { - /* as described by Frederic Loyer, these are spaces, and */ - /* not the unknown glyph. */ + /* as described by Frederic Loyer, these are spaces or */ + /* the unknown glyph. */ loader->bbox.xMin = 0; loader->bbox.xMax = 0; loader->bbox.yMin = 0; loader->bbox.yMax = 0; - loader->pp1.x = 0; - loader->pp2.x = loader->advance; - loader->pp3.y = 0; - loader->pp4.y = loader->pp3.y-loader->vadvance; + TT_LOADER_SET_PP( loader ); #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( ((TT_Face)(loader->face))->doblend ) { /* this must be done before scaling */ @@ -1149,31 +1204,24 @@ FT_FREE( deltas ); } + #endif if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { + loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale ); loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale ); + loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale ); loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale ); } -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - if ( loader->exec ) - loader->exec->glyphSize = 0; - -#endif - error = TT_Err_Ok; goto Exit; } - loader->byte_len = (FT_Int)count; - - offset = loader->glyf_offset + offset; - - /* access glyph frame */ - error = face->access_glyph_frame( loader, glyph_index, offset, count ); + error = face->access_glyph_frame( loader, glyph_index, + loader->glyf_offset + offset, + loader->byte_len ); if ( error ) goto Exit; @@ -1182,21 +1230,9 @@ /* read first glyph header */ error = face->read_glyph_header( loader ); if ( error ) - goto Fail; + goto Exit; - contours_count = loader->n_contours; - - count -= 10; - - loader->pp1.x = loader->bbox.xMin - loader->left_bearing; - loader->pp1.y = 0; - loader->pp2.x = loader->pp1.x + loader->advance; - loader->pp2.y = 0; - - loader->pp3.x = 0; - loader->pp3.y = loader->top_bearing + loader->bbox.yMax; - loader->pp4.x = 0; - loader->pp4.y = loader->pp3.y - loader->vadvance; + TT_LOADER_SET_PP( loader ); /***********************************************************************/ /***********************************************************************/ @@ -1204,40 +1240,21 @@ /* if it is a simple glyph, load it */ - if ( contours_count >= 0 ) + if ( loader->n_contours >= 0 ) { - /* check that we can add the contours to the glyph */ - error = FT_GlyphLoader_CheckPoints( gloader, 0, contours_count ); - if ( error ) - goto Fail; - error = face->read_simple_glyph( loader ); if ( error ) - goto Fail; + goto Exit; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - { - TT_Size size = (TT_Size)loader->size; - - - error = TT_Process_Simple_Glyph( loader, - (FT_Bool)( size && size->debug ) ); - } - -#else - - error = TT_Process_Simple_Glyph( loader, 0 ); - -#endif + /* all data have been read */ + face->forget_glyph_frame( loader ); + opened_frame = 0; + error = TT_Process_Simple_Glyph( loader ); if ( error ) - goto Fail; + goto Exit; FT_GlyphLoader_Add( gloader ); - - /* Note: We could have put the simple loader source there */ - /* but the code is fat enough already :-) */ } /***********************************************************************/ @@ -1245,29 +1262,25 @@ /***********************************************************************/ /* otherwise, load a composite! */ - else if ( contours_count == -1 ) + else if ( loader->n_contours == -1 ) { - TT_GlyphSlot glyph = (TT_GlyphSlot)loader->glyph; FT_UInt start_point; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER FT_UInt start_contour; FT_ULong ins_pos; /* position of composite instructions, if any */ -#endif + start_point = gloader->base.outline.n_points; + start_contour = gloader->base.outline.n_contours; + /* for each subglyph, read composite header */ - start_point = gloader->base.outline.n_points; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - start_contour = gloader->base.outline.n_contours; -#endif - error = face->read_composite_glyph( loader ); if ( error ) - goto Fail; + goto Exit; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + /* store the offset of instructions */ ins_pos = loader->ins_pos; -#endif + + /* all data we need are read */ face->forget_glyph_frame( loader ); opened_frame = 0; @@ -1290,7 +1303,6 @@ gloader->current.num_subglyphs + 4 )) != 0 ) goto Exit; - /* Note: No subglyph reallocation here, our pointers are stable. */ subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs; limit = gloader->current.num_subglyphs; @@ -1327,12 +1339,8 @@ /* */ if ( loader->load_flags & FT_LOAD_NO_RECURSE ) { - /* set up remaining glyph fields */ FT_GlyphLoader_Add( gloader ); - - glyph->num_subglyphs = gloader->base.num_subglyphs; - glyph->format = FT_GLYPH_FORMAT_COMPOSITE; - glyph->subglyphs = gloader->base.subglyphs; + loader->glyph->format = FT_GLYPH_FORMAT_COMPOSITE; goto Exit; } @@ -1341,21 +1349,21 @@ /*********************************************************************/ /*********************************************************************/ - /* Now, read each subglyph independently. */ { - FT_Int n, num_base_points, num_new_points; + FT_UInt n, num_base_points; FT_SubGlyph subglyph = 0; + FT_UInt num_points = start_point; FT_UInt num_subglyphs = gloader->current.num_subglyphs; FT_UInt num_base_subgs = gloader->base.num_subglyphs; FT_GlyphLoader_Add( gloader ); - for ( n = 0; n < (FT_Int)num_subglyphs; n++ ) + /* read each subglyph independently */ + for ( n = 0; n < num_subglyphs; n++ ) { - FT_Vector pp1, pp2, pp3, pp4; - FT_Pos x, y; + FT_Vector pp[4]; /* Each time we call load_truetype_glyph in this loop, the */ @@ -1364,316 +1372,83 @@ /* pointer on each iteration. */ subglyph = gloader->base.subglyphs + num_base_subgs + n; - pp1 = loader->pp1; - pp2 = loader->pp2; - pp3 = loader->pp3; - pp4 = loader->pp4; + pp[0] = loader->pp1; + pp[1] = loader->pp2; + pp[2] = loader->pp3; + pp[3] = loader->pp4; num_base_points = gloader->base.outline.n_points; error = load_truetype_glyph( loader, subglyph->index, recurse_count + 1 ); if ( error ) - goto Fail; + goto Exit; /* restore subglyph pointer */ subglyph = gloader->base.subglyphs + num_base_subgs + n; - if ( subglyph->flags & USE_MY_METRICS ) + if ( !( subglyph->flags & USE_MY_METRICS ) ) { - pp1 = loader->pp1; - pp2 = loader->pp2; - pp3 = loader->pp3; - pp4 = loader->pp4; - } - else - { - loader->pp1 = pp1; - loader->pp2 = pp2; - loader->pp3 = pp3; - loader->pp4 = pp4; + loader->pp1 = pp[0]; + loader->pp2 = pp[1]; + loader->pp3 = pp[2]; + loader->pp4 = pp[3]; } num_points = gloader->base.outline.n_points; - num_new_points = num_points - num_base_points; + if ( num_points == num_base_points ) + continue; - /* now perform the transform required for this subglyph */ - - if ( subglyph->flags & ( WE_HAVE_A_SCALE | - WE_HAVE_AN_XY_SCALE | - WE_HAVE_A_2X2 ) ) - { - FT_Vector* cur = gloader->base.outline.points + - num_base_points; - FT_Vector* org = gloader->base.extra_points + - num_base_points; - FT_Vector* limit = cur + num_new_points; - - - for ( ; cur < limit; cur++, org++ ) - { - FT_Vector_Transform( cur, &subglyph->transform ); - FT_Vector_Transform( org, &subglyph->transform ); - } - } - - /* apply offset */ - - if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) ) - { - FT_UInt k = subglyph->arg1; - FT_UInt l = subglyph->arg2; - FT_Vector* p1; - FT_Vector* p2; - - - if ( start_point + k >= (FT_UInt)num_base_points || - l >= (FT_UInt)num_new_points ) - { - error = TT_Err_Invalid_Composite; - goto Fail; - } - - l += num_base_points; - - p1 = gloader->base.outline.points + start_point + k; - p2 = gloader->base.outline.points + start_point + l; - - x = p1->x - p2->x; - y = p1->y - p2->y; - } - else - { - x = subglyph->arg1; - y = subglyph->arg2; - - /* Use a default value dependent on */ - /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */ - /* fonts which don't set the xxx_COMPONENT_OFFSET bit. */ - -#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED - if ( !( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) && -#else - if ( ( subglyph->flags & SCALED_COMPONENT_OFFSET ) && -#endif - ( subglyph->flags & ( WE_HAVE_A_SCALE | - WE_HAVE_AN_XY_SCALE | - WE_HAVE_A_2X2 )) ) - { -#if 0 - - /*************************************************************************/ - /* */ - /* This algorithm is what Apple documents. But it doesn't work. */ - /* */ - int a = subglyph->transform.xx > 0 ? subglyph->transform.xx - : -subglyph->transform.xx; - int b = subglyph->transform.yx > 0 ? subglyph->transform.yx - : -subglyph->transform.yx; - int c = subglyph->transform.xy > 0 ? subglyph->transform.xy - : -subglyph->transform.xy; - int d = subglyph->transform.yy > 0 ? subglyph->transform.yy - : -subglyph->transform.yy; - int m = a > b ? a : b; - int n = c > d ? c : d; - - - if ( a - b <= 33 && a - b >= -33 ) - m *= 2; - if ( c - d <= 33 && c - d >= -33 ) - n *= 2; - x = FT_MulFix( x, m ); - y = FT_MulFix( y, n ); - -#else /* 0 */ - - /*************************************************************************/ - /* */ - /* This algorithm is a guess and works much better than the above. */ - /* */ - FT_Fixed mac_xscale = FT_SqrtFixed( - FT_MulFix( subglyph->transform.xx, - subglyph->transform.xx ) + - FT_MulFix( subglyph->transform.xy, - subglyph->transform.xy) ); - FT_Fixed mac_yscale = FT_SqrtFixed( - FT_MulFix( subglyph->transform.yy, - subglyph->transform.yy ) + - FT_MulFix( subglyph->transform.yx, - subglyph->transform.yx ) ); - - - x = FT_MulFix( x, mac_xscale ); - y = FT_MulFix( y, mac_yscale ); -#endif /* 0 */ - - } - - if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) - { - x = FT_MulFix( x, x_scale ); - y = FT_MulFix( y, y_scale ); - - if ( subglyph->flags & ROUND_XY_TO_GRID ) - { - x = FT_PIX_ROUND( x ); - y = FT_PIX_ROUND( y ); - } - } - } - - if ( x || y ) - { - translate_array( num_new_points, - gloader->base.outline.points + num_base_points, - x, y ); - - translate_array( num_new_points, - gloader->base.extra_points + num_base_points, - x, y ); - } + /* gloader->base.outline consists of three part: */ + /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */ + /* */ + /* (1): exist from the beginning */ + /* (2): components that have been loaded so far */ + /* (3): the newly loaded component */ + TT_Process_Composite_Component( loader, subglyph, start_point, + num_base_points ); } - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /* we have finished loading all sub-glyphs; now, look for */ - /* instructions for this composite! */ + /* process the glyph */ + loader->ins_pos = ins_pos; + if ( IS_HINTED( loader->load_flags ) && #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - if ( num_subglyphs > 0 && - loader->exec && - ins_pos > 0 && - subglyph->flags & WE_HAVE_INSTR ) - { - FT_UShort n_ins; - TT_ExecContext exec = loader->exec; - TT_GlyphZone pts; - FT_Vector* pp1; + subglyph->flags & WE_HAVE_INSTR && +#endif - /* read size of instructions */ - if ( FT_STREAM_SEEK( ins_pos ) || - FT_READ_USHORT( n_ins ) ) - goto Fail; - FT_TRACE5(( " Instructions size = %d\n", n_ins )); - - /* in some fonts? */ - if ( n_ins == 0xFFFFU ) - n_ins = 0; - - /* check it */ - if ( n_ins > face->max_profile.maxSizeOfInstructions ) - { - FT_TRACE0(( "Too many instructions (%d) in composite glyph %ld\n", - n_ins, subglyph->index )); - error = TT_Err_Too_Many_Hints; - goto Fail; - } - - /* read the instructions */ - if ( FT_STREAM_READ( exec->glyphIns, n_ins ) ) - goto Fail; - - glyph->control_data = exec->glyphIns; - glyph->control_len = n_ins; - - error = TT_Set_CodeRange( exec, - tt_coderange_glyph, - exec->glyphIns, - n_ins ); - if ( error ) - goto Fail; - - error = FT_GlyphLoader_CheckPoints( gloader, num_points + 4, 0 ); - if ( error ) - goto Fail; - - /* prepare the execution context */ - tt_prepare_zone( &exec->pts, &gloader->base, - start_point, start_contour ); - pts = &exec->pts; - - pts->n_points = (short)( num_points + 4 ); - pts->n_contours = gloader->base.outline.n_contours; - - /* add phantom points */ - pp1 = pts->cur + num_points; - pp1[0] = loader->pp1; - pp1[1] = loader->pp2; - pp1[2] = loader->pp3; - pp1[3] = loader->pp4; - - pts->tags[num_points ] = 0; - pts->tags[num_points + 1] = 0; - pts->tags[num_points + 2] = 0; - pts->tags[num_points + 3] = 0; - - /* if hinting, round the phantom points */ - if ( IS_HINTED( loader->load_flags ) ) - { - pp1[0].x = FT_PIX_ROUND( loader->pp1.x ); - pp1[1].x = FT_PIX_ROUND( loader->pp2.x ); - pp1[2].y = FT_PIX_ROUND( loader->pp3.y ); - pp1[3].y = FT_PIX_ROUND( loader->pp4.y ); - } - - { - FT_UInt k; - - - for ( k = 0; k < num_points; k++ ) - pts->tags[k] &= FT_CURVE_TAG_ON; - } - - cur_to_org( num_points + 4, pts ); - - /* now consider hinting */ - if ( IS_HINTED( loader->load_flags ) && n_ins > 0 ) - { - exec->is_composite = TRUE; - error = TT_Run_Context( exec, ((TT_Size)loader->size)->debug ); - if ( error && exec->pedantic_hinting ) - goto Fail; - } - - /* save glyph origin and advance points */ - loader->pp1 = pp1[0]; - loader->pp2 = pp1[1]; - loader->pp3 = pp1[2]; - loader->pp4 = pp1[3]; - } - -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + num_points > start_point ) + TT_Process_Composite_Glyph( loader, start_point, start_contour ); } - /* end of composite loading */ } else { /* invalid composite count ( negative but not -1 ) */ error = TT_Err_Invalid_Outline; - goto Fail; + goto Exit; } /***********************************************************************/ /***********************************************************************/ /***********************************************************************/ - Fail: + Exit: + if ( opened_frame ) face->forget_glyph_frame( loader ); - Exit: - #ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( glyph_data_loaded ) face->root.internal->incremental_interface->funcs->free_glyph_data( face->root.internal->incremental_interface->object, &glyph_data ); + #endif return error; @@ -1696,27 +1471,7 @@ y_scale = size->root.metrics.y_scale; if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE ) - { - glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS; - - /* copy outline to our glyph slot */ - FT_GlyphLoader_CopyPoints( glyph->internal->loader, loader->gloader ); - glyph->outline = glyph->internal->loader->base.outline; - - /* translate array so that (0,0) is the glyph's origin */ - FT_Outline_Translate( &glyph->outline, -loader->pp1.x, 0 ); - FT_Outline_Get_CBox( &glyph->outline, &bbox ); - - if ( IS_HINTED( loader->load_flags ) ) - { - /* grid-fit the bounding box */ - bbox.xMin = FT_PIX_FLOOR( bbox.xMin ); - bbox.yMin = FT_PIX_FLOOR( bbox.yMin ); - bbox.xMax = FT_PIX_CEIL( bbox.xMax ); - bbox.yMax = FT_PIX_CEIL( bbox.yMax ); - } - } else bbox = loader->bbox; @@ -1744,144 +1499,114 @@ glyph->metrics.horiBearingY = bbox.yMax; glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; - /* don't forget to hint the advance when we need to */ - if ( IS_HINTED( loader->load_flags ) ) - glyph->metrics.horiAdvance = FT_PIX_ROUND( glyph->metrics.horiAdvance ); - /* Now take care of vertical metrics. In the case where there is */ /* no vertical information within the font (relatively common), make */ /* up some metrics by `hand'... */ { - FT_Short top_bearing; /* vertical top side bearing (EM units) */ - FT_UShort advance_height; /* vertical advance height (EM units) */ - - FT_Pos left; /* scaled vertical left side bearing */ - FT_Pos top; /* scaled vertical top side bearing */ - FT_Pos advance; /* scaled vertical advance height */ + FT_Pos top; /* scaled vertical top side bearing */ + FT_Pos advance; /* scaled vertical advance height */ /* Get the unscaled top bearing and advance height. */ if ( face->vertical_info && face->vertical.number_Of_VMetrics > 0 ) { - advance_height = (FT_UShort)( loader->pp4.y - loader->pp3.y ); - top_bearing = (FT_Short)( loader->pp3.y - bbox.yMax ); + top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax, + y_scale ); + + if ( loader->pp3.y <= loader->pp4.y ) + advance = 0; + else + advance = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y, + y_scale ); } else { - /* Make up the distances from the horizontal header. */ + FT_Pos height; + + + /* XXX Compute top side bearing and advance height in */ + /* Get_VMetrics instead of here. */ /* NOTE: The OS/2 values are the only `portable' ones, */ /* which is why we use them, if there is an OS/2 */ /* table in the font. Otherwise, we use the */ /* values defined in the horizontal header. */ - /* */ - /* NOTE2: The sTypoDescender is negative, which is why */ - /* we compute the baseline-to-baseline distance */ - /* here with: */ - /* ascender - descender + linegap */ - /* */ - /* NOTE3: This is different from what MS's rasterizer */ - /* appears to do when getting default values */ - /* for the vertical phantom points. We leave */ - /* the old code untouched, but relying on */ - /* phantom points alone might be reasonable */ - /* (i.e., removing the `if' above). */ + + height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin, + y_scale ); if ( face->os2.version != 0xFFFFU ) - { - top_bearing = (FT_Short)( face->os2.sTypoLineGap / 2 ); - advance_height = (FT_UShort)( face->os2.sTypoAscender - - face->os2.sTypoDescender + - face->os2.sTypoLineGap ); - } + advance = (FT_Pos)( face->os2.sTypoAscender - + face->os2.sTypoDescender ); else - { - top_bearing = (FT_Short)( face->horizontal.Line_Gap / 2 ); - advance_height = (FT_UShort)( face->horizontal.Ascender + - face->horizontal.Descender + - face->horizontal.Line_Gap ); - } + advance = (FT_Pos)( face->horizontal.Ascender - + face->horizontal.Descender ); + + top = ( advance - height ) / 2; } #ifdef FT_CONFIG_OPTION_INCREMENTAL - - /* If this is an incrementally loaded font see if there are */ - /* overriding metrics for this glyph. */ - if ( face->root.internal->incremental_interface && - face->root.internal->incremental_interface->funcs->get_glyph_metrics ) { - FT_Incremental_MetricsRec metrics; - FT_Error error = TT_Err_Ok; + FT_Incremental_InterfaceRec* incr; + FT_Incremental_MetricsRec metrics; + FT_Error error; - metrics.bearing_x = 0; - metrics.bearing_y = top_bearing; - metrics.advance = advance_height; - error = - face->root.internal->incremental_interface->funcs->get_glyph_metrics( - face->root.internal->incremental_interface->object, - glyph_index, TRUE, &metrics ); + incr = face->root.internal->incremental_interface; - if ( error ) - return error; + /* If this is an incrementally loaded font see if there are */ + /* overriding metrics for this glyph. */ + if ( incr && incr->funcs->get_glyph_metrics ) + { + metrics.bearing_x = 0; + metrics.bearing_y = top; + metrics.advance = advance; - top_bearing = (FT_Short)metrics.bearing_y; - advance_height = (FT_UShort)metrics.advance; + error = incr->funcs->get_glyph_metrics( incr->object, + glyph_index, + TRUE, + &metrics ); + if ( error ) + return error; + + top = metrics.bearing_y; + advance = metrics.advance; + } } /* GWW: Do vertical metrics get loaded incrementally too? */ #endif /* FT_CONFIG_OPTION_INCREMENTAL */ - /* We must adjust the top_bearing value from the bounding box given */ - /* in the glyph header to the bounding box calculated with */ - /* FT_Get_Outline_CBox(). */ + glyph->linearVertAdvance = advance; /* scale the metrics */ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) { - top = FT_MulFix( top_bearing + loader->bbox.yMax, y_scale ) - - bbox.yMax; - advance = FT_MulFix( advance_height, y_scale ); + top = FT_MulFix( top, y_scale ); + advance = FT_MulFix( advance, y_scale ); } - else - { - top = top_bearing + loader->bbox.yMax - bbox.yMax; - advance = advance_height; - } - - /* set the advance height in design units. It is scaled later by */ - /* the base layer. */ - glyph->linearVertAdvance = advance_height; /* XXX: for now, we have no better algorithm for the lsb, but it */ /* should work fine. */ /* */ - left = ( bbox.xMin - bbox.xMax ) / 2; - - /* grid-fit them if necessary */ - if ( IS_HINTED( loader->load_flags ) ) - { - left = FT_PIX_FLOOR( left ); - top = FT_PIX_CEIL( top ); - advance = FT_PIX_ROUND( advance ); - } - - glyph->metrics.vertBearingX = left; + glyph->metrics.vertBearingX = ( bbox.xMin - bbox.xMax ) / 2; glyph->metrics.vertBearingY = top; glyph->metrics.vertAdvance = advance; } /* adjust advance width to the value contained in the hdmx table */ - if ( !face->postscript.isFixedPitch && size && + if ( !face->postscript.isFixedPitch && IS_HINTED( loader->load_flags ) ) { - FT_Byte* widthp = Get_Advance_WidthPtr( face, - size->root.metrics.x_ppem, - glyph_index ); + FT_Byte* widthp; + widthp = tt_face_get_device_metrics( face, + size->root.metrics.x_ppem, + glyph_index ); + if ( widthp ) glyph->metrics.horiAdvance = *widthp << 6; } @@ -1894,6 +1619,159 @@ } +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + + static FT_Error + load_sbit_image( TT_Size size, + TT_GlyphSlot glyph, + FT_UInt glyph_index, + FT_Int32 load_flags ) + { + TT_Face face; + SFNT_Service sfnt; + FT_Stream stream; + FT_Error error; + TT_SBit_MetricsRec metrics; + + + face = (TT_Face)glyph->face; + sfnt = (SFNT_Service)face->sfnt; + stream = face->root.stream; + + error = sfnt->load_sbit_image( face, + size->strike_index, + glyph_index, + (FT_Int)load_flags, + stream, + &glyph->bitmap, + &metrics ); + if ( !error ) + { + glyph->outline.n_points = 0; + glyph->outline.n_contours = 0; + + glyph->metrics.width = (FT_Pos)metrics.width << 6; + glyph->metrics.height = (FT_Pos)metrics.height << 6; + + glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; + glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; + glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; + + glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; + glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; + glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; + + glyph->format = FT_GLYPH_FORMAT_BITMAP; + if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) + { + glyph->bitmap_left = metrics.vertBearingX; + glyph->bitmap_top = metrics.vertBearingY; + } + else + { + glyph->bitmap_left = metrics.horiBearingX; + glyph->bitmap_top = metrics.horiBearingY; + } + } + + return error; + } + +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + + + static FT_Error + tt_loader_init( TT_Loader loader, + TT_Size size, + TT_GlyphSlot glyph, + FT_Int32 load_flags ) + { + TT_Face face; + FT_Stream stream; + + + face = (TT_Face)glyph->face; + stream = face->root.stream; + + FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) ); + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + /* load execution context */ + { + TT_ExecContext exec; + + + /* query new execution context */ + exec = size->debug ? size->context + : ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + TT_Load_Context( exec, face, size ); + + /* see if the cvt program has disabled hinting */ + if ( exec->GS.instruct_control & 1 ) + load_flags |= FT_LOAD_NO_HINTING; + + /* load default graphics state - if needed */ + if ( exec->GS.instruct_control & 2 ) + exec->GS = tt_default_graphics_state; + + exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC ); + exec->grayscale = + FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_LOAD_TARGET_MONO ); + + loader->exec = exec; + loader->instructions = exec->glyphIns; + } + +#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + + /* seek to the beginning of the glyph table. For Type 42 fonts */ + /* the table might be accessed from a Postscript stream or something */ + /* else... */ + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + if ( face->root.internal->incremental_interface ) + loader->glyf_offset = 0; + else + +#endif + + { + FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 ); + + + if ( error ) + { + FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); + return error; + } + loader->glyf_offset = FT_STREAM_POS(); + } + + /* get face's glyph loader */ + { + FT_GlyphLoader gloader = glyph->internal->loader; + + + FT_GlyphLoader_Rewind( gloader ); + loader->gloader = gloader; + } + + loader->load_flags = load_flags; + + loader->face = (FT_Face)face; + loader->size = (FT_Size)size; + loader->glyph = (FT_GlyphSlot)glyph; + loader->stream = stream; + + return TT_Err_Ok; + } + + /*************************************************************************/ /* */ /* */ @@ -1927,7 +1805,6 @@ FT_UInt glyph_index, FT_Int32 load_flags ) { - SFNT_Service sfnt; TT_Face face; FT_Stream stream; FT_Error error; @@ -1935,194 +1812,71 @@ face = (TT_Face)glyph->face; - sfnt = (SFNT_Service)face->sfnt; stream = face->root.stream; error = TT_Err_Ok; - if ( !size || ( load_flags & FT_LOAD_NO_SCALE ) || - ( load_flags & FT_LOAD_NO_RECURSE ) ) - { - size = NULL; - load_flags |= FT_LOAD_NO_SCALE | - FT_LOAD_NO_HINTING | - FT_LOAD_NO_BITMAP; - } - - glyph->num_subglyphs = 0; - #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* try to load embedded bitmap if any */ /* */ /* XXX: The convention should be emphasized in */ /* the documents because it can be confusing. */ - if ( size && - size->strike_index != 0xFFFFU && - sfnt->load_sbits && + if ( size->strike_index != 0xFFFFFFFFUL && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) - { - TT_SBit_MetricsRec metrics; - - - error = sfnt->load_sbit_image( face, - (FT_ULong)size->strike_index, - glyph_index, - (FT_Int)load_flags, - stream, - &glyph->bitmap, - &metrics ); + error = load_sbit_image( size, glyph, glyph_index, load_flags ); if ( !error ) - { - glyph->outline.n_points = 0; - glyph->outline.n_contours = 0; - - glyph->metrics.width = (FT_Pos)metrics.width << 6; - glyph->metrics.height = (FT_Pos)metrics.height << 6; - - glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; - glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; - glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; - - glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; - glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; - glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; - - glyph->format = FT_GLYPH_FORMAT_BITMAP; - if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) - { - glyph->bitmap_left = metrics.vertBearingX; - glyph->bitmap_top = metrics.vertBearingY; - } - else - { - glyph->bitmap_left = metrics.horiBearingX; - glyph->bitmap_top = metrics.horiBearingY; - } - return error; - } + return TT_Err_Ok; } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - /* return immediately if we only want the embedded bitmaps */ + /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */ + if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid ) + return TT_Err_Invalid_Size_Handle; + if ( load_flags & FT_LOAD_SBITS_ONLY ) return TT_Err_Invalid_Argument; - /* seek to the beginning of the glyph table. For Type 42 fonts */ - /* the table might be accessed from a Postscript stream or something */ - /* else... */ + error = tt_loader_init( &loader, size, glyph, load_flags ); + if ( error ) + return error; -#ifdef FT_CONFIG_OPTION_INCREMENTAL - - /* Don't look for the glyph table if this is an incremental font. */ - if ( !face->root.internal->incremental_interface ) - -#endif - - { - error = face->goto_table( face, TTAG_glyf, stream, 0 ); - if ( error ) - { - FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); - goto Exit; - } - } - - FT_MEM_ZERO( &loader, sizeof ( loader ) ); - - /* update the glyph zone bounds */ - { - FT_GlyphLoader gloader = FT_FACE_DRIVER( face )->glyph_loader; - - - loader.gloader = gloader; - - FT_GlyphLoader_Rewind( gloader ); - - tt_prepare_zone( &loader.zone, &gloader->base, 0, 0 ); - tt_prepare_zone( &loader.base, &gloader->base, 0, 0 ); - } - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - if ( size ) - { - /* query new execution context */ - loader.exec = size->debug ? size->context : TT_New_Context( face ); - if ( !loader.exec ) - return TT_Err_Could_Not_Find_Context; - - TT_Load_Context( loader.exec, face, size ); - loader.instructions = loader.exec->glyphIns; - - /* load default graphics state - if needed */ - if ( size->GS.instruct_control & 2 ) - loader.exec->GS = tt_default_graphics_state; - - loader.exec->pedantic_hinting = - FT_BOOL( load_flags & FT_LOAD_PEDANTIC ); - - loader.exec->grayscale = - FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_LOAD_TARGET_MONO ); - } - -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ - - /* clear all outline flags, except the `owner' one */ - glyph->outline.flags = 0; - - /* let's initialize the rest of our loader now */ - - loader.load_flags = load_flags; - - loader.face = (FT_Face)face; - loader.size = (FT_Size)size; - loader.glyph = (FT_GlyphSlot)glyph; - loader.stream = stream; - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - - if ( face->root.internal->incremental_interface ) - loader.glyf_offset = 0; - else - -#endif - - loader.glyf_offset = FT_STREAM_POS(); - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - /* if the cvt program has disabled hinting, the argument */ - /* is ignored. */ - if ( size && ( size->GS.instruct_control & 1 ) ) - loader.load_flags |= FT_LOAD_NO_HINTING; - -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ - - /* Main loading loop */ glyph->format = FT_GLYPH_FORMAT_OUTLINE; glyph->num_subglyphs = 0; + glyph->outline.flags = 0; + /* Main loading loop */ error = load_truetype_glyph( &loader, glyph_index, 0 ); if ( !error ) + { + if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE ) + { + glyph->num_subglyphs = loader.gloader->base.num_subglyphs; + glyph->subglyphs = loader.gloader->base.subglyphs; + } + else + { + glyph->outline = loader.gloader->base.outline; + glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS; + + /* In case bit 1 of the `flags' field in the `head' table isn't */ + /* set, translate array so that (0,0) is the glyph's origin. */ + if ( ( face->header.Flags & 2 ) == 0 && loader.pp1.x ) + FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 ); + } + compute_glyph_metrics( &loader, glyph_index ); - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - if ( !size || !size->debug ) - TT_Done_Context( loader.exec ); - -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + } /* Set the `high precision' bit flag. */ /* This is _critical_ to get correct output for monochrome */ /* TrueType glyphs at all sizes using the bytecode interpreter. */ /* */ - if ( size && size->root.metrics.y_ppem < 24 ) + if ( !( load_flags & FT_LOAD_NO_SCALE ) && + size->root.metrics.y_ppem < 24 ) glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION; - Exit: return error; } diff --git a/src/libs/freetype2/truetype/ttgxvar.c b/src/libs/freetype2/truetype/ttgxvar.c index fe5eaa312b..c3ae970d72 100644 --- a/src/libs/freetype2/truetype/ttgxvar.c +++ b/src/libs/freetype2/truetype/ttgxvar.c @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader */ /* */ -/* Copyright 2004, 2005 by */ +/* Copyright 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -684,15 +684,17 @@ goto Exit; } - if ( FT_ALLOC( face->blend, sizeof ( GX_BlendRec ) ) ) + if ( FT_NEW( face->blend ) ) goto Exit; + /* XXX: TODO - check for overflows */ face->blend->mmvar_len = sizeof ( FT_MM_Var ) + fvar_head.axisCount * sizeof ( FT_Var_Axis ) + fvar_head.instanceCount * sizeof ( FT_Var_Named_Style ) + fvar_head.instanceCount * fvar_head.axisCount * sizeof ( FT_Fixed ) + 5 * fvar_head.axisCount; + if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) ) goto Exit; face->blend->mmvar = mmvar; @@ -1253,7 +1255,7 @@ for ( j = 0; j < point_count; ++j ) { int pindex = localpoints[j]; - + face->cvt[pindex] = (FT_Short)( face->cvt[pindex] + FT_MulFix( deltas[j], apply ) ); } diff --git a/src/libs/freetype2/truetype/ttinterp.c b/src/libs/freetype2/truetype/ttinterp.c index ec8daae510..bb08a5ae22 100644 --- a/src/libs/freetype2/truetype/ttinterp.c +++ b/src/libs/freetype2/truetype/ttinterp.c @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -94,10 +94,19 @@ #define CUR (*exc) /* see ttobjs.h */ + /*************************************************************************/ + /* */ + /* This macro is used whenever `exec' is unused in a function, to avoid */ + /* stupid warnings from pedantic compilers. */ + /* */ +#define FT_UNUSED_EXEC FT_UNUSED( exc ) + #else /* static implementation */ #define CUR cur +#define FT_UNUSED_EXEC int __dummy = __dummy + static TT_ExecContextRec cur; /* static exec. context variable */ @@ -115,14 +124,6 @@ #define INS_ARG EXEC_OP_ FT_Long* args /* see ttobjs.h for EXEC_OP_ */ - /*************************************************************************/ - /* */ - /* This macro is used whenever `exec' is unused in a function, to avoid */ - /* stupid warnings from pedantic compilers. */ - /* */ -#define FT_UNUSED_EXEC FT_UNUSED( CUR ) - - /*************************************************************************/ /* */ /* This macro is used whenever `args' is unused in a function, to avoid */ @@ -371,7 +372,7 @@ /*************************************************************************/ /* */ /* */ - /* TT_Destroy_Context */ + /* TT_Done_Context */ /* */ /* */ /* Destroys a given context. */ @@ -388,12 +389,10 @@ /* Only the glyph loader and debugger should call this function. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Destroy_Context( TT_ExecContext exec, - FT_Memory memory ) + TT_Done_Context( TT_ExecContext exec ) { - /* free composite load stack */ - FT_FREE( exec->loadStack ); - exec->loadSize = 0; + FT_Memory memory = exec->memory; + /* points zone */ exec->maxPoints = 0; @@ -416,6 +415,7 @@ exec->face = NULL; FT_FREE( exec ); + return TT_Err_Ok; } @@ -431,8 +431,6 @@ /* */ /* memory :: A handle to the parent memory object. */ /* */ - /* face :: A handle to the source TrueType face object. */ - /* */ /* */ /* exec :: A handle to the target execution context. */ /* */ @@ -441,14 +439,12 @@ /* */ static FT_Error Init_Context( TT_ExecContext exec, - TT_Face face, FT_Memory memory ) { FT_Error error; - FT_TRACE1(( "Init_Context: new object at 0x%08p, parent = 0x%08p\n", - exec, face )); + FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec )); exec->memory = memory; exec->callSize = 32; @@ -462,14 +458,12 @@ exec->maxContours = 0; exec->stackSize = 0; - exec->loadSize = 0; exec->glyphSize = 0; exec->stack = NULL; - exec->loadStack = NULL; exec->glyphIns = NULL; - exec->face = face; + exec->face = NULL; exec->size = NULL; return TT_Err_Ok; @@ -477,7 +471,7 @@ Fail_Memory: FT_ERROR(( "Init_Context: not enough memory for 0x%08lx\n", (FT_Long)exec )); - TT_Destroy_Context( exec, memory ); + TT_Done_Context( exec ); return error; } @@ -519,7 +513,7 @@ if ( *size < new_max ) { - if ( FT_REALLOC( *buff, *size, new_max * multiplier ) ) + if ( FT_REALLOC( *buff, *size * multiplier, new_max * multiplier ) ) return error; *size = new_max; } @@ -594,14 +588,6 @@ exec->twilight = size->twilight; } - error = Update_Max( exec->memory, - &exec->loadSize, - sizeof ( TT_SubGlyphRec ), - (void**)&exec->loadStack, - exec->face->max_components + 1 ); - if ( error ) - return error; - /* XXX: We reserve a little more elements on the stack to deal safely */ /* with broken fonts like arialbs, courbs, timesbs, etc. */ tmp = exec->stackSize; @@ -770,18 +756,12 @@ /* documentation is in ttinterp.h */ FT_EXPORT_DEF( TT_ExecContext ) - TT_New_Context( TT_Face face ) + TT_New_Context( TT_Driver driver ) { - TT_Driver driver; TT_ExecContext exec; FT_Memory memory; - if ( !face ) - return 0; - - driver = (TT_Driver)face->root.driver; - memory = driver->root.root.memory; exec = driver->context; @@ -795,7 +775,7 @@ goto Exit; /* initialize it */ - error = Init_Context( exec, face, memory ); + error = Init_Context( exec, memory ); if ( error ) goto Fail; @@ -813,34 +793,6 @@ } - /*************************************************************************/ - /* */ - /* */ - /* TT_Done_Context */ - /* */ - /* */ - /* Discards an execution context. */ - /* */ - /* */ - /* exec :: A handle to the target execution context. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Only the glyph loader and debugger should call this function. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - TT_Done_Context( TT_ExecContext exec ) - { - /* Nothing at all for now */ - FT_UNUSED( exec ); - - return TT_Err_Ok; - } - - - /*************************************************************************/ /* */ /* Before an opcode is executed, the interpreter verifies that there are */ diff --git a/src/libs/freetype2/truetype/ttinterp.h b/src/libs/freetype2/truetype/ttinterp.h index 43f662c047..2b8dae100b 100644 --- a/src/libs/freetype2/truetype/ttinterp.h +++ b/src/libs/freetype2/truetype/ttinterp.h @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -216,9 +216,6 @@ FT_BEGIN_HEADER TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */ TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */ - FT_ULong loadSize; - TT_SubGlyph_Stack loadStack; /* loading subglyph stack */ - FT_Bool grayscale; /* are we hinting for grayscale? */ } TT_ExecContextRec; @@ -263,16 +260,11 @@ FT_BEGIN_HEADER /* Only the glyph loader and debugger should call this function. */ /* */ FT_EXPORT( TT_ExecContext ) - TT_New_Context( TT_Face face ); - + TT_New_Context( TT_Driver driver ); FT_LOCAL( FT_Error ) TT_Done_Context( TT_ExecContext exec ); - FT_LOCAL( FT_Error ) - TT_Destroy_Context( TT_ExecContext exec, - FT_Memory memory ); - FT_LOCAL( FT_Error ) TT_Load_Context( TT_ExecContext exec, TT_Face face, diff --git a/src/libs/freetype2/truetype/ttobjs.c b/src/libs/freetype2/truetype/ttobjs.c index 05e673dbc3..89ef75d918 100644 --- a/src/libs/freetype2/truetype/ttobjs.c +++ b/src/libs/freetype2/truetype/ttobjs.c @@ -4,7 +4,7 @@ /* */ /* Objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -66,7 +66,7 @@ /* tt_glyphzone_done */ /* */ /* */ - /* Deallocates a glyph zone. */ + /* Deallocate a glyph zone. */ /* */ /* */ /* zone :: A pointer to the target glyph zone. */ @@ -97,7 +97,7 @@ /* tt_glyphzone_new */ /* */ /* */ - /* Allocates a new glyph zone. */ + /* Allocate a new glyph zone. */ /* */ /* */ /* memory :: A handle to the current memory object. */ @@ -121,19 +121,21 @@ FT_Error error; - if ( maxPoints > 0 ) - maxPoints += 2; - FT_MEM_ZERO( zone, sizeof ( *zone ) ); zone->memory = memory; - if ( FT_NEW_ARRAY( zone->org, maxPoints * 2 ) || - FT_NEW_ARRAY( zone->cur, maxPoints * 2 ) || - FT_NEW_ARRAY( zone->tags, maxPoints ) || - FT_NEW_ARRAY( zone->contours, maxContours ) ) + if ( FT_NEW_ARRAY( zone->org, maxPoints ) || + FT_NEW_ARRAY( zone->cur, maxPoints ) || + FT_NEW_ARRAY( zone->tags, maxPoints ) || + FT_NEW_ARRAY( zone->contours, maxContours ) ) { tt_glyphzone_done( zone ); } + else + { + zone->max_points = maxPoints; + zone->max_contours = maxContours; + } return error; } @@ -146,7 +148,7 @@ /* tt_face_init */ /* */ /* */ - /* Initializes a given TrueType face object. */ + /* Initialize a given TrueType face object. */ /* */ /* */ /* stream :: The source font stream. */ @@ -201,7 +203,11 @@ goto Bad_Format; } - /* If we are performing a simple font format check, exit immediately */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + face->root.face_flags |= FT_FACE_FLAG_HINTER; +#endif + + /* If we are performing a simple font format check, exit immediately. */ if ( face_index < 0 ) return TT_Err_Ok; @@ -210,6 +216,10 @@ if ( error ) goto Exit; + error = tt_face_load_hdmx( face, stream ); + if ( error ) + goto Exit; + if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE ) { @@ -218,18 +228,17 @@ if ( !face->root.internal->incremental_interface ) error = tt_face_load_loca( face, stream ); if ( !error ) - { - error = tt_face_load_cvt( face, stream ); - if ( !error ) - error = tt_face_load_fpgm( face, stream ); - } + error = tt_face_load_cvt( face, stream ) || + tt_face_load_fpgm( face, stream ) || + tt_face_load_prep( face, stream ); #else if ( !error ) error = tt_face_load_loca( face, stream ) || tt_face_load_cvt( face, stream ) || - tt_face_load_fpgm( face, stream ); + tt_face_load_fpgm( face, stream ) || + tt_face_load_prep( face, stream ); #endif @@ -270,7 +279,7 @@ /* tt_face_done */ /* */ /* */ - /* Finalizes a given face object. */ + /* Finalize a given face object. */ /* */ /* */ /* face :: A pointer to the face object to destroy. */ @@ -295,6 +304,8 @@ /* freeing the locations table */ tt_face_done_loca( face ); + tt_face_free_hdmx( face ); + /* freeing the CVT */ FT_FREE( face->cvt ); face->cvt_size = 0; @@ -318,6 +329,158 @@ /* */ /*************************************************************************/ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + /*************************************************************************/ + /* */ + /* */ + /* tt_size_run_fpgm */ + /* */ + /* */ + /* Run the font program. */ + /* */ + /* */ + /* size :: A handle to the size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + tt_size_run_fpgm( TT_Size size ) + { + TT_Face face = (TT_Face)size->root.face; + TT_ExecContext exec; + FT_Error error; + + + /* debugging instances have their own context */ + if ( size->debug ) + exec = size->context; + else + exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + TT_Load_Context( exec, face, size ); + + exec->callTop = 0; + exec->top = 0; + + exec->period = 64; + exec->phase = 0; + exec->threshold = 0; + + exec->instruction_trap = FALSE; + exec->F_dot_P = 0x10000L; + + { + FT_Size_Metrics* metrics = &exec->metrics; + TT_Size_Metrics* tt_metrics = &exec->tt_metrics; + + + metrics->x_ppem = 0; + metrics->y_ppem = 0; + metrics->x_scale = 0; + metrics->y_scale = 0; + + tt_metrics->ppem = 0; + tt_metrics->scale = 0; + tt_metrics->ratio = 0x10000L; + } + + /* allow font program execution */ + TT_Set_CodeRange( exec, + tt_coderange_font, + face->font_program, + face->font_program_size ); + + /* disable CVT and glyph programs coderange */ + TT_Clear_CodeRange( exec, tt_coderange_cvt ); + TT_Clear_CodeRange( exec, tt_coderange_glyph ); + + if ( face->font_program_size > 0 ) + { + error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); + + if ( !error ) + error = face->interpreter( exec ); + } + else + error = TT_Err_Ok; + + if ( !error ) + TT_Save_Context( exec, size ); + + return error; + } + + + /*************************************************************************/ + /* */ + /* */ + /* tt_size_run_prep */ + /* */ + /* */ + /* Run the control value program. */ + /* */ + /* */ + /* size :: A handle to the size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + tt_size_run_prep( TT_Size size ) + { + TT_Face face = (TT_Face)size->root.face; + TT_ExecContext exec; + FT_Error error; + + + /* debugging instances have their own context */ + if ( size->debug ) + exec = size->context; + else + exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + TT_Load_Context( exec, face, size ); + + exec->callTop = 0; + exec->top = 0; + + exec->instruction_trap = FALSE; + + TT_Set_CodeRange( exec, + tt_coderange_cvt, + face->cvt_program, + face->cvt_program_size ); + + TT_Clear_CodeRange( exec, tt_coderange_glyph ); + + if ( face->cvt_program_size > 0 ) + { + error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); + + if ( !error && !size->debug ) + error = face->interpreter( exec ); + } + else + error = TT_Err_Ok; + + /* save as default graphics state */ + size->GS = exec->GS; + + TT_Save_Context( exec, size ); + + return error; + } + +#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + /*************************************************************************/ /* */ @@ -325,7 +488,7 @@ /* tt_size_init */ /* */ /* */ - /* Initializes a new TrueType size object. */ + /* Initialize a new TrueType size object. */ /* */ /* */ /* size :: A handle to the size object. */ @@ -339,20 +502,16 @@ TT_Size size = (TT_Size)ttsize; FT_Error error = TT_Err_Ok; - #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER TT_Face face = (TT_Face)size->root.face; FT_Memory memory = face->root.memory; FT_Int i; - TT_ExecContext exec; FT_UShort n_twilight; TT_MaxProfile* maxp = &face->max_profile; - size->ttmetrics.valid = FALSE; - size->max_function_defs = maxp->maxFunctionDefs; size->max_instruction_defs = maxp->maxInstructionDefs; @@ -387,17 +546,30 @@ FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || FT_NEW_ARRAY( size->cvt, size->cvt_size ) || FT_NEW_ARRAY( size->storage, size->storage_size ) ) + { + tt_size_done( ttsize ); - goto Fail_Memory; + return error; + } /* reserve twilight zone */ n_twilight = maxp->maxTwilightPoints; + + /* there are 4 phantom points (do we need this?) */ + n_twilight += 4; + error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); if ( error ) - goto Fail_Memory; + { + tt_size_done( ttsize ); + + return error; + } size->twilight.n_points = n_twilight; + size->GS = tt_default_graphics_state; + /* set `face->interpreter' according to the debug hook present */ { FT_Library library = face->root.driver->root.library; @@ -409,95 +581,18 @@ face->interpreter = (TT_Interpreter)TT_RunIns; } - /* Fine, now execute the font program! */ - exec = size->context; - /* size objects used during debugging have their own context */ - if ( !size->debug ) - exec = TT_New_Context( face ); + /* Fine, now run the font program! */ + error = tt_size_run_fpgm( size ); - if ( !exec ) - { - error = TT_Err_Could_Not_Find_Context; - goto Fail_Memory; - } - - size->GS = tt_default_graphics_state; - TT_Load_Context( exec, face, size ); - - exec->callTop = 0; - exec->top = 0; - - exec->period = 64; - exec->phase = 0; - exec->threshold = 0; - - { - FT_Size_Metrics* metrics = &exec->metrics; - TT_Size_Metrics* tt_metrics = &exec->tt_metrics; - - - metrics->x_ppem = 0; - metrics->y_ppem = 0; - metrics->x_scale = 0; - metrics->y_scale = 0; - - tt_metrics->ppem = 0; - tt_metrics->scale = 0; - tt_metrics->ratio = 0x10000L; - } - - exec->instruction_trap = FALSE; - - exec->cvtSize = size->cvt_size; - exec->cvt = size->cvt; - - exec->F_dot_P = 0x10000L; - - /* allow font program execution */ - TT_Set_CodeRange( exec, - tt_coderange_font, - face->font_program, - face->font_program_size ); - - /* disable CVT and glyph programs coderange */ - TT_Clear_CodeRange( exec, tt_coderange_cvt ); - TT_Clear_CodeRange( exec, tt_coderange_glyph ); - - if ( face->font_program_size > 0 ) - { - error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); - if ( !error ) - error = face->interpreter( exec ); - - if ( error ) - goto Fail_Exec; - } - else - error = TT_Err_Ok; - - TT_Save_Context( exec, size ); - - if ( !size->debug ) - TT_Done_Context( exec ); + if ( error ) + tt_size_done( ttsize ); #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ size->ttmetrics.valid = FALSE; + size->strike_index = 0xFFFFFFFFUL; + return error; - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - Fail_Exec: - if ( !size->debug ) - TT_Done_Context( exec ); - - Fail_Memory: - - tt_size_done( ttsize ); - return error; - -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ - } @@ -559,34 +654,57 @@ /*************************************************************************/ /* */ /* */ - /* Reset_Outline_Size */ + /* tt_size_reset */ /* */ /* */ - /* Resets a TrueType outline size when resolutions and character */ - /* dimensions have been changed. */ + /* Reset a TrueType size when resolutions and character dimensions */ + /* have been changed. */ /* */ /* */ /* size :: A handle to the target size object. */ /* */ - static FT_Error - Reset_Outline_Size( TT_Size size ) + FT_LOCAL_DEF( FT_Error ) + tt_size_reset( TT_Size size ) { TT_Face face; FT_Error error = TT_Err_Ok; - FT_Size_Metrics* metrics; - if ( size->ttmetrics.valid ) - return TT_Err_Ok; + size->ttmetrics.valid = FALSE; face = (TT_Face)size->root.face; metrics = &size->metrics; + /* copy the result from base layer */ + *metrics = size->root.metrics; + if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 ) return TT_Err_Invalid_PPem; + /* This bit flag, if set, indicates that the ppems must be */ + /* rounded to integers. Nearly all TrueType fonts have this bit */ + /* set, as hinting won't work really well otherwise. */ + /* */ + if ( face->header.Flags & 8 ) + { + metrics->x_scale = FT_DivFix( metrics->x_ppem << 6, + face->root.units_per_EM ); + metrics->y_scale = FT_DivFix( metrics->y_ppem << 6, + face->root.units_per_EM ); + + metrics->ascender = + FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) ); + metrics->descender = + FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) ); + metrics->height = + FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) ); + metrics->max_advance = + FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width, + metrics->x_scale ) ); + } + /* compute new transformation */ if ( metrics->x_ppem >= metrics->y_ppem ) { @@ -607,28 +725,11 @@ size->ttmetrics.y_ratio = 0x10000L; } - /* Compute root ascender, descender, text height, and max_advance */ - metrics->ascender = - FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) ); - metrics->descender = - FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) ); - metrics->height = - FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) ); - metrics->max_advance = - FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width, - metrics->x_scale ) ); - - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /* set to `invalid' by default */ - size->strike_index = 0xFFFFU; -#endif #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER { - TT_ExecContext exec; - FT_UInt i, j; + FT_UInt i; /* Scale the cvt values to the new ppem. */ @@ -637,12 +738,12 @@ size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); /* All twilight points are originally zero */ - for ( j = 0; j < (FT_UInt)size->twilight.n_points; j++ ) + for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) { - size->twilight.org[j].x = 0; - size->twilight.org[j].y = 0; - size->twilight.cur[j].x = 0; - size->twilight.cur[j].y = 0; + size->twilight.org[i].x = 0; + size->twilight.org[i].y = 0; + size->twilight.cur[i].x = 0; + size->twilight.cur[i].y = 0; } /* clear storage area */ @@ -651,51 +752,7 @@ size->GS = tt_default_graphics_state; - /* get execution context and run prep program */ - if ( size->debug ) - exec = size->context; - else - exec = TT_New_Context( face ); - /* debugging instances have their own context */ - - if ( !exec ) - return TT_Err_Could_Not_Find_Context; - - TT_Load_Context( exec, face, size ); - - TT_Set_CodeRange( exec, - tt_coderange_cvt, - face->cvt_program, - face->cvt_program_size ); - - TT_Clear_CodeRange( exec, tt_coderange_glyph ); - - exec->instruction_trap = FALSE; - - exec->top = 0; - exec->callTop = 0; - - if ( face->cvt_program_size > 0 ) - { - error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); - if ( error ) - goto End; - - if ( !size->debug ) - error = face->interpreter( exec ); - } - else - error = TT_Err_Ok; - - size->GS = exec->GS; - /* save default graphics state */ - - End: - TT_Save_Context( exec, size ); - - if ( !size->debug ) - TT_Done_Context( exec ); - /* debugging instances keep their context */ + error = tt_size_run_prep( size ); } #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ @@ -707,160 +764,13 @@ } -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - /*************************************************************************/ - /* */ - /* */ - /* Reset_SBit_Size */ - /* */ - /* */ - /* Resets a TrueType sbit size when resolutions and character */ - /* dimensions have been changed. */ - /* */ - /* */ - /* size :: A handle to the target size object. */ - /* */ - static FT_Error - Reset_SBit_Size( TT_Size size ) - { - TT_Face face; - FT_Error error = TT_Err_Ok; - - FT_ULong strike_index; - FT_Size_Metrics* metrics; - FT_Size_Metrics* sbit_metrics; - SFNT_Service sfnt; - - - metrics = &size->metrics; - - if ( size->strike_index != 0xFFFFU ) - return TT_Err_Ok; - - face = (TT_Face)size->root.face; - sfnt = (SFNT_Service)face->sfnt; - - sbit_metrics = &size->strike_metrics; - - error = sfnt->set_sbit_strike( face, - metrics->x_ppem, metrics->y_ppem, - &strike_index ); - - if ( !error ) - { - /* XXX: TODO: move this code to the SFNT module where it belongs */ - -#ifdef FT_OPTIMIZE_MEMORY - FT_Byte* strike = face->sbit_table + 8 + strike_index*48; - - sbit_metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */ - sbit_metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */ - - /* XXX: Is this correct? */ - sbit_metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */ - strike[18] + /* max_width */ - (FT_Char)strike[23] /* min_advance_SB */ - ) << 6; - -#else /* !FT_OPTIMIZE_MEMORY */ - - TT_SBit_Strike strike = face->sbit_strikes + strike_index; - - - sbit_metrics->ascender = strike->hori.ascender << 6; - sbit_metrics->descender = strike->hori.descender << 6; - - /* XXX: Is this correct? */ - sbit_metrics->max_advance = ( strike->hori.min_origin_SB + - strike->hori.max_width + - strike->hori.min_advance_SB ) << 6; - -#endif /* !FT_OPTIMIZE_MEMORY */ - - /* XXX: Is this correct? */ - sbit_metrics->height = sbit_metrics->ascender - - sbit_metrics->descender; - - sbit_metrics->x_ppem = metrics->x_ppem; - sbit_metrics->y_ppem = metrics->y_ppem; - size->strike_index = (FT_UInt)strike_index; - } - else - { - size->strike_index = 0xFFFFU; - - sbit_metrics->x_ppem = 0; - sbit_metrics->y_ppem = 0; - sbit_metrics->ascender = 0; - sbit_metrics->descender = 0; - sbit_metrics->height = 0; - sbit_metrics->max_advance = 0; - } - - return error; - } - -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - - - /*************************************************************************/ - /* */ - /* */ - /* tt_size_reset */ - /* */ - /* */ - /* Resets a TrueType size when resolutions and character dimensions */ - /* have been changed. */ - /* */ - /* */ - /* size :: A handle to the target size object. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - tt_size_reset( TT_Size size ) - { - FT_Face face; - FT_Error error = TT_Err_Ok; - - - face = size->root.face; - - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - { - if ( !size->ttmetrics.valid ) - error = Reset_Outline_Size( size ); - - if ( error ) - return error; - } - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - if ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) - { - if ( size->strike_index == 0xFFFFU ) - error = Reset_SBit_Size( size ); - - if ( !error && !( face->face_flags & FT_FACE_FLAG_SCALABLE ) ) - size->root.metrics = size->strike_metrics; - } - -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - return TT_Err_Ok; - else - return error; - } - - /*************************************************************************/ /* */ /* */ /* tt_driver_init */ /* */ /* */ - /* Initializes a given TrueType driver object. */ + /* Initialize a given TrueType driver object. */ /* */ /* */ /* driver :: A handle to the target driver object. */ @@ -869,15 +779,24 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_driver_init( FT_Module driver ) /* TT_Driver */ + tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ { - FT_Error error; + +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + TT_Driver driver = (TT_Driver)ttdriver; - /* set `extra' in glyph loader */ - error = FT_GlyphLoader_CreateExtra( FT_DRIVER( driver )->glyph_loader ); + if ( !TT_New_Context( driver ) ) + return TT_Err_Could_Not_Find_Context; - return error; +#else + + FT_UNUSED( ttdriver ); + +#endif + + return TT_Err_Ok; } @@ -887,7 +806,7 @@ /* tt_driver_done */ /* */ /* */ - /* Finalizes a given TrueType driver. */ + /* Finalize a given TrueType driver. */ /* */ /* */ /* driver :: A handle to the target TrueType driver. */ @@ -902,7 +821,7 @@ /* destroy the execution context */ if ( driver->context ) { - TT_Destroy_Context( driver->context, driver->root.root.memory ); + TT_Done_Context( driver->context ); driver->context = NULL; } #else @@ -912,4 +831,25 @@ } + /*************************************************************************/ + /* */ + /* */ + /* tt_slot_init */ + /* */ + /* */ + /* Initialize a new slot object. */ + /* */ + /* */ + /* slot :: A handle to the slot object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + tt_slot_init( FT_GlyphSlot slot ) + { + return FT_GlyphLoader_CreateExtra( slot->internal->loader ); + } + + /* END */ diff --git a/src/libs/freetype2/truetype/ttobjs.h b/src/libs/freetype2/truetype/ttobjs.h index 423d3f0056..b42b73594b 100644 --- a/src/libs/freetype2/truetype/ttobjs.h +++ b/src/libs/freetype2/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -316,15 +316,13 @@ FT_BEGIN_HEADER { FT_SizeRec root; - FT_Size_Metrics metrics; /* slightly different from the root metrics */ + /* we have our own copy of metrics so that we can modify */ + /* it without affecting auto-hinting (when used) */ + FT_Size_Metrics metrics; + TT_Size_Metrics ttmetrics; -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - FT_UInt strike_index; /* 0xFFFF to indicate invalid */ - FT_Size_Metrics strike_metrics; /* current strike's metrics */ - -#endif + FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER @@ -414,6 +412,16 @@ FT_BEGIN_HEADER FT_LOCAL( void ) tt_size_done( FT_Size ttsize ); /* TT_Size */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + FT_LOCAL( FT_Error ) + tt_size_run_fpgm( TT_Size size ); + + FT_LOCAL( FT_Error ) + tt_size_run_prep( TT_Size size ); + +#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + FT_LOCAL( FT_Error ) tt_size_reset( TT_Size size ); @@ -429,6 +437,14 @@ FT_BEGIN_HEADER tt_driver_done( FT_Module ttdriver ); /* TT_Driver */ + /*************************************************************************/ + /* */ + /* Slot functions */ + /* */ + FT_LOCAL( FT_Error ) + tt_slot_init( FT_GlyphSlot slot ); + + FT_END_HEADER #endif /* __TTOBJS_H__ */ diff --git a/src/libs/freetype2/truetype/ttpload.c b/src/libs/freetype2/truetype/ttpload.c index b9c83e1a45..36e5a66069 100644 --- a/src/libs/freetype2/truetype/ttpload.c +++ b/src/libs/freetype2/truetype/ttpload.c @@ -2,9 +2,9 @@ /* */ /* ttpload.c */ /* */ -/* TrueType glyph data/program tables loader (body). */ +/* TrueType-specific tables loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -47,7 +47,7 @@ /* tt_face_load_loca */ /* */ /* */ - /* Loads the locations table. */ + /* Load the locations table. */ /* */ /* */ /* face :: A handle to the target face object. */ @@ -83,7 +83,7 @@ if ( face->header.Index_To_Loc_Format != 0 ) { - if ( table_len >= 0x40000 ) + if ( table_len >= 0x40000L ) { FT_TRACE2(( "table too large!\n" )); error = TT_Err_Invalid_Table; @@ -93,7 +93,7 @@ } else { - if ( table_len >= 0x20000 ) + if ( table_len >= 0x20000L ) { FT_TRACE2(( "table too large!\n" )); error = TT_Err_Invalid_Table; @@ -319,7 +319,7 @@ /* tt_face_load_cvt */ /* */ /* */ - /* Loads the control value table into a face object. */ + /* Load the control value table into a face object. */ /* */ /* */ /* face :: A handle to the target face object. */ @@ -400,7 +400,7 @@ /* tt_face_load_fpgm */ /* */ /* */ - /* Loads the font program and the cvt program. */ + /* Load the font program. */ /* */ /* */ /* face :: A handle to the target face object. */ @@ -417,8 +417,8 @@ { #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - FT_Error error; - FT_ULong table_len; + FT_Error error; + FT_ULong table_len; FT_TRACE2(( "Font program " )); @@ -429,6 +429,7 @@ { face->font_program = NULL; face->font_program_size = 0; + error = TT_Err_Ok; FT_TRACE2(( "is missing!\n" )); } @@ -441,6 +442,47 @@ FT_TRACE2(( "loaded, %12d bytes\n", face->font_program_size )); } + Exit: + return error; + +#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ + + FT_UNUSED( face ); + FT_UNUSED( stream ); + + return TT_Err_Ok; + +#endif + } + + + /*************************************************************************/ + /* */ + /* */ + /* tt_face_load_prep */ + /* */ + /* */ + /* Load the cvt program. */ + /* */ + /* */ + /* face :: A handle to the target face object. */ + /* */ + /* */ + /* stream :: A handle to the input stream. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + tt_face_load_prep( TT_Face face, + FT_Stream stream ) + { +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + FT_Error error; + FT_ULong table_len; + + FT_TRACE2(( "Prep program " )); error = face->goto_table( face, TTAG_prep, stream, &table_len ); @@ -475,4 +517,232 @@ } + /*************************************************************************/ + /* */ + /* */ + /* tt_face_load_hdmx */ + /* */ + /* */ + /* Load the `hdmx' table into the face object. */ + /* */ + /* */ + /* face :: A handle to the target face object. */ + /* */ + /* stream :: A handle to the input stream. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ +#ifdef FT_OPTIMIZE_MEMORY + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_hdmx( TT_Face face, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = stream->memory; + FT_UInt version, nn, num_records; + FT_ULong table_size, record_size; + FT_Byte* p; + FT_Byte* limit; + + + /* this table is optional */ + error = face->goto_table( face, TTAG_hdmx, stream, &table_size ); + if ( error || table_size < 8 ) + return TT_Err_Ok; + + if ( FT_FRAME_EXTRACT( table_size, face->hdmx_table ) ) + goto Exit; + + p = face->hdmx_table; + limit = p + table_size; + + version = FT_NEXT_USHORT( p ); + num_records = FT_NEXT_USHORT( p ); + record_size = FT_NEXT_ULONG( p ); + + if ( version != 0 || num_records > 255 || record_size > 0x40000 ) + { + error = TT_Err_Invalid_File_Format; + goto Fail; + } + + if ( FT_NEW_ARRAY( face->hdmx_record_sizes, num_records ) ) + goto Fail; + + for ( nn = 0; nn < num_records; nn++ ) + { + if ( p + record_size > limit ) + break; + + face->hdmx_record_sizes[nn] = p[0]; + p += record_size; + } + + face->hdmx_record_count = nn; + face->hdmx_table_size = table_size; + face->hdmx_record_size = record_size; + + Exit: + return error; + + Fail: + FT_FRAME_RELEASE( face->hdmx_table ); + face->hdmx_table_size = 0; + goto Exit; + } + + + FT_LOCAL_DEF( void ) + tt_face_free_hdmx( TT_Face face ) + { + FT_Stream stream = face->root.stream; + FT_Memory memory = stream->memory; + + + FT_FREE( face->hdmx_record_sizes ); + FT_FRAME_RELEASE( face->hdmx_table ); + } + +#else /* !FT_OPTIMIZE_MEMORY */ + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_hdmx( TT_Face face, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = stream->memory; + + TT_Hdmx hdmx = &face->hdmx; + FT_Short num_records; + FT_Long num_glyphs; + FT_Long record_size; + + + hdmx->version = 0; + hdmx->num_records = 0; + hdmx->records = 0; + + /* this table is optional */ + error = face->goto_table( face, TTAG_hdmx, stream, 0 ); + if ( error ) + return TT_Err_Ok; + + if ( FT_FRAME_ENTER( 8L ) ) + goto Exit; + + hdmx->version = FT_GET_USHORT(); + num_records = FT_GET_SHORT(); + record_size = FT_GET_LONG(); + + FT_FRAME_EXIT(); + + if ( record_size < 0 || num_records < 0 ) + return TT_Err_Invalid_File_Format; + + /* Only recognize format 0 */ + if ( hdmx->version != 0 ) + goto Exit; + + /* we can't use FT_QNEW_ARRAY here; otherwise tt_face_free_hdmx */ + /* could fail during deallocation */ + if ( FT_NEW_ARRAY( hdmx->records, num_records ) ) + goto Exit; + + hdmx->num_records = num_records; + num_glyphs = face->root.num_glyphs; + record_size -= num_glyphs + 2; + + { + TT_HdmxEntry cur = hdmx->records; + TT_HdmxEntry limit = cur + hdmx->num_records; + + + for ( ; cur < limit; cur++ ) + { + /* read record */ + if ( FT_READ_BYTE( cur->ppem ) || + FT_READ_BYTE( cur->max_width ) ) + goto Exit; + + if ( FT_QALLOC( cur->widths, num_glyphs ) || + FT_STREAM_READ( cur->widths, num_glyphs ) ) + goto Exit; + + /* skip padding bytes */ + if ( record_size > 0 && FT_STREAM_SKIP( record_size ) ) + goto Exit; + } + } + + Exit: + return error; + } + + + FT_LOCAL_DEF( void ) + tt_face_free_hdmx( TT_Face face ) + { + if ( face ) + { + FT_Int n; + FT_Memory memory = face->root.driver->root.memory; + + + for ( n = 0; n < face->hdmx.num_records; n++ ) + FT_FREE( face->hdmx.records[n].widths ); + + FT_FREE( face->hdmx.records ); + face->hdmx.num_records = 0; + } + } + +#endif /* !OPTIMIZE_MEMORY */ + + + /*************************************************************************/ + /* */ + /* Return the advance width table for a given pixel size if it is found */ + /* in the font's `hdmx' table (if any). */ + /* */ + FT_LOCAL_DEF( FT_Byte* ) + tt_face_get_device_metrics( TT_Face face, + FT_UInt ppem, + FT_UInt gindex ) + { +#ifdef FT_OPTIMIZE_MEMORY + + FT_UInt nn; + FT_Byte* result = NULL; + FT_ULong record_size = face->hdmx_record_size; + FT_Byte* record = face->hdmx_table + 8; + + + for ( nn = 0; nn < face->hdmx_record_count; nn++ ) + if ( face->hdmx_record_sizes[nn] == ppem ) + { + gindex += 2; + if ( gindex < record_size ) + result = record + nn * record_size + gindex; + break; + } + + return result; + +#else + + FT_UShort n; + + + for ( n = 0; n < face->hdmx.num_records; n++ ) + if ( face->hdmx.records[n].ppem == ppem ) + return &face->hdmx.records[n].widths[gindex]; + + return NULL; + +#endif + } + + /* END */ diff --git a/src/libs/freetype2/truetype/ttpload.h b/src/libs/freetype2/truetype/ttpload.h index 2acb4b360a..f61ac079ce 100644 --- a/src/libs/freetype2/truetype/ttpload.h +++ b/src/libs/freetype2/truetype/ttpload.h @@ -2,9 +2,9 @@ /* */ /* ttpload.h */ /* */ -/* TrueType glyph data/program tables loader (specification). */ +/* TrueType-specific tables loader (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2005 by */ +/* Copyright 1996-2001, 2002, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -48,6 +48,25 @@ FT_BEGIN_HEADER FT_Stream stream ); + FT_LOCAL( FT_Error ) + tt_face_load_prep( TT_Face face, + FT_Stream stream ); + + + FT_LOCAL( FT_Error ) + tt_face_load_hdmx( TT_Face face, + FT_Stream stream ); + + + FT_LOCAL( void ) + tt_face_free_hdmx( TT_Face face ); + + + FT_LOCAL( FT_Byte* ) + tt_face_get_device_metrics( TT_Face face, + FT_UInt ppem, + FT_UInt gindex ); + FT_END_HEADER #endif /* __TTPLOAD_H__ */ diff --git a/src/libs/freetype2/type1/module.mk b/src/libs/freetype2/type1/module.mk index 82d9355ba3..baf98c00ea 100644 --- a/src/libs/freetype2/type1/module.mk +++ b/src/libs/freetype2/type1/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_type1_driver +FTMODULE_H_COMMANDS += TYPE1_DRIVER -add_type1_driver: - $(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE) +define TYPE1_DRIVER +$(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/type1/t1afm.c b/src/libs/freetype2/type1/t1afm.c index bef8251e19..379b33067d 100644 --- a/src/libs/freetype2/type1/t1afm.c +++ b/src/libs/freetype2/type1/t1afm.c @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,7 +20,7 @@ #include "t1afm.h" #include "t1errors.h" #include FT_INTERNAL_STREAM_H -#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H /*************************************************************************/ @@ -34,102 +34,41 @@ FT_LOCAL_DEF( void ) - T1_Done_Metrics( FT_Memory memory, - T1_AFM* afm ) + T1_Done_Metrics( FT_Memory memory, + AFM_FontInfo fi ) { - FT_FREE( afm->kern_pairs ); - afm->num_pairs = 0; - FT_FREE( afm ); + FT_FREE( fi->KernPairs ); + fi->NumKernPair = 0; + + FT_FREE( fi->TrackKerns ); + fi->NumTrackKern = 0; + + FT_FREE( fi ); } -#undef IS_KERN_PAIR -#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' ) - -#define IS_ALPHANUM( c ) ( ft_isalnum( c ) || \ - c == '_' || \ - c == '.' ) - - /* read a glyph name and return the equivalent glyph index */ - static FT_UInt - afm_atoindex( FT_Byte** start, - FT_Byte* limit, - T1_Font type1 ) + static FT_Int + t1_get_index( const char* name, + FT_UInt len, + void* user_data ) { - FT_Byte* p = *start; - FT_PtrDist len; - FT_UInt result = 0; - char temp[64]; + T1_Font type1 = (T1_Font)user_data; + FT_Int n; - /* skip whitespace */ - while ( p < limit && - ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) ) - p++; - *start = p; - - /* now, read glyph name */ - while ( p < limit && IS_ALPHANUM( *p ) ) - p++; - - len = p - *start; - - if ( len > 0 && len < 64 ) + for ( n = 0; n < type1->num_glyphs; n++ ) { - FT_Int n; + char* gname = (char*)type1->glyph_names[n]; - /* copy glyph name to intermediate array */ - FT_MEM_COPY( temp, *start, len ); - temp[len] = 0; - - /* lookup glyph name in face array */ - for ( n = 0; n < type1->num_glyphs; n++ ) - { - char* gname = (char*)type1->glyph_names[n]; - - - if ( gname && gname[0] == temp[0] && ft_strcmp( gname, temp ) == 0 ) - { - result = n; - break; - } - } - } - *start = p; - return result; - } - - - /* read an integer */ - static int - afm_atoi( FT_Byte** start, - FT_Byte* limit ) - { - FT_Byte* p = *start; - int sum = 0; - int sign = 1; - - - /* skip everything that is not a number */ - while ( p < limit && !isdigit( *p ) ) - { - sign = 1; - if ( *p == '-' ) - sign = -1; - - p++; + if ( gname && gname[0] == name[0] && + ft_strlen( gname ) == len && + ft_strncmp( gname, name, len ) == 0 ) + return n; } - while ( p < limit && isdigit( *p ) ) - { - sum = sum * 10 + ( *p - '0' ); - p++; - } - *start = p; - - return sum * sign; + return 0; } @@ -142,125 +81,33 @@ compare_kern_pairs( const void* a, const void* b ) { - T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a; - T1_Kern_Pair* pair2 = (T1_Kern_Pair*)b; + AFM_KernPair pair1 = (AFM_KernPair)a; + AFM_KernPair pair2 = (AFM_KernPair)b; - FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 ); - FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 ); + FT_ULong index1 = KERN_INDEX( pair1->index1, pair1->index2 ); + FT_ULong index2 = KERN_INDEX( pair2->index1, pair2->index2 ); return (int)( index1 - index2 ); } - /* parse an AFM file -- for now, only read the kerning pairs */ - static FT_Error - T1_Read_AFM( FT_Face t1_face, - FT_Stream stream ) - { - FT_Error error = T1_Err_Ok; - FT_Memory memory = stream->memory; - FT_Byte* start; - FT_Byte* limit; - FT_Byte* p; - FT_Int count = 0; - T1_Kern_Pair* pair; - T1_Font type1 = &((T1_Face)t1_face)->type1; - T1_AFM* afm = 0; - - - start = (FT_Byte*)stream->cursor; - limit = (FT_Byte*)stream->limit; - p = start; - - /* we are now going to count the occurences of `KP' or `KPX' in */ - /* the AFM file */ - count = 0; - for ( p = start; p < limit - 3; p++ ) - { - if ( IS_KERN_PAIR( p ) ) - count++; - } - - /* Actually, kerning pairs are simply optional! */ - if ( count == 0 ) - goto Exit; - - /* allocate the pairs */ - if ( FT_NEW( afm ) || FT_NEW_ARRAY( afm->kern_pairs, count ) ) - goto Exit; - - /* now, read each kern pair */ - pair = afm->kern_pairs; - afm->num_pairs = count; - - /* save in face object */ - ((T1_Face)t1_face)->afm_data = afm; - - t1_face->face_flags |= FT_FACE_FLAG_KERNING; - - for ( p = start; p < limit - 3; p++ ) - { - if ( IS_KERN_PAIR( p ) ) - { - FT_Byte* q; - - - /* skip keyword (KP or KPX) */ - q = p + 2; - if ( *q == 'X' ) - q++; - - pair->glyph1 = afm_atoindex( &q, limit, type1 ); - pair->glyph2 = afm_atoindex( &q, limit, type1 ); - pair->kerning.x = afm_atoi( &q, limit ); - - pair->kerning.y = 0; - if ( p[2] != 'X' ) - pair->kerning.y = afm_atoi( &q, limit ); - - pair++; - } - } - - /* now, sort the kern pairs according to their glyph indices */ - ft_qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ), - compare_kern_pairs ); - - Exit: - if ( error ) - FT_FREE( afm ); - - return error; - } - - -#define LITTLE_ENDIAN_USHORT( p ) (FT_UShort)( ( (p)[0] ) | \ - ( (p)[1] << 8 ) ) - -#define LITTLE_ENDIAN_UINT( p ) (FT_UInt)( ( (p)[0] ) | \ - ( (p)[1] << 8 ) | \ - ( (p)[2] << 16 ) | \ - ( (p)[3] << 24 ) ) - - /* parse a PFM file -- for now, only read the kerning pairs */ static FT_Error - T1_Read_PFM( FT_Face t1_face, - FT_Stream stream ) + T1_Read_PFM( FT_Face t1_face, + FT_Stream stream, + AFM_FontInfo fi ) { - FT_Error error = T1_Err_Ok; - FT_Memory memory = stream->memory; - FT_Byte* start; - FT_Byte* limit; - FT_Byte* p; - FT_Int kern_count = 0; - T1_Kern_Pair* pair; - T1_AFM* afm = 0; - FT_Int width_table_length; - FT_CharMap oldcharmap; - FT_CharMap charmap; - FT_Int n; + FT_Error error = T1_Err_Ok; + FT_Memory memory = stream->memory; + FT_Byte* start; + FT_Byte* limit; + FT_Byte* p; + AFM_KernPair kp; + FT_Int width_table_length; + FT_CharMap oldcharmap; + FT_CharMap charmap; + FT_Int n; start = (FT_Byte*)stream->cursor; @@ -275,47 +122,46 @@ error = T1_Err_Unknown_File_Format; goto Exit; } - width_table_length = LITTLE_ENDIAN_USHORT( p ); + width_table_length = FT_PEEK_USHORT_LE( p ); p += 18 + width_table_length; - if ( p + 0x12 > limit || LITTLE_ENDIAN_USHORT( p ) < 0x12 ) + if ( p + 0x12 > limit || FT_PEEK_USHORT_LE( p ) < 0x12 ) /* extension table is probably optional */ goto Exit; /* Kerning offset is 14 bytes from start of extensions table. */ p += 14; - p = start + LITTLE_ENDIAN_UINT( p ); + p = start + FT_PEEK_ULONG_LE( p ); + + if ( p == start ) + /* zero offset means no table */ + goto Exit; + if ( p + 2 > limit ) { error = T1_Err_Unknown_File_Format; goto Exit; } - kern_count = LITTLE_ENDIAN_USHORT( p ); + fi->NumKernPair = FT_PEEK_USHORT_LE( p ); p += 2; - if ( p + 4 * kern_count > limit ) + if ( p + 4 * fi->NumKernPair > limit ) { error = T1_Err_Unknown_File_Format; goto Exit; } /* Actually, kerning pairs are simply optional! */ - if ( kern_count == 0 ) + if ( fi->NumKernPair == 0 ) goto Exit; /* allocate the pairs */ - if ( FT_NEW( afm ) || FT_NEW_ARRAY( afm->kern_pairs, kern_count ) ) + if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) ) goto Exit; - /* save in face object */ - ((T1_Face)t1_face)->afm_data = afm; - - t1_face->face_flags |= FT_FACE_FLAG_KERNING; - /* now, read each kern pair */ - pair = afm->kern_pairs; - afm->num_pairs = kern_count; - limit = p + 4 * kern_count; + kp = fi->KernPairs; + limit = p + 4 * fi->NumKernPair; /* PFM kerning data are stored by encoding rather than glyph index, */ /* so find the PostScript charmap of this font and install it */ @@ -342,15 +188,15 @@ /* encoding of first glyph (1 byte) */ /* encoding of second glyph (1 byte) */ /* offset (little-endian short) */ - for ( ; p < limit ; p+=4 ) + for ( ; p < limit ; p += 4 ) { - pair->glyph1 = FT_Get_Char_Index( t1_face, p[0] ); - pair->glyph2 = FT_Get_Char_Index( t1_face, p[1] ); + kp->index1 = FT_Get_Char_Index( t1_face, p[0] ); + kp->index2 = FT_Get_Char_Index( t1_face, p[1] ); - pair->kerning.x = (FT_Short)LITTLE_ENDIAN_USHORT(p + 2); - pair->kerning.y = 0; + kp->x = (FT_Int)FT_PEEK_USHORT_LE(p + 2); + kp->y = 0; - pair++; + kp++; } if ( oldcharmap != NULL ) @@ -359,12 +205,15 @@ goto Exit; /* now, sort the kern pairs according to their glyph indices */ - ft_qsort( afm->kern_pairs, kern_count, sizeof ( T1_Kern_Pair ), + ft_qsort( fi->KernPairs, fi->NumKernPair, sizeof ( AFM_KernPairRec ), compare_kern_pairs ); Exit: if ( error ) - FT_FREE( afm ); + { + FT_FREE( fi->KernPairs ); + fi->NumKernPair = 0; + } return error; } @@ -376,27 +225,75 @@ T1_Read_Metrics( FT_Face t1_face, FT_Stream stream ) { - FT_Error error; - FT_Byte* start; + PSAux_Service psaux; + FT_Memory memory = stream->memory; + AFM_ParserRec parser; + AFM_FontInfo fi; + FT_Error error = T1_Err_Unknown_File_Format; + T1_Font t1_font = &( (T1_Face)t1_face )->type1; - if ( FT_FRAME_ENTER( stream->size ) ) + if ( FT_NEW( fi ) ) return error; - start = (FT_Byte*)stream->cursor; + if ( FT_FRAME_ENTER( stream->size ) ) + { + FT_FREE( fi ); + return error; + } - if ( stream->size >= ft_strlen( "StartFontMetrics" ) && - ft_strncmp( (const char*)start, "StartFontMetrics", - ft_strlen( "StartFontMetrics" ) ) == 0 ) - error = T1_Read_AFM( t1_face, stream ); + fi->FontBBox = t1_font->font_bbox; + fi->Ascender = t1_font->font_bbox.yMax; + fi->Descender = t1_font->font_bbox.yMin; - else if ( stream->size > 6 && - start[0] == 0x00 && start[1] == 0x01 && - LITTLE_ENDIAN_UINT( start + 2 ) == stream->size ) - error = T1_Read_PFM( t1_face, stream ); + psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux; + if ( psaux && psaux->afm_parser_funcs ) + { + error = psaux->afm_parser_funcs->init( &parser, + stream->memory, + stream->cursor, + stream->limit ); - else - error = T1_Err_Unknown_File_Format; + if ( !error ) + { + parser.FontInfo = fi; + parser.get_index = t1_get_index; + parser.user_data = t1_font; + + error = psaux->afm_parser_funcs->parse( &parser ); + psaux->afm_parser_funcs->done( &parser ); + } + } + + if ( error == T1_Err_Unknown_File_Format ) + { + FT_Byte* start = stream->cursor; + + + if ( stream->size > 6 && + start[0] == 0x00 && start[1] == 0x01 && + FT_PEEK_ULONG_LE( start + 2 ) == stream->size ) + error = T1_Read_PFM( t1_face, stream, fi ); + } + + if ( !error ) + { + t1_font->font_bbox = fi->FontBBox; + + t1_face->bbox.xMin = fi->FontBBox.xMin >> 16; + t1_face->bbox.yMin = fi->FontBBox.yMin >> 16; + t1_face->bbox.xMax = ( fi->FontBBox.xMax + 0xFFFFU ) >> 16; + t1_face->bbox.yMax = ( fi->FontBBox.yMax + 0xFFFFU ) >> 16; + + t1_face->ascender = (FT_Short)( ( fi->Ascender + 0x8000U ) >> 16 ); + t1_face->descender = (FT_Short)( ( fi->Descender + 0x8000U ) >> 16 ); + + if ( fi->NumKernPair ) + { + t1_face->face_flags |= FT_FACE_FLAG_KERNING; + ( (T1_Face)t1_face )->afm_data = fi; + } + } FT_FRAME_EXIT(); @@ -406,18 +303,18 @@ /* find the kerning for a given glyph pair */ FT_LOCAL_DEF( void ) - T1_Get_Kerning( T1_AFM* afm, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ) + T1_Get_Kerning( AFM_FontInfo fi, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ) { - T1_Kern_Pair *min, *mid, *max; + AFM_KernPair min, mid, max; FT_ULong idx = KERN_INDEX( glyph1, glyph2 ); /* simple binary search */ - min = afm->kern_pairs; - max = min + afm->num_pairs - 1; + min = fi->KernPairs; + max = min + fi->NumKernPair - 1; while ( min <= max ) { @@ -425,11 +322,13 @@ mid = min + ( max - min ) / 2; - midi = KERN_INDEX( mid->glyph1, mid->glyph2 ); + midi = KERN_INDEX( mid->index1, mid->index2 ); if ( midi == idx ) { - *kerning = mid->kerning; + kerning->x = mid->x; + kerning->y = mid->y; + return; } @@ -444,4 +343,42 @@ } + FT_LOCAL_DEF( FT_Error ) + T1_Get_Track_Kerning( FT_Face face, + FT_Fixed ptsize, + FT_Int degree, + FT_Fixed* kerning ) + { + AFM_FontInfo fi = (AFM_FontInfo)( (T1_Face)face )->afm_data; + FT_Int i; + + + if ( !fi ) + return T1_Err_Invalid_Argument; + + for ( i = 0; i < fi->NumTrackKern; i++ ) + { + AFM_TrackKern tk = fi->TrackKerns + i; + + + if ( tk->degree != degree ) + continue; + + if ( ptsize < tk->min_ptsize ) + *kerning = tk->min_kern; + else if ( ptsize > tk->max_ptsize ) + *kerning = tk->max_kern; + else + { + *kerning = FT_MulDiv( ptsize - tk->min_ptsize, + tk->max_kern - tk->min_kern, + tk->max_ptsize - tk->min_ptsize ) + + tk->min_kern; + } + } + + return T1_Err_Ok; + } + + /* END */ diff --git a/src/libs/freetype2/type1/t1afm.h b/src/libs/freetype2/type1/t1afm.h index 5aaeb67a74..8eb1764de7 100644 --- a/src/libs/freetype2/type1/t1afm.h +++ b/src/libs/freetype2/type1/t1afm.h @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (specification). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,42 +21,30 @@ #include #include "t1objs.h" - +#include FT_INTERNAL_TYPE1_TYPES_H FT_BEGIN_HEADER - typedef struct T1_Kern_Pair_ - { - FT_UInt glyph1; - FT_UInt glyph2; - FT_Vector kerning; - - } T1_Kern_Pair; - - - typedef struct T1_AFM_ - { - FT_Int num_pairs; - T1_Kern_Pair* kern_pairs; - - } T1_AFM; - - FT_LOCAL( FT_Error ) T1_Read_Metrics( FT_Face face, FT_Stream stream ); FT_LOCAL( void ) - T1_Done_Metrics( FT_Memory memory, - T1_AFM* afm ); + T1_Done_Metrics( FT_Memory memory, + AFM_FontInfo fi ); FT_LOCAL( void ) - T1_Get_Kerning( T1_AFM* afm, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ); + T1_Get_Kerning( AFM_FontInfo fi, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ); + FT_LOCAL( FT_Error ) + T1_Get_Track_Kerning( FT_Face face, + FT_Fixed ptsize, + FT_Int degree, + FT_Fixed* kerning ); FT_END_HEADER diff --git a/src/libs/freetype2/type1/t1driver.c b/src/libs/freetype2/type1/t1driver.c index dbcdb2a5f9..806d35d017 100644 --- a/src/libs/freetype2/type1/t1driver.c +++ b/src/libs/freetype2/type1/t1driver.c @@ -4,7 +4,7 @@ /* */ /* Type 1 driver interface (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -36,6 +36,8 @@ #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SERVICE_POSTSCRIPT_INFO_H +#include FT_SERVICE_KERNING_H + /*************************************************************************/ /* */ @@ -176,6 +178,12 @@ (PS_GetFontPrivateFunc)t1_ps_get_font_private, }; +#ifndef T1_CONFIG_OPTION_NO_AFM + static const FT_Service_KerningRec t1_service_kerning = + { + T1_Get_Track_Kerning, + }; +#endif /* * SERVICE LIST @@ -189,6 +197,10 @@ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_1 }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info }, +#ifndef T1_CONFIG_OPTION_NO_AFM + { FT_SERVICE_ID_KERNING, &t1_service_kerning }, +#endif + #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters }, #endif @@ -246,15 +258,14 @@ FT_UInt right_glyph, FT_Vector* kerning ) { - T1_AFM* afm; - - kerning->x = 0; kerning->y = 0; - afm = (T1_AFM*)face->afm_data; - if ( afm ) - T1_Get_Kerning( afm, left_glyph, right_glyph, kerning ); + if ( face->afm_data ) + T1_Get_Kerning( (AFM_FontInfo)face->afm_data, + left_glyph, + right_glyph, + kerning ); return T1_Err_Ok; } @@ -295,8 +306,10 @@ (FT_Slot_InitFunc) T1_GlyphSlot_Init, (FT_Slot_DoneFunc) T1_GlyphSlot_Done, - (FT_Size_ResetPointsFunc) T1_Size_Reset, - (FT_Size_ResetPixelsFunc) T1_Size_Reset, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif (FT_Slot_LoadFunc) T1_Load_Glyph, #ifdef T1_CONFIG_OPTION_NO_AFM @@ -306,7 +319,9 @@ (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) T1_Read_Metrics, #endif - (FT_Face_GetAdvancesFunc) 0 + (FT_Face_GetAdvancesFunc) 0, + (FT_Size_RequestFunc) T1_Size_Request, + (FT_Size_SelectFunc) 0 }; diff --git a/src/libs/freetype2/type1/t1gload.c b/src/libs/freetype2/type1/t1gload.c index f45a83b406..28190001f5 100644 --- a/src/libs/freetype2/type1/t1gload.c +++ b/src/libs/freetype2/type1/t1gload.c @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -195,23 +195,6 @@ } - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** UNHINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of loading a *********/ - /********** single outline. It completely ignores hinting *********/ - /********** and is used when FT_LOAD_NO_HINTING is set. *********/ - /********** *********/ - /********** The Type 1 hinter is located in `t1hint.c' *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - FT_LOCAL_DEF( FT_Error ) T1_Load_Glyph( T1_GlyphSlot glyph, T1_Size size, @@ -315,12 +298,10 @@ glyph->root.linearHoriAdvance = decoder.builder.advance.x; glyph->root.internal->glyph_transformed = 0; - /* make up vertical metrics */ - metrics->vertBearingX = 0; - metrics->vertBearingY = 0; - metrics->vertAdvance = 0; - - glyph->root.linearVertAdvance = 0; + /* make up vertical ones */ + metrics->vertAdvance = ( face->type1.font_bbox.yMax - + face->type1.font_bbox.yMin ) >> 16; + glyph->root.linearVertAdvance = metrics->vertAdvance; glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; @@ -356,49 +337,30 @@ /* First of all, scale the points, if we are not hinting */ - if ( !hinting ) + if ( !hinting || ! decoder.builder.hints_funcs ) for ( n = cur->n_points; n > 0; n--, vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } - FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); - - metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); - metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - - if ( hinting ) - { - metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); - metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); - - metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); - metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); - } } /* compute the other metrics */ FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - /* grid fit the bounding box if necessary */ - if ( hinting ) - { - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL( cbox.yMax ); - } - metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; + + /* make up vertical ones */ + ft_synthesize_vertical_metrics( metrics, + metrics->vertAdvance ); } /* Set control data to the glyph charstrings. Note that this is */ diff --git a/src/libs/freetype2/type1/t1load.c b/src/libs/freetype2/type1/t1load.c index 2080a76674..219563a03b 100644 --- a/src/libs/freetype2/type1/t1load.c +++ b/src/libs/freetype2/type1/t1load.c @@ -4,7 +4,7 @@ /* */ /* Type 1 font loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -335,8 +335,8 @@ mmvar->axis[i].def = ( mmvar->axis[i].minimum + mmvar->axis[i].maximum ) / 2; /* Does not apply. But this value is in range */ - mmvar->axis[i].strid = 0xFFFFFFFFLU; /* Does not apply */ - mmvar->axis[i].tag = 0xFFFFFFFFLU; /* Does not apply */ + mmvar->axis[i].strid = 0xFFFFFFFFUL; /* Does not apply */ + mmvar->axis[i].tag = 0xFFFFFFFFUL; /* Does not apply */ if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 ) mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' ); @@ -1856,9 +1856,9 @@ /* field to deal adequately with synthetic */ /* fonts; /Subrs and /CharStrings are */ /* handled specially. */ - if ( keyword_flag[0] == 0 || - ft_strcmp( (const char*)name, "Subrs" ) == 0 || - ft_strcmp( (const char*)name, "CharStrings") == 0 ) + if ( keyword_flag[0] == 0 || + ft_strcmp( (const char*)name, "Subrs" ) == 0 || + ft_strcmp( (const char*)name, "CharStrings" ) == 0 ) { parser->root.error = t1_load_keyword( face, loader, @@ -1989,6 +1989,9 @@ keyword_flags ); if ( error ) goto Exit; + + /* ensure even-ness of `num_blue_values' */ + priv->num_blue_values &= ~1; #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT diff --git a/src/libs/freetype2/type1/t1objs.c b/src/libs/freetype2/type1/t1objs.c index 519fa08d9c..aa95122e30 100644 --- a/src/libs/freetype2/type1/t1objs.c +++ b/src/libs/freetype2/type1/t1objs.c @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -111,18 +111,21 @@ FT_LOCAL_DEF( FT_Error ) - T1_Size_Reset( T1_Size size ) + T1_Size_Request( T1_Size size, + FT_Size_Request req ) { PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size ); - FT_Error error = 0; + FT_Request_Metrics( size->root.face, req ); + if ( funcs ) - error = funcs->set_scale( (PSH_Globals)size->root.internal, - size->root.metrics.x_scale, - size->root.metrics.y_scale, - 0, 0 ); - return error; + funcs->set_scale( (PSH_Globals)size->root.internal, + size->root.metrics.x_scale, + size->root.metrics.y_scale, + 0, 0 ); + + return T1_Err_Ok; } @@ -233,12 +236,15 @@ #ifndef T1_CONFIG_OPTION_NO_AFM /* release afm data if present */ if ( face->afm_data ) - T1_Done_Metrics( memory, (T1_AFM*)face->afm_data ); + T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data ); #endif /* release unicode map, if any */ - FT_FREE( face->unicode_map.maps ); - face->unicode_map.num_maps = 0; +#if 0 + FT_FREE( face->unicode_map_rec.maps ); + face->unicode_map_rec.num_maps = 0; + face->unicode_map = NULL; +#endif face->root.family_name = 0; face->root.style_name = 0; @@ -329,9 +335,10 @@ root->num_glyphs = type1->num_glyphs; root->face_index = face_index; - root->face_flags = FT_FACE_FLAG_SCALABLE; - root->face_flags |= FT_FACE_FLAG_HORIZONTAL; - root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; + root->face_flags = FT_FACE_FLAG_SCALABLE | + FT_FACE_FLAG_HORIZONTAL | + FT_FACE_FLAG_GLYPH_NAMES | + FT_FACE_FLAG_HINTER; if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; @@ -410,8 +417,10 @@ root->ascender = (FT_Short)( root->bbox.yMax ); root->descender = (FT_Short)( root->bbox.yMin ); - root->height = (FT_Short)( - ( ( root->ascender - root->descender ) * 12 ) / 10 ); + + root->height = (FT_Short)( ( root->units_per_EM * 12 ) / 10 ); + if ( root->height < root->ascender - root->descender ) + root->height = (FT_Short)( root->ascender - root->descender ); /* now compute the maximum advance width */ root->max_advance_width = @@ -433,9 +442,6 @@ root->underline_position = (FT_Short)info->underline_position; root->underline_thickness = (FT_Short)info->underline_thickness; - - root->internal->max_points = 0; - root->internal->max_contours = 0; } { diff --git a/src/libs/freetype2/type1/t1objs.h b/src/libs/freetype2/type1/t1objs.h index 9aeb10dd22..ba258d267a 100644 --- a/src/libs/freetype2/type1/t1objs.h +++ b/src/libs/freetype2/type1/t1objs.h @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -109,7 +109,8 @@ FT_BEGIN_HEADER T1_Size_Done( T1_Size size ); FT_LOCAL( FT_Error ) - T1_Size_Reset( T1_Size size ); + T1_Size_Request( T1_Size size, + FT_Size_Request req ); FT_LOCAL( FT_Error ) T1_Size_Init( T1_Size size ); diff --git a/src/libs/freetype2/type42/descrip.mms b/src/libs/freetype2/type42/descrip.mms deleted file mode 100644 index a52ba06fb0..0000000000 --- a/src/libs/freetype2/type42/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 Type 42 driver compilation rules for VMS -# - - -# Copyright 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.type42]) - -OBJS=type42.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/type42/module.mk b/src/libs/freetype2/type42/module.mk index ceaea41b08..8bd40a5cc4 100644 --- a/src/libs/freetype2/type42/module.mk +++ b/src/libs/freetype2/type42/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002 by +# Copyright 2002, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,10 +13,11 @@ # fully. -make_module_list: add_type42_driver +FTMODULE_H_COMMANDS += TYPE42_DRIVER -add_type42_driver: - $(OPEN_DRIVER)t42_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)type42 $(ECHO_DRIVER_DESC)Type 42 font files with no known extension$(ECHO_DRIVER_DONE) +define TYPE42_DRIVER +$(OPEN_DRIVER)t42_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)type42 $(ECHO_DRIVER_DESC)Type 42 font files with no known extension$(ECHO_DRIVER_DONE) +endef # EOF diff --git a/src/libs/freetype2/type42/t42drivr.c b/src/libs/freetype2/type42/t42drivr.c index c87c3f2aa5..e3c469742b 100644 --- a/src/libs/freetype2/type42/t42drivr.c +++ b/src/libs/freetype2/type42/t42drivr.c @@ -4,7 +4,7 @@ /* */ /* High-level Type 42 driver interface (body). */ /* */ -/* Copyright 2002, 2003, 2004 by Roberto Alameda. */ +/* Copyright 2002, 2003, 2004, 2006 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ @@ -229,14 +229,18 @@ (FT_Slot_InitFunc) T42_GlyphSlot_Init, (FT_Slot_DoneFunc) T42_GlyphSlot_Done, - (FT_Size_ResetPointsFunc) T42_Size_SetChars, - (FT_Size_ResetPixelsFunc) T42_Size_SetPixels, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif (FT_Slot_LoadFunc) T42_GlyphSlot_Load, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0 + (FT_Face_GetAdvancesFunc) 0, + (FT_Size_RequestFunc) T42_Size_Request, + (FT_Size_SelectFunc) T42_Size_Select }; diff --git a/src/libs/freetype2/type42/t42objs.c b/src/libs/freetype2/type42/t42objs.c index d51a91cd51..30d9dcc8fe 100644 --- a/src/libs/freetype2/type42/t42objs.c +++ b/src/libs/freetype2/type42/t42objs.c @@ -4,7 +4,7 @@ /* */ /* Type 42 objects manager (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by Roberto Alameda. */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ @@ -202,13 +202,17 @@ root->num_charmaps = 0; root->face_index = face_index; - root->face_flags = FT_FACE_FLAG_SCALABLE; - root->face_flags |= FT_FACE_FLAG_HORIZONTAL; - root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; + root->face_flags = FT_FACE_FLAG_SCALABLE | + FT_FACE_FLAG_HORIZONTAL | + FT_FACE_FLAG_GLYPH_NAMES; if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + root->face_flags |= FT_FACE_FLAG_HINTER; +#endif + /* XXX: TODO -- add kerning with .afm support */ /* get style name -- be careful, some broken fonts only */ @@ -259,11 +263,25 @@ root->available_sizes = 0; /* Load the TTF font embedded in the T42 font */ - error = FT_New_Memory_Face( FT_FACE_LIBRARY( face ), - face->ttf_data, - face->ttf_size, - 0, - &face->ttf_face ); + { + FT_Open_Args args; + + + args.flags = FT_OPEN_MEMORY; + args.memory_base = face->ttf_data; + args.memory_size = face->ttf_size; + + if ( num_params ) + { + args.flags |= FT_OPEN_PARAMS; + args.num_params = num_params; + args.params = params; + } + + error = FT_Open_Face( FT_FACE_LIBRARY( face ), + &args, 0, &face->ttf_face ); + } + if ( error ) goto Exit; @@ -284,9 +302,6 @@ root->underline_position = (FT_Short)info->underline_position; root->underline_thickness = (FT_Short)info->underline_thickness; - root->internal->max_points = 0; - root->internal->max_contours = 0; - /* compute style flags */ root->style_flags = 0; if ( info->italic_angle ) @@ -471,6 +486,43 @@ } + FT_LOCAL_DEF( FT_Error ) + T42_Size_Request( T42_Size size, + FT_Size_Request req ) + { + T42_Face face = (T42_Face)size->root.face; + FT_Error error; + + + FT_Activate_Size( size->ttsize ); + + error = FT_Request_Size( face->ttf_face, req ); + if ( !error ) + ( (FT_Size)size )->metrics = face->ttf_face->size->metrics; + + return error; + } + + + FT_LOCAL_DEF( FT_Error ) + T42_Size_Select( T42_Size size, + FT_ULong strike_index ) + { + T42_Face face = (T42_Face)size->root.face; + FT_Error error; + + + FT_Activate_Size( size->ttsize ); + + error = FT_Select_Size( face->ttf_face, strike_index ); + if ( !error ) + ( (FT_Size)size )->metrics = face->ttf_face->size->metrics; + + return error; + + } + + FT_LOCAL_DEF( void ) T42_Size_Done( T42_Size size ) { @@ -519,45 +571,6 @@ } - - FT_LOCAL_DEF( FT_Error ) - T42_Size_SetChars( T42_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) - { - FT_Face face = size->root.face; - T42_Face t42face = (T42_Face)face; - - - FT_Activate_Size( size->ttsize ); - - return FT_Set_Char_Size( t42face->ttf_face, - char_width, - char_height, - horz_resolution, - vert_resolution ); - } - - - FT_LOCAL_DEF( FT_Error ) - T42_Size_SetPixels( T42_Size size, - FT_UInt pixel_width, - FT_UInt pixel_height ) - { - FT_Face face = size->root.face; - T42_Face t42face = (T42_Face)face; - - - FT_Activate_Size( size->ttsize ); - - return FT_Set_Pixel_Sizes( t42face->ttf_face, - pixel_width, - pixel_height ); - } - - static void t42_glyphslot_clear( FT_GlyphSlot slot ) { diff --git a/src/libs/freetype2/type42/t42objs.h b/src/libs/freetype2/type42/t42objs.h index 623809573e..aff26751f2 100644 --- a/src/libs/freetype2/type42/t42objs.h +++ b/src/libs/freetype2/type42/t42objs.h @@ -4,7 +4,7 @@ /* */ /* Type 42 objects manager (specification). */ /* */ -/* Copyright 2002, 2003 by Roberto Alameda. */ +/* Copyright 2002, 2003, 2006 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ @@ -80,16 +80,14 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - T42_Size_SetChars( T42_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); + T42_Size_Request( T42_Size size, + FT_Size_Request req ); + FT_LOCAL( FT_Error ) - T42_Size_SetPixels( T42_Size size, - FT_UInt pixel_width, - FT_UInt pixel_height ); + T42_Size_Select( T42_Size size, + FT_ULong index ); + FT_LOCAL( void ) T42_Size_Done( T42_Size size ); diff --git a/src/libs/freetype2/type42/t42parse.c b/src/libs/freetype2/type42/t42parse.c index 80e7547b90..6e1a683278 100644 --- a/src/libs/freetype2/type42/t42parse.c +++ b/src/libs/freetype2/type42/t42parse.c @@ -4,7 +4,7 @@ /* */ /* Type 42 font parser (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005 by Roberto Alameda. */ +/* Copyright 2002, 2003, 2004, 2005, 2006 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ @@ -623,6 +623,7 @@ status = OTHER_TABLES; face->ttf_size = ttf_size; + /* there are no more than 256 tables, so no size check here */ if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables, ttf_size + 1 ) ) goto Fail; @@ -1071,7 +1072,7 @@ if ( !name ) continue; - if ( cur[0] == name[0] && + if ( cur[0] == name[0] && len == (FT_PtrDist)ft_strlen( (const char *)name ) && ft_memcmp( cur, name, len ) == 0 ) { diff --git a/src/libs/freetype2/type42/t42types.h b/src/libs/freetype2/type42/t42types.h index d44ac4e671..6626b04458 100644 --- a/src/libs/freetype2/type42/t42types.h +++ b/src/libs/freetype2/type42/t42types.h @@ -4,7 +4,7 @@ /* */ /* Type 42 font data types (specification only). */ /* */ -/* Copyright 2002, 2003 by Roberto Alameda. */ +/* Copyright 2002, 2003, 2006 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ @@ -31,17 +31,17 @@ FT_BEGIN_HEADER typedef struct T42_FaceRec_ { - FT_FaceRec root; - T1_FontRec type1; - const void* psnames; - const void* psaux; - const void* afm_data; - FT_Byte* ttf_data; - FT_ULong ttf_size; - FT_Face ttf_face; - FT_CharMapRec charmaprecs[2]; - FT_CharMap charmaps[2]; - PS_Unicodes unicode_map; + FT_FaceRec root; + T1_FontRec type1; + const void* psnames; + const void* psaux; + const void* afm_data; + FT_Byte* ttf_data; + FT_ULong ttf_size; + FT_Face ttf_face; + FT_CharMapRec charmaprecs[2]; + FT_CharMap charmaps[2]; + PS_UnicodesRec unicode_map; } T42_FaceRec, *T42_Face; diff --git a/src/libs/freetype2/winfonts/descrip.mms b/src/libs/freetype2/winfonts/descrip.mms deleted file mode 100644 index 475cdbb6bd..0000000000 --- a/src/libs/freetype2/winfonts/descrip.mms +++ /dev/null @@ -1,23 +0,0 @@ -# -# FreeType 2 Windows FNT/FON driver compilation rules for VMS -# - - -# Copyright 2001, 2002 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.include],[--.src.winfonts]) - -OBJS=winfnt.obj - -all : $(OBJS) - library [--.lib]freetype.olb $(OBJS) - -# EOF diff --git a/src/libs/freetype2/winfonts/module.mk b/src/libs/freetype2/winfonts/module.mk index 99be845c19..0ace3ae6de 100644 --- a/src/libs/freetype2/winfonts/module.mk +++ b/src/libs/freetype2/winfonts/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2006 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,9 +13,11 @@ # fully. -make_module_list: add_windows_driver +FTMODULE_H_COMMANDS += WINDOWS_DRIVER -add_windows_driver: - $(OPEN_DRIVER)winfnt_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)winfnt $(ECHO_DRIVER_DESC)Windows bitmap fonts with extension *.fnt or *.fon$(ECHO_DRIVER_DONE) +define WINDOWS_DRIVER +$(OPEN_DRIVER)winfnt_driver_class$(CLOSE_DRIVER) +$(ECHO_DRIVER)winfnt $(ECHO_DRIVER_DESC)Windows bitmap fonts with extension *.fnt or *.fon$(ECHO_DRIVER_DONE) +endef +# EOF diff --git a/src/libs/freetype2/winfonts/winfnt.c b/src/libs/freetype2/winfonts/winfnt.c index 92174aedb0..3523b14f81 100644 --- a/src/libs/freetype2/winfonts/winfnt.c +++ b/src/libs/freetype2/winfonts/winfnt.c @@ -4,7 +4,7 @@ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -460,14 +460,43 @@ { FT_Bitmap_Size* bsize = root->available_sizes; + FT_UShort x_res, y_res; bsize->width = font->header.avg_width; bsize->height = (FT_Short)( font->header.pixel_height + font->header.external_leading ); bsize->size = font->header.nominal_point_size << 6; - bsize->x_ppem = font->header.pixel_width << 6; - bsize->y_ppem = font->header.pixel_height << 6; + + x_res = font->header.horizontal_resolution; + if ( !x_res ) + x_res = 72; + + y_res = font->header.vertical_resolution; + if ( !y_res ) + y_res = 72; + + bsize->y_ppem = FT_MulDiv( bsize->size, y_res, 72 ); + bsize->y_ppem = FT_PIX_ROUND( bsize->y_ppem ); + + /* + * this reads: + * + * the nominal height is larger than the bbox's height + * + * => nominal_point_size contains incorrect value; + * use pixel_height as the nominal height + */ + if ( bsize->y_ppem > font->header.pixel_height << 6 ) + { + FT_TRACE2(( "use pixel_height as the nominal height\n" )); + + bsize->y_ppem = font->header.pixel_height << 6; + bsize->size = FT_MulDiv( bsize->y_ppem, 72, y_res ); + } + + bsize->x_ppem = FT_MulDiv( bsize->size, x_res, 72 ); + bsize->x_ppem = FT_PIX_ROUND( bsize->x_ppem ); } { @@ -502,7 +531,7 @@ /* reserve one slot for the .notdef glyph at index 0 */ root->num_glyphs = font->header.last_char - - font->header.first_char + 1 + 1; + font->header.first_char + 1 + 1; /* Some broken fonts don't delimit the face name with a final */ /* NULL byte -- the frame is erroneously one byte too small. */ @@ -511,14 +540,18 @@ family_size = font->header.file_size - font->header.face_name_offset; if ( FT_ALLOC( font->family_name, family_size + 1 ) ) goto Fail; + FT_MEM_COPY( font->family_name, font->fnt_frame + font->header.face_name_offset, family_size ); + font->family_name[family_size] = '\0'; + if ( FT_REALLOC( font->family_name, family_size, ft_strlen( font->family_name ) + 1 ) ) goto Fail; + root->family_name = font->family_name; root->style_name = (char *)"Regular"; @@ -543,27 +576,58 @@ static FT_Error - FNT_Size_Set_Pixels( FT_Size size ) + FNT_Size_Select( FT_Size size ) { - FNT_Face face = (FNT_Face)FT_SIZE_FACE( size ); - FT_Face root = FT_FACE( face ); + FNT_Face face = (FNT_Face)size->face; + FT_WinFNT_Header header = &face->font->header; - if ( size->metrics.y_ppem == root->available_sizes->y_ppem >> 6 ) + FT_Select_Metrics( size->face, 0 ); + + size->metrics.ascender = header->ascent * 64; + size->metrics.descender = -( header->pixel_height - + header->ascent ) * 64; + size->metrics.max_advance = header->max_width * 64; + + return FNT_Err_Ok; + } + + + static FT_Error + FNT_Size_Request( FT_Size size, + FT_Size_Request req ) + { + FNT_Face face = (FNT_Face)size->face; + FT_WinFNT_Header header = &face->font->header; + FT_Bitmap_Size* bsize = size->face->available_sizes; + FT_Error error = FNT_Err_Invalid_Pixel_Size; + FT_Long height; + + + height = FT_REQUEST_HEIGHT( req ); + height = ( height + 32 ) >> 6; + + switch ( req->type ) { - FNT_Font font = face->font; + case FT_SIZE_REQUEST_TYPE_NOMINAL: + if ( height == ( bsize->y_ppem + 32 ) >> 6 ) + error = FNT_Err_Ok; + break; + case FT_SIZE_REQUEST_TYPE_REAL_DIM: + if ( height == header->pixel_height ) + error = FNT_Err_Ok; + break; - size->metrics.ascender = font->header.ascent * 64; - size->metrics.descender = -( font->header.pixel_height - - font->header.ascent ) * 64; - size->metrics.height = font->header.pixel_height * 64; - size->metrics.max_advance = font->header.max_width * 64; - - return FNT_Err_Ok; + default: + error = FNT_Err_Unimplemented_Feature; + break; } + + if ( error ) + return error; else - return FNT_Err_Invalid_Pixel_Size; + return FNT_Size_Select( size ); } @@ -633,7 +697,7 @@ /* note: since glyphs are stored in columns and not in rows we */ /* can't use ft_glyphslot_set_bitmap */ - if ( FT_ALLOC( bitmap->buffer, pitch * bitmap->rows ) ) + if ( FT_ALLOC_MULT( bitmap->buffer, pitch, bitmap->rows ) ) goto Exit; column = (FT_Byte*)bitmap->buffer; @@ -660,8 +724,8 @@ slot->metrics.horiBearingX = 0; slot->metrics.horiBearingY = slot->bitmap_top << 6; - slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16; - slot->format = FT_GLYPH_FORMAT_BITMAP; + ft_synthesize_vertical_metrics( &slot->metrics, + bitmap->rows << 6 ); Exit: return error; @@ -741,13 +805,18 @@ (FT_Slot_InitFunc) 0, (FT_Slot_DoneFunc) 0, - (FT_Size_ResetPointsFunc) FNT_Size_Set_Pixels, - (FT_Size_ResetPixelsFunc) FNT_Size_Set_Pixels, +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + ft_stub_set_char_sizes, + ft_stub_set_pixel_sizes, +#endif (FT_Slot_LoadFunc) FNT_Load_Glyph, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0 + (FT_Face_GetAdvancesFunc) 0, + + (FT_Size_RequestFunc) FNT_Size_Request, + (FT_Size_SelectFunc) FNT_Size_Select }; diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 606ed6f35f..14fb1aa162 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -27,7 +27,7 @@ // functions needed to convert a freetype vector graphics to a BShape inline BPoint -VectorToPoint(FT_Vector *vector) +VectorToPoint(const FT_Vector *vector) { BPoint result; result.x = float(vector->x) / 64; @@ -37,7 +37,7 @@ VectorToPoint(FT_Vector *vector) int -MoveToFunc(FT_Vector *to, void *user) +MoveToFunc(const FT_Vector *to, void *user) { ((BShape *)user)->MoveTo(VectorToPoint(to)); return 0; @@ -45,7 +45,7 @@ MoveToFunc(FT_Vector *to, void *user) int -LineToFunc(FT_Vector *to, void *user) +LineToFunc(const FT_Vector *to, void *user) { ((BShape *)user)->LineTo(VectorToPoint(to)); return 0; @@ -53,7 +53,7 @@ LineToFunc(FT_Vector *to, void *user) int -ConicToFunc(FT_Vector *control, FT_Vector *to, void *user) +ConicToFunc(const FT_Vector *control, const FT_Vector *to, void *user) { BPoint controls[3]; @@ -67,7 +67,7 @@ ConicToFunc(FT_Vector *control, FT_Vector *to, void *user) int -CubicToFunc(FT_Vector *control1, FT_Vector *control2, FT_Vector *to, void *user) +CubicToFunc(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *user) { BPoint controls[3];