Commit 5c4e40d7fd1fa1f971733d8c7e559962bb49f195

suzuki toshiya 2017-09-09T00:59:33

[sfnt, truetype] Register the tags for marginal fonts. The first 32bit of standard TrueType variants is 0x00010000, `OTTO', `ttcf', `true' or `typ1'. 2 marginal dfonts on legacy Mac OS X, Keyboard.dfont and LastResort.dfont, have the sfnt resources starting 0xA5 followed by `kbd' or `lst'. Considering the following data could be parsed as conventional TrueType fonts, the header checking is updated to allow these tags. It seems that recent Mac OS X has already switched to normal TTF for these fonts. See the discussion at http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3931.0 * include/freetype/tttags.h (TTAG_0xA5kbd, TTAG_0xA5lst): New header tags for Keyboard.dfont and LastResort.dfont. * src/sfnt/sfobjs.c (sfnt_open_font): Accept the sfnt resource starts with TTAG_0xA5kbd or TTAG_0xA5lst. * src/truetype/ttobjs.c (tt_face_init): Accept the face with the format tag is TTAG_0xA5kbd or TTAG_0xA5lst.

diff --git a/include/freetype/tttags.h b/include/freetype/tttags.h
index 32eb2fd..b7d3bac 100644
--- a/include/freetype/tttags.h
+++ b/include/freetype/tttags.h
@@ -106,6 +106,12 @@ FT_BEGIN_HEADER
 #define TTAG_VVAR  FT_MAKE_TAG( 'V', 'V', 'A', 'R' )
 #define TTAG_wOFF  FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
 
+/* used by "Keyboard.dfont" on legacy Mac OS X */
+#define TTAG_0xA5kbd  FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' )
+
+/* used by "LastResort.dfont" on legacy Mac OS X */
+#define TTAG_0xA5lst  FT_MAKE_TAG( 0xA5, 'l', 's', 't' )
+
 
 FT_END_HEADER
 
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 289eeef..69bf0a5 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -787,6 +787,8 @@
          tag != TTAG_OTTO    &&
          tag != TTAG_true    &&
          tag != TTAG_typ1    &&
+         tag != TTAG_0xA5kbd &&
+         tag != TTAG_0xA5lst &&
          tag != 0x00020000UL )
     {
       FT_TRACE2(( "  not a font using the SFNT container format\n" ));
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 53e402b..783df30 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -576,9 +576,11 @@
     /* We must also be able to accept Mac/GX fonts, as well as OT ones. */
     /* The 0x00020000 tag is completely undocumented; some fonts from   */
     /* Arphic made for Chinese Windows 3.1 have this.                   */
-    if ( face->format_tag != 0x00010000L &&    /* MS fonts  */
-         face->format_tag != 0x00020000L &&    /* CJK fonts for Win 3.1 */
-         face->format_tag != TTAG_true   )     /* Mac fonts */
+    if ( face->format_tag != 0x00010000L  &&    /* MS fonts  */
+         face->format_tag != 0x00020000L  &&    /* CJK fonts for Win 3.1 */
+         face->format_tag != TTAG_true    &&    /* Mac fonts */
+         face->format_tag != TTAG_0xA5kbd &&    /* Keyboard.dfont for legacy Mac OS X */
+         face->format_tag != TTAG_0xA5lst )     /* LastResort.dfont for legacy Mac OS X */
     {
       FT_TRACE2(( "  not a TTF font\n" ));
       goto Bad_Format;