shithub: freetype+ttf2subf

Download patch

ref: 3605e470c1c846715d2383e84ac7330660ccdf56
parent: 023a4bf3bee24599ae0760042685f18624860641
author: Werner Lemberg <[email protected]>
date: Fri Nov 12 02:02:45 EST 2004

Add new function FT_Get_PS_Font_Private().

* include/freetype/internal/services/svpsinfo.h
(PS_GetFontPrivateFunc): New service function.

* include/freetype/t1tables.h, src/base/fttype1.c
(FT_Get_PS_Font_Private): New function.

* src/type1/t1driver.c (t1_ps_get_font_private): New function.
(t1_service_ps_info): Updated.

* src/cff/cffdrivr.c (cff_service_ps_info): Updated.
* src/cid/cidriver.c (cid_service_ps_info): Updated.
* src/type42/t42drivr.c (t42_ps_get_font_private): New function.
(t42_service_ps_info): Updated.

* src/type42/t42parse.c (t42_parse_dict): Remove compiler warning.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2004-11-11  Werner Lemberg  <[email protected]>
+
+	* src/cff/cffdrivr.c (cff_service_ps_info): Updated.
+	* src/cid/cidriver.c (cid_service_ps_info): Updated.
+	* src/type42/t42drivr.c (t42_ps_get_font_private): New function.
+	(t42_service_ps_info): Updated.
+
+	* src/type42/t42parse.c (t42_parse_dict): Remove compiler warning.
+
+2004-11-11  David Bevan  <[email protected]>
+
+	Add new function FT_Get_PS_Font_Private().
+
+	* include/freetype/internal/services/svpsinfo.h
+	(PS_GetFontPrivateFunc): New service function.
+
+	* include/freetype/t1tables.h, src/base/fttype1.c
+	(FT_Get_PS_Font_Private): New function.
+
+	* src/type1/t1driver.c (t1_ps_get_font_private): New function.
+	(t1_service_ps_info): Updated.
+
 2004-10-13  Werner Lemberg  <[email protected]>
 
 	* include/freetype/config/ftstdlib.h: Include `stddef.h'.
--- a/include/freetype/internal/services/svpsinfo.h
+++ b/include/freetype/internal/services/svpsinfo.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    The FreeType PostScript info service (specification).                */
 /*                                                                         */
-/*  Copyright 2003 by                                                      */
+/*  Copyright 2003, 2004 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -36,11 +36,16 @@
   typedef FT_Int
   (*PS_HasGlyphNamesFunc)( FT_Face   face );
 
+  typedef FT_Error
+  (*PS_GetFontPrivateFunc)( FT_Face         face,
+                            PS_PrivateRec*  afont_private );
 
+
   FT_DEFINE_SERVICE( PsInfo )
   {
-    PS_GetFontInfoFunc    ps_get_font_info;
-    PS_HasGlyphNamesFunc  ps_has_glyph_names;
+    PS_GetFontInfoFunc     ps_get_font_info;
+    PS_HasGlyphNamesFunc   ps_has_glyph_names;
+    PS_GetFontPrivateFunc  ps_get_font_private;
   };
 
   /* */
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -387,6 +387,38 @@
   FT_Get_PS_Font_Info( FT_Face          face,
                        PS_FontInfoRec  *afont_info );
 
+
+ /************************************************************************
+  *
+  * @function:
+  *    FT_Get_PS_Font_Private
+  *
+  * @description:
+  *    Retrieve the @PS_PrivateRec structure corresponding to a given
+  *    Postscript font.
+  *
+  * @input:
+  *    face ::
+  *       Postscript face handle.
+  *
+  * @output:
+  *    afont_private ::
+  *       Output private dictionary structure pointer.
+  *
+  * @return:
+  *    FreeType error code.  0 means success.
+  *
+  * @note:
+  *    The string pointers within the font info structure are owned by
+  *    the face and don't need to be freed by the caller.
+  *
+  *    If the font's format is not Postscript-based, this function will
+  *    return the FT_Err_Invalid_Argument error code.
+  */
+  FT_EXPORT( FT_Error )
+  FT_Get_PS_Font_Private( FT_Face         face,
+                          PS_PrivateRec  *afont_private );
+
  /* */
 
 
--- a/src/base/fttype1.c
+++ b/src/base/fttype1.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType utility file for PS names support (body).                   */
 /*                                                                         */
-/*  Copyright 2002, 2003 by                                                */
+/*  Copyright 2002, 2003, 2004 by                                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -64,6 +64,30 @@
     }
 
     return result;
+  }
+
+
+  /* documentation is in t1tables.h */
+
+  FT_EXPORT_DEF( FT_Error )
+  FT_Get_PS_Font_Private( FT_Face         face,
+                          PS_PrivateRec*  afont_private )
+  {
+    FT_Error  error = FT_Err_Invalid_Argument;
+
+
+    if ( face )
+    {
+      FT_Service_PsInfo  service = NULL;
+
+
+      FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
+
+      if ( service && service->ps_get_font_private )
+        error = service->ps_get_font_private( face, afont_private );
+    }
+
+    return error;
   }
 
 
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -338,8 +338,9 @@
 
   static const FT_Service_PsInfoRec  cff_service_ps_info =
   {
-    (PS_GetFontInfoFunc)  NULL,         /* unsupported with CFF fonts */
-    (PS_HasGlyphNamesFunc)cff_ps_has_glyph_names
+    (PS_GetFontInfoFunc)   NULL,        /* unsupported with CFF fonts */
+    (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
+    (PS_GetFontPrivateFunc)NULL         /* unsupported with CFF fonts */
   };
 
 
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -78,8 +78,9 @@
 
   static const FT_Service_PsInfoRec  cid_service_ps_info =
   {
-    (PS_GetFontInfoFunc)  cid_ps_get_font_info,
-    (PS_HasGlyphNamesFunc)NULL          /* unsupported with CID fonts */
+    (PS_GetFontInfoFunc)   cid_ps_get_font_info,
+    (PS_HasGlyphNamesFunc) NULL,        /* unsupported with CID fonts */
+    (PS_GetFontPrivateFunc)NULL         /* unsupported                */
   };
 
 
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -160,10 +160,20 @@
   }
 
 
+  static FT_Error
+  t1_ps_get_font_private( FT_Face         face,
+                          PS_PrivateRec*  afont_private )
+  {
+    *afont_private = ((T1_Face)face)->type1.private_dict;
+    return 0;
+  }
+
+
   static const FT_Service_PsInfoRec  t1_service_ps_info =
   {
-    (PS_GetFontInfoFunc)  t1_ps_get_font_info,
-    (PS_HasGlyphNamesFunc)t1_ps_has_glyph_names
+    (PS_GetFontInfoFunc)   t1_ps_get_font_info,
+    (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,
+    (PS_GetFontPrivateFunc)t1_ps_get_font_private,
   };
 
 
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -139,7 +139,7 @@
                         PS_FontInfoRec*  afont_info )
   {
     *afont_info = ((T42_Face)face)->type1.font_info;
-    return 0;
+    return T42_Err_Ok;
   }
 
 
@@ -151,10 +151,20 @@
   }
 
 
+  static FT_Error
+  t42_ps_get_font_private( FT_Face         face,
+                           PS_PrivateRec*  afont_private )
+  {
+    *afont_private = ((T42_Face)face)->type1.private_dict;
+    return T42_Err_Ok;
+  }
+
+
   static const FT_Service_PsInfoRec  t42_service_ps_info =
   {
-    (PS_GetFontInfoFunc)  t42_ps_get_font_info,
-    (PS_HasGlyphNamesFunc)t42_ps_has_glyph_names
+    (PS_GetFontInfoFunc)   t42_ps_get_font_info,
+    (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names,
+    (PS_GetFontPrivateFunc)t42_ps_get_font_private
   };
 
 
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -1053,9 +1053,9 @@
             if ( !name )
               continue;
 
-            if ( cur[0] == name[0]                      && 
-                 len == ft_strlen( (const char *)name ) &&
-                 ft_memcmp( cur, name, len ) == 0       )
+            if ( cur[0] == name[0]                                  && 
+                 len == (FT_PtrDist)ft_strlen( (const char *)name ) &&
+                 ft_memcmp( cur, name, len ) == 0                   )
             {
               /* we found it -- run the parsing callback! */
               parser->root.error = t42_load_keyword( face,