[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 committed by Werner Lemberg
parent c6c2c0b574
commit 7a1639bc1e
4 changed files with 95 additions and 70 deletions

View File

@ -1,3 +1,19 @@
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.

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 */
@ -87,4 +91,8 @@ const FT_ULong KnownTags[63] = {
};
return known_tags[index];
}
/* END */

View File

@ -33,8 +33,9 @@ FT_BEGIN_HEADER
#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