ref: 21e046e0c40e25bccf995314bae3dfd7b1e4ba02
parent: 0f58446b3ea11c1796079f0e501e96d5db336ed3
author: Werner Lemberg <[email protected]>
date: Thu Dec 20 12:49:10 EST 2001
Formatting. * src/cache/ftccache.c (ftc_node_destroy, ftc_cache_lookup): Fix tracing strings. * src/cache/ftccmap.c (ftc_cmap_family_init): Ditto. * src/cache/ftcmanag.c (ftc_family_table_alloc, ftc_family_table_free, FTC_Manager_Check): Ditto. * src/cache/ftcsbits.c (ftc_sbit_node_load): Ditto.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,36 +1,44 @@
-2001-12-20 David Turner <[email protected]>
+2001-12-20 Werner Lemberg <[email protected]>
- * include/freetype/config/ftoption.h: disabling bytecode interpreter
- for new release
+ * src/cache/ftccache.c (ftc_node_destroy, ftc_cache_lookup): Fix
+ tracing strings.
+ * src/cache/ftccmap.c (ftc_cmap_family_init): Ditto.
+ * src/cache/ftcmanag.c (ftc_family_table_alloc,
+ ftc_family_table_free, FTC_Manager_Check): Ditto.
+ * src/cache/ftcsbits.c (ftc_sbit_node_load): Ditto.
- * docs/CHANGES: updated for 2.0.6 release
+2001-12-20 David Turner <[email protected]>
- * src/cff/cffload.h, src/cff/cffload.c, src/cff/cffgload.c: updated
- to mode the definition of encoding tables within "cffload.c" instead
- of making them part of a shared header (causing problems in "multi"
- builds)
+ * include/freetype/config/ftoption.h: Disabling bytecode interpreter
+ for new release.
- * docs/TODO: added "stem3 and counter hints support" to the TODO list
- for the Postscript hinter
+ * docs/CHANGES: Updated for 2.0.6 release.
- * docs/BUGS: closed the AUTOHINT-NO-SBITS bug.
+ * src/cff/cffload.h, src/cff/cffload.c, src/cff/cffgload.c: Updated
+ to mode the definition of encoding tables within "cffload.c" instead
+ of making them part of a shared header (causing problems in "multi"
+ builds).
- * src/pshinter/pshrec.c (t2_hint_stems), src/cff/cffobjs.h,
- src/cff/cffobjs.c, src/cff/cffload.c, src/cff/cffload.h,
- src/cff/cffgload.c, src/cff/cffgload.h, src/cff/cffdriver.c,
- include/freetype/internal/cfftypes.h: added Postscript hinter support
- to the CFF driver
+ * docs/TODO: Added "stem3 and counter hints support" to the TODO list
+ for the Postscript hinter.
- * src/base/ftobjs.c (FT_Done_Library): fixed a stupid bug that crashed
- the library on exit
+ * docs/BUGS: Closed the AUTOHINT-NO-SBITS bug.
- * src/type1/t1gload.c (T1_Load_Glyph): enable font matrix transform
- on hinted glyphs..
+ * src/pshinter/pshrec.c (t2_hint_stems), src/cff/cffobjs.h,
+ src/cff/cffobjs.c, src/cff/cffload.c, src/cff/cffload.h,
+ src/cff/cffgload.c, src/cff/cffgload.h, src/cff/cffdriver.c,
+ include/freetype/internal/cfftypes.h: added Postscript hinter support
+ to the CFF driver.
- * src/cid/cidgload.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
- src/cid/cidriver.c, include/freetype/internal/t1types.h: added
- Postscript hinter support to the CID font driver !!
+ * src/base/ftobjs.c (FT_Done_Library): Fixed a stupid bug that crashed
+ the library on exit.
+ * src/type1/t1gload.c (T1_Load_Glyph): Enable font matrix transform
+ on hinted glyphs.
+
+ * src/cid/cidgload.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
+ src/cid/cidriver.c, include/freetype/internal/t1types.h: Added
+ Postscript hinter support to the CID font driver.
2001-12-19 David Turner <[email protected]>
--- a/include/freetype/cache/ftccache.h
+++ b/include/freetype/cache/ftccache.h
@@ -1,24 +1,40 @@
-#ifndef __FT_CACHE_CACHE_H__
-#define __FT_CACHE_CACHE_H__
+/***************************************************************************/
+/* */
+/* ftccache.h */
+/* */
+/* FreeType internal cache interface (specification). */
+/* */
+/* Copyright 2000-2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+#ifndef __FTCCACHE_H__
+#define __FTCCACHE_H__
+
+
FT_BEGIN_HEADER
/* handle to cache object */
typedef struct FTC_CacheRec_* FTC_Cache;
-
/* handle to cache class */
typedef const struct FTC_Cache_ClassRec_* FTC_Cache_Class;
+ /* handle to cache node family */
+ typedef struct FTC_FamilyRec_* FTC_Family;
- /* handle to cache node family */
- typedef struct FTC_FamilyRec_* FTC_Family;
-
-
- /* handle to cache root query */
+ /* handle to cache root query */
typedef struct FTC_QueryRec_* FTC_Query;
-
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -37,23 +53,25 @@
/* the cache. It can be an individual glyph image, a set of bitmaps */
/* glyphs for a given size, some metrics, etc. */
/* */
+ /*************************************************************************/
-
- /* structure size should be 20 bytes on 32-bits machines */
+ /* structure size should be 20 bytes on 32-bits machines */
typedef struct FTC_NodeRec_
{
FTC_Node mru_next; /* circular mru list pointer */
FTC_Node mru_prev; /* circular mru list pointer */
- FTC_Node link; /* used for hashing.. */
- FT_UInt32 hash; /* used for hashing too.. */
+ FTC_Node link; /* used for hashing */
+ FT_UInt32 hash; /* used for hashing too */
FT_UShort fam_index; /* index of family the node belongs to */
- FT_Short ref_count; /* reference count for this node.. */
-
+ FT_Short ref_count; /* reference count for this node */
+
} FTC_NodeRec;
-#define FTC_NODE(x) ((FTC_Node)(x))
-#define FTC_NODE_P(x) ((FTC_Node*)(x))
+#define FTC_NODE( x ) ( (FTC_Node)(x) )
+#define FTC_NODE_P( x ) ( (FTC_Node*)(x) )
+
+
/*************************************************************************/
/* */
/* These functions are exported so that they can be called from */
@@ -66,7 +84,6 @@
ftc_node_done( FTC_Node node,
FTC_Cache cache );
-
/* reserved for manager's use */
FT_EXPORT( void )
ftc_node_destroy( FTC_Node node,
@@ -81,11 +98,11 @@
/*************************************************************************/
/*************************************************************************/
- /* structure modelling a cache node query. the following fields must */
- /* all be set by the @FTC_Family_CompareFunc method of a cache's family */
- /* list */
- /* */
- typedef struct FTC_QueryRec_
+ /* A structure modelling a cache node query. The following fields must */
+ /* all be set by the @FTC_Family_CompareFunc method of a cache's family */
+ /* list. */
+ /* */
+ typedef struct FTC_QueryRec_
{
FTC_Family family;
FT_UFast hash;
@@ -93,12 +110,10 @@
} FTC_QueryRec;
-#define FTC_QUERY(x) ((FTC_Query)(x))
-#define FTC_QUERY_P(x) ((FTC_Query*)(x))
+#define FTC_QUERY( x ) ( (FTC_Query)(x) )
+#define FTC_QUERY_P( x ) ( (FTC_Query*)(x) )
-
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -107,19 +122,20 @@
/*************************************************************************/
/*************************************************************************/
- typedef struct FTC_FamilyRec_
+ typedef struct FTC_FamilyRec_
{
FT_LruNodeRec lru;
FTC_Cache cache;
FT_UInt num_nodes;
FT_UInt fam_index;
-
+
} FTC_FamilyRec;
-#define FTC_FAMILY(x) ((FTC_Family)(x))
-#define FTC_FAMILY_P(x) ((FTC_Family*)(x))
+#define FTC_FAMILY( x ) ( (FTC_Family)(x) )
+#define FTC_FAMILY_P( x ) ( (FTC_Family*)(x) )
+
/*************************************************************************/
/* */
/* These functions are exported so that they can be called from */
@@ -127,16 +143,16 @@
/* cache sub-system internals. */
/* */
- /* must be called by any FTC_Node_InitFunc routine */
- FT_EXPORT(FT_Error)
+ /* must be called by any FTC_Node_InitFunc routine */
+ FT_EXPORT( FT_Error )
ftc_family_init( FTC_Family family,
FTC_Query query,
FTC_Cache cache );
- /* can be used as a FTC_Family_DoneFunc, otherwise, must be called */
- /* by any family finalizer function.. */
- FT_EXPORT(void)
+ /* can be used as a FTC_Family_DoneFunc; otherwise, must be called */
+ /* by any family finalizer function */
+ FT_EXPORT( void )
ftc_family_done( FTC_Family family );
@@ -148,7 +164,7 @@
/*************************************************************************/
/*************************************************************************/
- /* each cache really implements a dynamic hash table to manage its nodes */
+ /* each cache really implements a dynamic hash table to manage its nodes */
typedef struct FTC_CacheRec_
{
FTC_Manager manager;
@@ -168,47 +184,57 @@
} FTC_CacheRec;
-#define FTC_CACHE(x) ((FTC_Cache)(x))
-#define FTC_CACHE_P(x) ((FTC_Cache*)(x))
+#define FTC_CACHE( x ) ( (FTC_Cache)(x) )
+#define FTC_CACHE_P( x ) ( (FTC_Cache*)(x) )
/* initialize a given cache */
- typedef FT_Error (*FTC_Cache_InitFunc)( FTC_Cache cache );
+ typedef FT_Error
+ (*FTC_Cache_InitFunc)( FTC_Cache cache );
/* clear a cache */
- typedef void (*FTC_Cache_ClearFunc)( FTC_Cache cache );
-
- /* finalize a given cache */
- typedef void (*FTC_Cache_DoneFunc)( FTC_Cache cache );
+ typedef void
+ (*FTC_Cache_ClearFunc)( FTC_Cache cache );
+ /* finalize a given cache */
+ typedef void
+ (*FTC_Cache_DoneFunc)( FTC_Cache cache );
- typedef FT_Error (*FTC_Family_InitFunc)( FTC_Family family,
- FTC_Query query,
- FTC_Cache cache );
- typedef FT_Int (*FTC_Family_CompareFunc)( FTC_Family family,
- FTC_Query query );
+ typedef FT_Error
+ (*FTC_Family_InitFunc)( FTC_Family family,
+ FTC_Query query,
+ FTC_Cache cache );
- typedef void (*FTC_Family_DoneFunc)( FTC_Family family,
- FTC_Cache cache );
-
- /* initialize a new cache node */
- typedef FT_Error (*FTC_Node_InitFunc)( FTC_Node node,
- FT_Pointer type,
- FTC_Cache cache );
+ typedef FT_Int
+ (*FTC_Family_CompareFunc)( FTC_Family family,
+ FTC_Query query );
+
+ typedef void
+ (*FTC_Family_DoneFunc)( FTC_Family family,
+ FTC_Cache cache );
+ /* initialize a new cache node */
+ typedef FT_Error
+ (*FTC_Node_InitFunc)( FTC_Node node,
+ FT_Pointer type,
+ FTC_Cache cache );
+
/* compute the weight of a given cache node */
- typedef FT_ULong (*FTC_Node_WeightFunc)( FTC_Node node,
- FTC_Cache cache );
+ typedef FT_ULong
+ (*FTC_Node_WeightFunc)( FTC_Node node,
+ FTC_Cache cache );
/* compare a node to a given key pair */
- typedef FT_Bool (*FTC_Node_CompareFunc)( FTC_Node node,
- FT_Pointer key,
- FTC_Cache cache );
+ typedef FT_Bool
+ (*FTC_Node_CompareFunc)( FTC_Node node,
+ FT_Pointer key,
+ FTC_Cache cache );
/* finalize a given cache node */
- typedef void (*FTC_Node_DoneFunc)( FTC_Node node,
- FTC_Cache cache );
+ typedef void
+ (*FTC_Node_DoneFunc)( FTC_Node node,
+ FTC_Cache cache );
typedef struct FTC_Cache_ClassRec_
@@ -222,17 +248,19 @@
FTC_Family_InitFunc family_init;
FTC_Family_CompareFunc family_compare;
FTC_Family_DoneFunc family_done;
-
+
FT_UInt node_size;
FTC_Node_InitFunc node_init;
FTC_Node_WeightFunc node_weight;
FTC_Node_CompareFunc node_compare;
FTC_Node_DoneFunc node_done;
-
+
} FTC_Cache_ClassRec;
+
/* */
+
/*************************************************************************/
/* */
/* These functions are exported so that they can be called from */
@@ -245,28 +273,28 @@
FT_EXPORT( void )
ftc_cache_done( FTC_Cache cache );
-
/* can be used directly as FTC_Cache_ClearFunc(), or called by custom */
- /* cache clear routines.. */
+ /* cache clear routines */
FT_EXPORT( void )
ftc_cache_clear( FTC_Cache cache );
-
/* initalize the hash table within the cache */
FT_EXPORT( FT_Error )
ftc_cache_init( FTC_Cache cache );
+ /* can be called when the key's hash value has been computed */
+ FT_EXPORT( FT_Error )
+ ftc_cache_lookup( FTC_Cache cache,
+ FTC_Query query,
+ FTC_Node *anode );
- /* can be called when the key's hash value has been computed */
- FT_EXPORT(FT_Error)
- ftc_cache_lookup( FTC_Cache cache,
- FTC_Query query,
- FTC_Node *anode );
+ /* */
+FT_END_HEADER
- /* */
-FT_END_HEADER
+#endif /* __FTCCACHE_H__ */
-#endif /* __FT_CACHE_CACHE_H__ */
+
+/* END */
--- a/include/freetype/cache/ftccmap.h
+++ b/include/freetype/cache/ftccmap.h
@@ -2,7 +2,7 @@
/* */
/* ftccmap.h */
/* */
-/* FreeType charmap cache */
+/* FreeType charmap cache (specification). */
/* */
/* Copyright 2000-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -15,111 +15,119 @@
/* */
/***************************************************************************/
-#ifndef __FT_CACHE_CHARMAP_H__
-#define __FT_CACHE_CHARMAP_H__
+#ifndef __FTCCMAP_H__
+#define __FTCCMAP_H__
+
#include <ft2build.h>
#include FT_CACHE_H
+
FT_BEGIN_HEADER
- /************************************************************************
- *
- * @type: FTC_CmapCache
- *
- * @description:
- * opaque handle used to manager a charmap cache. This cache is used
- * to hold character codes -> glyph indices mappings
- */
- typedef struct FTC_CMapCacheRec_* FTC_CMapCache;
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* FTC_CmapCache */
+ /* */
+ /* @description: */
+ /* An opaque handle used to manager a charmap cache. This cache is */
+ /* to hold character codes -> glyph indices mappings. */
+ /* */
+ typedef struct FTC_CMapCacheRec_* FTC_CMapCache;
- /************************************************************************
- *
- * @type: FTC_CMapDesc
- *
- * @description:
- * handle to a @FTC_CMapDescRec structure used to describe a given charmap
- * in a charmap cache.
- *
- * each @FTC_CMapDesc describes which charmap, of which @FTC_Face we
- * want to use in @FTC_CMapCache_Lookup
- */
- typedef struct FTC_CMapDescRec_* FTC_CMapDesc;
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* FTC_CMapDesc */
+ /* */
+ /* @description: */
+ /* A handle to an @FTC_CMapDescRec structure used to describe a given */
+ /* charmap in a charmap cache. */
+ /* */
+ /* Each @FTC_CMapDesc describes which charmap (of which @FTC_Face) we */
+ /* want to use in @FTC_CMapCache_Lookup. */
+ /* */
+ typedef struct FTC_CMapDescRec_* FTC_CMapDesc;
- /************************************************************************
- *
- * @enum: FTC_CMapType
- *
- * @description:
- * the list of valid @FTC_CMap types, they indicate how we want to
- * address a charmap within a @FTC_FaceID
- *
- * @values:
- * FTC_CMAP_BY_INDEX ::
- * used to indicate that we want to address a charmap by its index in
- * the corresponding @FT_Face
- *
- * FTC_CMAP_BY_ENCODING ::
- * used to indicate that we want to use a @FT_Face charmap that
- * corresponds to a given encoding
- *
- * FTC_CMAP_BY_ID ::
- * used to indicate that we want to use a @FT_Face charmap that
- * corresponds to a given (platform,encoding) id. see @FTC_CMapIdRec
- */
- typedef enum
+
+ /*************************************************************************/
+ /* */
+ /* @enum: */
+ /* FTC_CMapType */
+ /* */
+ /* @description: */
+ /* The list of valid @FTC_CMap types. They indicate how we want to */
+ /* address a charmap within an @FTC_FaceID. */
+ /* */
+ /* @values: */
+ /* FTC_CMAP_BY_INDEX :: */
+ /* Address a charmap by its index in the corresponding @FT_Face. */
+ /* */
+ /* FTC_CMAP_BY_ENCODING :: */
+ /* Use a @FT_Face charmap that corresponds to a given encoding. */
+ /* */
+ /* FTC_CMAP_BY_ID :: */
+ /* Use an @FT_Face charmap that corresponds to a given */
+ /* (platform,encoding) ID. See @FTC_CMapIdRec. */
+ /* */
+ typedef enum FTC_CMapType_
{
FTC_CMAP_BY_INDEX = 0,
FTC_CMAP_BY_ENCODING = 1,
FTC_CMAP_BY_ID = 2
-
+
} FTC_CMapType;
- /************************************************************************
- *
- * @struct: FTC_CMapIdRec
- *
- * @description:
- * a short structure used to identify a charmap by a (platform,encoding)
- * pair of values
- *
- * @fields:
- * platform :: platform ID
- * encoding :: encoding ID
- */
- typedef struct FTC_CMapIdRec_
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* FTC_CMapIdRec */
+ /* */
+ /* @description: */
+ /* A short structure to identify a charmap by a (platform,encoding) */
+ /* pair of values. */
+ /* */
+ /* @fields: */
+ /* platform :: The platform ID. */
+ /* */
+ /* encoding :: The encoding ID. */
+ /* */
+ typedef struct FTC_CMapIdRec_
{
FT_UInt platform;
FT_UInt encoding;
-
+
} FTC_CMapIdRec;
- /************************************************************************
- *
- * @struct: FTC_CMapDescRec
- *
- * @description:
- * a structure used to describe a given charmap to the @FTC_CMapCache
- *
- * @fields:
- * face_id :: @FTC_FaceID of the face this charmap belongs to
- * type :: type of charmap, see @FTC_CMapType
- *
- * u.index :: for @FTC_CMAP_BY_INDEX types, this is the charmap index
- * (within a @FT_Face) we want to use.
- *
- * u.encoding :: for @FTC_CMAP_BY_ENCODING types, this is the charmap
- * encoding we want to use. see @FT_Encoding
- *
- * u.id :: for @FTC_CMAP_BY_ID types, this is the (platform,encoding)
- * pair we want to use. see @FTC_CMapIdRec and
- * @FT_CharMapRec
- */
- typedef struct FTC_CMapDescRec_
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* FTC_CMapDescRec */
+ /* */
+ /* @description: */
+ /* A structure to describe a given charmap to @FTC_CMapCache. */
+ /* */
+ /* @fields: */
+ /* face_id :: @FTC_FaceID of the face this charmap belongs to. */
+ /* */
+ /* type :: The type of charmap, see @FTC_CMapType. */
+ /* */
+ /* u.index :: For @FTC_CMAP_BY_INDEX types, this is the charmap */
+ /* index (within a @FT_Face) we want to use. */
+ /* */
+ /* u.encoding :: For @FTC_CMAP_BY_ENCODING types, this is the charmap */
+ /* encoding we want to use. see @FT_Encoding. */
+ /* */
+ /* u.id :: For @FTC_CMAP_BY_ID types, this is the */
+ /* (platform,encoding) pair we want to use. see */
+ /* @FTC_CMapIdRec and @FT_CharMapRec. */
+ /* */
+ typedef struct FTC_CMapDescRec_
{
FTC_FaceID face_id;
FTC_CMapType type;
@@ -129,67 +137,73 @@
FT_UInt index;
FT_Encoding encoding;
FTC_CMapIdRec id;
-
+
} u;
-
+
} FTC_CMapDescRec;
-
- /************************************************************************
- *
- * @function: FTC_CMapCache_New
- *
- * @description:
- * create a new charmap cache
- *
- * @input:
- * manager :: handle to cache manager
- *
- * @output:
- * acache :: new cache handle. NULL in case of error
- *
- * @return:
- * FreeType error code. 0 means success
- *
- * @note:
- * like all other caches, this one will be destroyed with the
- * cache manager
- */
+ /*************************************************************************/
+ /* */
+ /* @function: */
+ /* FTC_CMapCache_New */
+ /* */
+ /* @description: */
+ /* Creates a new charmap cache. */
+ /* */
+ /* @input: */
+ /* manager :: A handle to the cache manager. */
+ /* */
+ /* @output: */
+ /* acache :: A new cache handle. NULL in case of error. */
+ /* */
+ /* @return: */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* @note: */
+ /* Like all other caches, this one will be destroyed with the cache */
+ /* manager. */
+ /* */
FT_EXPORT( FT_Error )
FTC_CMapCache_New( FTC_Manager manager,
FTC_CMapCache *acache );
-
- /************************************************************************
- *
- * @function: FTC_CMapCache_Lookup
- *
- * @description:
- * translate a character code into a glyph index, using the charmap
- * cache.
- *
- * @input:
- * cache :: charmap cache handle
- * cmap_desc :: charmap descriptor handle
- * char_code :: character code (in the corresponding charmap)
- *
- * @return:
- * glyph index. 0 means "no glyph" !!
- *
- * @note:
- * this function doesn't return @FTC_Node handles, since there is
- * no real use for them with typical uses of charmaps
- */
+ /*************************************************************************/
+ /* */
+ /* @function: */
+ /* FTC_CMapCache_Lookup */
+ /* */
+ /* @description: */
+ /* Translates a character code into a glyph index, using the charmap */
+ /* cache. */
+ /* */
+ /* @input: */
+ /* cache :: A charmap cache handle. */
+ /* */
+ /* cmap_desc :: A charmap descriptor handle. */
+ /* */
+ /* char_code :: The character code (in the corresponding charmap). */
+ /* */
+ /* @return: */
+ /* Glyph index. 0 means "no glyph". */
+ /* */
+ /* @note: */
+ /* This function doesn't return @FTC_Node handles, since there is no */
+ /* real use for them with typical uses of charmaps. */
+ /* */
FT_EXPORT( FT_UInt )
FTC_CMapCache_Lookup( FTC_CMapCache cache,
FTC_CMapDesc cmap_desc,
FT_UInt32 char_code );
+ /* */
- /* */
FT_END_HEADER
-#endif /* __FT_CACHE_CHARMAP_H__ */
+
+#endif /* __FTCCMAP_H__ */
+
+
+/* END */
--- a/include/freetype/cache/ftcglyph.h
+++ b/include/freetype/cache/ftcglyph.h
@@ -64,18 +64,18 @@
FT_BEGIN_HEADER
- /* each glyph set is caracterized by a "glyph set type" which must be */
- /* defined by sub-classes.. */
- typedef struct FTC_GlyphFamilyRec_* FTC_GlyphFamily;
+ /* each glyph set is characterized by a "glyph set type" which must be */
+ /* defined by sub-classes */
+ typedef struct FTC_GlyphFamilyRec_* FTC_GlyphFamily;
- /* handle to a glyph cache node */
- typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
+ /* handle to a glyph cache node */
+ typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
- /* size should be 24 + chunk size on 32-bit machines */
- /* note that the node's hash is ((gfam->hash << 16) | glyph_index) */
- /* this _must_ be set properly by the glyph node initializer.. */
- /* */
+ /* size should be 24 + chunk size on 32-bit machines; */
+ /* note that the node's hash is ((gfam->hash << 16) | glyph_index) -- */
+ /* this _must_ be set properly by the glyph node initializer */
+ /* */
typedef struct FTC_GlyphNodeRec_
{
FTC_NodeRec node;
@@ -84,9 +84,9 @@
} FTC_GlyphNodeRec;
-#define FTC_GLYPH_NODE(x) ((FTC_GlyphNode)(x))
-#define FTC_GLYPH_NODE_P(x) ((FTC_GlyphNode*)(x))
+#define FTC_GLYPH_NODE( x ) ( (FTC_GlyphNode)(x) )
+#define FTC_GLYPH_NODE_P( x ) ( (FTC_GlyphNode*)(x) )
typedef struct FTC_GlyphQueryRec_
@@ -96,13 +96,12 @@
} FTC_GlyphQueryRec, *FTC_GlyphQuery;
-#define FTC_GLYPH_QUERY(x) ((FTC_GlyphQuery)(x))
+#define FTC_GLYPH_QUERY( x ) ( (FTC_GlyphQuery)(x) )
-
- /* a glyph set is used to categorize glyphs of a given type */
- typedef struct FTC_GlyphFamilyRec_
+ /* a glyph set is used to categorize glyphs of a given type */
+ typedef struct FTC_GlyphFamilyRec_
{
FTC_FamilyRec family;
FT_UInt32 hash;
@@ -112,42 +111,43 @@
} FTC_GlyphFamilyRec;
-#define FTC_GLYPH_FAMILY(x) ((FTC_GlyphFamily)(x))
-#define FTC_GLYPH_FAMILY_P(x) ((FTC_GlyphFamily*)(x))
+#define FTC_GLYPH_FAMILY( x ) ( (FTC_GlyphFamily)(x) )
+#define FTC_GLYPH_FAMILY_P( x ) ( (FTC_GlyphFamily*)(x) )
-#define FTC_GLYPH_FAMILY_MEMORY(x) FTC_FAMILY(x)->cache->memory
+#define FTC_GLYPH_FAMILY_MEMORY( x ) FTC_FAMILY(x)->cache->memory
-/* each glyph node contains a 'chunk' of glyph items */
-/* translate a glyph index into a chunk index */
-#define FTC_GLYPH_FAMILY_CHUNK(gfam,gindex) \
- ( (gindex) / FTC_GLYPH_FAMILY(gfam)->item_count )
-/* find a glyph index's chunk, and return its start index */
-/* */
-#define FTC_GLYPH_FAMILY_START(gfam,gindex) \
- ( FTC_GLYPH_FAMILY_CHUNK(gfam,gindex) * FTC_GLYPH_FAMILY(gfam)->item_count )
+ /* each glyph node contains a 'chunk' of glyph items; */
+ /* translate a glyph index into a chunk index */
+#define FTC_GLYPH_FAMILY_CHUNK( gfam, gindex ) \
+ ( ( gindex ) / FTC_GLYPH_FAMILY( gfam )->item_count )
-/* compute a glyph request's hash value */
-/* */
-#define FTC_GLYPH_FAMILY_HASH(gfam,gindex) \
- ((FT_UFast)( (FTC_GLYPH_FAMILY(gfam)->hash << 16) | \
- (FTC_GLYPH_FAMILY_CHUNK(gfam,gindex) & 0xFFFF) ))
+ /* find a glyph index's chunk, and return its start index */
+#define FTC_GLYPH_FAMILY_START( gfam, gindex ) \
+ ( FTC_GLYPH_FAMILY_CHUNK( gfam, gindex ) * \
+ FTC_GLYPH_FAMILY( gfam )->item_count )
-/* must be called in a FTC_Family_CompareFunc to update the query */
-/* whenever a glyph set is matched in the lookup.. or when it */
-/* is created */
-/* */
-#define FTC_GLYPH_FAMILY_FOUND(gfam,gquery) \
- do { \
- FTC_QUERY(gquery)->family = FTC_FAMILY(gfam); \
- FTC_QUERY(gquery)->hash = \
- FTC_GLYPH_FAMILY_HASH(gfam,FTC_GLYPH_QUERY(gquery)->gindex); \
- } while (0)
+ /* compute a glyph request's hash value */
+#define FTC_GLYPH_FAMILY_HASH( gfam, gindex ) \
+ ( (FT_UFast)( \
+ ( FTC_GLYPH_FAMILY( gfam )->hash << 16 ) | \
+ ( FTC_GLYPH_FAMILY_CHUNK( gfam, gindex ) & 0xFFFF ) ) )
+ /* must be called in an FTC_Family_CompareFunc to update the query */
+ /* whenever a glyph set is matched in the lookup, or when it */
+ /* is created */
+#define FTC_GLYPH_FAMILY_FOUND( gfam, gquery ) \
+ do \
+ { \
+ FTC_QUERY( gquery )->family = FTC_FAMILY( gfam ); \
+ FTC_QUERY( gquery )->hash = \
+ FTC_GLYPH_FAMILY_HASH( gfam, \
+ FTC_GLYPH_QUERY( gquery )->gindex ); \
+ } while ( 0 )
-/* retrieve glyph index of glyph node */
-#define FTC_GLYPH_NODE_GINDEX(x) \
- ((FT_UInt)(FTC_GLYPH_NODE(x)->node.hash & 0xFFFF))
+ /* retrieve glyph index of glyph node */
+#define FTC_GLYPH_NODE_GINDEX( x ) \
+ ( (FT_UInt)( FTC_GLYPH_NODE( x )->node.hash & 0xFFFF ) )
/*************************************************************************/
@@ -159,19 +159,17 @@
/* must be called by derived FTC_Node_InitFunc routines */
FT_EXPORT( void )
- ftc_glyph_node_init( FTC_GlyphNode node,
- FT_UInt gindex, /* glyph index for node */
- FTC_GlyphFamily gfam );
+ ftc_glyph_node_init( FTC_GlyphNode node,
+ FT_UInt gindex, /* glyph index for node */
+ FTC_GlyphFamily gfam );
- /* returns TRUE iff the query's glyph index correspond to the node */
- /* this assume that the "family" and "hash" fields of the query are */
- /* already correctly set.. */
- /* */
+ /* returns TRUE iff the query's glyph index correspond to the node; */
+ /* this assumes that the "family" and "hash" fields of the query are */
+ /* already correctly set */
FT_EXPORT( FT_Bool )
- ftc_glyph_node_compare( FTC_GlyphNode gnode,
- FTC_GlyphQuery gquery );
+ ftc_glyph_node_compare( FTC_GlyphNode gnode,
+ FTC_GlyphQuery gquery );
-
/* must be called by derived FTC_Node_DoneFunc routines */
FT_EXPORT( void )
ftc_glyph_node_done( FTC_GlyphNode node,
@@ -178,7 +176,8 @@
FTC_Cache cache );
- /* must be called by derived FTC_Family_InitFunc, calls "ftc_family_init" */
+ /* must be called by derived FTC_Family_InitFunc; */
+ /* calls "ftc_family_init" */
FT_EXPORT( FT_Error )
ftc_glyph_family_init( FTC_GlyphFamily gfam,
FT_UInt32 hash,
@@ -187,14 +186,16 @@
FTC_GlyphQuery gquery,
FTC_Cache cache );
-
FT_EXPORT( void )
ftc_glyph_family_done( FTC_GlyphFamily gfam );
-
- /* */
+ /* */
FT_END_HEADER
-#endif /* __FTC_GLYPH_H__ */
+
+#endif /* __FTCGLYPH_H__ */
+
+
+/* END */
--- a/include/freetype/cache/ftcimage.h
+++ b/include/freetype/cache/ftcimage.h
@@ -2,7 +2,7 @@
/* */
/* ftcimage.h */
/* */
-/* FreeType Image cache (body). */
+/* FreeType Image cache (specification). */
/* */
/* Copyright 2000-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -56,16 +56,16 @@
#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 )
-#define ftc_image_format_bitmap 0x0000
-#define ftc_image_format_outline 0x0001
+#define ftc_image_format_bitmap 0x0000
+#define ftc_image_format_outline 0x0001
-#define ftc_image_format_mask 0x000F
+#define ftc_image_format_mask 0x000F
-#define ftc_image_flag_monochrome 0x0010
-#define ftc_image_flag_unhinted 0x0020
-#define ftc_image_flag_autohinted 0x0040
-#define ftc_image_flag_unscaled 0x0080
-#define ftc_image_flag_no_sbits 0x0100
+#define ftc_image_flag_monochrome 0x0010
+#define ftc_image_flag_unhinted 0x0020
+#define ftc_image_flag_autohinted 0x0040
+#define ftc_image_flag_unscaled 0x0080
+#define ftc_image_flag_no_sbits 0x0100
/* monochrome bitmap */
#define ftc_image_mono ftc_image_format_bitmap | \
@@ -85,16 +85,16 @@
/* */
/* <Description> */
/* A simple structure used to describe a given glyph image category. */
- /* note that this is different from @FTC_Image_Desc */
+ /* Note that this is different from @FTC_Image_Desc. */
/* */
/* <Fields> */
- /* size :: An FTC_SizeRec used to describe the glyph's face & */
+ /* size :: An @FTC_SizeRec used to describe the glyph's face and */
/* size. */
/* */
- /* type :: The glyph image's type. note that it's a 32-bit uint */
+ /* type :: The glyph image's type. Note that it is a 32-bit uint. */
/* */
/* <Note> */
- /* this type deprecates @FTC_Image_Desc */
+ /* This type deprecates @FTC_Image_Desc. */
/* */
typedef struct FTC_ImageDesc_
{
@@ -104,14 +104,16 @@
} FTC_ImageDesc;
/* */
-#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \
- ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
- (d1)->type == (d2)->type )
-#define FTC_IMAGE_DESC_HASH(d) \
- (FT_UFast)( FTC_FONT_HASH(&(d)->font) ^ \
- ((d)->type << 4) )
+#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \
+ ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
+ (d1)->type == (d2)->type )
+#define FTC_IMAGE_DESC_HASH( d ) \
+ (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
+ ( (d)->type << 4 ) )
+
+
/*************************************************************************/
/* */
/* <Type> */
@@ -119,7 +121,7 @@
/* */
/* <Description> */
/* 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. */
/* */
typedef struct FTC_ImageCacheRec_* FTC_ImageCache;
@@ -153,10 +155,9 @@
/* FTC_ImageCache_Lookup */
/* */
/* <Description> */
- /* Retrieves a given glyph image from a glyph image cache */
- /* and 'acquire' it. This prevents the glyph image from being */
- /* flushed out of the cache, until @FTC_Image_Cache_Release is */
- /* called */
+ /* Retrieves a given glyph image from a glyph image cache and */
+ /* `acquires' it. This prevents the glyph image from being flushed */
+ /* out of the cache, until @FTC_Image_Cache_Release is called. */
/* */
/* <Input> */
/* cache :: A handle to the source glyph image cache. */
@@ -166,13 +167,13 @@
/* gindex :: The glyph index to retrieve. */
/* */
/* <Output> */
- /* aglyph :: The corresponding FT_Glyph object. 0 in case of */
+ /* aglyph :: The corresponding @FT_Glyph object. 0 in case of */
/* failure. */
/* */
- /* anode :: an opaque cache node pointer that will be used */
- /* to release the glyph once it becomes unuseful. */
- /* can be NULL, in which case this function will */
- /* have the same effect than @FTC_Image_Cache_Lookup */
+ /* anode :: An opaque cache node pointer that will be used to */
+ /* release the glyph once it becomes unuseful. Can be */
+ /* NULL, in which case this function will have the same */
+ /* effect as @FTC_Image_Cache_Release. XXX */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@@ -180,20 +181,19 @@
/* <Note> */
/* The returned glyph is owned and managed 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. */
+ /* create a copy with @FT_Glyph_Copy and modify the new one. */
/* */
- /* if 'anode' is NULL */
- /* */
/* 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... */
+ /* on a later invocation of this function! It is a cache after */
+ /* all... */
/* */
FT_EXPORT( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache,
FTC_ImageDesc* desc,
- FT_UInt gindex,
- FT_Glyph *aglyph,
- FTC_Node *anode );
+ FT_UInt gindex,
+ FT_Glyph *aglyph,
+ FTC_Node *anode );
/* */
@@ -204,18 +204,16 @@
/* FTC_Image_Desc */
/* */
/* <Description> */
- /* THIS TYPE IS DEPRECATED. USE @FTC_ImageDesc instead.. */
+ /* THIS TYPE IS DEPRECATED. Use @FTC_ImageDesc instead. */
+ /* */
/* A simple structure used to describe a given glyph image category. */
/* */
/* <Fields> */
- /* size :: An FTC_SizeRec used to describe the glyph's face & */
- /* size. */
+ /* size :: An @FTC_SizeRec used to describe the glyph's face */
+ /* and size. */
/* */
/* image_type :: The glyph image's type. */
/* */
- /* <Note> */
- /* */
- /* */
typedef struct FTC_Image_Desc_
{
FTC_FontRec font;
@@ -230,12 +228,11 @@
/* FTC_Image_Cache */
/* */
/* <Description> */
- /* THIS TYPE IS DEPRECATED, USE @FTC_ImageCache instead */
+ /* THIS TYPE IS DEPRECATED. Use @FTC_ImageCache instead. */
/* */
typedef FTC_ImageCache FTC_Image_Cache;
-
/*************************************************************************/
/* */
/* <Function> */
@@ -242,7 +239,8 @@
/* FTC_Image_Cache_New */
/* */
/* <Description> */
- /* THIS FUNCTION IS DEPRECATED, USE @FTC_ImageCache_New instead */
+ /* THIS FUNCTION IS DEPRECATED. Use @FTC_ImageCache_New instead. */
+ /* */
/* Creates a new glyph image cache. */
/* */
/* <Input> */
@@ -265,7 +263,7 @@
/* FTC_Image_Cache_Lookup */
/* */
/* <Description> */
- /* THIS FUNCTION IS DEPRECATED. USE @FTC_ImageCache_Lookup instead */
+ /* THIS FUNCTION IS DEPRECATED. Use @FTC_ImageCache_Lookup instead. */
/* */
/* <Input> */
/* cache :: A handle to the source glyph image cache. */
@@ -275,7 +273,7 @@
/* gindex :: The glyph index to retrieve. */
/* */
/* <Output> */
- /* aglyph :: The corresponding FT_Glyph object. 0 in case of */
+ /* aglyph :: The corresponding @FT_Glyph object. 0 in case of */
/* failure. */
/* */
/* <Return> */
@@ -284,14 +282,14 @@
/* <Note> */
/* The returned glyph is owned and managed 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. */
+ /* 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... */
+ /* on a later invocation of this function! It is a cache after */
+ /* all... */
/* */
- /* use @FTC_ImageCache_Lookup to "lock" the glyph as long as you */
- /* need it.. */
+ /* Use this function to "lock" the glyph as long as it is needed. */
/* */
FT_EXPORT( FT_Error )
FTC_Image_Cache_Lookup( FTC_Image_Cache cache,
@@ -302,6 +300,7 @@
/* */
FT_END_HEADER
+
#endif /* __FTCIMAGE_H__ */
--- a/include/freetype/cache/ftcmanag.h
+++ b/include/freetype/cache/ftcmanag.h
@@ -23,7 +23,7 @@
/* - Maintain a mapping between generic FTC_FaceIDs and live FT_Face */
/* objects. The mapping itself is performed through a user-provided */
/* callback. However, the manager maintains a small cache of FT_Face */
- /* & FT_Size objects in order to speed up things considerably. */
+ /* and FT_Size objects in order to speed up things considerably. */
/* */
/* - Manage one or more cache objects. Each cache is in charge of */
/* holding a varying number of `cache nodes'. Each cache node */
@@ -68,6 +68,7 @@
#include FT_CACHE_INTERNAL_LRU_H
#include FT_CACHE_INTERNAL_CACHE_H
+
FT_BEGIN_HEADER
@@ -81,24 +82,26 @@
#define FTC_MAX_FACES_DEFAULT 2
#define FTC_MAX_SIZES_DEFAULT 4
-#define FTC_MAX_BYTES_DEFAULT 200000L /* ~200 KB bytes by default */
+#define FTC_MAX_BYTES_DEFAULT 200000L /* ~200kByte by default */
/* maximum number of caches registered in a single manager */
#define FTC_MAX_CACHES 16
- typedef struct FTC_FamilyEntryRec_
+ typedef struct FTC_FamilyEntryRec_
{
- FTC_Family family;
- FTC_Cache cache;
- FT_UInt index;
- FT_UInt link;
+ FTC_Family family;
+ FTC_Cache cache;
+ FT_UInt index;
+ FT_UInt link;
} FTC_FamilyEntryRec, *FTC_FamilyEntry;
-#define FTC_FAMILY_ENTRY_NONE ((FT_UInt)-1)
- typedef struct FTC_FamilyTableRec_
+#define FTC_FAMILY_ENTRY_NONE ( (FT_UInt)-1 )
+
+
+ typedef struct FTC_FamilyTableRec_
{
FT_UInt count;
FT_UInt size;
@@ -113,7 +116,6 @@
FT_Memory memory,
FTC_FamilyEntry *aentry );
-
FT_EXPORT( void )
ftc_family_table_free( FTC_FamilyTable table,
FT_UInt index );
@@ -130,9 +132,9 @@
/* <Fields> */
/* library :: A handle to a FreeType library instance. */
/* */
- /* faces_list :: The lru list of FT_Face objects in the cache. */
+ /* faces_list :: The lru list of @FT_Face objects in the cache. */
/* */
- /* sizes_list :: The lru list of FT_Size objects in the cache. */
+ /* sizes_list :: The lru list of @FT_Size objects in the cache. */
/* */
/* max_weight :: The maximum cache pool weight. */
/* */
@@ -147,9 +149,11 @@
/* request_data :: User-provided data passed to the requester. */
/* */
/* request_face :: User-provided function used to implement a mapping */
- /* between abstract FTC_FaceIDs and real FT_Face */
- /* objects. */
+ /* between abstract @FTC_FaceID values and real */
+ /* @FT_Face objects. */
/* */
+ /* families :: XXX */
+ /* */
typedef struct FTC_ManagerRec_
{
FT_Library library;
@@ -167,7 +171,7 @@
FT_Pointer request_data;
FTC_Face_Requester request_face;
- FTC_FamilyTableRec families;
+ FTC_FamilyTableRec families;
} FTC_ManagerRec;
@@ -204,8 +208,8 @@
FTC_Cache *acache );
- /* can be called to increment a node's reference count */
- FT_EXPORT(void)
+ /* can be called to increment a node's reference count */
+ FT_EXPORT( void )
FTC_Node_Ref( FTC_Node node,
FTC_Manager manager );
@@ -232,6 +236,7 @@
/* */
FT_END_HEADER
+
#endif /* __FTCMANAG_H__ */
--- a/include/freetype/cache/ftcsbits.h
+++ b/include/freetype/cache/ftcsbits.h
@@ -42,7 +42,7 @@
/* FTC_SBit */
/* */
/* <Description> */
- /* A handle to a small bitmap descriptor. See the FTC_SBitRec */
+ /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */
/* structure for details. */
/* */
typedef struct FTC_SBitRec_* FTC_SBit;
@@ -98,20 +98,20 @@
} FTC_SBitRec;
-
/*************************************************************************/
/* */
/* <Type> */
- /* FTC_SBit_Cache */
+ /* FTC_SBitCache */
/* */
/* <Description> */
/* A handle to a small bitmap cache. These are special cache objects */
/* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */
/* much more efficient way than the traditional glyph image cache */
- /* implemented by FTC_Image_Cache. */
+ /* implemented by @FTC_ImageCache. */
/* */
- typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
+ typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
+
/*************************************************************************/
/* */
/* <Type> */
@@ -118,13 +118,11 @@
/* FTC_SBit_Cache */
/* */
/* <Description> */
- /* deprecated. please use @FTC_SBitCache instead */
+ /* DEPRECATED. Use @FTC_SBitCache instead. */
/* */
- typedef FTC_SBitCache FTC_SBit_Cache;
+ typedef FTC_SBitCache FTC_SBit_Cache;
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -158,16 +156,18 @@
/* */
/* <Input> */
/* cache :: A handle to the source sbit cache. */
+ /* */
/* desc :: A pointer to the glyph image descriptor. */
+ /* */
/* gindex :: The glyph index. */
/* */
/* <Output> */
/* sbit :: A handle to a small bitmap descriptor. */
/* */
- /* anode :: an opaque cache node pointer that will be used */
+ /* anode :: An opaque cache node pointer that will be used */
/* to release the sbit once it becomes unuseful. */
- /* can be NULL, in which case this function will */
- /* have the same effect than @FTC_SBit_Cache_Lookup */
+ /* Can be NULL, in which case this function will */
+ /* have the same effect as @FTC_SBitCache_Lookup. XXX */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@@ -198,6 +198,8 @@
/* FTC_SBit_Cache_New */
/* */
/* <Description> */
+ /* DEPRECATED. Use @FTC_SBitCache_New instead. */
+ /* */
/* Creates a new cache to store small glyph bitmaps. */
/* */
/* <Input> */
@@ -220,11 +222,15 @@
/* FTC_SBit_Cache_Lookup */
/* */
/* <Description> */
+ /* DEPRECATED. Use @FTC_SBitCache_Lookup instead. */
+ /* */
/* Looks up a given small glyph bitmap in a given sbit cache. */
/* */
/* <Input> */
/* cache :: A handle to the source sbit cache. */
+ /* */
/* desc :: A pointer to the glyph image descriptor. */
+ /* */
/* gindex :: The glyph index. */
/* */
/* <Output> */
--- a/include/freetype/cache/ftlru.h
+++ b/include/freetype/cache/ftlru.h
@@ -19,7 +19,7 @@
/*************************************************************************/
/* */
/* An LRU is a list that cannot hold more than a certain number of */
- /* elements (`max_elements'). All elements on the list are sorted in */
+ /* elements (`max_elements'). All elements in the list are sorted in */
/* least-recently-used order, i.e., the `oldest' element is at the tail */
/* of the list. */
/* */
@@ -58,11 +58,14 @@
#ifndef __FTLRU_H__
#define __FTLRU_H__
+
#include <ft2build.h>
#include FT_FREETYPE_H
+
FT_BEGIN_HEADER
+
/* generic list key type */
typedef FT_Pointer FT_LruKey;
@@ -69,11 +72,11 @@
/* a list list handle */
typedef struct FT_LruListRec_* FT_LruList;
- /* list class handle */
+ /* a list class handle */
typedef const struct FT_LruList_ClassRec_* FT_LruList_Class;
- /* an list node handle */
- typedef struct FT_LruNodeRec_* FT_LruNode;
+ /* a list node handle */
+ typedef struct FT_LruNodeRec_* FT_LruNode;
/* the list node structure */
typedef struct FT_LruNodeRec_
@@ -87,53 +90,60 @@
/* the list structure */
typedef struct FT_LruListRec_
{
- FT_Memory memory;
- FT_LruList_Class clazz;
- FT_LruNode nodes;
- FT_UInt max_nodes;
- FT_UInt num_nodes;
- FT_Pointer data;
+ FT_Memory memory;
+ FT_LruList_Class clazz;
+ FT_LruNode nodes;
+ FT_UInt max_nodes;
+ FT_UInt num_nodes;
+ FT_Pointer data;
} FT_LruListRec;
/* initialize a list list */
- typedef FT_Error (*FT_LruList_InitFunc)( FT_LruList list );
+ typedef FT_Error
+ (*FT_LruList_InitFunc)( FT_LruList list );
- /* finalize a list list */
- typedef void (*FT_LruList_DoneFunc)( FT_LruList list );
+ /* finalize a list list */
+ typedef void
+ (*FT_LruList_DoneFunc)( FT_LruList list );
/* this method is used to initialize a new list element node */
- typedef FT_Error (*FT_LruNode_InitFunc)( FT_LruNode node,
- FT_LruKey key,
- FT_Pointer data );
+ typedef FT_Error
+ (*FT_LruNode_InitFunc)( FT_LruNode node,
+ FT_LruKey key,
+ FT_Pointer data );
/* this method is used to finalize a given list element node */
- typedef void (*FT_LruNode_DoneFunc)( FT_LruNode node,
- FT_Pointer data );
+ typedef void
+ (*FT_LruNode_DoneFunc)( FT_LruNode node,
+ FT_Pointer data );
/* If defined, this method is called when the list if full */
/* during the lookup process -- it is used to change the contents */
- /* of a list element node, instead of calling `done_element()', */
+ /* of a list element node instead of calling `done_element()', */
/* then `init_element()'. Set it to 0 for default behaviour. */
- typedef FT_Error (*FT_LruNode_FlushFunc)( FT_LruNode node,
- FT_LruKey new_key,
- FT_Pointer data );
+ typedef FT_Error
+ (*FT_LruNode_FlushFunc)( FT_LruNode node,
+ FT_LruKey new_key,
+ FT_Pointer data );
/* If defined, this method is used to compare a list element node */
/* with a given key during a lookup. If set to 0, the `key' */
/* fields will be directly compared instead. */
- typedef FT_Bool (*FT_LruNode_CompareFunc)( FT_LruNode node,
- FT_LruKey key,
- FT_Pointer data );
+ typedef FT_Bool
+ (*FT_LruNode_CompareFunc)( FT_LruNode node,
+ FT_LruKey key,
+ FT_Pointer data );
/* A selector is used to indicate whether a given list element node */
/* is part of a selection for FT_LruList_Remove_Selection(). The */
/* functrion must return true (i.e., non-null) to indicate that the */
/* node is part of it. */
- typedef FT_Bool (*FT_LruNode_SelectFunc)( FT_LruNode node,
- FT_Pointer data,
- FT_Pointer list_data );
+ typedef FT_Bool
+ (*FT_LruNode_SelectFunc)( FT_LruNode node,
+ FT_Pointer data,
+ FT_Pointer list_data );
/* LRU class */
typedef struct FT_LruList_ClassRec_
@@ -164,22 +174,18 @@
FT_EXPORT( void )
FT_LruList_Reset( FT_LruList list );
-
FT_EXPORT( void )
FT_LruList_Destroy ( FT_LruList list );
-
FT_EXPORT( FT_Error )
FT_LruList_Lookup( FT_LruList list,
FT_LruKey key,
FT_LruNode *anode );
-
FT_EXPORT( void )
FT_LruList_Remove( FT_LruList list,
FT_LruNode node );
-
FT_EXPORT( void )
FT_LruList_Remove_Selection( FT_LruList list,
FT_LruNode_SelectFunc select_func,
@@ -188,6 +194,7 @@
/* */
FT_END_HEADER
+
#endif /* __FTLRU_H__ */
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -2,7 +2,7 @@
/* */
/* ftcache.h */
/* */
-/* FreeType Cache subsystem. */
+/* FreeType Cache subsystem (specification). */
/* */
/* Copyright 1996-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -122,7 +122,7 @@
/* */
/* <Description> */
/* 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> */
/* face_id :: The face ID to resolve. */
@@ -132,7 +132,7 @@
/* data :: Application-provided request data. */
/* */
/* <Output> */
- /* aface :: A new FT_Face handle. */
+ /* aface :: A new @FT_Face handle. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@@ -139,8 +139,8 @@
/* */
/* <Note> */
/* The face requester should not perform funny things on the returned */
- /* face object, like creating a new FT_Size for it, or setting a */
- /* transformation through FT_Set_Transform()! */
+ /* face object, like creating a new @FT_Size for it, or setting a */
+ /* transformation through @FT_Set_Transform! */
/* */
typedef FT_Error
(*FTC_Face_Requester)( FTC_FaceID face_id,
@@ -175,8 +175,9 @@
} FTC_FontRec;
- /* */
+ /* */
+
#define FTC_FONT_COMPARE( f1, f2 ) \
( (f1)->face_id == (f2)->face_id && \
(f1)->pix_width == (f2)->pix_width && \
@@ -189,6 +190,7 @@
((f)->pix_width << 8) ^ \
((f)->pix_height) )
+
/*************************************************************************/
/* */
/* <Type> */
@@ -195,7 +197,7 @@
/* FTC_Font */
/* */
/* <Description> */
- /* A simple handle to a FTC_FontRec structure. */
+ /* A simple handle to an @FTC_FontRec structure. */
/* */
typedef FTC_FontRec* FTC_Font;
@@ -217,8 +219,8 @@
/* FTC_Manager */
/* */
/* <Description> */
- /* This object is used to cache one or more FT_Face objects, along */
- /* with corresponding FT_Size objects. */
+ /* This object is used to cache one or more @FT_Face objects, along */
+ /* with corresponding @FT_Size objects. */
/* */
typedef struct FTC_ManagerRec_* FTC_Manager;
@@ -229,18 +231,18 @@
/* FTC_Node */
/* */
/* <Description> */
- /* an opaque handle to a cache node object. Each cache node is */
- /* reference-counted. A node with a count of 0 might be flushed */
- /* out of a full cache whenever a lookup request is performed */
+ /* An opaque handle to a cache node object. Each cache node is */
+ /* reference-counted. A node with a count of 0 might be flushed */
+ /* out of a full cache whenever a lookup request is performed. */
/* */
- /* when you lookup nodes, you have the ability to "acquire" them, */
- /* i.e. increment their reference count. This will prevent the node */
- /* from being flushed out of the cache until you explicitely */
- /* "release" it (see @FTC_Node_Release) */
+ /* If you lookup nodes, you have the ability to "acquire" them, i.e., */
+ /* to increment their reference count. This will prevent the node */
+ /* from being flushed out of the cache until you explicitly "release" */
+ /* it (see @FTC_Node_Release). */
/* */
- /* see @FTC_BitsetCache_Lookup and @FTC_ImageCache_Lookup */
+ /* See also @FTC_BitsetCache_Lookup and @FTC_ImageCache_Lookup. */
/* */
- typedef struct FTC_NodeRec_* FTC_Node;
+ typedef struct FTC_NodeRec_* FTC_Node;
/*************************************************************************/
@@ -264,10 +266,10 @@
/* Use 0 for defaults. */
/* */
/* 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 */
- /* each time it is called (see FTC_Face_Requester) */
+ /* each time it is called (see @FTC_Face_Requester). */
/* */
/* <Output> */
/* amanager :: A handle to a new manager object. 0 in case of */
@@ -293,7 +295,7 @@
/* */
/* <Description> */
/* 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 and @FT_Size objects within the manager. */
/* */
/* <InOut> */
/* manager :: A handle to the manager. */
@@ -323,7 +325,7 @@
/* FTC_Manager_Lookup_Face */
/* */
/* <Description> */
- /* Retrieves the FT_Face object that corresponds to a given face ID */
+ /* Retrieves the @FT_Face object that corresponds to a given face ID */
/* through a cache manager. */
/* */
/* <Input> */
@@ -338,15 +340,15 @@
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
- /* The returned FT_Face object is always owned by the manager. You */
+ /* 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 */
+ /* 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. */
+ /* 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 */
+ /* the @FT_Set_Transform function) on a returned face! If you need */
/* to transform glyphs, do it yourself after glyph loading. */
/* */
FT_EXPORT( FT_Error )
@@ -361,8 +363,8 @@
/* FTC_Manager_Lookup_Size */
/* */
/* <Description> */
- /* Retrieves the FT_Face & FT_Size objects that correspond to a given */
- /* FTC_SizeID. */
+ /* Retrieves the @FT_Face and @FT_Size objects that correspond to a */
+ /* given @FTC_SizeID. */
/* */
/* <Input> */
/* manager :: A handle to the cache manager. */
@@ -380,19 +382,19 @@
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
- /* The returned FT_Face object is always owned by the manager. You */
+ /* 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 */
+ /* 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 */
+ /* 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()! */
+ /* 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. */
+ /* that you can call @FT_Load_Glyph with the face if you need to. */
/* */
FT_EXPORT( FT_Error )
FTC_Manager_Lookup_Size( FTC_Manager manager,
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/* */
+/* ftccache.c */
+/* */
+/* The FreeType internal cache interface (body). */
+/* */
+/* Copyright 2000-2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <ft2build.h>
#include FT_CACHE_MANAGER_H
#include FT_INTERNAL_OBJECTS_H
@@ -5,6 +23,7 @@
#include "ftcerror.h"
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -13,7 +32,7 @@
/*************************************************************************/
/*************************************************************************/
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
ftc_node_done( FTC_Node node,
FTC_Cache cache )
{
@@ -20,6 +39,7 @@
FTC_Family family;
FTC_FamilyEntry entry;
+
entry = cache->manager->families.entries + node->fam_index;
family = entry->family;
@@ -29,9 +49,7 @@
}
-
-
- /* add a new node to the head of the manager's circular MRU list */
+ /* add a new node to the head of the manager's circular MRU list */
static void
ftc_node_mru_link( FTC_Node node,
FTC_Manager manager )
@@ -162,7 +180,7 @@
/* find node's cache */
if ( node->fam_index >= manager->families.count )
{
- FT_ERROR(( "FreeType.cache.node_destroy: invalid node handle\n" ));
+ FT_ERROR(( "ftc_node_destroy: invalid node handle\n" ));
return;
}
#endif
@@ -173,7 +191,7 @@
#ifdef FT_DEBUG_ERROR
if ( cache == NULL )
{
- FT_ERROR(( "FreeType.cache.node_destroy: invalid node handle\n" ));
+ FT_ERROR(( "ftc_node_destroy: invalid node handle\n" ));
return;
}
#endif
@@ -196,7 +214,7 @@
/* check, just in case of general corruption :-) */
if ( manager->num_nodes <= 0 )
- FT_ERROR(( "FTC_Manager_Compress: Invalid cache node count! = %d\n",
+ FT_ERROR(( "ftc_node_destroy: invalid cache node count! = %d\n",
manager->num_nodes ));
}
@@ -210,7 +228,7 @@
/*************************************************************************/
- FT_EXPORT_DEF(FT_Error)
+ FT_EXPORT_DEF( FT_Error )
ftc_family_init( FTC_Family family,
FTC_Query query,
FTC_Cache cache )
@@ -220,12 +238,13 @@
FT_Memory memory = manager->library->memory;
FTC_FamilyEntry entry;
+
family->cache = cache;
family->num_nodes = 0;
/* now add to manager's family table */
error = ftc_family_table_alloc( &manager->families, memory, &entry );
- if (!error)
+ if ( !error )
{
entry->cache = cache;
entry->family = family;
@@ -233,16 +252,17 @@
query->family = family; /* save family in query */
}
+
return error;
}
-
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
ftc_family_done( FTC_Family family )
{
FTC_Manager manager = family->cache->manager;
+
/* remove from manager's family table */
ftc_family_table_free( &manager->families, family->fam_index );
}
@@ -318,7 +338,6 @@
(c)->size*3 < (c)->nodes )
-
static void
ftc_cache_resize( FTC_Cache cache )
{
@@ -333,7 +352,8 @@
FTC_Node* new_buckets ;
FT_ULong i;
- /* no need to report an error, we'll simply keep using the same */
+
+ /* no need to report an error; we'll simply keep using the same */
/* buckets number / size */
if ( ALLOC_ARRAY( new_buckets, new_size, FTC_Node ) )
return;
@@ -386,22 +406,23 @@
{
FT_LruList_ClassRec* lru_class = &cache->family_class;
+
lru_class->list_size = sizeof( FT_LruListRec );
lru_class->list_init = NULL;
lru_class->list_done = NULL;
lru_class->node_size = clazz->family_size;
- lru_class->node_init = (FT_LruNode_InitFunc) clazz->family_init;
- lru_class->node_done = (FT_LruNode_DoneFunc) clazz->family_done;
- lru_class->node_flush = (FT_LruNode_FlushFunc) NULL;
- lru_class->node_compare = (FT_LruNode_CompareFunc) clazz->family_compare;
+ lru_class->node_init = (FT_LruNode_InitFunc) clazz->family_init;
+ lru_class->node_done = (FT_LruNode_DoneFunc) clazz->family_done;
+ lru_class->node_flush = (FT_LruNode_FlushFunc) NULL;
+ lru_class->node_compare = (FT_LruNode_CompareFunc)clazz->family_compare;
error = FT_LruList_New( (FT_LruList_Class) lru_class,
- 0, /* max items == 0 => unbounded list */
+ 0, /* max items == 0 => unbounded list */
cache,
memory,
&cache->families );
- if (error)
+ if ( error )
FREE( cache->buckets );
}
@@ -410,7 +431,7 @@
}
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
ftc_cache_clear( FTC_Cache cache )
{
if ( cache )
@@ -425,6 +446,7 @@
{
FTC_Node *pnode = cache->buckets + i, next, node = *pnode;
+
while ( node )
{
next = node->link;
@@ -453,6 +475,7 @@
}
}
+
FT_EXPORT_DEF( void )
ftc_cache_done( FTC_Cache cache )
{
@@ -460,6 +483,7 @@
{
FT_Memory memory = cache->memory;
+
ftc_cache_clear( cache );
FREE( cache->buckets );
@@ -474,11 +498,10 @@
}
-
/* Look up a node in "top" of its cache's hash table. */
/* If not found, create a new node. */
/* */
- FT_EXPORT_DEF(FT_Error)
+ FT_EXPORT_DEF( FT_Error )
ftc_cache_lookup( FTC_Cache cache,
FTC_Query query,
FTC_Node *anode )
@@ -497,35 +520,38 @@
query->family = NULL;
error = FT_LruList_Lookup( cache->families, query, &lru );
- if (!error)
+ if ( !error )
{
FTC_Family family = (FTC_Family) lru;
FT_UFast hash = query->hash;
FTC_Node* bucket = cache->buckets + (hash % cache->size);
- if ( query->family != family ||
- family->fam_index >= cache->manager->families.size )
- {
- FT_ERROR(( "%s: invalid query (bad 'family' field)\n",
- "FreeType.cache.lookup" ));
- return FT_Err_Invalid_Argument;
- }
+ if ( query->family != family ||
+ family->fam_index >= cache->manager->families.size )
+ {
+ FT_ERROR((
+ "ftc_cache_lookup: invalid query (bad 'family' field)\n" ));
+ return FT_Err_Invalid_Argument;
+ }
+
if ( *bucket )
{
FTC_Node* pnode = bucket;
FTC_Node_CompareFunc compare = cache->clazz->node_compare;
+
for ( ;; )
{
FTC_Node node;
+
node = *pnode;
if ( node == NULL )
break;
if ( (FT_UInt)node->fam_index == family->fam_index &&
- compare( node, query, cache ) )
+ compare( node, query, cache ) )
{
/* move to head of bucket list */
if ( pnode != bucket )
@@ -582,8 +608,8 @@
node->ref_count--;
}
- /* try to resize the hash table when appropriate */
- if ( FTC_CACHE_RESIZE_TEST(cache) )
+ /* try to resize the hash table if appropriate */
+ if ( FTC_CACHE_RESIZE_TEST( cache ) )
ftc_cache_resize( cache );
*anode = node;
@@ -595,3 +621,4 @@
}
+/* END */
--- a/src/cache/ftccmap.c
+++ b/src/cache/ftccmap.c
@@ -2,7 +2,7 @@
/* */
/* ftccmap.c */
/* */
-/* FreeType CharMap cache */
+/* FreeType CharMap cache (body) */
/* */
/* Copyright 2000-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -26,46 +26,47 @@
#include "ftcerror.h"
+ /*************************************************************************/
+ /* */
+ /* Each FTC_CMapNode contains a simple array to map a range of character */
+ /* codes to equivalent glyph indices. */
+ /* */
+ /* For now, the implementation is very basic: Each node maps a range of */
+ /* 128 consecutive character codes to their correspondingglyph indices. */
+ /* */
+ /* We could do more complex things, but I don't think it is really very */
+ /* useful. */
+ /* */
+ /*************************************************************************/
- /* each FTC_CMapNode contains a simple array used to map a */
- /* range of character codes to equivalent glyph indices */
- /* */
- /* for now, the implementation is very basic: each node */
- /* maps a range of 128 consecutive character codes to their */
- /* correspondingglyph indices.. */
- /* */
- /* we could do more complex things, but I don't think it's */
- /* really very useful.. */
- /* */
+ /* number of glyph indices / character code per node */
+#define FTC_CMAP_INDICES_MAX 128
- /* number of glyph indices / character code per node */
-#define FTC_CMAP_INDICES_MAX 128
-
- typedef struct FTC_CMapNodeRec_
+ typedef struct FTC_CMapNodeRec_
{
FTC_NodeRec node;
- FT_UInt32 first; /* first character in node */
- FT_UInt16 indices[ FTC_CMAP_INDICES_MAX ]; /* array of glyph indices */
+ FT_UInt32 first; /* first character in node */
+ FT_UInt16 indices[FTC_CMAP_INDICES_MAX]; /* array of glyph indices */
} FTC_CMapNodeRec, *FTC_CMapNode;
-#define FTC_CMAP_NODE( x ) ((FTC_CMapNode)( x ))
- /* compute node hash value from cmap family and "requested" glyph index */
-#define FTC_CMAP_HASH(cfam,cquery) \
- ((cfam)->hash + ((cquery)->char_code/FTC_CMAP_INDICES_MAX))
+#define FTC_CMAP_NODE( x ) ( (FTC_CMapNode)( x ) )
- /* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */
- /* glyph indices hasn't been queried through @FT_Get_Glyph_Index yet.. */
- /* */
-#define FTC_CMAP_UNKNOWN ((FT_UInt16)-1)
+ /* compute node hash value from cmap family and "requested" glyph index */
+#define FTC_CMAP_HASH( cfam, cquery ) \
+ ( (cfam)->hash + ( (cquery)->char_code / FTC_CMAP_INDICES_MAX ) )
+ /* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */
+ /* glyph indices haven't been queried through FT_Get_Glyph_Index() yet */
+#define FTC_CMAP_UNKNOWN ( (FT_UInt16)-1 )
+
/* the charmap query */
- typedef struct FTC_CMapQueryRec_
+ typedef struct FTC_CMapQueryRec_
{
FTC_QueryRec query;
FTC_CMapDesc desc;
@@ -73,9 +74,10 @@
} FTC_CMapQueryRec, *FTC_CMapQuery;
-#define FTC_CMAP_QUERY( x ) ((FTC_CMapQuery)( x ))
+#define FTC_CMAP_QUERY( x ) ( (FTC_CMapQuery)( x ) )
+
/* the charmap family */
typedef struct FTC_CMapFamilyRec_
{
@@ -86,10 +88,11 @@
} FTC_CMapFamilyRec, *FTC_CMapFamily;
-#define FTC_CMAP_FAMILY( x ) ((FTC_CMapFamily)( x ))
-#define FTC_CMAP_FAMILY_MEMORY( x ) FTC_FAMILY(x)->memory
+#define FTC_CMAP_FAMILY( x ) ( (FTC_CMapFamily)( x ) )
+#define FTC_CMAP_FAMILY_MEMORY( x ) FTC_FAMILY( x )->memory
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -99,7 +102,7 @@
/*************************************************************************/
- /* no need for specific finalizer, we'll use "ftc_node_done" directly */
+ /* no need for specific finalizer; we use "ftc_node_done" directly */
/* initialize a new cmap node */
FT_CALLBACK_DEF( FT_Error )
@@ -112,7 +115,8 @@
FT_UNUSED( cache );
- first = (cquery->char_code / FTC_CMAP_INDICES_MAX) * FTC_CMAP_INDICES_MAX;
+ first = ( cquery->char_code / FTC_CMAP_INDICES_MAX ) *
+ FTC_CMAP_INDICES_MAX;
cnode->first = first;
for ( n = 0; n < FTC_CMAP_INDICES_MAX; n++ )
@@ -122,15 +126,15 @@
}
- /* compute the weight of a given cmap node */
+ /* compute the weight of a given cmap node */
FT_CALLBACK_DEF( FT_ULong )
ftc_cmap_node_weight( FTC_CMapNode cnode )
{
- return sizeof(*cnode);
+ return sizeof ( *cnode );
}
- /* compare a cmap node to a given query */
+ /* compare a cmap node to a given query */
FT_CALLBACK_DEF( FT_Bool )
ftc_cmap_node_compare( FTC_CMapNode cnode,
FTC_CMapQuery cquery )
@@ -166,7 +170,7 @@
/* setup charmap descriptor */
cfam->desc = *desc;
- /* let's see if the rest is correct too */
+ /* let's see whether the rest is correct too */
error = FTC_Manager_Lookup_Face( manager, desc->face_id, &face );
if ( !error )
{
@@ -173,44 +177,37 @@
FT_UInt count = face->num_charmaps;
FT_UInt index = count;
FT_CharMap* cur = face->charmaps;
-
+
+
switch ( desc->type )
{
- case FTC_CMAP_BY_INDEX:
- {
- index = desc->u.index;
- hash = index*33;
- break;
- }
+ case FTC_CMAP_BY_INDEX:
+ index = desc->u.index;
+ hash = index * 33;
+ break;
-
- case FTC_CMAP_BY_ENCODING:
- {
- for ( index = 0; index < count; index++, cur++ )
- if ( cur[0]->encoding == desc->u.encoding )
- break;
-
- hash = index*67;
+ case FTC_CMAP_BY_ENCODING:
+ for ( index = 0; index < count; index++, cur++ )
+ if ( cur[0]->encoding == desc->u.encoding )
break;
- }
+ hash = index * 67;
+ break;
- case FTC_CMAP_BY_ID:
+ case FTC_CMAP_BY_ID:
+ for ( index = 0; index < count; index++, cur++ )
+ {
+ if ( (FT_UInt)cur[0]->platform_id == desc->u.id.platform &&
+ (FT_UInt)cur[0]->encoding_id == desc->u.id.encoding )
{
- for ( index = 0; index < count; index++, cur++ )
- {
- if ( (FT_UInt) cur[0]->platform_id == desc->u.id.platform &&
- (FT_UInt) cur[0]->encoding_id == desc->u.id.encoding )
- {
- hash = ((desc->u.id.platform << 8) | desc->u.id.encoding)*7;
- break;
- }
- }
+ hash = ( ( desc->u.id.platform << 8 ) | desc->u.id.encoding ) * 7;
break;
}
+ }
+ break;
- default:
- ;
+ default:
+ ;
}
if ( index >= count )
@@ -217,23 +214,22 @@
goto Bad_Descriptor;
/* compute hash value, both in family and query */
- cfam->index = index;
- cfam->hash = hash ^ FTC_FACE_ID_HASH(desc->face_id);
- FTC_QUERY(cquery)->hash = FTC_CMAP_HASH(cfam,cquery);
+ cfam->index = index;
+ cfam->hash = hash ^ FTC_FACE_ID_HASH( desc->face_id );
+ FTC_QUERY( cquery )->hash = FTC_CMAP_HASH( cfam, cquery );
- error = ftc_family_init( FTC_FAMILY(cfam), FTC_QUERY(cquery), cache );
+ error = ftc_family_init( FTC_FAMILY( cfam ),
+ FTC_QUERY( cquery ), cache );
}
-
+
return error;
-
Bad_Descriptor:
- FT_ERROR(( "FreeType.cache.cmap.lookup: invalid charmap descriptor\n" ));
+ FT_ERROR(( "ftp_cmap_family_init: invalid charmap descriptor\n" ));
return FT_Err_Invalid_Argument;
}
-
FT_CALLBACK_DEF( FT_Bool )
ftc_cmap_family_compare( FTC_CMapFamily cfam,
FTC_CMapQuery cquery )
@@ -248,32 +244,32 @@
switch ( cfam->desc.type )
{
- case FTC_CMAP_BY_INDEX:
- result = ( cfam->desc.u.index == cquery->desc->u.index );
- break;
+ case FTC_CMAP_BY_INDEX:
+ result = ( cfam->desc.u.index == cquery->desc->u.index );
+ break;
- case FTC_CMAP_BY_ENCODING:
- result = ( cfam->desc.u.encoding == cquery->desc->u.encoding );
- break;
+ case FTC_CMAP_BY_ENCODING:
+ result = ( cfam->desc.u.encoding == cquery->desc->u.encoding );
+ break;
- case FTC_CMAP_BY_ID:
- result = ( cfam->desc.u.id.platform == cquery->desc->u.id.platform &&
- cfam->desc.u.id.encoding == cquery->desc->u.id.encoding );
- break;
+ case FTC_CMAP_BY_ID:
+ result = ( cfam->desc.u.id.platform == cquery->desc->u.id.platform &&
+ cfam->desc.u.id.encoding == cquery->desc->u.id.encoding );
+ break;
- default:
- ;
+ default:
+ ;
}
- if (result)
+ if ( result )
{
/* when found, update the 'family' and 'hash' field of the query */
- FTC_QUERY(cquery)->family = FTC_FAMILY(cfam);
- FTC_QUERY(cquery)->hash = FTC_CMAP_HASH(cfam,cquery);
+ FTC_QUERY( cquery )->family = FTC_FAMILY( cfam );
+ FTC_QUERY( cquery )->hash = FTC_CMAP_HASH( cfam, cquery );
}
Exit:
- return FT_BOOL(result);
+ return FT_BOOL( result );
}
@@ -286,25 +282,24 @@
/*************************************************************************/
-
FT_CALLBACK_TABLE_DEF
const FTC_Cache_ClassRec ftc_cmap_cache_class =
{
- sizeof( FTC_CacheRec ),
- (FTC_Cache_InitFunc) ftc_cache_init,
- (FTC_Cache_ClearFunc) ftc_cache_clear,
- (FTC_Cache_DoneFunc) ftc_cache_done,
+ sizeof ( FTC_CacheRec ),
+ (FTC_Cache_InitFunc) ftc_cache_init,
+ (FTC_Cache_ClearFunc)ftc_cache_clear,
+ (FTC_Cache_DoneFunc) ftc_cache_done,
- sizeof( FTC_CMapFamilyRec ),
- (FTC_Family_InitFunc) ftc_cmap_family_init,
- (FTC_Family_CompareFunc) ftc_cmap_family_compare,
- (FTC_Family_DoneFunc) ftc_family_done,
+ sizeof ( FTC_CMapFamilyRec ),
+ (FTC_Family_InitFunc) ftc_cmap_family_init,
+ (FTC_Family_CompareFunc)ftc_cmap_family_compare,
+ (FTC_Family_DoneFunc) ftc_family_done,
- sizeof( FTC_CMapNodeRec ),
- (FTC_Node_InitFunc) ftc_cmap_node_init,
- (FTC_Node_WeightFunc) ftc_cmap_node_weight,
- (FTC_Node_CompareFunc) ftc_cmap_node_compare,
- (FTC_Node_DoneFunc) ftc_node_done
+ sizeof ( FTC_CMapNodeRec ),
+ (FTC_Node_InitFunc) ftc_cmap_node_init,
+ (FTC_Node_WeightFunc) ftc_cmap_node_weight,
+ (FTC_Node_CompareFunc)ftc_cmap_node_compare,
+ (FTC_Node_DoneFunc) ftc_node_done
};
@@ -333,9 +328,10 @@
FT_Error error;
FT_UInt gindex = 0;
+
if ( !cache || !desc )
{
- FT_ERROR(( "FTC_CMapCache_Lookup: bad arguments, returning 0 !!\n" ));
+ FT_ERROR(( "FTC_CMapCache_Lookup: bad arguments, returning 0!\n" ));
return 0;
}
@@ -342,33 +338,35 @@
cquery.desc = desc;
cquery.char_code = char_code;
- error = ftc_cache_lookup( FTC_CACHE(cache),
- FTC_QUERY(&cquery),
- (FTC_Node*) &node );
+ error = ftc_cache_lookup( FTC_CACHE( cache ),
+ FTC_QUERY( &cquery ),
+ (FTC_Node*)&node );
if ( !error )
{
FT_UInt offset = (FT_UInt)( char_code - node->first );
+
gindex = node->indices[offset];
if ( gindex == FTC_CMAP_UNKNOWN )
{
- FT_Face face;
+ FT_Face face;
- /* we need to use @FT_Get_Char_Index */
+ /* we need to use FT_Get_Char_Index */
gindex = 0;
error = FTC_Manager_Lookup_Face( FTC_CACHE(cache)->manager,
desc->face_id,
&face );
- if (!error)
+ if ( !error )
{
- FT_CharMap old, cmap = NULL;
- FT_UInt cmap_index;
+ FT_CharMap old, cmap = NULL;
+ FT_UInt cmap_index;
+
/* save old charmap, select new one */
old = face->charmap;
- cmap_index = FTC_CMAP_FAMILY( FTC_QUERY(&cquery)->family )->index;
+ cmap_index = FTC_CMAP_FAMILY( FTC_QUERY( &cquery )->family )->index;
cmap = face->charmaps[cmap_index];
FT_Set_Charmap( face, cmap );
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -27,8 +27,6 @@
#include "ftcerror.h"
-
-
/* create a new chunk node, setting its cache index and ref count */
FT_EXPORT_DEF( void )
ftc_glyph_node_init( FTC_GlyphNode gnode,
@@ -35,17 +33,17 @@
FT_UInt gindex,
FTC_GlyphFamily gfam )
{
- FT_UInt len;
- FT_UInt start = FTC_GLYPH_FAMILY_START(gfam,gindex);
+ FT_UInt len;
+ FT_UInt start = FTC_GLYPH_FAMILY_START( gfam, gindex );
- gnode->item_start = (FT_UShort) start;
+ gnode->item_start = (FT_UShort)start;
len = gfam->item_total - start;
if ( len > gfam->item_count )
len = gfam->item_count;
- gnode->item_count = (FT_UShort) len;
+ gnode->item_count = (FT_UShort)len;
gfam->family.num_nodes++;
}
@@ -58,18 +56,18 @@
gnode->item_count = 0;
gnode->item_start = 0;
- ftc_node_done( FTC_NODE(gnode), cache );
+ ftc_node_done( FTC_NODE( gnode ), cache );
}
FT_EXPORT_DEF( FT_Bool )
- ftc_glyph_node_compare( FTC_GlyphNode gnode,
- FTC_GlyphQuery gquery )
+ ftc_glyph_node_compare( FTC_GlyphNode gnode,
+ FTC_GlyphQuery gquery )
{
- FT_UInt start = (FT_UInt) gnode->item_start;
- FT_UInt count = (FT_UInt) gnode->item_count;
+ FT_UInt start = (FT_UInt)gnode->item_start;
+ FT_UInt count = (FT_UInt)gnode->item_count;
- return FT_BOOL( (FT_UInt)(gquery->gindex - start) < count );
+ return FT_BOOL( (FT_UInt)( gquery->gindex - start ) < count );
}
@@ -93,14 +91,14 @@
FT_Error error;
- error = ftc_family_init( FTC_FAMILY(gfam), FTC_QUERY(gquery), cache );
- if (!error)
+ error = ftc_family_init( FTC_FAMILY( gfam ), FTC_QUERY( gquery ), cache );
+ if ( !error )
{
gfam->hash = hash;
gfam->item_total = item_total;
gfam->item_count = item_count;
- FTC_GLYPH_FAMILY_FOUND(gfam,gquery);
+ FTC_GLYPH_FAMILY_FOUND( gfam, gquery );
}
return error;
@@ -110,9 +108,8 @@
FT_EXPORT_DEF( void )
ftc_glyph_family_done( FTC_GlyphFamily gfam )
{
- ftc_family_done( FTC_FAMILY(gfam) );
+ ftc_family_done( FTC_FAMILY( gfam ) );
}
-
/* END */
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -37,7 +37,7 @@
} FTC_ImageNodeRec, *FTC_ImageNode;
-#define FTC_IMAGE_NODE( x ) ((FTC_ImageNode)( x ))
+#define FTC_IMAGE_NODE( x ) ( (FTC_ImageNode)( x ) )
#define FTC_IMAGE_NODE_GINDEX( x ) FTC_GLYPH_NODE_GINDEX( x )
@@ -49,8 +49,8 @@
} FTC_ImageQueryRec, *FTC_ImageQuery;
-#define FTC_IMAGE_QUERY(x) ((FTC_ImageQuery)(x))
+#define FTC_IMAGE_QUERY( x ) ( (FTC_ImageQuery)( x ) )
/* the glyph image set type */
@@ -62,8 +62,8 @@
} FTC_ImageFamilyRec, *FTC_ImageFamily;
-#define FTC_IMAGE_FAMILY( x ) ((FTC_ImageFamily)( x ))
-#define FTC_IMAGE_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &(x)->gfam )
+#define FTC_IMAGE_FAMILY( x ) ( (FTC_ImageFamily)( x ) )
+#define FTC_IMAGE_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &(x)->gfam )
/*************************************************************************/
@@ -85,11 +85,11 @@
FT_Done_Glyph( inode->glyph );
inode->glyph = NULL;
}
- ftc_glyph_node_done( FTC_GLYPH_NODE(inode), cache );
+
+ ftc_glyph_node_done( FTC_GLYPH_NODE( inode ), cache );
}
-
/* initialize a new glyph image node */
FT_CALLBACK_DEF( FT_Error )
ftc_image_node_init( FTC_ImageNode inode,
@@ -96,26 +96,26 @@
FTC_GlyphQuery gquery,
FTC_Cache cache )
{
- FTC_ImageFamily ifam = FTC_IMAGE_FAMILY( gquery->query.family );
- FT_Error error;
- FT_Face face;
- FT_Size size;
+ FTC_ImageFamily ifam = FTC_IMAGE_FAMILY( gquery->query.family );
+ FT_Error error;
+ FT_Face face;
+ FT_Size size;
/* initialize its inner fields */
- ftc_glyph_node_init( FTC_GLYPH_NODE(inode),
+ ftc_glyph_node_init( FTC_GLYPH_NODE( inode ),
gquery->gindex,
- FTC_GLYPH_FAMILY(ifam) );
+ FTC_GLYPH_FAMILY( ifam ) );
/* we will now load the glyph image */
- error = FTC_Manager_Lookup_Size( FTC_FAMILY(ifam)->cache->manager,
+ error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager,
&ifam->desc.font,
&face, &size );
if ( !error )
{
- FT_UInt gindex = FTC_GLYPH_NODE_GINDEX(inode);
- FT_UInt load_flags = FT_LOAD_DEFAULT;
- FT_UInt type = ifam->desc.type;
+ FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode );
+ FT_UInt load_flags = FT_LOAD_DEFAULT;
+ FT_UInt type = ifam->desc.type;
if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
@@ -242,11 +242,11 @@
&face );
if ( !error )
{
- error = ftc_glyph_family_init( FTC_GLYPH_FAMILY(ifam),
+ error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ),
FTC_IMAGE_DESC_HASH( &ifam->desc ),
1,
face->num_glyphs,
- FTC_GLYPH_QUERY(iquery),
+ FTC_GLYPH_QUERY( iquery ),
cache );
}
@@ -263,7 +263,7 @@
result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &ifam->desc, &iquery->desc ) );
if ( result )
- FTC_GLYPH_FAMILY_FOUND(ifam,iquery);
+ FTC_GLYPH_FAMILY_FOUND( ifam, iquery );
return result;
}
@@ -282,21 +282,21 @@
FT_CALLBACK_TABLE_DEF
const FTC_Cache_ClassRec ftc_image_cache_class =
{
- sizeof( FTC_CacheRec ),
- (FTC_Cache_InitFunc) ftc_cache_init,
- (FTC_Cache_ClearFunc) ftc_cache_clear,
- (FTC_Cache_DoneFunc) ftc_cache_done,
+ sizeof ( FTC_CacheRec ),
+ (FTC_Cache_InitFunc) ftc_cache_init,
+ (FTC_Cache_ClearFunc)ftc_cache_clear,
+ (FTC_Cache_DoneFunc) ftc_cache_done,
- sizeof( FTC_ImageFamilyRec ),
- (FTC_Family_InitFunc) ftc_image_family_init,
- (FTC_Family_CompareFunc) ftc_image_family_compare,
- (FTC_Family_DoneFunc) ftc_glyph_family_done,
+ sizeof ( FTC_ImageFamilyRec ),
+ (FTC_Family_InitFunc) ftc_image_family_init,
+ (FTC_Family_CompareFunc)ftc_image_family_compare,
+ (FTC_Family_DoneFunc) ftc_glyph_family_done,
- sizeof( FTC_ImageNodeRec ),
- (FTC_Node_InitFunc) ftc_image_node_init,
- (FTC_Node_WeightFunc) ftc_image_node_weight,
- (FTC_Node_CompareFunc) ftc_glyph_node_compare,
- (FTC_Node_DoneFunc) ftc_image_node_done
+ sizeof ( FTC_ImageNodeRec ),
+ (FTC_Node_InitFunc) ftc_image_node_init,
+ (FTC_Node_WeightFunc) ftc_image_node_weight,
+ (FTC_Node_CompareFunc)ftc_glyph_node_compare,
+ (FTC_Node_DoneFunc) ftc_image_node_done
};
@@ -339,17 +339,17 @@
iquery.gquery.gindex = gindex;
iquery.desc = *desc;
- error = ftc_cache_lookup( FTC_CACHE(cache),
- FTC_QUERY(&iquery),
- (FTC_Node*) &node );
+ error = ftc_cache_lookup( FTC_CACHE( cache ),
+ FTC_QUERY( &iquery ),
+ (FTC_Node*)&node );
if ( !error )
{
*aglyph = node->glyph;
- if (anode)
+ if ( anode )
{
*anode = (FTC_Node)node;
- FTC_NODE(node)->ref_count++;
+ FTC_NODE( node )->ref_count++;
}
}
@@ -357,9 +357,8 @@
}
+ /* backwards-compatibility functions */
- /* backwards-compatibility functions */
-
FT_EXPORT_DEF( FT_Error )
FTC_Image_Cache_New( FTC_Manager manager,
FTC_Image_Cache *acache )
@@ -376,11 +375,12 @@
{
FTC_ImageDesc desc0;
+
if ( !desc )
return FT_Err_Invalid_Argument;
desc0.font = desc->font;
- desc0.type = (FT_UInt32) desc->image_type;
+ desc0.type = (FT_UInt32)desc->image_type;
return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
&desc0,
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -62,9 +62,9 @@
FT_CALLBACK_DEF( FT_Error )
- ftc_face_node_init( FTC_FaceNode node,
- FTC_FaceID face_id,
- FTC_Manager manager )
+ ftc_face_node_init( FTC_FaceNode node,
+ FTC_FaceID face_id,
+ FTC_Manager manager )
{
FT_Error error;
@@ -84,7 +84,7 @@
}
- /* helper function for ftc_manager_done_face() */
+ /* helper function for ftc_face_node_done() */
FT_CALLBACK_DEF( FT_Bool )
ftc_size_node_select( FTC_SizeNode node,
FT_Face face )
@@ -116,8 +116,8 @@
const FT_LruList_ClassRec ftc_face_list_class =
{
sizeof ( FT_LruListRec ),
- (FT_LruList_InitFunc) 0,
- (FT_LruList_DoneFunc) 0,
+ (FT_LruList_InitFunc)0,
+ (FT_LruList_DoneFunc)0,
sizeof ( FTC_FaceNodeRec ),
(FT_LruNode_InitFunc) ftc_face_node_init,
@@ -156,7 +156,6 @@
}
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -258,8 +257,8 @@
const FT_LruList_ClassRec ftc_size_list_class =
{
sizeof ( FT_LruListRec ),
- (FT_LruList_InitFunc) 0,
- (FT_LruList_DoneFunc) 0,
+ (FT_LruList_InitFunc)0,
+ (FT_LruList_DoneFunc)0,
sizeof ( FTC_SizeNodeRec ),
(FT_LruNode_InitFunc) ftc_size_node_init,
@@ -269,7 +268,6 @@
};
-
/* documentation is in ftcache.h */
FT_EXPORT_DEF( FT_Error )
@@ -353,17 +351,19 @@
FTC_FamilyEntry entry;
FT_Error error = 0;
- /* re-allocate table size when needed */
+
+ /* re-allocate table size when needed */
if ( table->free == FTC_FAMILY_ENTRY_NONE && table->count >= table->size )
{
FT_UInt old_size = table->size;
FT_UInt new_size, index;
+
if ( old_size == 0 )
new_size = 8;
else
{
- new_size = old_size*2;
+ new_size = old_size * 2;
/* check for (unlikely) overflow */
if ( new_size < old_size )
@@ -370,7 +370,8 @@
new_size = 65534;
}
- if ( REALLOC_ARRAY( table->entries, old_size, new_size, FTC_FamilyEntryRec ) )
+ if ( REALLOC_ARRAY( table->entries, old_size, new_size,
+ FTC_FamilyEntryRec ) )
return error;
table->size = new_size;
@@ -378,9 +379,9 @@
entry = table->entries + old_size;
table->free = old_size;
- for ( index = old_size; index+1 < new_size; index++, entry++ )
+ for ( index = old_size; index + 1 < new_size; index++, entry++ )
{
- entry->link = index+1;
+ entry->link = index + 1;
entry->index = index;
}
@@ -399,7 +400,7 @@
}
else
{
- FT_ERROR(( "FreeType.cache.alloc_set: internal bug !!" ));
+ FT_ERROR(( "ftc_family_table_alloc: internal bug!" ));
return FT_Err_Invalid_Argument;
}
@@ -420,8 +421,9 @@
{
FTC_FamilyEntry entry = table->entries + index;
+
if ( entry->link != FTC_FAMILY_ENTRY_NONE )
- FT_ERROR(( "FreeType.cache.set_free: internal bug !!\n" ));
+ FT_ERROR(( "ftc_family_table_free: internal bug!\n" ));
else
{
entry->link = table->free;
@@ -569,10 +571,9 @@
}
-
-
#ifdef FT_DEBUG_ERROR
- FT_EXPORT_DEF(void)
+
+ FT_EXPORT_DEF( void )
FTC_Manager_Check( FTC_Manager manager )
{
FTC_Node node, first;
@@ -595,7 +596,7 @@
if ( (FT_UInt)node->fam_index >= manager->families.count ||
entry->link != FTC_FAMILY_ENTRY_NONE )
- FT_ERROR(( "FTC_Manager_Compress: invalid node (family index = %ld\n",
+ FT_ERROR(( "FTC_Manager_Check: invalid node (family index = %ld\n",
node->fam_index ));
else
{
@@ -604,13 +605,12 @@
}
node = node->mru_next;
- }
- while (node != first);
+ } while ( node != first );
+
if ( weight != manager->cur_weight )
- FT_ERROR((
- "FTC_Manager_Compress: invalid weight %ld instead of %ld\n",
- manager->cur_weight, weight ));
+ FT_ERROR(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n",
+ manager->cur_weight, weight ));
}
/* check circular list */
@@ -624,15 +624,16 @@
{
count++;
node = node->mru_next;
- }
- while (node != first);
+ } while ( node != first );
+
if ( count != manager->num_nodes )
FT_ERROR((
- "FTC_Manager_Compress: invalid cache node count %d instead of %d\n",
+ "FTC_Manager_Check: invalid cache node count %d instead of %d\n",
manager->num_nodes, count ));
}
}
+
#endif /* FT_DEBUG_ERROR */
@@ -682,6 +683,8 @@
}
+ /* documentation is in ftcmanag.h */
+
FT_EXPORT_DEF( FT_Error )
FTC_Manager_Register_Cache( FTC_Manager manager,
FTC_Cache_Class clazz,
@@ -746,12 +749,9 @@
}
+ /* documentation is in ftcmanag.h */
-
-
-
-
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
FTC_Node_Unref( FTC_Node node,
FTC_Manager manager )
{
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -32,17 +32,17 @@
#define FTC_SBIT_ITEMS_PER_NODE 16
- typedef struct FTC_SBitNodeRec_* FTC_SBitNode;
+ typedef struct FTC_SBitNodeRec_* FTC_SBitNode;
- typedef struct FTC_SBitNodeRec_
+ typedef struct FTC_SBitNodeRec_
{
- FTC_GlyphNodeRec gnode;
- FTC_SBitRec sbits[ FTC_SBIT_ITEMS_PER_NODE ];
+ FTC_GlyphNodeRec gnode;
+ FTC_SBitRec sbits[FTC_SBIT_ITEMS_PER_NODE];
} FTC_SBitNodeRec;
-#define FTC_SBIT_NODE(x) ((FTC_SBitNode)(x))
+#define FTC_SBIT_NODE( x ) ( (FTC_SBitNode)( x ) )
typedef struct FTC_SBitQueryRec_
@@ -52,13 +52,13 @@
} FTC_SBitQueryRec, *FTC_SBitQuery;
-#define FTC_SBIT_QUERY(x) ((FTC_SBitQuery)(x))
+#define FTC_SBIT_QUERY( x ) ( (FTC_SBitQuery)( x ) )
typedef struct FTC_SBitFamilyRec_* FTC_SBitFamily;
- /* sbit family structure */
+ /* sbit family structure */
typedef struct FTC_SBitFamilyRec_
{
FTC_GlyphFamilyRec gfam;
@@ -65,12 +65,12 @@
FTC_ImageDesc desc;
} FTC_SBitFamilyRec;
+
-#define FTC_SBIT_FAMILY( x ) ( (FTC_SBitFamily)(x) )
-#define FTC_SBIT_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &(x)->cset )
+#define FTC_SBIT_FAMILY( x ) ( (FTC_SBitFamily)( x ) )
+#define FTC_SBIT_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &( x )->cset )
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -102,13 +102,12 @@
}
-
FT_CALLBACK_DEF( void )
ftc_sbit_node_done( FTC_SBitNode snode,
FTC_Cache cache )
{
FTC_SBit sbit = snode->sbits;
- FT_UInt count = FTC_GLYPH_NODE(snode)->item_count;
+ FT_UInt count = FTC_GLYPH_NODE( snode )->item_count;
FT_Memory memory = cache->memory;
@@ -115,41 +114,42 @@
for ( ; count > 0; sbit++, count-- )
FREE( sbit->buffer );
- ftc_glyph_node_done( FTC_GLYPH_NODE(snode), cache );
+ ftc_glyph_node_done( FTC_GLYPH_NODE( snode ), cache );
}
static FT_Error
- ftc_sbit_node_load( FTC_SBitNode snode,
- FTC_Manager manager,
- FTC_SBitFamily sfam,
- FT_UInt gindex,
- FT_ULong *asize )
+ ftc_sbit_node_load( FTC_SBitNode snode,
+ FTC_Manager manager,
+ FTC_SBitFamily sfam,
+ FT_UInt gindex,
+ FT_ULong *asize )
{
- FT_Error error;
- FTC_GlyphNode gnode = FTC_GLYPH_NODE(snode);
- FT_Memory memory;
- FT_Face face;
- FT_Size size;
- FTC_SBit sbit;
+ FT_Error error;
+ FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode );
+ FT_Memory memory;
+ FT_Face face;
+ FT_Size size;
+ FTC_SBit sbit;
+
if ( gindex < (FT_UInt)gnode->item_start ||
gindex >= (FT_UInt)gnode->item_start + gnode->item_count )
{
- FT_ERROR(( "FreeType.cache.sbit_load: invalid glyph index" ));
+ FT_ERROR(( "ftc_sbit_node_load: invalid glyph index" ));
return FTC_Err_Invalid_Argument;
}
memory = manager->library->memory;
- sbit = snode->sbits + (gindex - gnode->item_start);
+ sbit = snode->sbits + ( gindex - gnode->item_start );
error = FTC_Manager_Lookup_Size( manager, &sfam->desc.font,
&face, &size );
if ( !error )
{
- FT_UInt load_flags = FT_LOAD_DEFAULT;
- FT_UInt type = sfam->desc.type;
+ FT_UInt load_flags = FT_LOAD_DEFAULT;
+ FT_UInt type = sfam->desc.type;
/* determine load flags, depending on the font description's */
@@ -167,7 +167,7 @@
else
{
FT_ERROR((
- "FreeType.cache.sbit_load: cannot load scalable glyphs in an"
+ "ftc_sbit_node_load: cannot load scalable glyphs in an"
" sbit cache, please check your arguments!\n" ));
error = FTC_Err_Invalid_Argument;
goto Exit;
@@ -215,14 +215,14 @@
CHECK_CHAR( xadvance ) &&
CHECK_CHAR( yadvance ) )
{
- sbit->width = (FT_Byte) bitmap->width;
- sbit->height = (FT_Byte) bitmap->rows;
- sbit->pitch = (FT_Char) bitmap->pitch;
- sbit->left = (FT_Char) slot->bitmap_left;
- sbit->top = (FT_Char) slot->bitmap_top;
- sbit->xadvance = (FT_Char) xadvance;
- sbit->yadvance = (FT_Char) yadvance;
- sbit->format = (FT_Byte) bitmap->pixel_mode;
+ sbit->width = (FT_Byte)bitmap->width;
+ sbit->height = (FT_Byte)bitmap->rows;
+ sbit->pitch = (FT_Char)bitmap->pitch;
+ sbit->left = (FT_Char)slot->bitmap_left;
+ sbit->top = (FT_Char)slot->bitmap_top;
+ sbit->xadvance = (FT_Char)xadvance;
+ sbit->yadvance = (FT_Char)yadvance;
+ sbit->format = (FT_Byte)bitmap->pixel_mode;
/* grab the bitmap when possible - this is a hack !! */
if ( slot->flags & ft_glyph_own_bitmap )
@@ -238,16 +238,16 @@
/* now, compute size */
if ( asize )
- *asize = ABS(sbit->pitch) * sbit->height;
+ *asize = ABS( sbit->pitch ) * sbit->height;
} /* glyph dimensions ok */
} /* glyph loading successful */
- /* ignore the errors that might have occurred -- */
- /* we recognize unloaded glyphs with `sbit.buffer == 0' */
- /* and 'width == 255', 'height == 0' */
- /* */
+ /* ignore the errors that might have occurred -- */
+ /* we mark unloaded glyphs with `sbit.buffer == 0' */
+ /* and 'width == 255', 'height == 0' */
+ /* */
if ( error )
{
sbit->width = 255;
@@ -268,17 +268,18 @@
{
FT_Error error;
- ftc_glyph_node_init( FTC_GLYPH_NODE(snode),
+
+ ftc_glyph_node_init( FTC_GLYPH_NODE( snode ),
gquery->gindex,
- FTC_GLYPH_FAMILY(gquery->query.family) );
+ FTC_GLYPH_FAMILY( gquery->query.family ) );
error = ftc_sbit_node_load( snode,
cache->manager,
- FTC_SBIT_FAMILY( FTC_QUERY(gquery)->family ),
+ FTC_SBIT_FAMILY( FTC_QUERY( gquery )->family ),
gquery->gindex,
NULL );
if ( error )
- ftc_glyph_node_done( FTC_GLYPH_NODE(snode), cache );
+ ftc_glyph_node_done( FTC_GLYPH_NODE( snode ), cache );
return error;
}
@@ -287,7 +288,7 @@
FT_CALLBACK_DEF( FT_ULong )
ftc_sbit_node_weight( FTC_SBitNode snode )
{
- FTC_GlyphNode gnode = FTC_GLYPH_NODE(snode);
+ FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode );
FT_UInt count = gnode->item_count;
FTC_SBit sbit = snode->sbits;
FT_Int pitch;
@@ -295,10 +296,10 @@
/* the node itself */
- size = sizeof ( *snode );
+ size = sizeof ( *snode );
/* the sbit records */
- size += FTC_GLYPH_NODE(snode)->item_count * sizeof ( FTC_SBitRec );
+ size += FTC_GLYPH_NODE( snode )->item_count * sizeof ( FTC_SBitRec );
for ( ; count > 0; count--, sbit++ )
{
@@ -322,25 +323,28 @@
FTC_SBitQuery squery,
FTC_Cache cache )
{
- FTC_GlyphQuery gquery = FTC_GLYPH_QUERY(squery);
- FTC_GlyphNode gnode = FTC_GLYPH_NODE(snode);
+ FTC_GlyphQuery gquery = FTC_GLYPH_QUERY( squery );
+ FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode );
FT_Bool result;
+
result = ftc_glyph_node_compare( gnode, gquery );
if ( result )
{
/* check if we need to load the glyph bitmap now */
FT_UInt gindex = gquery->gindex;
- FTC_SBit sbit = snode->sbits + (gindex - gnode->item_start);
+ FTC_SBit sbit = snode->sbits + ( gindex - gnode->item_start );
+
if ( sbit->buffer == NULL && sbit->width != 255 )
{
FT_ULong size;
+
/* yes, it's safe to ignore errors here */
ftc_sbit_node_load( snode,
cache->manager,
- FTC_SBIT_FAMILY( FTC_QUERY(squery)->family ),
+ FTC_SBIT_FAMILY( FTC_QUERY( squery )->family ),
gindex,
&size );
@@ -370,6 +374,7 @@
FT_Error error;
FT_Face face;
+
sfam->desc = squery->desc;
/* we need to compute "cquery.item_total" now */
@@ -378,11 +383,11 @@
&face );
if ( !error )
{
- error = ftc_glyph_family_init( FTC_GLYPH_FAMILY(sfam),
+ error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( sfam ),
FTC_IMAGE_DESC_HASH( &sfam->desc ),
FTC_SBIT_ITEMS_PER_NODE,
face->num_glyphs,
- FTC_GLYPH_QUERY(squery),
+ FTC_GLYPH_QUERY( squery ),
cache );
}
@@ -391,24 +396,23 @@
FT_CALLBACK_DEF( FT_Bool )
- ftc_sbit_family_compare( FTC_SBitFamily sfam,
- FTC_SBitQuery squery )
+ ftc_sbit_family_compare( FTC_SBitFamily sfam,
+ FTC_SBitQuery squery )
{
FT_Bool result;
/* we need to set the "cquery.cset" field or our query for */
- /* faster glyph comparisons in ftc_sbit_node_compare.. */
- /* */
+ /* faster glyph comparisons in ftc_sbit_node_compare */
+ /* */
result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sfam->desc, &squery->desc ) );
if ( result )
- FTC_GLYPH_FAMILY_FOUND(sfam,squery);
+ FTC_GLYPH_FAMILY_FOUND( sfam, squery );
return result;
}
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -418,25 +422,24 @@
/*************************************************************************/
-
FT_CALLBACK_TABLE_DEF
const FTC_Cache_ClassRec ftc_sbit_cache_class =
{
- sizeof( FTC_CacheRec ),
- (FTC_Cache_InitFunc) ftc_cache_init,
- (FTC_Cache_ClearFunc) ftc_cache_clear,
- (FTC_Cache_DoneFunc) ftc_cache_done,
+ sizeof ( FTC_CacheRec ),
+ (FTC_Cache_InitFunc) ftc_cache_init,
+ (FTC_Cache_ClearFunc)ftc_cache_clear,
+ (FTC_Cache_DoneFunc) ftc_cache_done,
- sizeof( FTC_SBitFamilyRec ),
- (FTC_Family_InitFunc) ftc_sbit_family_init,
- (FTC_Family_CompareFunc) ftc_sbit_family_compare,
- (FTC_Family_DoneFunc) ftc_glyph_family_done,
+ sizeof ( FTC_SBitFamilyRec ),
+ (FTC_Family_InitFunc) ftc_sbit_family_init,
+ (FTC_Family_CompareFunc)ftc_sbit_family_compare,
+ (FTC_Family_DoneFunc) ftc_glyph_family_done,
- sizeof( FTC_SBitNodeRec ),
- (FTC_Node_InitFunc) ftc_sbit_node_init,
- (FTC_Node_WeightFunc) ftc_sbit_node_weight,
- (FTC_Node_CompareFunc) ftc_sbit_node_compare,
- (FTC_Node_DoneFunc) ftc_sbit_node_done
+ sizeof ( FTC_SBitNodeRec ),
+ (FTC_Node_InitFunc) ftc_sbit_node_init,
+ (FTC_Node_WeightFunc) ftc_sbit_node_weight,
+ (FTC_Node_CompareFunc)ftc_sbit_node_compare,
+ (FTC_Node_DoneFunc) ftc_sbit_node_done
};
@@ -465,7 +468,8 @@
FTC_SBitQueryRec squery;
FTC_SBitNode node;
- /* argument checks delayed to ftc_cache_lookup */
+
+ /* other argument checks delayed to ftc_cache_lookup */
if ( !ansbit )
return FTC_Err_Invalid_Argument;
@@ -477,17 +481,17 @@
squery.gquery.gindex = gindex;
squery.desc = *desc;
- error = ftc_cache_lookup( FTC_CACHE(cache),
- FTC_QUERY(&squery),
- (FTC_Node*) &node );
+ error = ftc_cache_lookup( FTC_CACHE( cache ),
+ FTC_QUERY( &squery ),
+ (FTC_Node*)&node );
if ( !error )
{
- *ansbit = node->sbits + (gindex - FTC_GLYPH_NODE(node)->item_start);
+ *ansbit = node->sbits + ( gindex - FTC_GLYPH_NODE( node )->item_start );
if ( anode )
{
- *anode = FTC_NODE(node);
- FTC_NODE(node)->ref_count ++;
+ *anode = FTC_NODE( node );
+ FTC_NODE( node )->ref_count++;
}
}
return error;
@@ -494,9 +498,8 @@
}
+ /* backwards-compatibility functions */
- /* backwards-compatibility functions */
-
FT_EXPORT_DEF( FT_Error )
FTC_SBit_Cache_New( FTC_Manager manager,
FTC_SBit_Cache *acache )
@@ -513,11 +516,12 @@
{
FTC_ImageDesc desc0;
+
if ( !desc )
return FT_Err_Invalid_Argument;
desc0.font = desc->font;
- desc0.type = (FT_UInt32) desc->image_type;
+ desc0.type = (FT_UInt32)desc->image_type;
return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
&desc0,
@@ -525,7 +529,6 @@
ansbit,
NULL );
}
-
/* END */
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -46,7 +46,7 @@
list->clazz = clazz;
list->memory = memory;
list->max_nodes = max_nodes;
- list->data = user_data;
+ list->data = user_data;
if ( clazz->list_init )
{