From ee5105107b59049c5d012d7658810c8378c8f411 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sun, 27 Oct 2013 07:25:35 +0100 Subject: [PATCH] [sfnt] Implement support for `OS/2' table version 5. See http://typedrawers.com/discussion/470/new-microsoft-size-specific-design-selection-mechanism for the announcement. * include/freetype/tttables.h (TT_OS2): Add fields `usLowerPointSize' and `usUpperPointSize'. Since FreeType returns this structure only as a pointer through `FT_Get_Sfnt_Table', there shouldn't be any ABI problems. * src/sfnt/ttload.c (tt_face_load_os2): Implement it. * docs/CHANGES: Updated. --- ChangeLog | 19 +++++++++++++++++++ docs/CHANGES | 13 ++++++++++--- include/freetype/tttables.h | 9 +++++++-- src/sfnt/ttload.c | 24 ++++++++++++++++++++++-- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac9f00a36..2f5585a42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2013-10-27 Werner Lemberg + + [sfnt] Implement support for `OS/2' table version 5. + + See + + http://typedrawers.com/discussion/470/new-microsoft-size-specific-design-selection-mechanism + + for the announcement. + + * include/freetype/tttables.h (TT_OS2): Add fields + `usLowerPointSize' and `usUpperPointSize'. Since FreeType returns + this structure only as a pointer through `FT_Get_Sfnt_Table', there + shouldn't be any ABI problems. + + * src/sfnt/ttload.c (tt_face_load_os2): Implement it. + + * docs/CHANGES: Updated. + 2013-10-24 Werner Lemberg * README.git, docs/CHANGES, docs/INSTALL: Updated. diff --git a/docs/CHANGES b/docs/CHANGES index 32d6b6541..81a8eeb3d 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -14,11 +14,14 @@ CHANGES BETWEEN 2.5 and 2.5.1 II. IMPORTANT CHANGES - - WOFF support has been added. + - WOFF font format support has been added. - The auto-hinter now supports Hebrew. Greek and Cyrillic support has been improved. + - Support for the forthcoming `OS/2' SFNT table version 5, as can + be found e.g. in the `Sitka' font family for Windows 8.1. + III. MISCELLANEOUS @@ -28,8 +31,12 @@ CHANGES BETWEEN 2.5 and 2.5.1 - `ftgrid' has been updated to toggle various engines with the `H' key, similar to `ftview' and `ftdiff'. - - `ttdebug' now displays twilight data; key `t' shows the twilight - point table. + - Some keys in `ttdebug' have been reassigned from lowercase to + their uppercase equivalents; for example `q' to quit the program + is now `Q'. + + - `ttdebug' now displays twilight and storage area data; key `T' + shows the twilight point table, key `S' the storage data. - Better support of ARMv7 and x86_64 processors. diff --git a/include/freetype/tttables.h b/include/freetype/tttables.h index e0903223f..426072f7d 100644 --- a/include/freetype/tttables.h +++ b/include/freetype/tttables.h @@ -340,8 +340,8 @@ FT_BEGIN_HEADER /* TT_OS2 */ /* */ /* */ - /* A structure used to model a TrueType OS/2 table. This is the long */ - /* table version. All fields comply to the TrueType specification. */ + /* A structure used to model a TrueType OS/2 table. All fields */ + /* comply to the OpenType specification. */ /* */ /* Note that we now support old Mac fonts that do not include an OS/2 */ /* table. In this case, the `version' field is always set to 0xFFFF. */ @@ -396,6 +396,11 @@ FT_BEGIN_HEADER FT_UShort usBreakChar; FT_UShort usMaxContext; + /* only version 5 tables: */ + + FT_UShort usLowerPointSize; + FT_UShort usUpperPointSize; + } TT_OS2; diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 20e240a20..af9e311d8 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -1003,7 +1003,8 @@ FT_FRAME_END }; - static const FT_Frame_Field os2_fields_extra[] = + /* `OS/2' version 1 and newer */ + static const FT_Frame_Field os2_fields_extra1[] = { FT_FRAME_START( 8 ), FT_FRAME_ULONG( ulCodePageRange1 ), @@ -1011,6 +1012,7 @@ FT_FRAME_END }; + /* `OS/2' version 2 and newer */ static const FT_Frame_Field os2_fields_extra2[] = { FT_FRAME_START( 10 ), @@ -1022,6 +1024,15 @@ FT_FRAME_END }; + /* `OS/2' version 5 and newer */ + static const FT_Frame_Field os2_fields_extra5[] = + { + FT_FRAME_START( 4 ), + FT_FRAME_USHORT( usLowerPointSize ), + FT_FRAME_USHORT( usUpperPointSize ), + FT_FRAME_END + }; + /* We now support old Mac fonts where the OS/2 table doesn't */ /* exist. Simply put, we set the `version' field to 0xFFFF */ @@ -1042,11 +1053,13 @@ os2->usDefaultChar = 0; os2->usBreakChar = 0; os2->usMaxContext = 0; + os2->usLowerPointSize = 0; + os2->usUpperPointSize = 0; if ( os2->version >= 0x0001 ) { /* only version 1 tables */ - if ( FT_STREAM_READ_FIELDS( os2_fields_extra, os2 ) ) + if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) ) goto Exit; if ( os2->version >= 0x0002 ) @@ -1054,6 +1067,13 @@ /* only version 2 tables */ if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) ) goto Exit; + + if ( os2->version >= 0x0005 ) + { + /* only version 5 tables */ + if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) ) + goto Exit; + } } }