[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.
This commit is contained in:
Nikhil Ramakrishnan 2019-06-30 20:01:20 +05:30
parent 6cb1146433
commit 045c6b1162
3 changed files with 79 additions and 70 deletions

View File

@ -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;

View File

@ -19,8 +19,12 @@
#include "sfwoff.h"
#include FT_TRUETYPE_TAGS_H
/* Known table tags in the order given in WOFF2 specification. */
const FT_ULong KnownTags[63] = {
/* 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 */
@ -84,7 +88,11 @@ const FT_ULong KnownTags[63] = {
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 */

View File

@ -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