[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
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 );