shithub: freetype+ttf2subf

Download patch

ref: 7d9c189ac2583edb64147374ccd13a38b3ad5b2f
parent: 668425774214f407996e4db262db9a7f286c7b18
author: Werner Lemberg <[email protected]>
date: Sun Oct 21 04:12:30 EDT 2007

* 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).

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-21  Werner Lemberg  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* src/tools/docmaker/tohtml.py (html_header_2): Fix typo.
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1198,10 +1198,16 @@
   /*                                                                       */
   /* <Values>                                                              */
   /*    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.                             */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    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 )
--- 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).    */
 
-    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 ( 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
+
+
     /* 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