shithub: freetype+ttf2subf

Download patch

ref: a577bbcb5bd895b74c690f5d3eb640330d2fee68
parent: 80b13f5732dbf85d751e581c758a6decbfdd87f4
author: Alexei Podtelezhnikov <[email protected]>
date: Wed Oct 27 18:24:27 EDT 2021

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/include/freetype/internal/wofftypes.h
+++ b/include/freetype/internal/wofftypes.h
@@ -191,7 +191,7 @@
   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        */
 
--- 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 )
--- 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  */
--- 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 );