[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: |
Sun, 15 May 2016 11:38:18 +0900 |
User-agent: |
Mozilla-Thunderbird 2.0.0.24 (X11/20100329) |
Dear Khaled,
Thank you for providing another example. It seems that
oriya.ttf is really including a recursive reference
(gid=8 refers gid=64 & gid=8).
I updated the simplest fix in my hand. I was going to
commit it to head of git repository, but savannah is
in some network trouble. Attached is the patch, but
if anybody wants, I will make a "make dist" tarball
which is ready to "./configure && make". please let me
know.
Also I have more complex patch using same strategy but
do not rely on arbitrary usage of GID. I think the
current patch would work on the platforms whose default
pointer is 32-bit. For the platform whose default pointer
is 16-bit or shorter, some fonts having 64k glyphs can
confuse the simplest fix.
Regards,
mpsuzuki
Khaled Hosny wrote:
On Tue, May 10, 2016 at 08:32:48PM +0900, suzuki toshiya wrote:
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.
I can not comment on the code, but I confirm this patch fixes the issue
for DejaVu fonts. However I’m having a similar issues with oriya.ttf
font from http://www.indlinux.org/downloads/files/indic-otf-0.2.tar.gz:
$ FT2_DEBUG="any:2" ftview -m ଅ 100 oriya.ttf
Gives the same error, but I can’t ttx the font so it might be broken.
Regards,
Khaled
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/sfnt/ttload.c b/src/sfnt/ttload.c
index 2f5b2c3..64ab1ed 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -787,6 +787,11 @@
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
+ if ( maxProfile->numGlyphs > ULONG_MAX )
+ {
+ FT_TRACE3(( " max gid exceeds ULONG_MAX,"
+ " some validations could not work correctly\n" ));
+ }
Exit:
return error;
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index c4038ee..b656285 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*)ULONG_MAX;
+
+
/* 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*)(unsigned long)glyph_index;
+ }
else
{
- FT_ListNode node = NULL;
-
-
if ( FT_NEW( node ) )
goto Exit;
node->data = (void*)(unsigned long)glyph_index;
Re: [ft] Failure in loading U+033F in DejaVu fonts, Khaled Hosny, 2016/05/10