Formatting, small fixes.

Adding basic input parameter checking for exported functions.
This commit is contained in:
Werner Lemberg 2000-08-24 16:29:15 +00:00
parent 35db73220c
commit d1b7475be1
25 changed files with 743 additions and 623 deletions

View File

@ -349,7 +349,7 @@
/* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
/* calls during glyph loading. */ /* calls during glyph loading. */
/* */ /* */
#define T1_MAX_SUBRS_CALLS 8 #define T1_MAX_SUBRS_CALLS 16
/*************************************************************************/ /*************************************************************************/
@ -357,7 +357,7 @@
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
/* minimum of 16 is required. */ /* minimum of 16 is required. */
/* */ /* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32 #define T1_MAX_CHARSTRINGS_OPERANDS 64
/*************************************************************************/ /*************************************************************************/

View File

@ -349,7 +349,7 @@
/* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
/* calls during glyph loading. */ /* calls during glyph loading. */
/* */ /* */
#define T1_MAX_SUBRS_CALLS 8 #define T1_MAX_SUBRS_CALLS 16
/*************************************************************************/ /*************************************************************************/
@ -357,7 +357,7 @@
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
/* minimum of 16 is required. */ /* minimum of 16 is required. */
/* */ /* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32 #define T1_MAX_CHARSTRINGS_OPERANDS 64
/*************************************************************************/ /*************************************************************************/

View File

