shithub: freetype+ttf2subf

Download patch

ref: ad289d139f90bd9f439fdcde151127a2912f8834
parent: 24370d67f59a81b4fbc802a8a2abe3ae3e8b0c8b
author: suzuki toshiya <[email protected]>
date: Sun Jun 28 23:09:17 EDT 2009

ftpatent: Fix a bug by wrong usage of service->table_info().

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-06-28  suzuki toshiya  <[email protected]>
+
+	ftpatent: Fix a bug by wrong usage of service->table_info().
+	http://lists.gnu.org/archive/html/freetype-devel/2008-12/msg00039.html
+
+	* include/freetype/internal/services/svsfnt.h: Extend
+	FT_SFNT_TableInfoFunc() to take new argument to obtain the offset
+	to the specified table.
+	* src/sfnt/sfdriver.c (sfnt_table_info): Extend to return the
+	table-offset to the caller function.
+	* src/base/ftpatent.c (_tt_check_patents_in_table): Use new
+	service->table_info().
+	* src/base/ftobjs.c (FT_Sfnt_Table_Info): Synchronize to new
+	service->table_info().
+
 2009-06-28  Werner Lemberg  <[email protected]>
 
 	[psaux, cff] Protect against nested `seac' calls.
--- a/include/freetype/internal/services/svsfnt.h
+++ b/include/freetype/internal/services/svsfnt.h
@@ -58,6 +58,7 @@
   (*FT_SFNT_TableInfoFunc)( FT_Face    face,
                             FT_UInt    idx,
                             FT_ULong  *tag,
+                            FT_ULong  *offset,
                             FT_ULong  *length );
 
 
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3397,6 +3397,7 @@
                       FT_ULong  *length )
   {
     FT_Service_SFNT_Table  service;
+    FT_ULong               offset;
 
 
     if ( !face || !FT_IS_SFNT( face ) )
@@ -3406,7 +3407,7 @@
     if ( service == NULL )
       return FT_Err_Unimplemented_Feature;
 
-    return service->table_info( face, table_index, tag, length );
+    return service->table_info( face, table_index, tag, &offset, length );
   }
 
 
--- a/src/base/ftpatent.c
+++ b/src/base/ftpatent.c
@@ -113,7 +113,7 @@
                               FT_ULong  tag )
   {
     FT_Stream              stream = face->stream;
-    FT_Error               error;
+    FT_Error               error = FT_Err_Ok;
     FT_Service_SFNT_Table  service;
     FT_Bool                result = FALSE;
 
@@ -122,15 +122,18 @@
 
     if ( service )
     {
-      FT_ULong  offset, size;
+      FT_UInt   i = 0;
+      FT_ULong  tag_i = 0, offset_i, length_i;
 
+      for ( i = 0; !error && tag_i != tag ; i++ )
+        error = service->table_info( face, i,
+                                     &tag_i, &offset_i, &length_i );
 
-      error = service->table_info( face, tag, &offset, &size );
       if ( error                    ||
-           FT_STREAM_SEEK( offset ) )
+           FT_STREAM_SEEK( offset_i ) )
         goto Exit;
 
-      result = _tt_check_patents_in_range( stream, size );
+      result = _tt_check_patents_in_range( stream, length_i );
     }
 
   Exit:
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -104,9 +104,10 @@
   sfnt_table_info( TT_Face    face,
                    FT_UInt    idx,
                    FT_ULong  *tag,
+                   FT_ULong  *offset,
                    FT_ULong  *length )
   {
-    if ( !tag || !length )
+    if ( !tag || !offset || !length )
       return SFNT_Err_Invalid_Argument;
 
     if ( idx >= face->num_tables )
@@ -113,6 +114,7 @@
       return SFNT_Err_Table_Missing;
 
     *tag    = face->dir_tables[idx].Tag;
+    *offset = face->dir_tables[idx].Offset;
     *length = face->dir_tables[idx].Length;
 
     return SFNT_Err_Ok;