[woff2] Get known tags from function. Change `KnownTags' to a function (`woff2_known_tags'). This avoids introducing a global constant array. This function returns the specified index without *any* checks. The caller must ensure that `index' is within array limits. * src/sfnt/sfwoff2.c (woff2_open_font): Change `KnownTags[...]' notation to `woff2_known_tags( ... )'. * src/sfnt/woff2tags.c: Perform changes. * src/sfnt/woff2tags.h: Update definitions.
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
diff --git a/ChangeLog b/ChangeLog
index f89194b..ff6f840 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2019-08-27 Nikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com>
+ [woff2] Get known tags from function.
+
+ Change `KnownTags' to a function (`woff2_known_tags'). This avoids
+ introducing a global constant array. This function returns the
+ specified index without *any* checks. The caller must ensure that
+ `index' is within array limits.
+
+ * src/sfnt/sfwoff2.c (woff2_open_font): Change `KnownTags[...]'
+ notation to `woff2_known_tags( ... )'.
+
+ * src/sfnt/woff2tags.c: Perform changes.
+
+ * src/sfnt/woff2tags.h: Update definitions.
+
+2019-08-27 Nikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com>
+
[woff2] Minor.
* src/sfnt/sfwoff2.c (woff2_uncompress): Add error message
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
index 614c99b..545f7ed 100644
--- a/src/sfnt/sfwoff2.c
+++ b/src/sfnt/sfwoff2.c
@@ -360,7 +360,7 @@
goto Exit;
}
else
- table->Tag = KnownTags[table->FlagByte & 0x3f];
+ table->Tag = woff2_known_tags( table->FlagByte & 0x3f );
flags = 0;
xform_version = ( table->FlagByte >> 6 ) & 0x03;
diff --git a/src/sfnt/woff2tags.c b/src/sfnt/woff2tags.c
index 6a84d29..5b274d5 100644
--- a/src/sfnt/woff2tags.c
+++ b/src/sfnt/woff2tags.c
@@ -19,72 +19,80 @@
#include "sfwoff.h"
#include FT_TRUETYPE_TAGS_H
-/* Known table tags in the order given in WOFF2 specification. */
-const FT_ULong KnownTags[63] = {
- FT_MAKE_TAG('c', 'm', 'a', 'p'), /* 0 */
- FT_MAKE_TAG('h', 'e', 'a', 'd'), /* 1 */
- FT_MAKE_TAG('h', 'h', 'e', 'a'), /* 2 */
- FT_MAKE_TAG('h', 'm', 't', 'x'), /* 3 */
- FT_MAKE_TAG('m', 'a', 'x', 'p'), /* 4 */
- FT_MAKE_TAG('n', 'a', 'm', 'e'), /* 5 */
- FT_MAKE_TAG('O', 'S', '/', '2'), /* 6 */
- FT_MAKE_TAG('p', 'o', 's', 't'), /* 7 */
- FT_MAKE_TAG('c', 'v', 't', ' '), /* 8 */
- FT_MAKE_TAG('f', 'p', 'g', 'm'), /* 9 */
- FT_MAKE_TAG('g', 'l', 'y', 'f'), /* 10 */
- FT_MAKE_TAG('l', 'o', 'c', 'a'), /* 11 */
- FT_MAKE_TAG('p', 'r', 'e', 'p'), /* 12 */
- FT_MAKE_TAG('C', 'F', 'F', ' '), /* 13 */
- FT_MAKE_TAG('V', 'O', 'R', 'G'), /* 14 */
- FT_MAKE_TAG('E', 'B', 'D', 'T'), /* 15 */
- FT_MAKE_TAG('E', 'B', 'L', 'C'), /* 16 */
- FT_MAKE_TAG('g', 'a', 's', 'p'), /* 17 */
- FT_MAKE_TAG('h', 'd', 'm', 'x'), /* 18 */
- FT_MAKE_TAG('k', 'e', 'r', 'n'), /* 19 */
- FT_MAKE_TAG('L', 'T', 'S', 'H'), /* 20 */
- FT_MAKE_TAG('P', 'C', 'L', 'T'), /* 21 */
- FT_MAKE_TAG('V', 'D', 'M', 'X'), /* 22 */
- FT_MAKE_TAG('v', 'h', 'e', 'a'), /* 23 */
- FT_MAKE_TAG('v', 'm', 't', 'x'), /* 24 */
- FT_MAKE_TAG('B', 'A', 'S', 'E'), /* 25 */
- FT_MAKE_TAG('G', 'D', 'E', 'F'), /* 26 */
- FT_MAKE_TAG('G', 'P', 'O', 'S'), /* 27 */
- FT_MAKE_TAG('G', 'S', 'U', 'B'), /* 28 */
- FT_MAKE_TAG('E', 'B', 'S', 'C'), /* 29 */
- FT_MAKE_TAG('J', 'S', 'T', 'F'), /* 30 */
- FT_MAKE_TAG('M', 'A', 'T', 'H'), /* 31 */
- FT_MAKE_TAG('C', 'B', 'D', 'T'), /* 32 */
- FT_MAKE_TAG('C', 'B', 'L', 'C'), /* 33 */
- FT_MAKE_TAG('C', 'O', 'L', 'R'), /* 34 */
- FT_MAKE_TAG('C', 'P', 'A', 'L'), /* 35 */
- FT_MAKE_TAG('S', 'V', 'G', ' '), /* 36 */
- FT_MAKE_TAG('s', 'b', 'i', 'x'), /* 37 */
- FT_MAKE_TAG('a', 'c', 'n', 't'), /* 38 */
- FT_MAKE_TAG('a', 'v', 'a', 'r'), /* 39 */
- FT_MAKE_TAG('b', 'd', 'a', 't'), /* 40 */
- FT_MAKE_TAG('b', 'l', 'o', 'c'), /* 41 */
- FT_MAKE_TAG('b', 's', 'l', 'n'), /* 42 */
- FT_MAKE_TAG('c', 'v', 'a', 'r'), /* 43 */
- FT_MAKE_TAG('f', 'd', 's', 'c'), /* 44 */
- FT_MAKE_TAG('f', 'e', 'a', 't'), /* 45 */
- FT_MAKE_TAG('f', 'm', 't', 'x'), /* 46 */
- FT_MAKE_TAG('f', 'v', 'a', 'r'), /* 47 */
- FT_MAKE_TAG('g', 'v', 'a', 'r'), /* 48 */
- FT_MAKE_TAG('h', 's', 't', 'y'), /* 49 */
- FT_MAKE_TAG('j', 'u', 's', 't'), /* 50 */
- FT_MAKE_TAG('l', 'c', 'a', 'r'), /* 51 */
- FT_MAKE_TAG('m', 'o', 'r', 't'), /* 52 */
- FT_MAKE_TAG('m', 'o', 'r', 'x'), /* 53 */
- FT_MAKE_TAG('o', 'p', 'b', 'd'), /* 54 */
- FT_MAKE_TAG('p', 'r', 'o', 'p'), /* 55 */
- FT_MAKE_TAG('t', 'r', 'a', 'k'), /* 56 */
- FT_MAKE_TAG('Z', 'a', 'p', 'f'), /* 57 */
- FT_MAKE_TAG('S', 'i', 'l', 'f'), /* 58 */
- FT_MAKE_TAG('G', 'l', 'a', 't'), /* 59 */
- FT_MAKE_TAG('G', 'l', 'o', 'c'), /* 60 */
- FT_MAKE_TAG('F', 'e', 'a', 't'), /* 61 */
- FT_MAKE_TAG('S', 'i', 'l', 'l'), /* 62 */
-};
+ /* Return tag from index in the order given in WOFF2 specification. */
+ FT_LOCAL_DEF( FT_ULong )
+ woff2_known_tags( FT_Byte index )
+ {
+ const FT_ULong known_tags[63] =
+ {
+ FT_MAKE_TAG('c', 'm', 'a', 'p'), /* 0 */
+ FT_MAKE_TAG('h', 'e', 'a', 'd'), /* 1 */
+ FT_MAKE_TAG('h', 'h', 'e', 'a'), /* 2 */
+ FT_MAKE_TAG('h', 'm', 't', 'x'), /* 3 */
+ FT_MAKE_TAG('m', 'a', 'x', 'p'), /* 4 */
+ FT_MAKE_TAG('n', 'a', 'm', 'e'), /* 5 */
+ FT_MAKE_TAG('O', 'S', '/', '2'), /* 6 */
+ FT_MAKE_TAG('p', 'o', 's', 't'), /* 7 */
+ FT_MAKE_TAG('c', 'v', 't', ' '), /* 8 */
+ FT_MAKE_TAG('f', 'p', 'g', 'm'), /* 9 */
+ FT_MAKE_TAG('g', 'l', 'y', 'f'), /* 10 */
+ FT_MAKE_TAG('l', 'o', 'c', 'a'), /* 11 */
+ FT_MAKE_TAG('p', 'r', 'e', 'p'), /* 12 */
+ FT_MAKE_TAG('C', 'F', 'F', ' '), /* 13 */
+ FT_MAKE_TAG('V', 'O', 'R', 'G'), /* 14 */
+ FT_MAKE_TAG('E', 'B', 'D', 'T'), /* 15 */
+ FT_MAKE_TAG('E', 'B', 'L', 'C'), /* 16 */
+ FT_MAKE_TAG('g', 'a', 's', 'p'), /* 17 */
+ FT_MAKE_TAG('h', 'd', 'm', 'x'), /* 18 */
+ FT_MAKE_TAG('k', 'e', 'r', 'n'), /* 19 */
+ FT_MAKE_TAG('L', 'T', 'S', 'H'), /* 20 */
+ FT_MAKE_TAG('P', 'C', 'L', 'T'), /* 21 */
+ FT_MAKE_TAG('V', 'D', 'M', 'X'), /* 22 */
+ FT_MAKE_TAG('v', 'h', 'e', 'a'), /* 23 */
+ FT_MAKE_TAG('v', 'm', 't', 'x'), /* 24 */
+ FT_MAKE_TAG('B', 'A', 'S', 'E'), /* 25 */
+ FT_MAKE_TAG('G', 'D', 'E', 'F'), /* 26 */
+ FT_MAKE_TAG('G', 'P', 'O', 'S'), /* 27 */
+ FT_MAKE_TAG('G', 'S', 'U', 'B'), /* 28 */
+ FT_MAKE_TAG('E', 'B', 'S', 'C'), /* 29 */
+ FT_MAKE_TAG('J', 'S', 'T', 'F'), /* 30 */
+ FT_MAKE_TAG('M', 'A', 'T', 'H'), /* 31 */
+ FT_MAKE_TAG('C', 'B', 'D', 'T'), /* 32 */
+ FT_MAKE_TAG('C', 'B', 'L', 'C'), /* 33 */
+ FT_MAKE_TAG('C', 'O', 'L', 'R'), /* 34 */
+ FT_MAKE_TAG('C', 'P', 'A', 'L'), /* 35 */
+ FT_MAKE_TAG('S', 'V', 'G', ' '), /* 36 */
+ FT_MAKE_TAG('s', 'b', 'i', 'x'), /* 37 */
+ FT_MAKE_TAG('a', 'c', 'n', 't'), /* 38 */
+ FT_MAKE_TAG('a', 'v', 'a', 'r'), /* 39 */
+ FT_MAKE_TAG('b', 'd', 'a', 't'), /* 40 */
+ FT_MAKE_TAG('b', 'l', 'o', 'c'), /* 41 */
+ FT_MAKE_TAG('b', 's', 'l', 'n'), /* 42 */
+ FT_MAKE_TAG('c', 'v', 'a', 'r'), /* 43 */
+ FT_MAKE_TAG('f', 'd', 's', 'c'), /* 44 */
+ FT_MAKE_TAG('f', 'e', 'a', 't'), /* 45 */
+ FT_MAKE_TAG('f', 'm', 't', 'x'), /* 46 */
+ FT_MAKE_TAG('f', 'v', 'a', 'r'), /* 47 */
+ FT_MAKE_TAG('g', 'v', 'a', 'r'), /* 48 */
+ FT_MAKE_TAG('h', 's', 't', 'y'), /* 49 */
+ FT_MAKE_TAG('j', 'u', 's', 't'), /* 50 */
+ FT_MAKE_TAG('l', 'c', 'a', 'r'), /* 51 */
+ FT_MAKE_TAG('m', 'o', 'r', 't'), /* 52 */
+ FT_MAKE_TAG('m', 'o', 'r', 'x'), /* 53 */
+ FT_MAKE_TAG('o', 'p', 'b', 'd'), /* 54 */
+ FT_MAKE_TAG('p', 'r', 'o', 'p'), /* 55 */
+ FT_MAKE_TAG('t', 'r', 'a', 'k'), /* 56 */
+ FT_MAKE_TAG('Z', 'a', 'p', 'f'), /* 57 */
+ FT_MAKE_TAG('S', 'i', 'l', 'f'), /* 58 */
+ FT_MAKE_TAG('G', 'l', 'a', 't'), /* 59 */
+ FT_MAKE_TAG('G', 'l', 'o', 'c'), /* 60 */
+ FT_MAKE_TAG('F', 'e', 'a', 't'), /* 61 */
+ FT_MAKE_TAG('S', 'i', 'l', 'l'), /* 62 */
+ };
+
+
+ return known_tags[index];
+ }
/* END */
diff --git a/src/sfnt/woff2tags.h b/src/sfnt/woff2tags.h
index 97b7f9c..6579b85 100644
--- a/src/sfnt/woff2tags.h
+++ b/src/sfnt/woff2tags.h
@@ -27,14 +27,15 @@
FT_BEGIN_HEADER
-/* Leave the first byte open to store flag_byte. */
+ /* Leave the first byte open to store flag_byte. */
#define WOFF2_FLAGS_TRANSFORM 1 << 8
#define WOFF2_SFNT_HEADER_SIZE 12
#define WOFF2_SFNT_ENTRY_SIZE 16
-/* Known table tags. */
-extern const FT_ULong KnownTags[];
+ FT_LOCAL( FT_ULong )
+ woff2_known_tags( FT_Byte index );
+
FT_END_HEADER