From 7d9c189ac2583edb64147374ccd13a38b3ad5b2f Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sun, 21 Oct 2007 08:12:30 +0000 Subject: [PATCH] * src/sfnt/sfobjs.c (sfnt_load_face): Support bit 9 and prepare support for bit 8 in the `OS/2' table. MS is already using this; hopefully, this becomes part of OpenType 1.5. Prepare also support for `name' IDs 21 (WWS_FAMILY) and 22 (WWS_SUBFAMILY). --- ChangeLog | 8 ++++ include/freetype/freetype.h | 8 +++- src/sfnt/sfobjs.c | 77 +++++++++++++++++++++++++++++-------- 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bad7700f..ca2f5e2b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-10-21 Werner Lemberg + + * src/sfnt/sfobjs.c (sfnt_load_face): Support bit 9 and prepare + support for bit 8 in the `OS/2' table. MS is already using this; + hopefully, this becomes part of OpenType 1.5. + Prepare also support for `name' IDs 21 (WWS_FAMILY) and 22 + (WWS_SUBFAMILY). + 2006-10-20 Werner Lemberg * src/tools/docmaker/tohtml.py (html_header_2): Fix typo. diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 4399c8e83..8fc477d56 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -1198,11 +1198,17 @@ FT_BEGIN_HEADER /* */ /* */ /* FT_STYLE_FLAG_ITALIC :: */ - /* Indicates that a given face is italicized. */ + /* Indicates that a given face style is italic or oblique. */ /* */ /* FT_STYLE_FLAG_BOLD :: */ /* Indicates that a given face is bold. */ /* */ + /* */ + /* The style information as provided by FreeType is very basic. More */ + /* details are beyond the scope and should be done on a higher level */ + /* (for example, by analyzing various fields of the `OS/2' table in */ + /* SFNT based fonts). */ + /* */ #define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) #define FT_STYLE_FLAG_BOLD ( 1 << 1 ) diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index cc901100d..00ae000de 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -696,22 +696,60 @@ face->root.num_glyphs = face->max_profile.numGlyphs; - face->root.family_name = tt_face_get_name( face, - TT_NAME_ID_PREFERRED_FAMILY ); - if ( !face->root.family_name ) - face->root.family_name = tt_face_get_name( face, - TT_NAME_ID_FONT_FAMILY ); +#if 0 + /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */ + /* a WWS-only font face. `WWS' stands for `weight', width', and */ + /* `slope', a term used by Microsoft's Windows Presentation */ + /* Foundation (WPF). This flag will be introduced in version */ + /* 1.5 of the OpenType specification (but is already in use). */ + + if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 ) +#endif + { + face->root.family_name = + tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY ); + if ( !face->root.family_name ) + face->root.family_name = + tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY ); + + face->root.style_name = + tt_face_get_name( face, TT_NAME_ID_PREFERRED_SUBFAMILY ); + if ( !face->root.style_name ) + face->root.style_name = + tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY ); + } +#if 0 + else + { + /* Support for `name' table ID 21 (WWS family) and 22 (WWS */ + /* subfamily) is still under consideration by Microsoft and */ + /* not implemented in the current version of WPF. */ + + face->root.family_name = + tt_face_get_name( face, TT_NAME_ID_WWS_FAMILY ); + if ( !face->root.family_name ) + face->root.family_name = + tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY ); + if ( !face->root.family_name ) + face->root.family_name = + tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY ); + + face->root.style_name = + tt_face_get_name( face, TT_NAME_ID_WWS_SUBFAMILY ); + if ( !face->root.style_name ) + face->root.style_name = + tt_face_get_name( face, TT_NAME_ID_PREFERRED_SUBFAMILY ); + if ( !face->root.style_name ) + face->root.style_name = + tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY ); + } +#endif - face->root.style_name = tt_face_get_name( face, - TT_NAME_ID_PREFERRED_SUBFAMILY ); - if ( !face->root.style_name ) - face->root.style_name = tt_face_get_name( face, - TT_NAME_ID_FONT_SUBFAMILY ); /* now set up root fields */ { - FT_Face root = &face->root; - FT_Int32 flags = root->face_flags; + FT_Face root = &face->root; + FT_Int32 flags = root->face_flags; /*********************************************************************/ @@ -727,7 +765,7 @@ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES - if ( psnames_error == SFNT_Err_Ok && + if ( psnames_error == SFNT_Err_Ok && face->postscript.FormatType != 0x00030000L ) flags |= FT_FACE_FLAG_GLYPH_NAMES; #endif @@ -759,14 +797,21 @@ /* */ /* Compute style flags. */ /* */ + flags = 0; if ( has_outline == TRUE && face->os2.version != 0xFFFFU ) { - /* we have an OS/2 table; use the `fsSelection' field */ - if ( face->os2.fsSelection & 1 ) + /* We have an OS/2 table; use the `fsSelection' field. Bit 9 */ + /* indicates an oblique font face. This flag will be */ + /* introduced in version 1.5 of the OpenType specification (but */ + /* is already in use). */ + + if ( face->os2.fsSelection & 512 ) /* bit 9 */ + flags |= FT_STYLE_FLAG_ITALIC; + else if ( face->os2.fsSelection & 1 ) /* bit 0 */ flags |= FT_STYLE_FLAG_ITALIC; - if ( face->os2.fsSelection & 32 ) + if ( face->os2.fsSelection & 32 ) /* bit 5 */ flags |= FT_STYLE_FLAG_BOLD; } else