shithub: freetype+ttf2subf

Download patch

ref: b83239b7fdd6c3a086dd9ee09a73b9b03161fa80
parent: 819cbb8aa7da8c1eca1ec71a7258fb6d06a2a8e6
author: David Turner <[email protected]>
date: Wed Jun 9 17:07:49 EDT 2004

* include/freetype/cache/ftcmru.h, src/cache/ftcbasic.c,
        src/cache/ftccache.c, src/cache/ftcglyph.c, src/cache/ftcmanag.c,
        src/cache/ftcsbits.c:
        fixing some annoying bugs and inefficiencies in the cache sub-system.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,12 @@
         slot->metrics.width and slot->metrics.height when loading a Windows
         FNT glyph. Thanks to Huw Davies
 
+        * include/freetype/cache/ftcmru.h, src/cache/ftcbasic.c,
+        src/cache/ftccache.c, src/cache/ftcglyph.c, src/cache/ftcmanag.c,
+        src/cache/ftcsbits.c:
+        fixing some annoying bugs and inefficiencies in the cache sub-system.
+
+
 2004-06-05  Werner Lemberg  <[email protected]>
 
 	* src/autofit/afloader.c (af_loader_load_g): Set `lsb_delta' and
--- a/include/freetype/cache/ftcmru.h
+++ b/include/freetype/cache/ftcmru.h
@@ -86,7 +86,7 @@
   typedef struct FTC_MruListClassRec_ const *  FTC_MruListClass;
 
 
-  typedef FT_Int
+  typedef FT_Bool
   (*FTC_MruNode_CompareFunc)( FTC_MruNode  node,
                               FT_Pointer   key );
 
@@ -154,8 +154,8 @@
   FTC_MruList_Lookup( FTC_MruList   list,
                       FT_Pointer    key,
                       FTC_MruNode  *pnode );
-                      
 
+
   FT_EXPORT( void )
   FTC_MruList_Remove( FTC_MruList  list,
                       FTC_MruNode  node );
@@ -208,7 +208,7 @@
 #else  /* !FTC_INLINE */
 
 #define FTC_MRULIST_LOOKUP( list, key, node, error ) \
-  error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) ) 
+  error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) )
 
 #endif /* !FTC_INLINE */
 
--- a/src/cache/ftcbasic.c
+++ b/src/cache/ftcbasic.c
@@ -62,7 +62,7 @@
   } FTC_BasicFamilyRec, *FTC_BasicFamily;
 
 
-  FT_CALLBACK_DEF( FT_Int )
+  FT_CALLBACK_DEF( FT_Bool )
   ftc_basic_family_compare( FTC_MruNode  ftcfamily,
                             FT_Pointer   ftcquery )
   {
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -304,6 +304,13 @@
   FT_EXPORT_DEF( FT_Error )
   FTC_Cache_Init( FTC_Cache  cache )
   {
+    return ftc_cache_init( cache );
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
+  ftc_cache_init( FTC_Cache  cache )
+  {
     FT_Memory  memory = cache->memory;
 
 
@@ -315,13 +322,6 @@
   }
 
 
-  FT_LOCAL_DEF( FT_Error )
-  ftc_cache_init( FTC_Cache  cache )
-  {
-    return FTC_Cache_Init( cache );
-  }
-
-
   FT_EXPORT_DEF( void )
   FTC_Cache_Clear( FTC_Cache  cache )
   {
@@ -360,8 +360,8 @@
   }
 
 
-  FT_EXPORT_DEF( void )
-  FTC_Cache_Done( FTC_Cache  cache )
+  FT_LOCAL_DEF( void )
+  ftc_cache_done( FTC_Cache  cache )
   {
     if ( cache->memory )
     {
@@ -380,10 +380,10 @@
   }
 
 
-  FT_LOCAL_DEF( void )
-  ftc_cache_done( FTC_Cache  cache )
+  FT_EXPORT_DEF( void )
+  FTC_Cache_Done( FTC_Cache  cache )
   {
-    FTC_Cache_Done( cache );
+    ftc_cache_done( cache );
   }
 
 
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -64,15 +64,6 @@
   }
 
 
-  FT_EXPORT_DEF( FT_Bool )
-  FTC_GNode_Compare( FTC_GNode   gnode,
-                     FTC_GQuery  gquery )
-  {
-    return FT_BOOL(  gnode->family == gquery->family &&
-                     gnode->gindex == gquery->gindex );
-  }
-
-
   FT_LOCAL_DEF( FT_Bool )
   ftc_gnode_compare( FTC_Node    ftcgnode,
                      FT_Pointer  ftcgquery,
@@ -82,8 +73,16 @@
     FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
     FT_UNUSED( cache );
 
+    return FT_BOOL(  gnode->family == gquery->family &&
+                     gnode->gindex == gquery->gindex );
+  }
 
-    return FTC_GNode_Compare( gnode, gquery );
+
+  FT_EXPORT_DEF( FT_Bool )
+  FTC_GNode_Compare( FTC_GNode   gnode,
+                     FTC_GQuery  gquery )
+  {
+    return ftc_gnode_compare( FTC_NODE(gnode), gquery, NULL );
   }
 
 
@@ -108,10 +107,11 @@
   }
 
 
-  FT_EXPORT_DEF( FT_Error )
-  FTC_GCache_Init( FTC_GCache  cache )
+  FT_LOCAL_DEF( FT_Error )
+  ftc_gcache_init( FTC_Cache  ftccache )
   {
-    FT_Error error;
+    FTC_GCache  cache = (FTC_GCache)ftccache;
+    FT_Error    error;
 
     error = FTC_Cache_Init( FTC_CACHE( cache ) );
     if ( !error )
@@ -129,13 +129,10 @@
   }
 
 
-  FT_LOCAL_DEF( FT_Error )
-  ftc_gcache_init( FTC_Cache  ftccache )
+  FT_EXPORT_DEF( FT_Error )
+  FTC_GCache_Init( FTC_GCache  cache )
   {
-    FTC_GCache  cache = (FTC_GCache)ftccache;
-
-
-    return FTC_GCache_Init( cache );
+    return ftc_gcache_init( FTC_CACHE(cache) );
   }
 
 
@@ -142,8 +139,7 @@
   FT_EXPORT_DEF( void )
   FTC_GCache_Done( FTC_GCache  cache )
   {
-    FTC_Cache_Done( (FTC_Cache)cache );
-    FTC_MruList_Done( &cache->families );
+    return ftc_gcache_done( FTC_CACHE(cache) );
   }
 
 
@@ -153,7 +149,8 @@
     FTC_GCache  cache = (FTC_GCache)ftccache;
 
 
-    FTC_GCache_Done( cache );
+    FTC_Cache_Done( (FTC_Cache)cache );
+    FTC_MruList_Done( &cache->families );
   }
 
 
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -26,10 +26,11 @@
 
 
   /* finalize a given glyph image node */
-  FT_EXPORT_DEF( void )
-  FTC_INode_Free( FTC_INode  inode,
+  FT_LOCAL_DEF( void )
+  ftc_inode_free( FTC_Node   ftcinode,
                   FTC_Cache  cache )
   {
+    FTC_INode  inode = (FTC_INode)ftcinode;
     FT_Memory  memory = cache->memory;
 
 
@@ -44,14 +45,13 @@
   }
 
 
-  FT_LOCAL_DEF( void )
-  ftc_inode_free( FTC_Node   ftcinode,
-                  FTC_Cache  cache )
-  {
-    FTC_INode  inode = (FTC_INode)ftcinode;
 
 
-    FTC_INode_Free( inode, cache );
+  FT_EXPORT_DEF( void )
+  FTC_INode_Free( FTC_INode  inode,
+                  FTC_Cache  cache )
+  {
+    ftc_inode_free( FTC_NODE(inode), cache );
   }
 
 
@@ -100,12 +100,15 @@
   }
 
 
-  FT_EXPORT_DEF( FT_ULong )
-  FTC_INode_Weight( FTC_INode  inode )
+  FT_LOCAL_DEF( FT_ULong )
+  ftc_inode_weight( FTC_Node   ftcinode,
+                    FTC_Cache  ftccache )
   {
-    FT_ULong  size  = 0;
-    FT_Glyph  glyph = inode->glyph;
+    FTC_INode  inode = (FTC_INode)ftcinode;
+    FT_ULong   size  = 0;
+    FT_Glyph   glyph = inode->glyph;
 
+    FT_UNUSED(ftccache);
 
     switch ( glyph->format )
     {
@@ -142,15 +145,12 @@
   }
 
 
-  FT_LOCAL_DEF( FT_ULong )
-  ftc_inode_weight( FTC_Node   ftcinode,
-                    FTC_Cache  ftccache )
-  {
-    FTC_INode  inode = (FTC_INode)ftcinode;
-    FT_UNUSED( ftccache );
 
 
-    return FTC_INode_Weight( inode );
+  FT_EXPORT_DEF( FT_ULong )
+  FTC_INode_Weight( FTC_INode  inode )
+  {
+    return ftc_inode_weight( FTC_NODE(inode), NULL );
   }
 
 
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -92,7 +92,7 @@
   }
 
 
-  FT_CALLBACK_DEF( FT_Int )
+  FT_CALLBACK_DEF( FT_Bool )
   ftc_size_node_compare( FTC_MruNode  ftcnode,
                          FT_Pointer   ftcscaler )
   {
@@ -156,7 +156,7 @@
 
 
   /* helper function used by ftc_face_node_done */
-  static FT_Int
+  static FT_Bool
   ftc_size_node_compare_faceid( FTC_MruNode  ftcnode,
                                 FT_Pointer   ftcface_id )
   {
@@ -269,7 +269,7 @@
   }
 
 
-  FT_CALLBACK_DEF( FT_Int )
+  FT_CALLBACK_DEF( FT_Bool )
   ftc_face_node_compare( FTC_MruNode  ftcnode,
                          FT_Pointer   ftcface_id )
   {
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -58,10 +58,11 @@
   }
 
 
-  FT_EXPORT_DEF( void )
-  FTC_SNode_Free( FTC_SNode  snode,
+  FT_LOCAL_DEF( void )
+  ftc_snode_free( FTC_Node   ftcsnode,
                   FTC_Cache  cache )
   {
+    FTC_SNode  snode  = (FTC_SNode)ftcsnode;
     FTC_SBit   sbit   = snode->sbits;
     FT_UInt    count  = snode->count;
     FT_Memory  memory = cache->memory;
@@ -76,14 +77,13 @@
   }
 
 
-  FT_LOCAL_DEF( void )
-  ftc_snode_free( FTC_Node   ftcsnode,
-                  FTC_Cache  cache )
-  {
-    FTC_SNode  snode = (FTC_SNode)ftcsnode;
 
 
-    FTC_SNode_Free( snode, cache );
+  FT_EXPORT_DEF( void )
+  FTC_SNode_Free( FTC_SNode  snode,
+                  FTC_Cache  cache )
+  {
+    ftc_snode_free( FTC_NODE(snode), cache );
   }
 
 
@@ -255,14 +255,17 @@
   }
 
 
-  FT_EXPORT_DEF( FT_ULong )
-  FTC_SNode_Weight( FTC_SNode  snode )
+  FT_LOCAL_DEF( FT_ULong )
+  ftc_snode_weight( FTC_Node   ftcsnode,
+                    FTC_Cache  cache )
   {
+    FTC_SNode  snode = (FTC_SNode)ftcsnode;
     FT_UInt    count = snode->count;
     FTC_SBit   sbit  = snode->sbits;
     FT_Int     pitch;
     FT_ULong   size;
 
+    FT_UNUSED( cache );
 
     FT_ASSERT( snode->count <= FTC_SBIT_ITEMS_PER_NODE );
 
@@ -286,26 +289,23 @@
   }
 
 
-  FT_LOCAL_DEF( FT_ULong )
-  ftc_snode_weight( FTC_Node   ftcsnode,
-                    FTC_Cache  cache )
+  FT_EXPORT_DEF( FT_ULong )
+  FTC_SNode_Weight( FTC_SNode  snode )
   {
-    FTC_SNode  snode = (FTC_SNode)ftcsnode;
-    FT_UNUSED( cache );
-
-
-    return FTC_SNode_Weight( snode );
+    return ftc_snode_weight( FTC_NODE(snode), NULL );
   }
 
 
-  FT_EXPORT_DEF( FT_Bool )
-  FTC_SNode_Compare( FTC_SNode   snode,
-                     FTC_GQuery  gquery,
+  FT_LOCAL_DEF( FT_Bool )
+  ftc_snode_compare( FTC_Node    ftcsnode,
+                     FT_Pointer  ftcgquery,
                      FTC_Cache   cache )
   {
-    FTC_GNode  gnode  = FTC_GNODE( snode );
-    FT_UInt    gindex = gquery->gindex;
-    FT_Bool    result;
+    FTC_SNode   snode  = (FTC_SNode)ftcsnode;
+    FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
+    FTC_GNode   gnode  = FTC_GNODE( snode );
+    FT_UInt     gindex = gquery->gindex;
+    FT_Bool     result;
 
 
     result = FT_BOOL( gnode->family == gquery->family                    &&
@@ -333,16 +333,14 @@
   }
 
 
-  FT_LOCAL_DEF( FT_Bool )
-  ftc_snode_compare( FTC_Node    ftcsnode,
-                     FT_Pointer  ftcgquery,
-                     FTC_Cache   cache )
-  {
-    FTC_SNode   snode  = (FTC_SNode)ftcsnode;
-    FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
 
 
-    return FTC_SNode_Compare( snode, gquery, cache );
+  FT_EXPORT_DEF( FT_Bool )
+  FTC_SNode_Compare( FTC_SNode   snode,
+                     FTC_GQuery  gquery,
+                     FTC_Cache   cache )
+  {
+    return ftc_snode_compare( FTC_NODE(snode), gquery, cache );
   }