Commit a577bbcb5bd895b74c690f5d3eb640330d2fee68

Alexei Podtelezhnikov 2021-10-27T22:24:27

[woff2] Optimize table tagging. Fixes #1107. * include/freetype/internal/wofftypes.h (WOFF2_TableRec): Use 32-bit tag. * src/sfnt/sfwoff2.c (compare_tags, find_table, woff2_open_font): Use 32-bit tag. * src/sfnt/woff2tags.[ch] (woff2_known_tags): Use static storage and return 32-bit tag.

diff --git a/include/freetype/internal/wofftypes.h b/include/freetype/internal/wofftypes.h
index 367fdb7..217e799 100644
--- a/include/freetype/internal/wofftypes.h
+++ b/include/freetype/internal/wofftypes.h
@@ -191,7 +191,7 @@ FT_BEGIN_HEADER
   typedef struct  WOFF2_TableRec_
   {
     FT_Byte   FlagByte;           /* table type and flags      */
-    FT_ULong  Tag;                /* table file offset         */
+    FT_Tag    Tag;                /* table file offset         */
     FT_ULong  dst_length;         /* uncompressed table length */
     FT_ULong  TransformLength;    /* transformed length        */
 
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
index df04072..7041b75 100644
--- a/src/sfnt/sfwoff2.c
+++ b/src/sfnt/sfwoff2.c
@@ -108,8 +108,8 @@
     WOFF2_Table  table1 = *(WOFF2_Table*)a;
     WOFF2_Table  table2 = *(WOFF2_Table*)b;
 
-    FT_ULong  tag1 = table1->Tag;
-    FT_ULong  tag2 = table2->Tag;
+    FT_Tag  tag1 = table1->Tag;
+    FT_Tag  tag2 = table2->Tag;
 
 
     if ( tag1 > tag2 )
@@ -356,7 +356,7 @@
   static WOFF2_Table
   find_table( WOFF2_Table*  tables,
               FT_UShort     num_tables,
-              FT_ULong      tag )
+              FT_Tag        tag )
   {
     FT_Int  i;
 
@@ -2216,7 +2216,7 @@
     /* reject fonts that have multiple tables with the same tag */
     for ( nn = 1; nn < woff2.num_tables; nn++ )
     {
-      FT_ULong  tag = indices[nn]->Tag;
+      FT_Tag  tag = indices[nn]->Tag;
 
 
       if ( tag == indices[nn - 1]->Tag )
diff --git a/src/sfnt/woff2tags.c b/src/sfnt/woff2tags.c
index 8474826..a299822 100644
--- a/src/sfnt/woff2tags.c
+++ b/src/sfnt/woff2tags.c
@@ -28,10 +28,10 @@
    *
    * for details.
    */
-  FT_LOCAL_DEF( FT_ULong )
+  FT_LOCAL_DEF( FT_Tag )
   woff2_known_tags( FT_Byte  index )
   {
-    const FT_ULong  known_tags[63] =
+    static const FT_Tag  known_tags[63] =
     {
       FT_MAKE_TAG('c', 'm', 'a', 'p'),  /*  0  */
       FT_MAKE_TAG('h', 'e', 'a', 'd'),  /*  1  */
diff --git a/src/sfnt/woff2tags.h b/src/sfnt/woff2tags.h
index 543daf8..12db9cc 100644
--- a/src/sfnt/woff2tags.h
+++ b/src/sfnt/woff2tags.h
@@ -27,7 +27,7 @@
 FT_BEGIN_HEADER
 
 
-  FT_LOCAL( FT_ULong )
+  FT_LOCAL( FT_Tag )
   woff2_known_tags( FT_Byte  index );