@ -2,7 +2,7 @@
/* */ /* */
/* ftcache.h */ /* ftcache.h */
/* */ /* */
/* FreeType Cache subsystem */ /* FreeType Cache subsystem. */
/* */ /* */
/* Copyright 1996-2000 by */ /* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -15,84 +15,85 @@
/* */ /* */
/***************************************************************************/ /***************************************************************************/
#ifndef FTCACHE_H #ifndef FTCACHE_H
#define FTCACHE_H #define FTCACHE_H
#include <freetype/ftglyph.h> #include <freetype/ftglyph.h>
#ifdef __cplusplus
/**************************************************************************/ extern "C" {
/**************************************************************************/ #endif
/**************************************************************************/
/***** *****/
/***** BASIC TYPE DEFINITIONS *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** BASIC TYPE DEFINITIONS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
* /*************************************************************************/
* <Type> /* */
* FTC_FaceID /* <Type> */
* /* FTC_FaceID */
* <Description> /* */
* a generic pointer type that is used to identity face objects. /* <Description> */
* the content of such objects is application-dependent /* A generic pointer type that is used to identity face objects. The */
* /* contents of such objects is application-dependent. */
**************************************************************************/ /* */
typedef FT_Pointer FTC_FaceID; typedef FT_Pointer FTC_FaceID;
/*************************************************************************/
/************************************************************************** /* */
* /* <FuncType> */
* <FuncType> /* FTC_Face_Requester */
* FTC_Face_Requester /* */
* /* <Description> */
* <Description> /* A callback function provided by client applications. It is used */
* a callback function provided by client applications. It is used /* to translate a given FTC_FaceID into a new valid FT_Face object. */
* to translate a given FTC_FaceID into a new valid FT_Face object /* */
* /* <Input> */
* <Input> /* face_id :: The face ID to resolve. */
* face_id :: the face id to resolve /* */
* library :: handle to a FreeType library object /* library :: A handle to a FreeType library object. */
* data :: application-provided request data /* */
* /* data :: Application-provided request data. */
* <Output> /* */
* aface :: a new FT_Face handle /* <Output> */
* /* aface :: A new FT_Face handle. */
* <Return> /* */
* Error code. 0 means success /* <Return> */
* /* FreeType error code. 0 means success. */
**************************************************************************/ /* */
typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id, typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id,
FT_Library library, FT_Library library,
FT_Pointer request_data, FT_Pointer request_data,
FT_Face* aface ); FT_Face* aface );
/************************************************************************** /*************************************************************************/
* /* */
* <Struct> /* <Struct> */
* FTC_SizeRec /* FTC_SizeRec */
* /* */
* <Description> /* <Description> */
* A simple structure used to describe a given "font size" to the /* A simple structure used to describe a given `font size' to the */
* cache manager /* cache manager. */
* /* */
* <Fields> /* <Fields> */
* face_id :: id of face to use /* face_id :: The ID of the face to use. */
* pix_width :: character width in integer pixels /* */
* pix_height :: character height in integer pixels /* pix_width :: The character width in integer pixels. */
* /* */
**************************************************************************/ /* pix_height :: The character height in integer pixels. */
/* */
typedef struct FTC_SizeRec_ typedef struct FTC_SizeRec_
{ {
FTC_FaceID face_id; FTC_FaceID face_id;
@ -102,232 +103,221 @@
} FTC_SizeRec; } FTC_SizeRec;
/************************************************************************** /*************************************************************************/
* /* */
* <Type> /* <Type> */
* FTC_SizeID /* FTC_SizeID */
* /* */
* <Description> /* <Description> */
* A simple handle to a FTC_SizeRec structure /* A simple handle to a FTC_SizeRec structure. */
* /* */
**************************************************************************/
typedef FTC_SizeRec* FTC_SizeID; typedef FTC_SizeRec* FTC_SizeID;
/*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /***** *****/
/***** *****/ /***** CACHE MANAGER OBJECT *****/
/***** CACHE MANAGER OBJECT *****/ /***** *****/
/***** *****/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/
/*************************************************************************/
/* */
/************************************************************************** /* <Type> */
* /* FTC_Manager */
* <Type> /* */
* FTC_Manager /* <Description> */
* /* This object is used to cache one or more FT_Face objects, along */
* <Description> /* with corresponding FT_Size objects. */
* This object is used to cache one or more FT_Face object, along with /* */
* corresponding FT_Size objects.
*
**************************************************************************/
typedef struct FTC_ManagerRec_* FTC_Manager; typedef struct FTC_ManagerRec_* FTC_Manager;
/************************************************************************** /*************************************************************************/
* /* */
* <Function> /* <Function> */
* FTC_Manager_New /* FTC_Manager_New */
* /* */
* <Description> /* <Description> */
* Create a new cache manager. /* Creates a new cache manager. */
* /* */
* <Input> /* <Input> */
* library :: the parent FreeType library handle to use /* library :: The parent FreeType library handle to use. */
* /* */
* max_faces :: maximum number of faces to keep alive in manager /* max_faces :: Maximum number of faces to keep alive in manager. */
* use 0 for defaults /* Use 0 for defaults. */
* /* */
* max_sizes :: maximum number of sizes to keep alive in manager /* max_sizes :: Maximum number of sizes to keep alive in manager. */
* use 0 for defaults /* Use 0 for defaults. */
* /* */
* requester :: an application-provided callback used to translate /* requester :: An application-provided callback used to translate */
* face IDs into real FT_Face objects /* face IDs into real FT_Face objects. */
* /* */
* req_data :: a generic pointer that is passed to the requester /* req_data :: A generic pointer that is passed to the requester */
* each time it is called (see FTC_Face_Requester) /* each time it is called (see FTC_Face_Requester) */
* /* */
* <Output> /* <Output> */
* amanager :: handle to new manager object. 0 in case of failure /* amanager :: A handle to a new manager object. 0 in case of */
* /* failure. */
* <Return> /* */
* Error code. 0 means success /* <Return> */
* /* FreeType error code. 0 means success. */
**************************************************************************/ /* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_New( FT_Library library, FT_EXPORT_DEF( FT_Error ) FTC_Manager_New( FT_Library library,
FT_UInt max_faces, FT_UInt max_faces,
FT_UInt max_sizes, FT_UInt max_sizes,
FTC_Face_Requester requester, FTC_Face_Requester requester,
FT_Pointer req_data, FT_Pointer req_data,
FTC_Manager* amanager ); FTC_Manager* amanager );
/************************************************************************** /*************************************************************************/
* /* */
* <Function> /* <Function> */
* FTC_Manager_Reset /* FTC_Manager_Reset */
* /* */
* <Description> /* <Description> */
* Empty a given cache manager. This simply gets rid of all the /* Empties a given cache manager. This simply gets rid of all the */
* currently cached FT_Face & FT_Size objects within the manager /* currently cached FT_Face & FT_Size objects within the manager. */
* /* */
* <Input> /* <Input> */
* manager :: handle to manager /* manager :: A handle to the manager. */
* /* */
**************************************************************************/ FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager );
FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager );
/************************************************************************** /*************************************************************************/
* /* */
* <Function> /* <Function> */
* FTC_Manager_Done /* FTC_Manager_Done */
* /* */
* <Description> /* <Description> */
* destroys a given manager after emptying it.. /* Destroys a given manager after emptying it. */
* /* */
* <Input> /* <Input> */
* manager :: handle to target cache manager object /* manager :: A handle to the target cache manager object. */
* /* */
**************************************************************************/ FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager );
FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager );
/************************************************************************** /*************************************************************************/
* /* */
* <Function> /* <Function> */
* FTC_Manager_Lookup_Face /* FTC_Manager_Lookup_Face */
* /* */
* <Description> /* <Description> */
* retrieves the FT_Face that corresponds to a given face ID through /* Retrieves the FT_Face object that corresponds to a given face ID */
* a cache manager. /* through a cache manager. */
* /* */
* <Input> /* <Input> */
* manager :: handle to cache manager /* manager :: A handle to the cache manager. */
* face_id :: ID of face object /* */
* /* face_id :: The ID of the face object. */
* <Output> /* */
* aface :: handle to face object /* <Output> */
* /* aface :: A handle to the face object. */
* <Return> /* */
* Error code. 0 means success /* <Return> */
* /* FreeType error code. 0 means success. */
* <Note> /* */
* The returned FT_Face object is always owned by the manager, you /* <Note> */
* should never try to discard it yourself.. /* The returned FT_Face object is always owned by the manager. You */
* /* should never try to discard it yourself. */
* The FT_Face object doesn't necessarily have a current size object /* */
* (i.e. face->size can be 0). If you need a specific "font size", /* The FT_Face object doesn't necessarily have a current size object */
* use FTC_Manager_Lookup_Size instead.. /* (i.e., face->size can be 0). If you need a specific `font size', */
* /* use FTC_Manager_Lookup_Size() instead. */
* Never change the face's transform (i.e. NEVER CALL FT_Set_Transform) /* */
* on a returned face. If you need to transform glyphs, do it yourself /* Never change the face's transformation matrix (i.e., never call */
* after glyph loading.. /* the FT_Set_Transform() function) on a returned face! If you need */
* /* to transform glyphs, do it yourself after glyph loading. */
**************************************************************************/ /* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Face( FTC_Manager manager, FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id, FTC_FaceID face_id,
FT_Face* aface ); FT_Face* aface );
/************************************************************************** /*************************************************************************/
* /* */
* <Function> /* <Function> */
* FTC_Manager_Lookup_Size /* FTC_Manager_Lookup_Size */
* /* */
* <Description> /* <Description> */
* retrieves the FT_Face & FT_Size that correspond to a given /* Retrieves the FT_Face & FT_Size objects that correspond to a given */
* FTC_SizeID /* FTC_SizeID. */
* /* */
* <Input> /* <Input> */
* manager :: handle to cache manager. /* manager :: A handle to the cache manager. */
* size_id :: ID of the "font size" to use /* */
* /* size_id :: The ID of the `font size' to use. */
* <InOut> /* */
* aface :: ptr to handle to face object. Set to 0 if you don't need it /* <InOut> */
* asize :: ptr to handle to size object. Set to 0 if you don't need it /* aface :: A pointer to the handle of the face object. Set it to */
* /* zero if you don't need it. */
* <Return> /* */
* Error code. 0 means success /* asize :: A pointer to the handle of the size object. Set it to */
* /* zero if you don't need it. */
* <Note> /* */
* The returned FT_Face object is always owned by the manager, you /* <Return> */
* should never try to discard it yourself.. /* FreeType error code. 0 means success. */
* /* */
* Never change the face's transform (i.e. NEVER CALL FT_Set_Transform) /* <Note> */
* on a returned face. If you need to transform glyphs, do it yourself /* The returned FT_Face object is always owned by the manager. You */
* after glyph loading.. /* should never try to discard it yourself. */
* /* */
* The returned FT_Size object is always owned by the manager, you /* Never change the face's transformation matrix (i.e., never call */
* should never try to discard it, NEVER CHANGE ITS SETTINGS THROUGH /* the FT_Set_Transform() function) on a returned face! If you need */
* FT_Set_Pixel_Sizes OR FT_Set_Char_Size !! /* to transform glyphs, do it yourself after glyph loading. */
* /* */
* The returned size object is the face's current size, which means /* Similarly, the returned FT_Size object is always owned by the */
* that you can call FT_Load_Glyph with the face if you need to.. /* manager. You should never try to discard it, and never change its */
* /* settings with FT_Set_Pixel_Sizes() or FT_Set_Char_Size()! */
**************************************************************************/ /* */
/* The returned size object is the face's current size, which means */
/* that you can call FT_Load_Glyph() with the face if you need to. */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager, FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id, FTC_SizeID size_id,
FT_Face* aface, FT_Face* aface,
FT_Size* asize ); FT_Size* asize );
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/***** *****/ /***** *****/
/***** IMAGE CACHE OBJECT *****/ /***** IMAGE CACHE OBJECT *****/
/***** *****/ /***** *****/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/**************************************************************************/ /*************************************************************************/
/************************************************************************** /*************************************************************************/
* /* */
* <Enum> /* <Enum> */
* FTC_Image_Type /* FTC_Image_Type */
* /* */
* <Description> /* <Description> */
* An enumeration used to list the types of glyph images found in a /* An enumeration used to list the types of glyph images found in a */
* glyph image cache. /* glyph image cache. */
* /* */
* <Fields> /* <Fields> */
* ftc_image_mono :: monochrome bitmap glyphs /* ftc_image_mono :: Monochrome bitmap glyphs. */
* ftc_image_grays :: anti-aliased bitmap glyphs /* */
* ftc_image_outline :: scaled (and hinted) outline glyphs /* ftc_image_grays :: Anti-aliased bitmap glyphs. */
* ftc_master_outline :: unscaled original outline glyphs /* */
* /* ftc_image_outline :: Scaled (and hinted) outline glyphs. */
* <Note> /* */
* other types may be defined in the future /* ftc_master_outline :: Unscaled original outline glyphs. */
* /* */
**************************************************************************/ /* <Note> */
/* Other types may be defined in the future. */
/* */
typedef enum FTC_Image_Type_ typedef enum FTC_Image_Type_
{ {
ftc_image_mono = 0, /* monochrome bitmap */ ftc_image_mono = 0, /* monochrome bitmap */
@ -338,21 +328,21 @@
} FTC_Image_Type; } FTC_Image_Type;
/************************************************************************** /*************************************************************************/
* /* */
* <Struct> /* <Struct> */
* FTC_Image_Desc /* FTC_Image_Desc */
* /* */
* <Description> /* <Description> */
* A simple structure used to describe a given glyph image category /* A simple structure used to describe a given glyph image category. */
* /* */
* <Fields> /* <Fields> */
* size :: a FTC_SizeRec used to describe the glyph's face & size /* size :: An FTC_SizeRec used to describe the glyph's face & */
* image_type :: the glyph image's type /* size. */
* /* */
**************************************************************************/ /* image_type :: The glyph image's type. */
/* */
typedef struct FTC_Image_Desc_ typedef struct FTC_Image_Desc_
{ {
FTC_SizeRec size; FTC_SizeRec size;
FT_UInt image_type; FT_UInt image_type;
@ -360,95 +350,89 @@
} FTC_Image_Desc; } FTC_Image_Desc;
/*************************************************************************/
/************************************************************************** /* */
* /* <Type> */
* <Type> /* FTC_Image_Cache */
* FTC_Image_Cache /* */
* /* <Description> */
* <Description> /* A handle to an glyph image cache object. They are designed to */
* A handle to an glyph image cache object.. They are designed to /* hold many distinct glyph images, while not exceeding a certain */
* hold many distinct glyph images, while not exceeding a certain /* memory threshold. */
* memory threshold.. /* */
*
**************************************************************************/
typedef struct FTC_Image_CacheRec_* FTC_Image_Cache; typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
/*************************************************************************/
/************************************************************************** /* */
* /* <Function> */
* <Function> /* FTC_Image_Cache_New */
* FTC_Image_Cache_New /* */
* /* <Description> */
* <Description> /* Creates a new glyph image cache. */
* Create a new glyph image cache. /* */
* /* <Input> */
* <Input> /* manager :: The parent manager for the image cache. */
* manager :: parent manager for the image cache /* */
* /* max_bytes :: The maximum amount of memory that will be used to */
* max_bytes :: the maximum amount of memory that will be used to /* store glyph images. */
* store glyph images /* */
* /* <Output> */
* <Output> /* acache :: A handle to the new glyph image cache object. */
* acache :: handle to new glyph image cache object /* */
* /* <Return> */
* <Return> /* FreeType error code. 0 means success. */
* Error code. 0 means success /* */
*
**************************************************************************/
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager, FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager,
FT_ULong max_bytes, FT_ULong max_bytes,
FTC_Image_Cache* acache ); FTC_Image_Cache* acache );
/**************************************************************************
* /*************************************************************************/
* <Function> /* */
* FTC_Image_Cache_Done /* <Function> */
* /* FTC_Image_Cache_Done */
* <Description> /* */
* Destroys a given glyph image cache (and all glyphs within it). /* <Description> */
* /* Destroys a given glyph image cache (and all glyphs within it). */
* <Input> /* */
* manager :: parent manager for the image cache /* <Input> */
* /* manager :: The parent manager for the image cache. */
**************************************************************************/ /* */
FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache );
FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache );
/************************************************************************** /*************************************************************************/
* /* */
* <Function> /* <Function> */
* FTC_Image_Cache_Lookup /* FTC_Image_Cache_Lookup */
* /* */
* <Description> /* <Description> */
* Retrieve a given glyph image from a glyph image cache. /* Retrieves a given glyph image from a glyph image cache. */
* /* */
* <Input> /* <Input> */
* cache :: handle to source glyph image cache /* cache :: A handle to the source glyph image cache. */
* desc :: pointer to a glyph image descriptor /* */
* gindex :: index of glyph to retrieve /* desc :: A pointer to a glyph image descriptor. */
* /* */
* <Output> /* gindex :: The glyph index to retrieve. */
* aglyph :: the corresponding FT_Glyph object. 0 in case of failure /* */
* /* <Output> */
* <Return> /* aglyph :: The corresponding FT_Glyph object. 0 in case of */
* Error code. 0 means success /* failure. */
* /* */
* <Note> /* <Return> */
* the returned glyph is owned and manager by the glyph image cache, /* FreType error code. 0 means success. */
* never try to transform or discard it manually. You can however /* */
* create a copy with FT_Glyph_Copy and modify the new one at will. /* <Note> */
* /* the returned glyph is owned and manager by the glyph image cache. */
* Because the glyph image cache limits the total amount of memory /* Never try to transform or discard it manually! You can however */
* taken by the glyphs it holds, the returned glyph might disappear /* create a copy with FT_Glyph_Copy() and modify the new one. */
* on a later invocation of this function !! It's a cache after all ;-) /* */
* /* Because the glyph image cache limits the total amount of memory */
**************************************************************************/ /* taken by the glyphs it holds, the returned glyph might disappear */
/* on a later invocation of this function! It's a cache after all ;-) */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup( FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache, FTC_Image_Cache cache,
FTC_Image_Desc* desc, FTC_Image_Desc* desc,
@ -456,4 +440,12 @@
FT_Glyph* aglyph ); FT_Glyph* aglyph );
#ifdef __cplusplus
}
#endif
#endif /* FTCACHE_H */ #endif /* FTCACHE_H */
/* END */

