freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Failure in loading U+033F in DejaVu fonts


From: suzuki toshiya
Subject: Re: [ft] Failure in loading U+033F in DejaVu fonts
Date: Tue, 10 May 2016 20:32:48 +0900
User-agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100329)

Dear Werner,

> Should I consider overwriting (and extend if required)
> storategy, to minimize the memory management?

If we can assume the recurse_count in load_truetype_glyph()
is always incrementally changed, it is possible to use
the index of the node to record the recurse_count.
This assumption reduces the size of the patch.

To reduce the repeated allocation & freeing the node,
I fill the unused nodes by gid = -1.

Regards,
mpsuzuki

diff --git a/include/freetype/ftlist.h b/include/freetype/ftlist.h
index 82f437a..062a7b6 100644
--- a/include/freetype/ftlist.h
+++ b/include/freetype/ftlist.h
@@ -65,6 +65,7 @@ FT_BEGIN_HEADER
   /*    FT_List_Add                                                        */
   /*    FT_List_Insert                                                     */
   /*    FT_List_Find                                                       */
+  /*    FT_List_GetNodeAt                                                  */
   /*    FT_List_Remove                                                     */
   /*    FT_List_Up                                                         */
   /*    FT_List_Iterate                                                    */
@@ -98,6 +99,26 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
+  /*    FT_List_GetNodeAt                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Find the list node for a given index, counted from the head.       */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    list :: A pointer to the parent list.                              */
+  /*    index :: The index of the node, counted from the head.             */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    List node.  NULL if it wasn't found.                               */
+  /*                                                                       */
+  FT_EXPORT( FT_ListNode )
+  FT_List_GetNodeAt( FT_List  list,
+                     FT_UInt  index );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
   /*    FT_List_Add                                                        */
   /*                                                                       */
   /* <Description>                                                         */
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index fad7d1a..14ba37c 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -263,6 +263,30 @@
 
   /* documentation is in ftlist.h */
 
+  FT_EXPORT_DEF( FT_ListNode )
+  FT_List_GetNodeAt( FT_List  list,
+                     FT_UInt  index )
+  {
+    FT_ListNode  cur;
+
+
+    if ( !list )
+      return NULL;
+
+    for ( cur = list->head; cur; cur = cur->next )
+    {
+      if ( !index )
+        return cur;
+
+      index --;
+    }
+
+    return NULL;
+  }
+
+
+  /* documentation is in ftlist.h */
+
   FT_EXPORT_DEF( void )
   FT_List_Add( FT_List      list,
                FT_ListNode  node )
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index c4038ee..ecb0bb6 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1640,6 +1640,7 @@
       FT_UInt   start_point;
       FT_UInt   start_contour;
       FT_ULong  ins_pos;  /* position of composite instructions, if any */
+      FT_ListNode  node, node2;
 
 
       /*
@@ -1649,6 +1650,14 @@
        * pointers with a width of at least 32 bits.
        */
 
+
+      /* clear the nodes filled by sibling chains */
+      node = FT_List_GetNodeAt( &loader->composites, recurse_count );
+
+      for ( node2 = node ; node2 ; node2 = node2->next )
+        node2->data = (void*)(-1);
+
+
       /* check whether we already have a composite glyph with this index */
       if ( FT_List_Find( &loader->composites,
                          (void*)(unsigned long)glyph_index ) )
@@ -1658,11 +1667,12 @@
         error = FT_THROW( Invalid_Composite );
         goto Exit;
       }
+      else if ( node )
+      {
+        node->data = (void*)glyph_index;
+      }
       else
       {
-        FT_ListNode  node = NULL;
-
-
         if ( FT_NEW( node ) )
           goto Exit;
         node->data = (void*)(unsigned long)glyph_index;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]