ref: d1b7475be1da031a6f60c229cc0c96a37e6da37e
parent: 35db73220cc614150f56c2777ed611a0a2524665
author: Werner Lemberg <[email protected]>
date: Thu Aug 24 12:29:15 EDT 2000
Formatting, small fixes. Adding basic input parameter checking for exported functions.
--- a/builds/unix/devel/freetype/config/ftoption.h
+++ b/builds/unix/devel/freetype/config/ftoption.h
@@ -349,7 +349,7 @@
/* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
/* 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 */
/* minimum of 16 is required. */
/* */
-#define T1_MAX_CHARSTRINGS_OPERANDS 32
+#define T1_MAX_CHARSTRINGS_OPERANDS 64
/*************************************************************************/
--- a/builds/win32/devel/freetype/config/ftoption.h
+++ b/builds/win32/devel/freetype/config/ftoption.h
@@ -349,7 +349,7 @@
/* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
/* 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 */
/* minimum of 16 is required. */
/* */
-#define T1_MAX_CHARSTRINGS_OPERANDS 32
+#define T1_MAX_CHARSTRINGS_OPERANDS 64
/*************************************************************************/
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -2,7 +2,7 @@
/* */
/* ftcache.h */
/* */
-/* FreeType Cache subsystem */
+/* FreeType Cache subsystem. */
/* */
/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -15,6 +15,7 @@
/* */
/***************************************************************************/
+
#ifndef FTCACHE_H
#define FTCACHE_H
@@ -21,56 +22,56 @@
#include <freetype/ftglyph.h>
+#ifdef __cplusplus
+ extern "C" {
+#endif
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /***** *****/
- /***** BASIC TYPE DEFINITIONS *****/
- /***** *****/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** BASIC TYPE DEFINITIONS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
- /**************************************************************************
- *
- * <Type>
- * FTC_FaceID
- *
- * <Description>
- * a generic pointer type that is used to identity face objects.
- * the content of such objects is application-dependent
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FTC_FaceID */
+ /* */
+ /* <Description> */
+ /* A generic pointer type that is used to identity face objects. The */
+ /* contents of such objects is application-dependent. */
+ /* */
typedef FT_Pointer 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 :: handle to a FreeType library object
- * data :: application-provided request data
- *
- * <Output>
- * aface :: a new FT_Face handle
- *
- * <Return>
- * Error code. 0 means success
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <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. */
+ /* */
typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id,
FT_Library library,
FT_Pointer request_data,
@@ -77,22 +78,22 @@
FT_Face* aface );
- /**************************************************************************
- *
- * <Struct>
- * FTC_SizeRec
- *
- * <Description>
- * A simple structure used to describe a given "font size" to the
- * cache manager
- *
- * <Fields>
- * face_id :: id of face to use
- * pix_width :: character width in integer pixels
- * pix_height :: character height in integer pixels
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FTC_SizeRec */
+ /* */
+ /* <Description> */
+ /* A simple structure used to describe a given `font size' to the */
+ /* cache manager. */
+ /* */
+ /* <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_SizeRec_
{
FTC_FaceID face_id;
@@ -102,195 +103,183 @@
} FTC_SizeRec;
- /**************************************************************************
- *
- * <Type>
- * FTC_SizeID
- *
- * <Description>
- * A simple handle to a FTC_SizeRec structure
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FTC_SizeID */
+ /* */
+ /* <Description> */
+ /* A simple handle to a FTC_SizeRec structure. */
+ /* */
typedef FTC_SizeRec* FTC_SizeID;
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** CACHE MANAGER OBJECT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /***** *****/
- /***** CACHE MANAGER OBJECT *****/
- /***** *****/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
-
-
-
- /**************************************************************************
- *
- * <Type>
- * FTC_Manager
- *
- * <Description>
- * This object is used to cache one or more FT_Face object, along with
- * corresponding FT_Size objects.
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FTC_Manager */
+ /* */
+ /* <Description> */
+ /* This object is used to cache one or more FT_Face objects, along */
+ /* with corresponding FT_Size objects. */
+ /* */
typedef struct FTC_ManagerRec_* FTC_Manager;
- /**************************************************************************
- *
- * <Function>
- * FTC_Manager_New
- *
- * <Description>
- * Create a new cache manager.
- *
- * <Input>
- * library :: the parent FreeType library handle to use
- *
- * max_faces :: maximum number of faces to keep alive in manager
- * use 0 for defaults
- *
- * max_sizes :: maximum number of sizes to keep alive in manager
- * use 0 for defaults
- *
- * 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 :: handle to new manager object. 0 in case of failure
- *
- * <Return>
- * Error code. 0 means success
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Manager_New */
+ /* */
+ /* <Description> */
+ /* Creates a new cache manager. */
+ /* */
+ /* <Input> */
+ /* library :: The parent FreeType library handle to use. */
+ /* */
+ /* max_faces :: Maximum number of faces to keep alive in manager. */
+ /* Use 0 for defaults. */
+ /* */
+ /* max_sizes :: Maximum number of sizes to keep alive in manager. */
+ /* Use 0 for defaults. */
+ /* */
+ /* 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 */
+ /* failure. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_New( FT_Library library,
FT_UInt max_faces,
- FT_UInt max_sizes,
+ FT_UInt max_sizes,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager* amanager );
-
- /**************************************************************************
- *
- * <Function>
- * FTC_Manager_Reset
- *
- * <Description>
- * Empty a given cache manager. This simply gets rid of all the
- * currently cached FT_Face & FT_Size objects within the manager
- *
- * <Input>
- * manager :: handle to manager
- *
- **************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Manager_Reset */
+ /* */
+ /* <Description> */
+ /* Empties a given cache manager. This simply gets rid of all the */
+ /* currently cached FT_Face & FT_Size objects within the manager. */
+ /* */
+ /* <Input> */
+ /* 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> */
+ /* FTC_Manager_Done */
+ /* */
+ /* <Description> */
+ /* Destroys a given manager after emptying it. */
+ /* */
+ /* <Input> */
+ /* manager :: A handle to the target cache manager object. */
+ /* */
+ FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager );
- /**************************************************************************
- *
- * <Function>
- * FTC_Manager_Done
- *
- * <Description>
- * destroys a given manager after emptying it..
- *
- * <Input>
- * manager :: handle to target cache manager object
- *
- **************************************************************************/
-
- FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager );
-
- /**************************************************************************
- *
- * <Function>
- * FTC_Manager_Lookup_Face
- *
- * <Description>
- * retrieves the FT_Face that corresponds to a given face ID through
- * a cache manager.
- *
- * <Input>
- * manager :: handle to cache manager
- * face_id :: ID of face object
- *
- * <Output>
- * aface :: handle to face object
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * 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",
- * 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
- * after glyph loading..
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Manager_Lookup_Face */
+ /* */
+ /* <Description> */
+ /* Retrieves the FT_Face object that corresponds to a given face ID */
+ /* through a cache manager. */
+ /* */
+ /* <Input> */
+ /* manager :: A handle to the cache manager. */
+ /* */
+ /* face_id :: The ID of the face object. */
+ /* */
+ /* <Output> */
+ /* aface :: A handle to the face object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* 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', */
+ /* use FTC_Manager_Lookup_Size() instead. */
+ /* */
+ /* Never change the face's transformation matrix (i.e., never call */
+ /* 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,
FTC_FaceID face_id,
FT_Face* aface );
- /**************************************************************************
- *
- * <Function>
- * FTC_Manager_Lookup_Size
- *
- * <Description>
- * retrieves the FT_Face & FT_Size that correspond to a given
- * FTC_SizeID
- *
- * <Input>
- * manager :: handle to cache manager.
- * size_id :: ID of the "font size" to use
- *
- * <InOut>
- * aface :: ptr to handle to face object. Set to 0 if you don't need it
- * asize :: ptr to handle to size object. Set to 0 if you don't need it
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * The returned FT_Face object is always owned by the manager, you
- * should never try to discard it yourself..
- *
- * 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
- * after glyph loading..
- *
- * The returned FT_Size object is always owned by the manager, you
- * should never try to discard it, NEVER CHANGE ITS SETTINGS THROUGH
- * 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..
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Manager_Lookup_Size */
+ /* */
+ /* <Description> */
+ /* Retrieves the FT_Face & FT_Size objects that correspond to a given */
+ /* FTC_SizeID. */
+ /* */
+ /* <Input> */
+ /* manager :: A handle to the cache manager. */
+ /* */
+ /* size_id :: The ID of the `font size' to use. */
+ /* */
+ /* <InOut> */
+ /* aface :: A pointer to the handle of the face object. Set it to */
+ /* zero if you don't need it. */
+ /* */
+ /* asize :: A pointer to the handle of the size object. Set it to */
+ /* zero if you don't need it. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* The returned FT_Face object is always owned by the manager. You */
+ /* should never try to discard it yourself. */
+ /* */
+ /* Never change the face's transformation matrix (i.e., never call */
+ /* the FT_Set_Transform() function) on a returned face! If you need */
+ /* to transform glyphs, do it yourself after glyph loading. */
+ /* */
+ /* Similarly, the returned FT_Size object is always owned by the */
+ /* 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,
FTC_SizeID size_id,
FT_Face* aface,
@@ -297,37 +286,38 @@
FT_Size* asize );
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /***** *****/
- /***** IMAGE CACHE OBJECT *****/
- /***** *****/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** IMAGE CACHE OBJECT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
- /**************************************************************************
- *
- * <Enum>
- * FTC_Image_Type
- *
- * <Description>
- * An enumeration used to list the types of glyph images found in a
- * glyph image cache.
- *
- * <Fields>
- * ftc_image_mono :: monochrome bitmap glyphs
- * ftc_image_grays :: anti-aliased bitmap glyphs
- * ftc_image_outline :: scaled (and hinted) outline glyphs
- * ftc_master_outline :: unscaled original outline glyphs
- *
- * <Note>
- * other types may be defined in the future
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FTC_Image_Type */
+ /* */
+ /* <Description> */
+ /* An enumeration used to list the types of glyph images found in a */
+ /* glyph image cache. */
+ /* */
+ /* <Fields> */
+ /* ftc_image_mono :: Monochrome bitmap glyphs. */
+ /* */
+ /* ftc_image_grays :: Anti-aliased bitmap glyphs. */
+ /* */
+ /* ftc_image_outline :: Scaled (and hinted) outline glyphs. */
+ /* */
+ /* ftc_master_outline :: Unscaled original outline glyphs. */
+ /* */
+ /* <Note> */
+ /* Other types may be defined in the future. */
+ /* */
typedef enum FTC_Image_Type_
{
ftc_image_mono = 0, /* monochrome bitmap */
@@ -338,21 +328,21 @@
} FTC_Image_Type;
- /**************************************************************************
- *
- * <Struct>
- * FTC_Image_Desc
- *
- * <Description>
- * A simple structure used to describe a given glyph image category
- *
- * <Fields>
- * size :: a FTC_SizeRec used to describe the glyph's face & size
- * image_type :: the glyph image's type
- *
- **************************************************************************/
-
- typedef struct FTC_Image_Desc_
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FTC_Image_Desc */
+ /* */
+ /* <Description> */
+ /* A simple structure used to describe a given glyph image category. */
+ /* */
+ /* <Fields> */
+ /* size :: An FTC_SizeRec used to describe the glyph's face & */
+ /* size. */
+ /* */
+ /* image_type :: The glyph image's type. */
+ /* */
+ typedef struct FTC_Image_Desc_
{
FTC_SizeRec size;
FT_UInt image_type;
@@ -360,95 +350,89 @@
} FTC_Image_Desc;
-
- /**************************************************************************
- *
- * <Type>
- * FTC_Image_Cache
- *
- * <Description>
- * A handle to an glyph image cache object.. They are designed to
- * hold many distinct glyph images, while not exceeding a certain
- * memory threshold..
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Type> */
+ /* FTC_Image_Cache */
+ /* */
+ /* <Description> */
+ /* A handle to an glyph image cache object. They are designed to */
+ /* hold many distinct glyph images, while not exceeding a certain */
+ /* memory threshold. */
+ /* */
typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
-
- /**************************************************************************
- *
- * <Function>
- * FTC_Image_Cache_New
- *
- * <Description>
- * Create a new glyph image cache.
- *
- * <Input>
- * manager :: parent manager for the image cache
- *
- * max_bytes :: the maximum amount of memory that will be used to
- * store glyph images
- *
- * <Output>
- * acache :: handle to new glyph image cache object
- *
- * <Return>
- * Error code. 0 means success
- *
- **************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Image_Cache_New */
+ /* */
+ /* <Description> */
+ /* Creates a new glyph image cache. */
+ /* */
+ /* <Input> */
+ /* manager :: The parent manager for the image cache. */
+ /* */
+ /* max_bytes :: The maximum amount of memory that will be used to */
+ /* store glyph images. */
+ /* */
+ /* <Output> */
+ /* acache :: A handle to the new glyph image cache object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager,
FT_ULong max_bytes,
FTC_Image_Cache* acache );
- /**************************************************************************
- *
- * <Function>
- * FTC_Image_Cache_Done
- *
- * <Description>
- * Destroys a given glyph image cache (and all glyphs within it).
- *
- * <Input>
- * manager :: parent manager for the image cache
- *
- **************************************************************************/
-
- FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache );
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Image_Cache_Done */
+ /* */
+ /* <Description> */
+ /* Destroys a given glyph image cache (and all glyphs within it). */
+ /* */
+ /* <Input> */
+ /* manager :: The parent manager for the image cache. */
+ /* */
+ FT_EXPORT_DEF( void ) FTC_Image_Cache_Done( FTC_Image_Cache cache );
- /**************************************************************************
- *
- * <Function>
- * FTC_Image_Cache_Lookup
- *
- * <Description>
- * Retrieve a given glyph image from a glyph image cache.
- *
- * <Input>
- * cache :: handle to source glyph image cache
- * desc :: pointer to a glyph image descriptor
- * gindex :: index of glyph to retrieve
- *
- * <Output>
- * aglyph :: the corresponding FT_Glyph object. 0 in case of failure
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * the returned glyph is owned and manager by the glyph image cache,
- * 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.
- *
- * 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 ;-)
- *
- **************************************************************************/
-
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FTC_Image_Cache_Lookup */
+ /* */
+ /* <Description> */
+ /* Retrieves a given glyph image from a glyph image cache. */
+ /* */
+ /* <Input> */
+ /* cache :: A handle to the source glyph image cache. */
+ /* */
+ /* desc :: A pointer to a glyph image descriptor. */
+ /* */
+ /* gindex :: The glyph index to retrieve. */
+ /* */
+ /* <Output> */
+ /* aglyph :: The corresponding FT_Glyph object. 0 in case of */
+ /* failure. */
+ /* */
+ /* <Return> */
+ /* FreType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* the returned glyph is owned and manager by the glyph image cache. */
+ /* Never try to transform or discard it manually! You can however */
+ /* create a copy with FT_Glyph_Copy() and modify the new one. */
+ /* */
+ /* 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(
FTC_Image_Cache cache,
FTC_Image_Desc* desc,
@@ -456,4 +440,12 @@
FT_Glyph* aglyph );
+#ifdef __cplusplus
+ }
+#endif
+
+
#endif /* FTCACHE_H */
+
+
+/* END */
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -134,7 +134,7 @@
/*************************************************************************/
/*************************************************************************/
- typedef struct T1_Parser_ T1_Parser;
+ typedef struct T1_Parser_ T1_Parser;
/* simple enumeration type used to identify token types */
typedef enum T1_Token_Type_
@@ -189,33 +189,34 @@
} 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 */
typedef struct T1_Field_
{
- const char* ident; /* field identifier */
- T1_Field_Location location;
- T1_Field_Type type; /* type of field */
- T1_Field_Parser reader;
- FT_UInt offset; /* offset of field in object */
- FT_Byte size; /* size of field in bytes */
- FT_UInt array_max; /* maximal number of elements for */
- /* array */
- FT_UInt count_offset; /* offset of element count for */
- /* arrays */
+ const char* ident; /* field identifier */
+ T1_Field_Location location;
+ T1_Field_Type type; /* type of field */
+ T1_Field_Parser reader;
+ FT_UInt offset; /* offset of field in object */
+ FT_Byte size; /* size of field in bytes */
+ FT_UInt array_max; /* maximal number of elements for */
+ /* array */
+ FT_UInt count_offset; /* offset of element count for */
+ /* arrays */
} T1_Field;
#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
- { \
- _ident, T1CODE, _type, \
- 0, \
- FT_FIELD_OFFSET( _fname ), \
- FT_FIELD_SIZE( _fname ), \
- 0, 0 \
+ { \
+ _ident, T1CODE, _type, \
+ 0, \
+ FT_FIELD_OFFSET( _fname ), \
+ FT_FIELD_SIZE( _fname ), \
+ 0, 0 \
},
#define T1_NEW_CALLBACK_FIELD( _ident, _reader ) \
@@ -227,22 +228,22 @@
},
#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, \
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, \
- 0, \
- FT_FIELD_OFFSET( _fname ), \
- FT_FIELD_SIZE_DELTA( _fname ), \
- _max, 0 \
+ _max, 0 \
},
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1019,9 +1019,9 @@
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 )
{
/* get renderer */
--- a/src/cache/ftcache.c
+++ b/src/cache/ftcache.c
@@ -2,9 +2,9 @@
/* */
/* 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. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -2,7 +2,7 @@
/* */
/* ftcimage.c */
/* */
-/* FreeType Image Cache */
+/* FreeType Image Cache (body). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -21,29 +21,30 @@
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftlist.h>
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** IMAGE NODE MANAGEMENT *****/
- /***** *****/
- /***** For now, we simply ALLOC/FREE the FTC_ImageNode. However, *****/
- /***** it certainly is a good idea to use a chunk manager in the *****/
- /***** future in order to reduce memory waste/fragmentation *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /**************************************************************************/
+ /**************************************************************************/
+ /***** *****/
+ /***** IMAGE NODE MANAGEMENT *****/
+ /***** *****/
+ /***** For now, we simply ALLOC/FREE the FTC_ImageNode. However, it *****/
+ /***** certainly is a good idea to use a chunk manager in the future *****/
+ /***** in order to reduce memory waste resp. fragmentation. *****/
+ /***** *****/
+ /**************************************************************************/
+ /**************************************************************************/
static
- FT_Error FTC_ImageNode_New( FTC_Image_Cache cache,
- FTC_ImageNode *anode )
+ FT_Error FTC_ImageNode_New( FTC_Image_Cache cache,
+ FTC_ImageNode* anode )
{
FT_Error error;
FT_Memory memory = cache->memory;
FTC_ImageNode node;
+
*anode = 0;
- if (!ALLOC( node, sizeof(*node) ))
+ if ( !ALLOC( node, sizeof ( *node ) ) )
*anode = node;
return error;
@@ -51,24 +52,25 @@
static
- void FTC_ImageNode_Done( FTC_Image_Cache cache,
- FTC_ImageNode node )
+ void FTC_ImageNode_Done( FTC_Image_Cache cache,
+ FTC_ImageNode node )
{
- /* for now, we simply discard the node. We may later add a chunk */
- /* manager to the image cache.. */
+ /* for now, we simply discard the node; we may later add a chunk */
+ /* manager to the image cache. */
FT_Memory memory = cache->memory;
+
+
FREE( node );
}
-
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** GLYPH IMAGE QUEUES *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH IMAGE QUEUES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
static
@@ -324,19 +326,20 @@
static
- FT_Error FTC_Image_Queue_New( FTC_Image_Cache cache,
- FTC_Image_Desc* desc,
- FTC_Image_Queue *aqueue )
+ FT_Error FTC_Image_Queue_New( FTC_Image_Cache cache,
+ FTC_Image_Desc* desc,
+ FTC_Image_Queue* aqueue )
{
FT_Error error;
- FT_Memory memory = cache->memory;
+ FT_Memory memory = cache->memory;
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;
- if ( ALLOC( queue, sizeof(*queue) ) )
+ if ( ALLOC( queue, sizeof ( *queue ) ) )
goto Exit;
queue->cache = cache;
@@ -348,34 +351,35 @@
if ( ALLOC_ARRAY( queue->buckets, queue->hash_size, FT_ListRec ) )
goto Exit;
- switch (desc->image_type)
+ switch ( desc->image_type )
{
- case ftc_image_mono:
- clazz = &ftc_mono_image_class;
- break;
+ case ftc_image_mono:
+ clazz = &ftc_mono_image_class;
+ break;
- case ftc_image_grays:
- clazz = &ftc_gray_image_class;
- break;
+ case ftc_image_grays:
+ clazz = &ftc_gray_image_class;
+ break;
- case ftc_image_outline:
- clazz = &ftc_outline_image_class;
- break;
+ case ftc_image_outline:
+ clazz = &ftc_outline_image_class;
+ break;
- case ftc_image_master_outline:
- clazz = &ftc_master_outline_image_class;
- break;
+ case ftc_image_master_outline:
+ clazz = &ftc_master_outline_image_class;
+ break;
- default:
- /* invalid image type !! */
- error = FT_Err_Invalid_Argument;
- goto Exit;
+ default:
+ /* invalid image type! */
+ error = FT_Err_Invalid_Argument;
+ goto Exit;
}
queue->clazz = (FTC_Image_Class*)clazz;
*aqueue = queue;
+
Exit:
- if (error)
+ if ( error )
FREE( queue );
return error;
@@ -383,7 +387,7 @@
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;
FT_List glyphs_lru = &cache->glyphs_lru;
@@ -391,6 +395,7 @@
FT_List bucket_limit = bucket + queue->hash_size;
FT_Memory memory = cache->memory;
+
/* for each bucket, free the list of image nodes */
for ( ; bucket < bucket_limit; bucket++ )
{
@@ -399,11 +404,12 @@
FT_ListNode lrunode;
FTC_ImageNode inode;
+
for ( ; node; node = next )
{
next = node->next;
inode = (FTC_ImageNode)node;
- lrunode = FTC_IMAGENODE_TO_LISTNODE(inode);
+ lrunode = FTC_IMAGENODE_TO_LISTNODE( inode );
queue->clazz->done_image( queue, inode );
FT_List_Remove( glyphs_lru, lrunode );
@@ -413,6 +419,7 @@
bucket->head = bucket->tail = 0;
}
+
FREE( queue->buckets );
FREE( queue );
}
@@ -421,7 +428,7 @@
static
FT_Error FTC_Image_Queue_Lookup_Node( FTC_Image_Queue queue,
FT_UInt glyph_index,
- FTC_ImageNode *anode )
+ FTC_ImageNode* anode )
{
FTC_Image_Cache cache = queue->cache;
FT_UInt hash_index = glyph_index % queue->hash_size;
@@ -430,14 +437,15 @@
FT_Error error;
FTC_ImageNode inode;
+
*anode = 0;
for ( node = bucket->head; node; node = next )
{
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 );
*anode = inode;
return 0;
@@ -446,7 +454,7 @@
/* we didn't found the glyph image, we will now create a new one */
error = FTC_ImageNode_New( queue->cache, &inode );
- if (error)
+ if ( error )
goto Exit;
/* set the glyph and queue indices in the image node */
@@ -453,7 +461,7 @@
FTC_IMAGENODE_SET_INDICES( inode, glyph_index, queue->index );
error = queue->clazz->init_image( queue, inode );
- if (error)
+ if ( error )
{
FTC_ImageNode_Done( queue->cache, inode );
goto Exit;
@@ -463,7 +471,7 @@
FT_List_Insert( bucket, (FT_ListNode)inode );
/* 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);
@@ -473,31 +481,36 @@
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_LRUNODE_QUEUE(node) ((FTC_Image_Queue)(node)->root.data)
+#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_LRUNODE_QUEUE( node ) \
+ ( (FTC_Image_Queue)(node)->root.data )
+
+
static
- FT_Error ftc_image_cache_init_queue( FT_Lru lru,
- FT_LruNode node )
+ FT_Error ftc_image_cache_init_queue( FT_Lru lru,
+ FT_LruNode node )
{
- FTC_Image_Cache cache = FTC_QUEUE_LRU_GET_CACHE(lru);
- FTC_Image_Desc* desc = (FTC_Image_Desc*)node->key;
+ FTC_Image_Cache cache = FTC_QUEUE_LRU_GET_CACHE( lru );
+ FTC_Image_Desc* desc = (FTC_Image_Desc*)node->key;
FT_Error error;
FTC_Image_Queue queue;
+
error = FTC_Image_Queue_New( cache, desc, &queue );
- if (!error)
+ if ( !error )
{
/* good, now set the queue index within the queue object */
queue->index = node - lru->nodes;
@@ -509,34 +522,36 @@
static
- void ftc_image_cache_done_queue( FT_Lru lru,
- FT_LruNode node )
+ void ftc_image_cache_done_queue( FT_Lru lru,
+ FT_LruNode node )
{
- FTC_Image_Queue queue = FTC_LRUNODE_QUEUE(node);
+ FTC_Image_Queue queue = FTC_LRUNODE_QUEUE( node );
- FT_UNUSED(lru);
- FTC_Image_Queue_Done(queue);
+ FT_UNUSED( lru );
+
+
+ FTC_Image_Queue_Done( queue );
}
static
- FT_Bool ftc_image_cache_compare_queue( FT_LruNode node,
- FT_LruKey key )
+ FT_Bool ftc_image_cache_compare_queue( FT_LruNode node,
+ 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* desc1 = &queue->descriptor;
- return ( desc1->size.face_id == desc2->size.face_id &&
- desc1->size.pix_width == desc2->size.pix_width &&
- desc1->size.pix_height == desc2->size.pix_height &&
- desc1->image_type == desc2->image_type );
+
+ return ( desc1->size.face_id == desc2->size.face_id &&
+ desc1->size.pix_width == desc2->size.pix_width &&
+ desc1->size.pix_height == desc2->size.pix_height &&
+ desc1->image_type == desc2->image_type );
}
-
static
- const FT_Lru_Class ftc_image_queue_lru_class =
+ const FT_Lru_Class ftc_image_queue_lru_class =
{
sizeof( FT_LruRec ),
ftc_image_cache_init_queue,
@@ -546,17 +561,14 @@
};
-
-
-
- /* 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".. */
+ /* 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'. */
static
- void FTC_Image_Cache_Compress( FTC_Image_Cache cache,
- FTC_ImageNode new_node )
+ void FTC_Image_Cache_Compress( FTC_Image_Cache cache,
+ 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;
FTC_Image_Queue queue;
@@ -566,17 +578,19 @@
FT_ULong size;
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 */
- /* start of the list..) */
+
+ /* exit our loop if there isn't any glyph image left, or if */
+ /* 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 )
break;
- glyph_index = FTC_IMAGENODE_GET_GINDEX(inode);
- queue_index = FTC_IMAGENODE_GET_QINDEX(inode);
- queue = (FTC_Image_Queue)cache->queues_lru->nodes[queue_index].root.data;
+ glyph_index = FTC_IMAGENODE_GET_GINDEX( inode );
+ queue_index = FTC_IMAGENODE_GET_QINDEX( inode );
+ queue = (FTC_Image_Queue)cache->queues_lru->
+ nodes[queue_index].root.data;
hash_index = glyph_index % queue->hash_size;
size = queue->clazz->size_image( queue, inode );
@@ -599,10 +613,13 @@
FTC_Image_Cache cache;
+ if ( !acache || !manager || !manager->library )
+ return FT_Err_Invalid_Argument;
+
*acache = 0;
memory = manager->library->memory;
- if ( ALLOC( cache, sizeof(*cache) ) )
+ if ( ALLOC( cache, sizeof ( *cache ) ) )
goto Exit;
cache->manager = manager;
@@ -615,7 +632,7 @@
memory,
1, /* pre_alloc == TRUE */
&cache->queues_lru );
- if (error)
+ if ( error )
goto Exit;
*acache = cache;
@@ -628,11 +645,15 @@
}
-
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 */
FT_Lru_Done( cache->queues_lru );
@@ -642,7 +663,6 @@
}
-
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache,
FTC_Image_Desc* desc,
@@ -653,28 +673,34 @@
FTC_Image_Queue queue;
FTC_ImageNode inode;
+
+ /* check for valid `desc' delayed to FT_Lru_Lookup() */
+
+ if ( !cache || !aglyph )
+ return FT_Err_Invalid_Argument;
+
*aglyph = 0;
queue = cache->last_queue;
- if ( !queue ||
- queue->descriptor.size.face_id != desc->size.face_id ||
- queue->descriptor.size.pix_width != desc->size.pix_width ||
- queue->descriptor.size.pix_height != desc->size.pix_height ||
- queue->descriptor.image_type != desc->image_type )
+ if ( !queue ||
+ queue->descriptor.size.face_id != desc->size.face_id ||
+ queue->descriptor.size.pix_width != desc->size.pix_width ||
+ queue->descriptor.size.pix_height != desc->size.pix_height ||
+ queue->descriptor.image_type != desc->image_type )
{
- error = FT_Lru_Lookup( cache->queues_lru,
- (FT_LruKey)desc,
- (FT_Pointer*)&queue );
+ error = FT_Lru_Lookup( cache->queues_lru,
+ (FT_LruKey)desc,
+ (FT_Pointer*)&queue );
cache->last_queue = queue;
- if (error)
+ if ( error )
goto Exit;
}
error = FTC_Image_Queue_Lookup_Node( queue, gindex, &inode );
- if (error)
+ if ( error )
goto Exit;
FTC_Image_Cache_Compress( cache, inode );
- *aglyph = FTC_IMAGENODE_GET_GLYPH(inode);
+ *aglyph = FTC_IMAGENODE_GET_GLYPH( inode );
Exit:
return error;
--- a/src/cache/ftcimage.h
+++ b/src/cache/ftcimage.h
@@ -2,7 +2,7 @@
/* */
/* ftcimage.h */
/* */
-/* FreeType Image Cache */
+/* FreeType Image Cache (specification). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -42,7 +42,7 @@
typedef struct FTC_ImageNodeRec_
{
- /* root1.data contains a FT_Glyph handle */
+ /* root1.data contains an FT_Glyph handle */
FT_ListNodeRec root1;
/* root2.data contains a glyph index + queue index */
@@ -54,8 +54,12 @@
/* 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_QINDEX( n ) FTC_PTR_TO_QINDEX( (n)->root2.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_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_INDICES( n, g, q ) \
do \
{ \
@@ -64,26 +68,27 @@
/* this macro is used to extract a handle to the global LRU list node */
- /* corresponding to a given image node.. */
-#define FTC_IMAGENODE_TO_LISTNODE(n) \
- ((FT_ListNode)&(n)->root2)
+ /* corresponding to a given image node */
+#define FTC_IMAGENODE_TO_LISTNODE( n ) \
+ ( (FT_ListNode)&(n)->root2 )
/* 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.. */
-#define FTC_LISTNODE_TO_IMAGENODE(p) \
- ((FTC_ImageNode)((char*)(p) - offsetof(FTC_ImageNodeRec,root2)))
+#define FTC_LISTNODE_TO_IMAGENODE( p ) \
+ ( (FTC_ImageNode)( (char*)(p) - \
+ offsetof( FTC_ImageNodeRec,root2 ) ) )
typedef struct FTC_Image_CacheRec_
{
- FTC_Manager manager;
- FT_Memory memory;
+ FTC_Manager manager;
+ FT_Memory memory;
- FT_ULong max_bytes; /* maximum size of cache in bytes */
- FT_ULong num_bytes; /* current 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_Lru queues_lru; /* static queues lru list */
- FT_ListRec glyphs_lru; /* global lru list of glyph images */
+ FT_Lru queues_lru; /* static queues lru list */
+ FT_ListRec glyphs_lru; /* global lru list of glyph images */
FTC_Image_Queue last_queue; /* small cache */
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -1,8 +1,8 @@
/***************************************************************************/
/* */
-/* ftcmanag.h */
+/* ftcmanag.c */
/* */
-/* FreeType Cache Manager */
+/* FreeType Cache Manager (body). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -203,23 +203,28 @@
FT_EXPORT_FUNC( FT_Error ) FTC_Manager_New( FT_Library library,
FT_UInt max_faces,
- FT_UInt max_sizes,
+ FT_UInt max_sizes,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager* amanager )
{
FT_Error error;
- FT_Memory memory = library->memory;
+ FT_Memory memory;
FTC_Manager manager = 0;
+ if ( !library )
+ return FT_Err_Invalid_Library_Handle;
+
+ memory = library->memory;
+
if ( ALLOC( manager, sizeof ( *manager ) ) )
goto Exit;
- if (max_faces == 0)
+ if ( max_faces == 0 )
max_faces = FTC_MAX_FACES;
- if (max_sizes == 0)
+ if ( max_sizes == 0 )
max_sizes = FTC_MAX_SIZES;
error = FT_Lru_New( &ftc_face_lru_class,
@@ -259,9 +264,14 @@
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->faces_lru );
FREE( manager );
@@ -270,6 +280,9 @@
FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager )
{
+ if ( !manager )
+ return;
+
FT_Lru_Reset( manager->sizes_lru );
FT_Lru_Reset( manager->faces_lru );
}
@@ -279,6 +292,9 @@
FTC_FaceID face_id,
FT_Face* aface )
{
+ if ( !manager )
+ return FT_Err_Invalid_Argument;
+
return FT_Lru_Lookup( manager->faces_lru,
(FT_LruKey)face_id,
(FT_Pointer*)aface );
@@ -285,7 +301,6 @@
}
-
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_SizeID size_id,
FT_Face* aface,
@@ -296,17 +311,20 @@
FT_Face face;
- if (aface)
+ /* check for valid `manager' delayed to FTC_Manager_Lookup_Face() */
+
+ if ( aface )
*aface = 0;
- if (asize)
+ if ( asize )
*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 )
{
FT_Size size;
+
req.face = face;
req.width = size_id->pix_width;
req.height = size_id->pix_height;
@@ -319,10 +337,10 @@
/* select the size as the current one for this face */
face->size = size;
- if (asize)
+ if ( asize )
*asize = size;
- if (aface)
+ if ( aface )
*aface = face;
}
}
--- a/src/cache/ftcmanag.h
+++ b/src/cache/ftcmanag.h
@@ -2,7 +2,7 @@
/* */
/* ftcmanag.h */
/* */
-/* FreeType Cache Manager */
+/* FreeType Cache Manager (specification). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -2,7 +2,7 @@
/* */
/* ftlru.c */
/* */
-/* simple LRU list-cache */
+/* Simple LRU list-cache (body). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -47,6 +47,9 @@
FT_Lru lru;
+ if ( !alru )
+ return FT_Err_Invalid_Argument;
+
*alru = 0;
if ( !ALLOC( lru, sizeof ( *lru ) ) )
{
@@ -80,11 +83,18 @@
FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru )
{
- FT_ListNode node = lru->elements.head;
- FT_Lru_Class* clazz = lru->clazz;
- FT_Memory memory = lru->memory;
+ FT_ListNode node;
+ FT_Lru_Class* clazz;
+ FT_Memory memory;
+ if ( !lru )
+ return;
+
+ node = lru->elements.head;
+ clazz = lru->clazz;
+ memory = lru->memory;
+
while ( node )
{
FT_ListNode next = node->next;
@@ -108,9 +118,14 @@
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 );
FREE( lru );
}
@@ -120,13 +135,20 @@
FT_LruKey key,
FT_LruNode* anode )
{
- FT_Error error = 0;
- FT_ListNode node = lru->elements.head;
- FT_Lru_Class* clazz = lru->clazz;
- FT_LruNode found = 0;
- FT_Memory memory = lru->memory;
+ FT_Error error = 0;
+ FT_ListNode node;
+ FT_Lru_Class* clazz;
+ FT_LruNode found = 0;
+ 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 )
{
for ( ; node; node = node->next )
@@ -243,6 +265,11 @@
FT_LruNode node;
+ /* check for valid `lru' and `key' delayed to FT_Lru_Lookup_Node() */
+
+ if ( !aobject )
+ return FT_Err_Invalid_Argument;
+
*aobject = 0;
error = FT_Lru_Lookup_Node( lru, key, &node );
if ( !error )
@@ -255,6 +282,9 @@
FT_EXPORT_FUNC( void ) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node )
{
+ if ( !lru || !node )
+ return;
+
if ( lru->num_elements > 0 )
{
FT_List_Remove( &lru->elements, (FT_ListNode)node );
@@ -279,6 +309,9 @@
FT_Lru_Selector selector,
FT_Pointer data )
{
+ if ( !lru || !selector )
+ return;
+
if ( lru->num_elements > 0 )
{
FT_ListNode node = lru->elements.head;
--- a/src/cache/ftlru.h
+++ b/src/cache/ftlru.h
@@ -2,7 +2,7 @@
/* */
/* ftlru.h */
/* */
-/* simple LRU list-cache */
+/* Simple LRU list-cache (specification). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -41,7 +41,6 @@
typedef struct FT_LruRec_* FT_Lru;
-
typedef struct FT_Lru_Class_
{
FT_UInt lru_size; /* object size in bytes */
@@ -60,7 +59,6 @@
FT_LruKey key );
} FT_Lru_Class;
-
typedef FT_Bool (*FT_Lru_Selector)( FT_Lru lru,
--- a/src/cache/rules.mk
+++ b/src/cache/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000 by
+# Copyright 2000 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -26,7 +26,7 @@
# 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_)ftcimage.c
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -33,6 +33,7 @@
#include <freetype/internal/ftstream.h>
#include <freetype/ftoutln.h>
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -43,7 +44,6 @@
#define FT_COMPONENT trace_cidgload
-
static
FT_Error cid_load_glyph( T1_Decoder* decoder,
FT_UInt glyph_index )
@@ -60,8 +60,8 @@
/* read the CID font dict index and charstring offset from the CIDMap */
if ( FILE_Seek( cid->data_offset + cid->cidmap_offset +
- glyph_index * entry_len) ||
- ACCESS_Frame( 2 * entry_len ) )
+ glyph_index * entry_len ) ||
+ ACCESS_Frame( 2 * entry_len ) )
goto Exit;
p = (FT_Byte*)stream->cursor;
@@ -117,9 +117,6 @@
}
-
-
-
#if 0
@@ -151,6 +148,7 @@
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
+
*max_advance = 0;
/* Initialize load decoder */
@@ -158,10 +156,10 @@
(FT_Face)face,
0, /* size */
0, /* glyph slot */
- 0, /* glyph names !!!! XXXXX */
+ 0, /* glyph names! XXX */
0, /* blend == 0 */
cid_load_glyph );
- if (error)
+ if ( error )
return error;
decoder.builder.metrics_only = 1;
@@ -202,7 +200,6 @@
/*************************************************************************/
-
LOCAL_FUNC
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,
CID_Size size,
@@ -218,6 +215,7 @@
FT_Matrix font_matrix;
FT_Vector font_offset;
+
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@@ -237,12 +235,13 @@
(FT_Face)face,
(FT_Size)size,
(FT_GlyphSlot)glyph,
- 0, /* glyph names -- XXXX */
+ 0, /* glyph names -- XXX */
0, /* blend == 0 */
cid_load_glyph );
/* 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 );
@@ -270,8 +269,8 @@
}
else
{
- FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &glyph->root.metrics;
+ FT_BBox cbox;
+ FT_Glyph_Metrics* metrics = &glyph->root.metrics;
/* copy the _unscaled_ advance width */
@@ -329,8 +328,8 @@
{
cbox.xMin &= -64;
cbox.yMin &= -64;
- cbox.xMax = ( cbox.xMax+63 ) & -64;
- cbox.yMax = ( cbox.yMax+63 ) & -64;
+ cbox.xMax = ( cbox.xMax + 63 ) & -64;
+ cbox.yMax = ( cbox.yMax + 63 ) & -64;
}
metrics->width = cbox.xMax - cbox.xMin;
--- a/src/cid/cidgload.h
+++ b/src/cid/cidgload.h
@@ -36,8 +36,6 @@
#endif
-
-
#if 0
/* 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_Int* max_advance );
-#endif
+#endif /* 0 */
LOCAL_DEF
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -372,7 +372,9 @@
/* we found it - run the parsing callback */
parser->root.cursor = cur2;
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 )
return parser->root.error;
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -47,7 +47,6 @@
#define FT_COMPONENT trace_cidparse
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -70,6 +69,7 @@
FT_Byte buffer[256 + 10];
FT_Int buff_len;
+
MEM_Set( parser, 0, sizeof ( *parser ) );
psaux->t1_parser_funcs->init( &parser->root, 0, 0, memory );
@@ -97,6 +97,7 @@
for (;;)
{
FT_Byte *p, *limit = buffer + 256;
+
/* fill input buffer */
buff_len -= 256;
--- a/src/cid/cidparse.h
+++ b/src/cid/cidparse.h
@@ -28,7 +28,6 @@
#endif
-
/*************************************************************************/
/* */
/* <Struct> */
@@ -87,20 +86,25 @@
/* */
/*************************************************************************/
-#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_Spaces( p ) (p)->root.funcs.skip_spaces( &(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_ToFixed(p,t) (p)->root.funcs.to_fixed( &(p)->root, t )
+#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_ToCoordArray(p,m,c) (p)->root.funcs.to_coord_array( &(p)->root, m, c )
-#define CID_ToFixedArray(p,m,f,t) (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
-#define CID_ToToken(p,t) (p)->root.funcs.to_token( &(p)->root, t )
-#define CID_ToTokenArray(p,t,m,c) (p)->root.funcs.to_token_array( &(p)->root, t, m, c )
+#define CID_ToCoordArray( p, m, c ) \
+ (p)->root.funcs.to_coord_array( &(p)->root, m, c )
+#define CID_ToFixedArray( p, m, f, t ) \
+ (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
+#define CID_ToToken( p, t ) \
+ (p)->root.funcs.to_token( &(p)->root, t )
+#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 )
-
+#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
--- a/src/cid/cidtokens.h
+++ b/src/cid/cidtokens.h
@@ -21,17 +21,17 @@
#undef T1CODE
#define T1CODE t1_field_cid_info
- T1_FIELD_STRING ( "CIDFontName", cid_font_name )
- T1_FIELD_NUM ( "CIDFontVersion", cid_version )
- T1_FIELD_NUM ( "CIDFontType", cid_font_type )
- T1_FIELD_STRING ( "Registry", registry )
- T1_FIELD_STRING ( "Ordering", ordering )
- T1_FIELD_NUM ( "Supplement", supplement )
- T1_FIELD_NUM ( "UIDBase", uid_base )
- T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset )
- T1_FIELD_NUM ( "FDBytes", fd_bytes )
- T1_FIELD_NUM ( "GDBytes", gd_bytes )
- T1_FIELD_NUM ( "CIDCount", cid_count )
+ T1_FIELD_STRING( "CIDFontName", cid_font_name )
+ T1_FIELD_NUM ( "CIDFontVersion", cid_version )
+ T1_FIELD_NUM ( "CIDFontType", cid_font_type )
+ T1_FIELD_STRING( "Registry", registry )
+ T1_FIELD_STRING( "Ordering", ordering )
+ T1_FIELD_NUM ( "Supplement", supplement )
+ T1_FIELD_NUM ( "UIDBase", uid_base )
+ T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset )
+ T1_FIELD_NUM ( "FDBytes", fd_bytes )
+ T1_FIELD_NUM ( "GDBytes", gd_bytes )
+ T1_FIELD_NUM ( "CIDCount", cid_count )
#undef FT_STRUCTURE
@@ -55,15 +55,15 @@
#undef T1CODE
#define T1CODE t1_field_font_dict
- T1_FIELD_NUM ( "PaintType", paint_type )
- T1_FIELD_NUM ( "FontType", font_type )
- T1_FIELD_NUM ( "SubrMapOffset", subrmap_offset )
- T1_FIELD_NUM ( "SDBytes", sd_bytes )
- T1_FIELD_NUM ( "SubrCount", num_subrs )
- T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar )
- T1_FIELD_FIXED ( "ForceBoldThreshold", forcebold_threshold )
- T1_FIELD_FIXED ( "ExpansionFactor", expansion_factor )
- T1_FIELD_NUM ( "StrokeWidth", stroke_width )
+ T1_FIELD_NUM ( "PaintType", paint_type )
+ T1_FIELD_NUM ( "FontType", font_type )
+ T1_FIELD_NUM ( "SubrMapOffset", subrmap_offset )
+ T1_FIELD_NUM ( "SDBytes", sd_bytes )
+ T1_FIELD_NUM ( "SubrCount", num_subrs )
+ T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar )
+ T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
+ T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
+ T1_FIELD_NUM ( "StrokeWidth", stroke_width )
#undef FT_STRUCTURE
@@ -91,7 +91,6 @@
T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
-
/* END */
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -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/psobjs.h>
#include <psaux/t1decode.h>
+
LOCAL_FUNC
- const PS_Table_Funcs ps_table_funcs =
+ const PS_Table_Funcs ps_table_funcs =
{
PS_Table_New,
PS_Table_Done,
@@ -13,7 +32,7 @@
LOCAL_FUNC
- const T1_Parser_Funcs t1_parser_funcs =
+ const T1_Parser_Funcs t1_parser_funcs =
{
T1_Init_Parser,
T1_Done_Parser,
@@ -54,7 +73,7 @@
LOCAL_FUNC
- const PSAux_Interface psaux_interface =
+ const PSAux_Interface psaux_interface =
{
&ps_table_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,
sizeof( FT_ModuleRec ),
@@ -75,8 +94,10 @@
&psaux_interface, /* module-specific interface */
- (FT_Module_Constructor) 0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) 0
+ (FT_Module_Constructor)0,
+ (FT_Module_Destructor) 0,
+ (FT_Module_Requester) 0
};
+
+/* END */
--- a/src/psaux/psauxmod.h
+++ b/src/psaux/psauxmod.h
@@ -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
#define PSAUXMOD_H
@@ -14,3 +32,6 @@
#endif
#endif /* PSAUXMOD_H */
+
+
+/* END */
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -878,7 +878,7 @@
if ( pflags )
*pflags |= 1L << field->flag_bit;
#else
- FT_UNUSED(pflags);
+ FT_UNUSED( pflags );
#endif
error = FT_Err_Ok;
@@ -943,7 +943,7 @@
if ( pflags )
*pflags |= 1L << field->flag_bit;
#else
- FT_UNUSED(pflags);
+ FT_UNUSED( pflags );
#endif
parser->cursor = old_cursor;
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -185,12 +185,12 @@
/* seac weirdness */
adx += decoder->builder.left_bearing.x;
- /* glyph_names is set to 0 for CID fonts which do not */
- /* include an encoding.. How can we deal with these ?? */
- if (decoder->glyph_names == 0)
+ /* `glyph_names' is set to 0 for CID fonts which do not */
+ /* include an encoding. How can we deal with these? */
+ if ( decoder->glyph_names == 0 )
{
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;
}
--- a/src/type1z/z1gload.c
+++ b/src/type1z/z1gload.c
@@ -67,9 +67,10 @@
FT_Error Z1_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph_index )
{
- T1_Face face = (T1_Face)decoder->builder.face;
- T1_Font* type1 = &face->type1;
+ T1_Face face = (T1_Face)decoder->builder.face;
+ T1_Font* type1 = &face->type1;
+
decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset;
@@ -101,7 +102,7 @@
(FT_Byte**)type1->glyph_names,
face->blend,
Z1_Parse_Glyph );
- if (error)
+ if ( error )
return error;
decoder.builder.metrics_only = 1;
--- a/src/type1z/z1tokens.h
+++ b/src/type1z/z1tokens.h
@@ -69,4 +69,5 @@
T1_FIELD_NUM( "FontType", font_type )
T1_FIELD_NUM( "StrokeWidth", stroke_width )
+
/* END */