shithub: freetype+ttf2subf

Download patch

ref: 01ca4da20375cf64f7e6b8c22c038042cf849502
parent: 7585683c4a93a1f08ad3289d6564fda80818b2b4
author: David Turner <[email protected]>
date: Tue Mar 3 08:28:59 EST 2009

Remove ABI-breaking field in public PS_InfoFontRec definition.
    Instead, we define a new internal PS_FontExtraRec structure to
    hold the additionnal field, then place it in various internal
    positions of the corresponding FT_Face derived objects.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2009-03-03  David Turner  <[email protected]>
+
+	Remove ABI-breaking field in public PS_InfoFontRec definition.
+	Instead, we define a new internal PS_FontExtraRec structure to
+	hold the additionnal field, then place it in various internal
+	positions of the corresponding FT_Face derived objects.
+	
+	* include/freetype/t1tables.h (PS_FontInfoRec): Remove the
+	`fs_type' field from the public structure.
+
+	* include/freetype/internal/psaux.h (T1_FieldLocation),
+	include/freetype/internal/t1types.h (T1_FontRec, CID_FaceRec),
+	src/type1/t1load.c, src/type1/t1tokens.h,
+	src/cid/cidload.c, src/cid/cidtoken.h,
+	src/type42/t42parse.c: modify the various font parsers to store
+	the `fs_type' field in a different places, instead of the public
+	PS_FontInfoRec.
+
+	* include/freetype/internal/services/svpsinfo.h (PsInfo service),
+	src/base/ftfstype.c (FT_Get_FSType_Flags), src/cff/cffdrivr.c,
+	src/cid/cidriver.c, src/type1/t1driver.c, src/type42/t42drivr.c:
+	Modify the PsInfo service to add a GetExtra function, use it in
+	FT_Get_FSType_Flags() and modify the drivers accordingly.
+
 2009-03-02  Alexey Kryukov  <[email protected]>
 
 	Fix handling of EBDT formats 8 and 9.
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -197,6 +197,7 @@
   {
     T1_FIELD_LOCATION_CID_INFO,
     T1_FIELD_LOCATION_FONT_DICT,
+    T1_FIELD_LOCATION_FONT_EXTRA,
     T1_FIELD_LOCATION_FONT_INFO,
     T1_FIELD_LOCATION_PRIVATE,
     T1_FIELD_LOCATION_BBOX,
--- a/include/freetype/internal/services/svpsinfo.h
+++ b/include/freetype/internal/services/svpsinfo.h
@@ -33,6 +33,10 @@
   (*PS_GetFontInfoFunc)( FT_Face          face,
                          PS_FontInfoRec*  afont_info );
 
+  typedef FT_Error
+  (*PS_GetFontExtraFunc)( FT_Face           face,
+                          PS_FontExtraRec*  afont_extra );
+
   typedef FT_Int
   (*PS_HasGlyphNamesFunc)( FT_Face   face );
 
@@ -44,6 +48,7 @@
   FT_DEFINE_SERVICE( PsInfo )
   {
     PS_GetFontInfoFunc     ps_get_font_info;
+    PS_GetFontExtraFunc    ps_get_font_extra;
     PS_HasGlyphNamesFunc   ps_has_glyph_names;
     PS_GetFontPrivateFunc  ps_get_font_private;
   };
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -87,9 +87,21 @@
   } T1_EncodingType;
 
 
+  /* used to hold extra data of PS_FontInfoRec that
+   * cannot be stored in the publicly defined structure.
+   *
+   * Note these can't be blended with multiple-masters.
+   */
+  typedef struct PS_FontExtraRec_
+  {
+    FT_UShort   fs_type;
+
+  } PS_FontExtraRec;
+
   typedef struct  T1_FontRec_
   {
     PS_FontInfoRec   font_info;         /* font info dictionary */
+    PS_FontExtraRec  font_extra;        /* font info extra fields */
     PS_PrivateRec    private_dict;      /* private dictionary   */
     FT_String*       font_name;         /* top-level dictionary */
 
@@ -231,6 +243,7 @@
     void*            psnames;
     void*            psaux;
     CID_FaceInfoRec  cid;
+    PS_FontExtraRec  font_extra;
 #if 0
     void*            afm_data;
 #endif
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -78,10 +78,6 @@
     FT_Short    underline_position;
     FT_UShort   underline_thickness;
 
-    /* since 2.3.8 */
-
-    FT_UShort   fs_type;
-
   } PS_FontInfoRec;
 
 
--- a/src/base/ftfstype.c
+++ b/src/base/ftfstype.c
@@ -18,6 +18,8 @@
 #include <ft2build.h>
 #include FT_TYPE1_TABLES_H
 #include FT_TRUETYPE_TABLES_H
+#include FT_INTERNAL_SERVICE_H
+#include FT_SERVICE_POSTSCRIPT_INFO_H
 
 
   /* documentation is in freetype.h */