View File

@ -134,7 +134,7 @@
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
typedef struct T1_Parser_ T1_Parser; typedef struct T1_Parser_ T1_Parser;
/* simple enumeration type used to identify token types */ /* simple enumeration type used to identify token types */
typedef enum T1_Token_Type_ typedef enum T1_Token_Type_
@ -189,33 +189,34 @@
} T1_Field_Location; } T1_Field_Location;
typedef void (*T1_Field_Parser)( FT_Face face,
FT_Pointer parser ); typedef void (*T1_Field_Parser)( FT_Face face,
FT_Pointer parser );
/* structure type used to model object fields */ /* structure type used to model object fields */
typedef struct T1_Field_ typedef struct T1_Field_
{ {
const char* ident; /* field identifier */ const char* ident; /* field identifier */
T1_Field_Location location; T1_Field_Location location;
T1_Field_Type type; /* type of field */ T1_Field_Type type; /* type of field */
T1_Field_Parser reader; T1_Field_Parser reader;
FT_UInt offset; /* offset of field in object */ FT_UInt offset; /* offset of field in object */
FT_Byte size; /* size of field in bytes */ FT_Byte size; /* size of field in bytes */
FT_UInt array_max; /* maximal number of elements for */ FT_UInt array_max; /* maximal number of elements for */
/* array */ /* array */
FT_UInt count_offset; /* offset of element count for */ FT_UInt count_offset; /* offset of element count for */
/* arrays */ /* arrays */
} T1_Field; } T1_Field;
#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \ #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
{ \ { \
_ident, T1CODE, _type, \ _ident, T1CODE, _type, \
0, \ 0, \
FT_FIELD_OFFSET( _fname ), \ FT_FIELD_OFFSET( _fname ), \
FT_FIELD_SIZE( _fname ), \ FT_FIELD_SIZE( _fname ), \
0, 0 \ 0, 0 \
}, },
#define T1_NEW_CALLBACK_FIELD( _ident, _reader ) \ #define T1_NEW_CALLBACK_FIELD( _ident, _reader ) \
@ -227,22 +228,22 @@
}, },
#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \ #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \
{ \
_ident, T1CODE, _type, \
0, \
FT_FIELD_OFFSET( _fname ), \
FT_FIELD_SIZE_DELTA( _fname ), \
_max, \
FT_FIELD_OFFSET( num_ ## _fname ) \
},
#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max ) \
{ \ { \
_ident, T1CODE, _type, \ _ident, T1CODE, _type, \
0, \ 0, \
FT_FIELD_OFFSET( _fname ), \ FT_FIELD_OFFSET( _fname ), \
FT_FIELD_SIZE_DELTA( _fname ), \ FT_FIELD_SIZE_DELTA( _fname ), \
_max, \ _max, 0 \
FT_FIELD_OFFSET( num_ ## _fname ) \
},
#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max ) \
{ \
_ident, T1CODE, _type, \
0, \
FT_FIELD_OFFSET( _fname ), \
FT_FIELD_SIZE_DELTA( _fname ), \
_max, 0 \
}, },

View File

@ -1019,9 +1019,9 @@
slot->advance.y = 0; slot->advance.y = 0;
} }
if ((load_flags & FT_LOAD_NO_RECURSE)==0) if ( ( load_flags & FT_LOAD_NO_RECURSE ) == 0 )
{ {
/* now, transform the glyph image when needed */ /* now, transform the glyph image if needed */
if ( face->transform_flags ) if ( face->transform_flags )
{ {
/* get renderer */ /* get renderer */

4
src/cache/ftcache.c vendored
View File

@ -2,9 +2,9 @@
/* */ /* */
/* ftcache.c */ /* ftcache.c */
/* */ /* */
/* The FreeType Caching sub-system */ /* The FreeType Caching sub-system (body only). */
/* */ /* */
/* Copyright 1996-2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */

270
src/cache/ftcimage.c vendored
View File

@ -2,7 +2,7 @@
/* */ /* */
/* ftcimage.c */ /* ftcimage.c */
/* */ /* */
/* FreeType Image Cache */ /* FreeType Image Cache (body). */
/* */ /* */
/* Copyright 2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -21,29 +21,30 @@
#include <freetype/internal/ftobjs.h> #include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftlist.h> #include <freetype/internal/ftlist.h>
/***********************************************************************/ /**************************************************************************/
/***********************************************************************/ /**************************************************************************/
/***** *****/ /***** *****/
/***** IMAGE NODE MANAGEMENT *****/ /***** IMAGE NODE MANAGEMENT *****/
/***** *****/ /***** *****/
/***** For now, we simply ALLOC/FREE the FTC_ImageNode. However, *****/ /***** For now, we simply ALLOC/FREE the FTC_ImageNode. However, it *****/
/***** it certainly is a good idea to use a chunk manager in the *****/ /***** certainly is a good idea to use a chunk manager in the future *****/
/***** future in order to reduce memory waste/fragmentation *****/ /***** in order to reduce memory waste resp. fragmentation. *****/
/***** *****/ /***** *****/
/***********************************************************************/ /**************************************************************************/
/***********************************************************************/ /**************************************************************************/
static static
FT_Error FTC_ImageNode_New( FTC_Image_Cache cache, FT_Error FTC_ImageNode_New( FTC_Image_Cache cache,
FTC_ImageNode *anode ) FTC_ImageNode* anode )
{ {
FT_Error error; FT_Error error;
FT_Memory memory = cache->memory; FT_Memory memory = cache->memory;
FTC_ImageNode node; FTC_ImageNode node;
*anode = 0; *anode = 0;
if (!ALLOC( node, sizeof(*node) )) if ( !ALLOC( node, sizeof ( *node ) ) )
*anode = node; *anode = node;
return error; return error;
@ -51,24 +52,25 @@
static static
void FTC_ImageNode_Done( FTC_Image_Cache cache, void FTC_ImageNode_Done( FTC_Image_Cache cache,
FTC_ImageNode node ) FTC_ImageNode node )
{ {
/* for now, we simply discard the node. We may later add a chunk */ /* for now, we simply discard the node; we may later add a chunk */
/* manager to the image cache.. */ /* manager to the image cache. */
FT_Memory memory = cache->memory; FT_Memory memory = cache->memory;
FREE( node ); FREE( node );
} }
/*************************************************************************/
/***********************************************************************/ /*************************************************************************/
/***********************************************************************/ /***** *****/
/***** *****/ /***** GLYPH IMAGE QUEUES *****/
/***** GLYPH IMAGE QUEUES *****/ /***** *****/
/***** *****/ /*************************************************************************/
/***********************************************************************/ /*************************************************************************/
/***********************************************************************/
static static
@ -324,19 +326,20 @@
static static
FT_Error FTC_Image_Queue_New( FTC_Image_Cache cache, FT_Error FTC_Image_Queue_New( FTC_Image_Cache cache,
FTC_Image_Desc* desc, FTC_Image_Desc* desc,
FTC_Image_Queue *aqueue ) FTC_Image_Queue* aqueue )
{ {
FT_Error error; FT_Error error;
FT_Memory memory = cache->memory; FT_Memory memory = cache->memory;
FTC_Manager manager = cache->manager; FTC_Manager manager = cache->manager;
FTC_Image_Queue queue = 0; FTC_Image_Queue queue = 0;
const FTC_Image_Class* clazz; const FTC_Image_Class* clazz;
*aqueue = 0; *aqueue = 0;
if ( ALLOC( queue, sizeof(*queue) ) ) if ( ALLOC( queue, sizeof ( *queue ) ) )
goto Exit; goto Exit;
queue->cache = cache; queue->cache = cache;
@ -348,34 +351,35 @@
if ( ALLOC_ARRAY( queue->buckets, queue->hash_size, FT_ListRec ) ) if ( ALLOC_ARRAY( queue->buckets, queue->hash_size, FT_ListRec ) )
goto Exit; goto Exit;
switch (desc->image_type) switch ( desc->image_type )
{ {
case ftc_image_mono: case ftc_image_mono:
clazz = &ftc_mono_image_class; clazz = &ftc_mono_image_class;
break; break;
case ftc_image_grays: case ftc_image_grays:
clazz = &ftc_gray_image_class; clazz = &ftc_gray_image_class;
break; break;
case ftc_image_outline: case ftc_image_outline:
clazz = &ftc_outline_image_class; clazz = &ftc_outline_image_class;
break; break;
case ftc_image_master_outline: case ftc_image_master_outline:
clazz = &ftc_master_outline_image_class; clazz = &ftc_master_outline_image_class;
break; break;
default: default:
/* invalid image type !! */ /* invalid image type! */
error = FT_Err_Invalid_Argument; error = FT_Err_Invalid_Argument;
goto Exit; goto Exit;
} }
queue->clazz = (FTC_Image_Class*)clazz; queue->clazz = (FTC_Image_Class*)clazz;
*aqueue = queue; *aqueue = queue;
Exit: Exit:
if (error) if ( error )
FREE( queue ); FREE( queue );
return error; return error;
@ -383,7 +387,7 @@
static static
void FTC_Image_Queue_Done( FTC_Image_Queue queue ) void FTC_Image_Queue_Done( FTC_Image_Queue queue )
{ {
FTC_Image_Cache cache = queue->cache; FTC_Image_Cache cache = queue->cache;
FT_List glyphs_lru = &cache->glyphs_lru; FT_List glyphs_lru = &cache->glyphs_lru;
@ -391,6 +395,7 @@
FT_List bucket_limit = bucket + queue->hash_size; FT_List bucket_limit = bucket + queue->hash_size;
FT_Memory memory = cache->memory; FT_Memory memory = cache->memory;
/* for each bucket, free the list of image nodes */ /* for each bucket, free the list of image nodes */
for ( ; bucket < bucket_limit; bucket++ ) for ( ; bucket < bucket_limit; bucket++ )
{ {
@ -399,11 +404,12 @@
FT_ListNode lrunode; FT_ListNode lrunode;
FTC_ImageNode inode; FTC_ImageNode inode;
for ( ; node; node = next ) for ( ; node; node = next )
{ {
next = node->next; next = node->next;
inode = (FTC_ImageNode)node; inode = (FTC_ImageNode)node;
lrunode = FTC_IMAGENODE_TO_LISTNODE(inode); lrunode = FTC_IMAGENODE_TO_LISTNODE( inode );
queue->clazz->done_image( queue, inode ); queue->clazz->done_image( queue, inode );
FT_List_Remove( glyphs_lru, lrunode ); FT_List_Remove( glyphs_lru, lrunode );
@ -413,6 +419,7 @@
bucket->head = bucket->tail = 0; bucket->head = bucket->tail = 0;
} }
FREE( queue->buckets ); FREE( queue->buckets );
FREE( queue ); FREE( queue );
} }
@ -421,7 +428,7 @@
static static
FT_Error FTC_Image_Queue_Lookup_Node( FTC_Image_Queue queue, FT_Error FTC_Image_Queue_Lookup_Node( FTC_Image_Queue queue,
FT_UInt glyph_index, FT_UInt glyph_index,
FTC_ImageNode *anode ) FTC_ImageNode* anode )
{ {
FTC_Image_Cache cache = queue->cache; FTC_Image_Cache cache = queue->cache;
FT_UInt hash_index = glyph_index % queue->hash_size; FT_UInt hash_index = glyph_index % queue->hash_size;
@ -430,14 +437,15 @@
FT_Error error; FT_Error error;
FTC_ImageNode inode; FTC_ImageNode inode;
*anode = 0; *anode = 0;
for ( node = bucket->head; node; node = next ) for ( node = bucket->head; node; node = next )
{ {
inode = (FTC_ImageNode)node; inode = (FTC_ImageNode)node;
if ( FTC_IMAGENODE_GET_GINDEX(inode) == glyph_index ) if ( FTC_IMAGENODE_GET_GINDEX( inode ) == glyph_index )
{ {
/* we found it !! - move glyph to start of the list */ /* we found it! -- move glyph to start of the list */
FT_List_Up( bucket, node ); FT_List_Up( bucket, node );
*anode = inode; *anode = inode;
return 0; return 0;
@ -446,14 +454,14 @@
/* we didn't found the glyph image, we will now create a new one */ /* we didn't found the glyph image, we will now create a new one */
error = FTC_ImageNode_New( queue->cache, &inode ); error = FTC_ImageNode_New( queue->cache, &inode );
if (error) if ( error )
goto Exit; goto Exit;
/* set the glyph and queue indices in the image node */ /* set the glyph and queue indices in the image node */
FTC_IMAGENODE_SET_INDICES( inode, glyph_index, queue->index ); FTC_IMAGENODE_SET_INDICES( inode, glyph_index, queue->index );
error = queue->clazz->init_image( queue, inode ); error = queue->clazz->init_image( queue, inode );
if (error) if ( error )
{ {
FTC_ImageNode_Done( queue->cache, inode ); FTC_ImageNode_Done( queue->cache, inode );
goto Exit; goto Exit;
@ -463,7 +471,7 @@
FT_List_Insert( bucket, (FT_ListNode)inode ); FT_List_Insert( bucket, (FT_ListNode)inode );
/* insert the node at the start the global LRU glyph list */ /* insert the node at the start the global LRU glyph list */
FT_List_Insert( &cache->glyphs_lru, FTC_IMAGENODE_TO_LISTNODE(inode) ); FT_List_Insert( &cache->glyphs_lru, FTC_IMAGENODE_TO_LISTNODE( inode ) );
cache->num_bytes += queue->clazz->size_image(queue,inode); cache->num_bytes += queue->clazz->size_image(queue,inode);
@ -473,31 +481,36 @@
return error; return error;
} }
/***********************************************************************/ /*************************************************************************/
/***********************************************************************/ /*************************************************************************/
/***** *****/ /***** *****/
/***** IMAGE CACHE CALLBACKS *****/ /***** IMAGE CACHE CALLBACKS *****/
/***** *****/ /***** *****/
/***********************************************************************/ /*************************************************************************/
/***********************************************************************/ /*************************************************************************/
#define FTC_QUEUE_LRU_GET_CACHE(lru) ((FTC_Image_Cache)(lru)->user_data)
#define FTC_QUEUE_LRU_GET_MANAGER(lru) FTC_QUEUE_LRU_GET_CACHE(lru)->manager #define FTC_QUEUE_LRU_GET_CACHE( lru ) \
#define FTC_LRUNODE_QUEUE(node) ((FTC_Image_Queue)(node)->root.data) ( (FTC_Image_Cache)(lru)->user_data )
#define FTC_QUEUE_LRU_GET_MANAGER( lru ) \
FTC_QUEUE_LRU_GET_CACHE( lru )->manager
#define FTC_LRUNODE_QUEUE( node ) \
( (FTC_Image_Queue)(node)->root.data )
static static
FT_Error ftc_image_cache_init_queue( FT_Lru lru, FT_Error ftc_image_cache_init_queue( FT_Lru lru,
FT_LruNode node ) FT_LruNode node )
{ {
FTC_Image_Cache cache = FTC_QUEUE_LRU_GET_CACHE(lru); FTC_Image_Cache cache = FTC_QUEUE_LRU_GET_CACHE( lru );
FTC_Image_Desc* desc = (FTC_Image_Desc*)node->key; FTC_Image_Desc* desc = (FTC_Image_Desc*)node->key;
FT_Error error; FT_Error error;
FTC_Image_Queue queue; FTC_Image_Queue queue;
error = FTC_Image_Queue_New( cache, desc, &queue ); error = FTC_Image_Queue_New( cache, desc, &queue );
if (!error) if ( !error )
{ {
/* good, now set the queue index within the queue object */ /* good, now set the queue index within the queue object */
queue->index = node - lru->nodes; queue->index = node - lru->nodes;
@ -509,34 +522,36 @@
static static
void ftc_image_cache_done_queue( FT_Lru lru, void ftc_image_cache_done_queue( FT_Lru lru,
FT_LruNode node ) FT_LruNode node )
{ {
FTC_Image_Queue queue = FTC_LRUNODE_QUEUE(node); FTC_Image_Queue queue = FTC_LRUNODE_QUEUE( node );
FT_UNUSED(lru); FT_UNUSED( lru );
FTC_Image_Queue_Done(queue);
FTC_Image_Queue_Done( queue );
} }
static static
FT_Bool ftc_image_cache_compare_queue( FT_LruNode node, FT_Bool ftc_image_cache_compare_queue( FT_LruNode node,
FT_LruKey key ) FT_LruKey key )
{ {
FTC_Image_Queue queue = FTC_LRUNODE_QUEUE(node); FTC_Image_Queue queue = FTC_LRUNODE_QUEUE( node );
FTC_Image_Desc* desc2 = (FTC_Image_Desc*)key; FTC_Image_Desc* desc2 = (FTC_Image_Desc*)key;
FTC_Image_Desc* desc1 = &queue->descriptor; FTC_Image_Desc* desc1 = &queue->descriptor;
return ( desc1->size.face_id == desc2->size.face_id &&
desc1->size.pix_width == desc2->size.pix_width && return ( desc1->size.face_id == desc2->size.face_id &&
desc1->size.pix_height == desc2->size.pix_height && desc1->size.pix_width == desc2->size.pix_width &&
desc1->image_type == desc2->image_type ); desc1->size.pix_height == desc2->size.pix_height &&
desc1->image_type == desc2->image_type );
} }
static static
const FT_Lru_Class ftc_image_queue_lru_class = const FT_Lru_Class ftc_image_queue_lru_class =
{ {
sizeof( FT_LruRec ), sizeof( FT_LruRec ),
ftc_image_cache_init_queue, ftc_image_cache_init_queue,
@ -546,17 +561,14 @@
}; };
/* compress image cache if necessary, i.e., discard all old glyph images */
/* until `cache.num_bytes' is less than `cache.max_bytes'. Note that */
/* this function will avoid to remove `new_node'. */
/* compress image cache if it needs it.. i.e. discards all old glyph images */
/* until "cache.num_bytes" is under "cache.max_bytes". Note that this function */
/* will avoid to remove "new_node".. */
static static
void FTC_Image_Cache_Compress( FTC_Image_Cache cache, void FTC_Image_Cache_Compress( FTC_Image_Cache cache,
FTC_ImageNode new_node ) FTC_ImageNode new_node )
{ {
while (cache->num_bytes > cache->max_bytes) while ( cache->num_bytes > cache->max_bytes )
{ {
FT_ListNode cur = cache->glyphs_lru.tail; FT_ListNode cur = cache->glyphs_lru.tail;
FTC_Image_Queue queue; FTC_Image_Queue queue;
@ -566,17 +578,19 @@
FT_ULong size; FT_ULong size;
FTC_ImageNode inode; FTC_ImageNode inode;
/* exit our loop if there isn't any glyph image left, or if */
/* we reached the newly created node (which is always at the */ /* exit our loop if there isn't any glyph image left, or if */
/* start of the list..) */ /* we reached the newly created node (which happens always at the */
/* start of the list) */
inode = FTC_LISTNODE_TO_IMAGENODE(cur); inode = FTC_LISTNODE_TO_IMAGENODE( cur );
if ( !cur || inode == new_node ) if ( !cur || inode == new_node )
break; break;
glyph_index = FTC_IMAGENODE_GET_GINDEX(inode); glyph_index = FTC_IMAGENODE_GET_GINDEX( inode );
queue_index = FTC_IMAGENODE_GET_QINDEX(inode); queue_index = FTC_IMAGENODE_GET_QINDEX( inode );
queue = (FTC_Image_Queue)cache->queues_lru->nodes[queue_index].root.data; queue = (FTC_Image_Queue)cache->queues_lru->
nodes[queue_index].root.data;
hash_index = glyph_index % queue->hash_size; hash_index = glyph_index % queue->hash_size;
size = queue->clazz->size_image( queue, inode ); size = queue->clazz->size_image( queue, inode );
@ -599,10 +613,13 @@
FTC_Image_Cache cache; FTC_Image_Cache cache;
if ( !acache || !manager || !manager->library )
return FT_Err_Invalid_Argument;
*acache = 0; *acache = 0;
memory = manager->library->memory; memory = manager->library->memory;
if ( ALLOC( cache, sizeof(*cache) ) ) if ( ALLOC( cache, sizeof ( *cache ) ) )
goto Exit; goto Exit;
cache->manager = manager; cache->manager = manager;
@ -615,7 +632,7 @@
memory, memory,
1, /* pre_alloc == TRUE */ 1, /* pre_alloc == TRUE */
&cache->queues_lru ); &cache->queues_lru );
if (error) if ( error )
goto Exit; goto Exit;
*acache = cache; *acache = cache;
@ -628,11 +645,15 @@
} }
FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache ) FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache )
{ {
FT_Memory memory = cache->memory; FT_Memory memory;
if ( !cache )
return;
memory = cache->memory;
/* discard image queues */ /* discard image queues */
FT_Lru_Done( cache->queues_lru ); FT_Lru_Done( cache->queues_lru );
@ -642,7 +663,6 @@
} }
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup( FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache, FTC_Image_Cache cache,
FTC_Image_Desc* desc, FTC_Image_Desc* desc,
@ -653,28 +673,34 @@
FTC_Image_Queue queue; FTC_Image_Queue queue;
FTC_ImageNode inode; FTC_ImageNode inode;
/* check for valid `desc' delayed to FT_Lru_Lookup() */
if ( !cache || !aglyph )
return FT_Err_Invalid_Argument;
*aglyph = 0; *aglyph = 0;
queue = cache->last_queue; queue = cache->last_queue;
if ( !queue || if ( !queue ||
queue->descriptor.size.face_id != desc->size.face_id || queue->descriptor.size.face_id != desc->size.face_id ||
queue->descriptor.size.pix_width != desc->size.pix_width || queue->descriptor.size.pix_width != desc->size.pix_width ||
queue->descriptor.size.pix_height != desc->size.pix_height || queue->descriptor.size.pix_height != desc->size.pix_height ||
queue->descriptor.image_type != desc->image_type ) queue->descriptor.image_type != desc->image_type )
{ {
error = FT_Lru_Lookup( cache->queues_lru, error = FT_Lru_Lookup( cache->queues_lru,
(FT_LruKey)desc, (FT_LruKey)desc,
(FT_Pointer*)&queue ); (FT_Pointer*)&queue );
cache->last_queue = queue; cache->last_queue = queue;
if (error) if ( error )
goto Exit; goto Exit;
} }
error = FTC_Image_Queue_Lookup_Node( queue, gindex, &inode ); error = FTC_Image_Queue_Lookup_Node( queue, gindex, &inode );
if (error) if ( error )
goto Exit; goto Exit;
FTC_Image_Cache_Compress( cache, inode ); FTC_Image_Cache_Compress( cache, inode );
*aglyph = FTC_IMAGENODE_GET_GLYPH(inode); *aglyph = FTC_IMAGENODE_GET_GLYPH( inode );
Exit: Exit:
return error; return error;

35
src/cache/ftcimage.h vendored
View File

@ -2,7 +2,7 @@
/* */ /* */
/* ftcimage.h */ /* ftcimage.h */
/* */ /* */
/* FreeType Image Cache */ /* FreeType Image Cache (specification). */
/* */ /* */
/* Copyright 2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -42,7 +42,7 @@
typedef struct FTC_ImageNodeRec_ typedef struct FTC_ImageNodeRec_
{ {
/* root1.data contains a FT_Glyph handle */ /* root1.data contains an FT_Glyph handle */
FT_ListNodeRec root1; FT_ListNodeRec root1;
/* root2.data contains a glyph index + queue index */ /* root2.data contains a glyph index + queue index */
@ -54,8 +54,12 @@
/* macros to read/set the glyph & queue index in a FTC_ImageNode */ /* macros to read/set the glyph & queue index in a FTC_ImageNode */
#define FTC_IMAGENODE_GET_GINDEX( n ) FTC_PTR_TO_GINDEX( (n)->root2.data ) #define FTC_IMAGENODE_GET_GINDEX( n ) FTC_PTR_TO_GINDEX( (n)->root2.data )
#define FTC_IMAGENODE_GET_QINDEX( n ) FTC_PTR_TO_QINDEX( (n)->root2.data ) #define FTC_IMAGENODE_GET_QINDEX( n ) FTC_PTR_TO_QINDEX( (n)->root2.data )
#define FTC_IMAGENODE_GET_GLYPH(n) ((FT_Glyph)(n)->root1.data) #define FTC_IMAGENODE_GET_GLYPH( n ) ( (FT_Glyph)(n)->root1.data )
#define FTC_IMAGENODE_SET_GLYPH(n,g) do { (n)->root1.data = g; } while (0) #define FTC_IMAGENODE_SET_GLYPH( n, g ) \
do \
{ \
(n)->root1.data = g; \
} while ( 0 )
#define FTC_IMAGENODE_SET_INDICES( n, g, q ) \ #define FTC_IMAGENODE_SET_INDICES( n, g, q ) \
do \ do \
{ \ { \
@ -64,26 +68,27 @@
/* this macro is used to extract a handle to the global LRU list node */ /* this macro is used to extract a handle to the global LRU list node */
/* corresponding to a given image node.. */ /* corresponding to a given image node */
#define FTC_IMAGENODE_TO_LISTNODE(n) \ #define FTC_IMAGENODE_TO_LISTNODE( n ) \
((FT_ListNode)&(n)->root2) ( (FT_ListNode)&(n)->root2 )
/* this macro is used to extract a handle to a given image node from */ /* this macro is used to extract a handle to a given image node from */
/* the corresponding LRU glyph list node. That's a bit hackish.. */ /* the corresponding LRU glyph list node. That's a bit hackish.. */
#define FTC_LISTNODE_TO_IMAGENODE(p) \ #define FTC_LISTNODE_TO_IMAGENODE( p ) \
((FTC_ImageNode)((char*)(p) - offsetof(FTC_ImageNodeRec,root2))) ( (FTC_ImageNode)( (char*)(p) - \
offsetof( FTC_ImageNodeRec,root2 ) ) )
typedef struct FTC_Image_CacheRec_ typedef struct FTC_Image_CacheRec_
{ {
FTC_Manager manager; FTC_Manager manager;
FT_Memory memory; FT_Memory memory;
FT_ULong max_bytes; /* maximum size of cache in bytes */ FT_ULong max_bytes; /* maximum size of cache in bytes */
FT_ULong num_bytes; /* current size of cache in bytes */ FT_ULong num_bytes; /* current size of cache in bytes */
FT_Lru queues_lru; /* static queues lru list */ FT_Lru queues_lru; /* static queues lru list */
FT_ListRec glyphs_lru; /* global lru list of glyph images */ FT_ListRec glyphs_lru; /* global lru list of glyph images */
FTC_Image_Queue last_queue; /* small cache */ FTC_Image_Queue last_queue; /* small cache */

44
src/cache/ftcmanag.c vendored
View File

@ -1,8 +1,8 @@
/***************************************************************************/ /***************************************************************************/
/* */ /* */
/* ftcmanag.h */ /* ftcmanag.c */
/* */ /* */
/* FreeType Cache Manager */ /* FreeType Cache Manager (body). */
/* */ /* */
/* Copyright 2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -203,23 +203,28 @@
FT_EXPORT_FUNC( FT_Error ) FTC_Manager_New( FT_Library library, FT_EXPORT_FUNC( FT_Error ) FTC_Manager_New( FT_Library library,
FT_UInt max_faces, FT_UInt max_faces,
FT_UInt max_sizes, FT_UInt max_sizes,
FTC_Face_Requester requester, FTC_Face_Requester requester,
FT_Pointer req_data, FT_Pointer req_data,
FTC_Manager* amanager ) FTC_Manager* amanager )
{ {
FT_Error error; FT_Error error;
FT_Memory memory = library->memory; FT_Memory memory;
FTC_Manager manager = 0; FTC_Manager manager = 0;
if ( !library )
return FT_Err_Invalid_Library_Handle;
memory = library->memory;
if ( ALLOC( manager, sizeof ( *manager ) ) ) if ( ALLOC( manager, sizeof ( *manager ) ) )
goto Exit; goto Exit;
if (max_faces == 0) if ( max_faces == 0 )
max_faces = FTC_MAX_FACES; max_faces = FTC_MAX_FACES;
if (max_sizes == 0) if ( max_sizes == 0 )
max_sizes = FTC_MAX_SIZES; max_sizes = FTC_MAX_SIZES;
error = FT_Lru_New( &ftc_face_lru_class, error = FT_Lru_New( &ftc_face_lru_class,
@ -259,9 +264,14 @@
FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager ) FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager )
{ {
FT_Memory memory = manager->library->memory; FT_Memory memory;
if ( !manager || !manager->library )
return;
memory = manager->library->memory;
FT_Lru_Done( manager->sizes_lru ); FT_Lru_Done( manager->sizes_lru );
FT_Lru_Done( manager->faces_lru ); FT_Lru_Done( manager->faces_lru );
FREE( manager ); FREE( manager );
@ -270,6 +280,9 @@
FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager ) FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager )
{ {
if ( !manager )
return;
FT_Lru_Reset( manager->sizes_lru ); FT_Lru_Reset( manager->sizes_lru );
FT_Lru_Reset( manager->faces_lru ); FT_Lru_Reset( manager->faces_lru );
} }
@ -279,13 +292,15 @@
FTC_FaceID face_id, FTC_FaceID face_id,
FT_Face* aface ) FT_Face* aface )
{ {
if ( !manager )
return FT_Err_Invalid_Argument;
return FT_Lru_Lookup( manager->faces_lru, return FT_Lru_Lookup( manager->faces_lru,
(FT_LruKey)face_id, (FT_LruKey)face_id,
(FT_Pointer*)aface ); (FT_Pointer*)aface );
} }
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager, FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id, FTC_SizeID size_id,
FT_Face* aface, FT_Face* aface,
@ -296,17 +311,20 @@
FT_Face face; FT_Face face;
if (aface) /* check for valid `manager' delayed to FTC_Manager_Lookup_Face() */
if ( aface )
*aface = 0; *aface = 0;
if (asize) if ( asize )
*asize = 0; *asize = 0;
error = FTC_Manager_Lookup_Face( manager, size_id->face_id, &face ); error = FTC_Manager_Lookup_Face( manager, size_id->face_id, &face );
if ( !error ) if ( !error )
{ {
FT_Size size; FT_Size size;
req.face = face; req.face = face;
req.width = size_id->pix_width; req.width = size_id->pix_width;
req.height = size_id->pix_height; req.height = size_id->pix_height;
@ -319,10 +337,10 @@
/* select the size as the current one for this face */ /* select the size as the current one for this face */
face->size = size; face->size = size;
if (asize) if ( asize )
*asize = size; *asize = size;
if (aface) if ( aface )
*aface = face; *aface = face;
} }
} }

View File

@ -2,7 +2,7 @@
/* */ /* */
/* ftcmanag.h */ /* ftcmanag.h */
/* */ /* */
/* FreeType Cache Manager */ /* FreeType Cache Manager (specification). */
/* */ /* */
/* Copyright 2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */

53
src/cache/ftlru.c vendored
View File

@ -2,7 +2,7 @@
/* */ /* */
/* ftlru.c */ /* ftlru.c */
/* */ /* */
/* simple LRU list-cache */ /* Simple LRU list-cache (body). */
/* */ /* */
/* Copyright 2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -47,6 +47,9 @@
FT_Lru lru; FT_Lru lru;
if ( !alru )
return FT_Err_Invalid_Argument;
*alru = 0; *alru = 0;
if ( !ALLOC( lru, sizeof ( *lru ) ) ) if ( !ALLOC( lru, sizeof ( *lru ) ) )
{ {
@ -80,11 +83,18 @@
FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru ) FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru )
{ {
FT_ListNode node = lru->elements.head; FT_ListNode node;
FT_Lru_Class* clazz = lru->clazz; FT_Lru_Class* clazz;
FT_Memory memory = lru->memory; FT_Memory memory;
if ( !lru )
return;
node = lru->elements.head;
clazz = lru->clazz;
memory = lru->memory;
while ( node ) while ( node )
{ {
FT_ListNode next = node->next; FT_ListNode next = node->next;
@ -108,9 +118,14 @@
FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru ) FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru )
{ {
FT_Memory memory = lru->memory; FT_Memory memory;
if ( !lru )
return;
memory = lru->memory;
FT_Lru_Reset( lru ); FT_Lru_Reset( lru );
FREE( lru ); FREE( lru );
} }
@ -120,13 +135,20 @@
FT_LruKey key, FT_LruKey key,
FT_LruNode* anode ) FT_LruNode* anode )
{ {
FT_Error error = 0; FT_Error error = 0;
FT_ListNode node = lru->elements.head; FT_ListNode node;
FT_Lru_Class* clazz = lru->clazz; FT_Lru_Class* clazz;
FT_LruNode found = 0; FT_LruNode found = 0;
FT_Memory memory = lru->memory; FT_Memory memory;
if ( !lru || !key || !anode )
return FT_Err_Invalid_Argument;
node = lru->elements.head;
clazz = lru->clazz;
memory = lru->memory;
if ( clazz->compare_element ) if ( clazz->compare_element )
{ {
for ( ; node; node = node->next ) for ( ; node; node = node->next )
@ -243,6 +265,11 @@
FT_LruNode node; FT_LruNode node;
/* check for valid `lru' and `key' delayed to FT_Lru_Lookup_Node() */
if ( !aobject )
return FT_Err_Invalid_Argument;
*aobject = 0; *aobject = 0;
error = FT_Lru_Lookup_Node( lru, key, &node ); error = FT_Lru_Lookup_Node( lru, key, &node );
if ( !error ) if ( !error )
@ -255,6 +282,9 @@
FT_EXPORT_FUNC( void ) FT_Lru_Remove_Node( FT_Lru lru, FT_EXPORT_FUNC( void ) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node ) FT_LruNode node )
{ {
if ( !lru || !node )
return;
if ( lru->num_elements > 0 ) if ( lru->num_elements > 0 )
{ {
FT_List_Remove( &lru->elements, (FT_ListNode)node ); FT_List_Remove( &lru->elements, (FT_ListNode)node );
@ -279,6 +309,9 @@
FT_Lru_Selector selector, FT_Lru_Selector selector,
FT_Pointer data ) FT_Pointer data )
{ {
if ( !lru || !selector )
return;
if ( lru->num_elements > 0 ) if ( lru->num_elements > 0 )
{ {
FT_ListNode node = lru->elements.head; FT_ListNode node = lru->elements.head;

4
src/cache/ftlru.h vendored
View File

@ -2,7 +2,7 @@
/* */ /* */
/* ftlru.h */ /* ftlru.h */
/* */ /* */
/* simple LRU list-cache */ /* Simple LRU list-cache (specification). */
/* */ /* */
/* Copyright 2000 by */ /* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -41,7 +41,6 @@
typedef struct FT_LruRec_* FT_Lru; typedef struct FT_LruRec_* FT_Lru;
typedef struct FT_Lru_Class_ typedef struct FT_Lru_Class_
{ {
FT_UInt lru_size; /* object size in bytes */ FT_UInt lru_size; /* object size in bytes */
@ -62,7 +61,6 @@
} FT_Lru_Class; } FT_Lru_Class;
typedef FT_Bool (*FT_Lru_Selector)( FT_Lru lru, typedef FT_Bool (*FT_Lru_Selector)( FT_Lru lru,
FT_LruNode node, FT_LruNode node,
FT_Pointer data ); FT_Pointer data );

4
src/cache/rules.mk vendored
View File

@ -3,7 +3,7 @@
# #
# Copyright 1996-2000 by # Copyright 2000 by
# David Turner, Robert Wilhelm, and Werner Lemberg. # David Turner, Robert Wilhelm, and Werner Lemberg.
# #
# This file is part of the FreeType project, and may only be used, modified, # This file is part of the FreeType project, and may only be used, modified,
@ -26,7 +26,7 @@ Cache_COMPILE := $(FT_COMPILE)
# Cache driver sources (i.e., C files) # Cache driver sources (i.e., C files)
# #
Cache_DRV_SRC := $(Cache_DIR_)ftlru.c \ Cache_DRV_SRC := $(Cache_DIR_)ftlru.c \
$(Cache_DIR_)ftcmanag.c \ $(Cache_DIR_)ftcmanag.c \
$(Cache_DIR_)ftcimage.c $(Cache_DIR_)ftcimage.c

View File

@ -33,6 +33,7 @@
#include <freetype/internal/ftstream.h> #include <freetype/internal/ftstream.h>
#include <freetype/ftoutln.h> #include <freetype/ftoutln.h>
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@ -43,7 +44,6 @@
#define FT_COMPONENT trace_cidgload #define FT_COMPONENT trace_cidgload
static static
FT_Error cid_load_glyph( T1_Decoder* decoder, FT_Error cid_load_glyph( T1_Decoder* decoder,
FT_UInt glyph_index ) FT_UInt glyph_index )
@ -60,8 +60,8 @@
/* read the CID font dict index and charstring offset from the CIDMap */ /* read the CID font dict index and charstring offset from the CIDMap */
if ( FILE_Seek( cid->data_offset + cid->cidmap_offset + if ( FILE_Seek( cid->data_offset + cid->cidmap_offset +
glyph_index * entry_len) || glyph_index * entry_len ) ||
ACCESS_Frame( 2 * entry_len ) ) ACCESS_Frame( 2 * entry_len ) )
goto Exit; goto Exit;
p = (FT_Byte*)stream->cursor; p = (FT_Byte*)stream->cursor;
@ -117,9 +117,6 @@
} }
#if 0 #if 0
@ -151,6 +148,7 @@
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux; PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
*max_advance = 0; *max_advance = 0;
/* Initialize load decoder */ /* Initialize load decoder */
@ -158,10 +156,10 @@
(FT_Face)face, (FT_Face)face,
0, /* size */ 0, /* size */
0, /* glyph slot */ 0, /* glyph slot */
0, /* glyph names !!!! XXXXX */ 0, /* glyph names! XXX */
0, /* blend == 0 */ 0, /* blend == 0 */
cid_load_glyph ); cid_load_glyph );
if (error) if ( error )
return error; return error;
decoder.builder.metrics_only = 1; decoder.builder.metrics_only = 1;
@ -202,7 +200,6 @@
/*************************************************************************/ /*************************************************************************/
LOCAL_FUNC LOCAL_FUNC
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph, FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,
CID_Size size, CID_Size size,
@ -218,6 +215,7 @@
FT_Matrix font_matrix; FT_Matrix font_matrix;
FT_Vector font_offset; FT_Vector font_offset;
if ( load_flags & FT_LOAD_NO_RECURSE ) if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@ -237,12 +235,13 @@
(FT_Face)face, (FT_Face)face,
(FT_Size)size, (FT_Size)size,
(FT_GlyphSlot)glyph, (FT_GlyphSlot)glyph,
0, /* glyph names -- XXXX */ 0, /* glyph names -- XXX */
0, /* blend == 0 */ 0, /* blend == 0 */
cid_load_glyph ); cid_load_glyph );
/* set up the decoder */ /* set up the decoder */
decoder.builder.no_recurse = (load_flags & FT_LOAD_NO_RECURSE) != 0; decoder.builder.no_recurse =
( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
error = cid_load_glyph( &decoder, glyph_index ); error = cid_load_glyph( &decoder, glyph_index );
@ -270,8 +269,8 @@
} }
else else
{ {
FT_BBox cbox; FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics; FT_Glyph_Metrics* metrics = &glyph->root.metrics;
/* copy the _unscaled_ advance width */ /* copy the _unscaled_ advance width */
@ -329,8 +328,8 @@
{ {
cbox.xMin &= -64; cbox.xMin &= -64;
cbox.yMin &= -64; cbox.yMin &= -64;
cbox.xMax = ( cbox.xMax+63 ) & -64; cbox.xMax = ( cbox.xMax + 63 ) & -64;
cbox.yMax = ( cbox.yMax+63 ) & -64; cbox.yMax = ( cbox.yMax + 63 ) & -64;
} }
metrics->width = cbox.xMax - cbox.xMin; metrics->width = cbox.xMax - cbox.xMin;

View File

@ -36,8 +36,6 @@
#endif #endif
#if 0 #if 0
/* Compute the maximum advance width of a font through quick parsing */ /* Compute the maximum advance width of a font through quick parsing */
@ -45,7 +43,7 @@
FT_Error CID_Compute_Max_Advance( CID_Face face, FT_Error CID_Compute_Max_Advance( CID_Face face,
FT_Int* max_advance ); FT_Int* max_advance );
#endif #endif /* 0 */
LOCAL_DEF LOCAL_DEF
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph, FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,

View File

@ -372,7 +372,9 @@
/* we found it - run the parsing callback */ /* we found it - run the parsing callback */
parser->root.cursor = cur2; parser->root.cursor = cur2;
CID_Skip_Spaces( parser ); CID_Skip_Spaces( parser );
parser->root.error = cid_load_keyword( face, loader, keyword ); parser->root.error = cid_load_keyword( face,
loader,
keyword );
if ( parser->root.error ) if ( parser->root.error )
return parser->root.error; return parser->root.error;

View File

@ -47,7 +47,6 @@
#define FT_COMPONENT trace_cidparse #define FT_COMPONENT trace_cidparse
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@ -70,6 +69,7 @@
FT_Byte buffer[256 + 10]; FT_Byte buffer[256 + 10];
FT_Int buff_len; FT_Int buff_len;
MEM_Set( parser, 0, sizeof ( *parser ) ); MEM_Set( parser, 0, sizeof ( *parser ) );
psaux->t1_parser_funcs->init( &parser->root, 0, 0, memory ); psaux->t1_parser_funcs->init( &parser->root, 0, 0, memory );
@ -98,6 +98,7 @@
{ {
FT_Byte *p, *limit = buffer + 256; FT_Byte *p, *limit = buffer + 256;
/* fill input buffer */ /* fill input buffer */
buff_len -= 256; buff_len -= 256;
if ( buff_len > 0 ) if ( buff_len > 0 )

View File

@ -28,7 +28,6 @@
#endif #endif
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Struct> */ /* <Struct> */
@ -87,20 +86,25 @@
/* */ /* */
/*************************************************************************/ /*************************************************************************/
#define CID_Skip_Spaces(p) (p)->root.funcs.skip_spaces( &(p)->root ) #define CID_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
#define CID_Skip_Alpha(p) (p)->root.funcs.skip_alpha ( &(p)->root ) #define CID_Skip_Alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
#define CID_ToInt(p) (p)->root.funcs.to_int( &(p)->root ) #define CID_ToInt( p ) (p)->root.funcs.to_int( &(p)->root )
#define CID_ToFixed(p,t) (p)->root.funcs.to_fixed( &(p)->root, t ) #define CID_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
#define CID_ToCoordArray(p,m,c) (p)->root.funcs.to_coord_array( &(p)->root, m, c ) #define CID_ToCoordArray( p, m, c ) \
#define CID_ToFixedArray(p,m,f,t) (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t ) (p)->root.funcs.to_coord_array( &(p)->root, m, c )
#define CID_ToToken(p,t) (p)->root.funcs.to_token( &(p)->root, t ) #define CID_ToFixedArray( p, m, f, t ) \
#define CID_ToTokenArray(p,t,m,c) (p)->root.funcs.to_token_array( &(p)->root, t, m, c ) (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
#define CID_ToToken( p, t ) \
#define CID_Load_Field(p,f,o) (p)->root.funcs.load_field( &(p)->root, f, o, 0, 0 ) (p)->root.funcs.to_token( &(p)->root, t )
#define CID_Load_Field_Table(p,f,o) (p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 ) #define CID_ToTokenArray( p, t, m, c ) \
(p)->root.funcs.to_token_array( &(p)->root, t, m, c )
#define CID_Load_Field( p, f, o ) \
(p)->root.funcs.load_field( &(p)->root, f, o, 0, 0 )
#define CID_Load_Field_Table( p, f, o ) \
(p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 )
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -21,17 +21,17 @@
#undef T1CODE #undef T1CODE
#define T1CODE t1_field_cid_info #define T1CODE t1_field_cid_info
T1_FIELD_STRING ( "CIDFontName", cid_font_name ) T1_FIELD_STRING( "CIDFontName", cid_font_name )
T1_FIELD_NUM ( "CIDFontVersion", cid_version ) T1_FIELD_NUM ( "CIDFontVersion", cid_version )
T1_FIELD_NUM ( "CIDFontType", cid_font_type ) T1_FIELD_NUM ( "CIDFontType", cid_font_type )
T1_FIELD_STRING ( "Registry", registry ) T1_FIELD_STRING( "Registry", registry )
T1_FIELD_STRING ( "Ordering", ordering ) T1_FIELD_STRING( "Ordering", ordering )
T1_FIELD_NUM ( "Supplement", supplement ) T1_FIELD_NUM ( "Supplement", supplement )
T1_FIELD_NUM ( "UIDBase", uid_base ) T1_FIELD_NUM ( "UIDBase", uid_base )
T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset ) T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset )
T1_FIELD_NUM ( "FDBytes", fd_bytes ) T1_FIELD_NUM ( "FDBytes", fd_bytes )
T1_FIELD_NUM ( "GDBytes", gd_bytes ) T1_FIELD_NUM ( "GDBytes", gd_bytes )
T1_FIELD_NUM ( "CIDCount", cid_count ) T1_FIELD_NUM ( "CIDCount", cid_count )
#undef FT_STRUCTURE #undef FT_STRUCTURE
@ -55,15 +55,15 @@
#undef T1CODE #undef T1CODE
#define T1CODE t1_field_font_dict #define T1CODE t1_field_font_dict
T1_FIELD_NUM ( "PaintType", paint_type ) T1_FIELD_NUM ( "PaintType", paint_type )
T1_FIELD_NUM ( "FontType", font_type ) T1_FIELD_NUM ( "FontType", font_type )
T1_FIELD_NUM ( "SubrMapOffset", subrmap_offset ) T1_FIELD_NUM ( "SubrMapOffset", subrmap_offset )
T1_FIELD_NUM ( "SDBytes", sd_bytes ) T1_FIELD_NUM ( "SDBytes", sd_bytes )
T1_FIELD_NUM ( "SubrCount", num_subrs ) T1_FIELD_NUM ( "SubrCount", num_subrs )
T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar ) T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar )
T1_FIELD_FIXED ( "ForceBoldThreshold", forcebold_threshold ) T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
T1_FIELD_FIXED ( "ExpansionFactor", expansion_factor ) T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
T1_FIELD_NUM ( "StrokeWidth", stroke_width ) T1_FIELD_NUM ( "StrokeWidth", stroke_width )
#undef FT_STRUCTURE #undef FT_STRUCTURE
@ -93,5 +93,4 @@
T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 ) T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
/* END */ /* END */

View File

@ -1,9 +1,28 @@
/***************************************************************************/
/* */
/* psauxmod.c */
/* */
/* FreeType auxiliary PostScript module implementation (body). */
/* */
/* Copyright 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. */
/* */
/***************************************************************************/
#include <psaux/psauxmod.h> #include <psaux/psauxmod.h>
#include <psaux/psobjs.h> #include <psaux/psobjs.h>
#include <psaux/t1decode.h> #include <psaux/t1decode.h>
LOCAL_FUNC LOCAL_FUNC
const PS_Table_Funcs ps_table_funcs = const PS_Table_Funcs ps_table_funcs =
{ {
PS_Table_New, PS_Table_New,
PS_Table_Done, PS_Table_Done,
@ -13,7 +32,7 @@
LOCAL_FUNC LOCAL_FUNC
const T1_Parser_Funcs t1_parser_funcs = const T1_Parser_Funcs t1_parser_funcs =
{ {
T1_Init_Parser, T1_Init_Parser,
T1_Done_Parser, T1_Done_Parser,
@ -54,7 +73,7 @@
LOCAL_FUNC LOCAL_FUNC
const PSAux_Interface psaux_interface = const PSAux_Interface psaux_interface =
{ {
&ps_table_funcs, &ps_table_funcs,
&t1_parser_funcs, &t1_parser_funcs,
@ -65,7 +84,7 @@
}; };
FT_CPLUSPLUS(const FT_Module_Class) psaux_module_class = FT_CPLUSPLUS( const FT_Module_Class ) psaux_module_class =
{ {
0, 0,
sizeof( FT_ModuleRec ), sizeof( FT_ModuleRec ),
@ -75,8 +94,10 @@
&psaux_interface, /* module-specific interface */ &psaux_interface, /* module-specific interface */
(FT_Module_Constructor) 0, (FT_Module_Constructor)0,
(FT_Module_Destructor) 0, (FT_Module_Destructor) 0,
(FT_Module_Requester) 0 (FT_Module_Requester) 0
}; };
/* END */

View File

@ -1,3 +1,21 @@
/***************************************************************************/
/* */
/* psauxmod.h */
/* */
/* FreeType auxiliary PostScript module implementation (specification). */
/* */
/* Copyright 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. */
/* */
/***************************************************************************/
#ifndef PSAUXMOD_H #ifndef PSAUXMOD_H
#define PSAUXMOD_H #define PSAUXMOD_H
@ -14,3 +32,6 @@
#endif #endif
#endif /* PSAUXMOD_H */ #endif /* PSAUXMOD_H */
/* END */

View File

@ -878,7 +878,7 @@
if ( pflags ) if ( pflags )
*pflags |= 1L << field->flag_bit; *pflags |= 1L << field->flag_bit;
#else #else
FT_UNUSED(pflags); FT_UNUSED( pflags );
#endif #endif
error = FT_Err_Ok; error = FT_Err_Ok;
@ -943,7 +943,7 @@
if ( pflags ) if ( pflags )
*pflags |= 1L << field->flag_bit; *pflags |= 1L << field->flag_bit;
#else #else
FT_UNUSED(pflags); FT_UNUSED( pflags );
#endif #endif
parser->cursor = old_cursor; parser->cursor = old_cursor;

View File

@ -185,12 +185,12 @@
/* seac weirdness */ /* seac weirdness */
adx += decoder->builder.left_bearing.x; adx += decoder->builder.left_bearing.x;
/* glyph_names is set to 0 for CID fonts which do not */ /* `glyph_names' is set to 0 for CID fonts which do not */
/* include an encoding.. How can we deal with these ?? */ /* include an encoding. How can we deal with these? */
if (decoder->glyph_names == 0) if ( decoder->glyph_names == 0 )
{ {
FT_ERROR(( "t1operator_seac:" )); FT_ERROR(( "t1operator_seac:" ));
FT_ERROR(( " glyph names table not available in this font !!\n" )); FT_ERROR(( " glyph names table not available in this font!\n" ));
return T1_Err_Syntax_Error; return T1_Err_Syntax_Error;
} }

View File

@ -67,8 +67,9 @@
FT_Error Z1_Parse_Glyph( T1_Decoder* decoder, FT_Error Z1_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph_index ) FT_UInt glyph_index )
{ {
T1_Face face = (T1_Face)decoder->builder.face; T1_Face face = (T1_Face)decoder->builder.face;
T1_Font* type1 = &face->type1; T1_Font* type1 = &face->type1;
decoder->font_matrix = type1->font_matrix; decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset; decoder->font_offset = type1->font_offset;
@ -101,7 +102,7 @@
(FT_Byte**)type1->glyph_names, (FT_Byte**)type1->glyph_names,
face->blend, face->blend,
Z1_Parse_Glyph ); Z1_Parse_Glyph );
if (error) if ( error )
return error; return error;
decoder.builder.metrics_only = 1; decoder.builder.metrics_only = 1;

View File

@ -69,4 +69,5 @@
T1_FIELD_NUM( "FontType", font_type ) T1_FIELD_NUM( "FontType", font_type )
T1_FIELD_NUM( "StrokeWidth", stroke_width ) T1_FIELD_NUM( "StrokeWidth", stroke_width )
/* END */ /* END */