@@ -25,15 +27,30 @@
   FT_EXPORT_DEF( FT_UShort )
   FT_Get_FSType_Flags( FT_Face  face )
   {
-    PS_FontInfoRec  font_info;
-    TT_OS2*         os2;
+    TT_OS2*  os2;
 
 
-    /* look at FSType before fsType for Type42 */
+    /* first, try to get the fs_type directly from the font */
+    if ( face )
+    {
+      FT_Service_PsInfo  service = NULL;
 
-    if ( !FT_Get_PS_Font_Info( face, &font_info ) &&
-         font_info.fs_type != 0                   )
-      return font_info.fs_type;
+
+      FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
+
+      if ( service && service->ps_get_font_extra )
+      {
+        PS_FontExtraRec  extra;
+
+        if ( !service->ps_get_font_extra( face, &extra ) &&
+             extra.fs_type != 0 )
+        {
+          return extra.fs_type;
+        }
+      }
+    }
+
+    /* look at FSType before fsType for Type42 */
 
     if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, ft_sfnt_os2 ) ) != NULL &&
          os2->version != 0xFFFFU                                           )
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -380,6 +380,7 @@
   static const FT_Service_PsInfoRec  cff_service_ps_info =
   {
     (PS_GetFontInfoFunc)   cff_ps_get_font_info,
+    (PS_GetFontExtraFunc)  NULL,
     (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
     (PS_GetFontPrivateFunc)NULL         /* unsupported with CFF fonts */
   };
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -97,6 +97,10 @@
       object = (FT_Byte*)&cid->font_info;
       break;
 
+    case T1_FIELD_LOCATION_FONT_EXTRA:
+      object = (FT_Byte*)&face->font_extra;
+      break;
+
     case T1_FIELD_LOCATION_BBOX:
       object = (FT_Byte*)&cid->font_bbox;
       break;
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -77,10 +77,18 @@
     return 0;
   }
 
+  static FT_Error
+  cid_ps_get_font_extra( FT_Face          face,
+                        PS_FontExtraRec*  afont_extra )
+  {
+    *afont_extra = ((CID_Face)face)->font_extra;
+    return 0;
+  }
 
   static const FT_Service_PsInfoRec  cid_service_ps_info =
   {
     (PS_GetFontInfoFunc)   cid_ps_get_font_info,
+    (PS_GetFontExtraFunc)  cid_ps_get_font_extra,
     (PS_HasGlyphNamesFunc) NULL,        /* unsupported with CID fonts */
     (PS_GetFontPrivateFunc)NULL         /* unsupported                */
   };
--- a/src/cid/cidtoken.h
+++ b/src/cid/cidtoken.h
@@ -48,6 +48,12 @@
   T1_FIELD_BOOL  ( "isFixedPitch",       is_fixed_pitch,      0 )
   T1_FIELD_NUM   ( "UnderlinePosition",  underline_position,  0 )
   T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness, 0 )
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  PS_FontExtraRec
+#undef  T1CODE
+#define T1CODE        T1_FIELD_LOCATION_FONT_EXTRA
+
   T1_FIELD_NUM   ( "FSType",             fs_type,             0 )
 
 
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -138,6 +138,13 @@
     return 0;
   }
 
+  static FT_Error
+  t1_ps_get_font_extra( FT_Face           face,
+                        PS_FontExtraRec*  afont_extra )
+  {
+    *afont_extra = ((T1_Face)face)->type1.font_extra;
+    return 0;
+  }
 
   static FT_Int
   t1_ps_has_glyph_names( FT_Face  face )
@@ -159,6 +166,7 @@
   static const FT_Service_PsInfoRec  t1_service_ps_info =
   {
     (PS_GetFontInfoFunc)   t1_ps_get_font_info,
+    (PS_GetFontExtraFunc)  t1_ps_get_font_extra,
     (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,
     (PS_GetFontPrivateFunc)t1_ps_get_font_private,
   };
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -948,6 +948,12 @@
       }
       break;
 
+    case T1_FIELD_LOCATION_FONT_EXTRA:
+      dummy_object = &face->type1.font_extra;
+      objects      = &dummy_object;
+      max_objects  = 0;
+      break;
+
     case T1_FIELD_LOCATION_PRIVATE:
       dummy_object = &face->type1.private_dict;
       objects      = &dummy_object;
--- a/src/type1/t1tokens.h
+++ b/src/type1/t1tokens.h
@@ -41,6 +41,12 @@
                    T1_FIELD_DICT_FONTDICT )
   T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness,
                    T1_FIELD_DICT_FONTDICT )
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  PS_FontExtraRec
+#undef  T1CODE
+#define T1CODE        T1_FIELD_LOCATION_FONT_EXTRA
+
   T1_FIELD_NUM   ( "FSType", fs_type,
                    T1_FIELD_DICT_FONTDICT )
 
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -127,6 +127,13 @@
     return T42_Err_Ok;
   }
 
+  static FT_Error
+  t42_ps_get_font_extra( FT_Face           face,
+                         PS_FontExtraRec*  afont_extra )
+  {
+    *afont_extra = ((T42_Face)face)->type1.font_extra;
+    return T42_Err_Ok;
+  }
 
   static FT_Int
   t42_ps_has_glyph_names( FT_Face  face )
@@ -148,6 +155,7 @@
   static const FT_Service_PsInfoRec  t42_service_ps_info =
   {
     (PS_GetFontInfoFunc)   t42_ps_get_font_info,
+    (PS_GetFontExtraFunc)   t42_ps_get_font_extra,
     (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names,
     (PS_GetFontPrivateFunc)t42_ps_get_font_private
   };
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -68,6 +68,12 @@
     T1_FIELD_BOOL  ( "isFixedPitch",       is_fixed_pitch,      0 )
     T1_FIELD_NUM   ( "UnderlinePosition",  underline_position,  0 )
     T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness, 0 )
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  PS_FontExtraRec
+#undef  T1CODE
+#define T1CODE        T1_FIELD_LOCATION_FONT_EXTRA
+
     T1_FIELD_NUM   ( "FSType",             fs_type,             0 )
 
 #undef  FT_STRUCTURE