shithub: freetype+ttf2subf

Download patch

ref: ef915c36f45ee58c5b6b09814d13d918563aa1b3
parent: 2f10956744dd32fc4bc5e427ab5425f87ba7feb5
author: Werner Lemberg <[email protected]>
date: Mon Jul 16 16:46:05 EDT 2007

* docs/CHANGES: Updated.


Add new service for getting the ROS from a CID font.

* include/freetype/config/ftheader.h (FT_CID_H): New macro.
* include/freetype/ftcid.h: New file.

* include/freetype/internal/ftserv.h (FT_SERVIVE_CID_H): New macro.
* include/freetype/internal/services/svcid.h: New file.

* src/base/ftcid.c: New file.

* src/cff/cffdrivr.c: Include FT_SERVICE_CID_H.
(cff_get_ros): New function.
(cff_service_cid_info): New service structure.
(cff_services): Register it.

* src/cff/cffload.c (cff_font_done): Free registry and ordering.

* src/cff/cfftypes.h (CFF_FontRec): Add `registry' and `ordering'.

* modules.cfg (BASE_EXTENSIONS): Add ftcid.c.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2007-07-16  Werner Lemberg  <[email protected]>
+
+	* docs/CHANGES: Updated.
+
+2007-07-16  Derek Clegg  <[email protected]>
+
+	Add new service for getting the ROS from a CID font.
+
+	* include/freetype/config/ftheader.h (FT_CID_H): New macro.
+	* include/freetype/ftcid.h: New file.
+
+	* include/freetype/internal/ftserv.h (FT_SERVIVE_CID_H): New macro.
+	* include/freetype/internal/services/svcid.h: New file.
+
+	* src/base/ftcid.c: New file.
+
+	* src/cff/cffdrivr.c: Include FT_SERVICE_CID_H.
+	(cff_get_ros): New function.
+	(cff_service_cid_info): New service structure.
+	(cff_services): Register it.
+
+	* src/cff/cffload.c (cff_font_done): Free registry and ordering.
+
+	* src/cff/cfftypes.h (CFF_FontRec): Add `registry' and `ordering'.
+
+	* modules.cfg (BASE_EXTENSIONS): Add ftcid.c.
+
 2007-07-11  Derek Clegg  <[email protected]>
 
 	Add support for postscript name service to CFF driver.
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -1,4 +1,16 @@
 
+CHANGES BETWEEN 2.3.6 and 2.3.5
+
+  II. IMPORTANT CHANGES
+
+    - The new function `FT_Get_CID_Registry_Ordering_Supplement' gives
+      access to  those fields in a CID-keyed font.  The code  has been
+      contributed by Derek Clegg.
+
+
+======================================================================
+
+
 CHANGES BETWEEN 2.3.5 and 2.3.4
 
   I. IMPORTANT BUG FIXES
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -386,6 +386,20 @@
   /*************************************************************************
    *
    * @macro:
+   *   FT_CID_H
+   *
+   * @description:
+   *   A macro used in #include statements to name the file containing the
+   *   definitions of an API which access CID font information from a
+   *   face.
+   *
+   */
+#define FT_CID_H  <freetype/ftcid.h>
+
+
+  /*************************************************************************
+   *
+   * @macro:
    *   FT_GZIP_H
    *
    * @description:
--- a/include/freetype/ftchapters.h
+++ b/include/freetype/ftchapters.h
@@ -54,6 +54,7 @@
 /*    type1_tables                                                         */
 /*    sfnt_names                                                           */
 /*    bdf_fonts                                                            */
+/*    cid_fonts                                                            */
 /*    pfr_fonts                                                            */
 /*    winfnt_fonts                                                         */
 /*    font_formats                                                         */
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -301,6 +301,7 @@
    */
 
 #define FT_SERVICE_BDF_H                <freetype/internal/services/svbdf.h>
+#define FT_SERVICE_CID_H                <freetype/internal/services/svcid.h>
 #define FT_SERVICE_GLYPH_DICT_H         <freetype/internal/services/svgldict.h>
 #define FT_SERVICE_GX_VALIDATE_H        <freetype/internal/services/svgxval.h>
 #define FT_SERVICE_KERNING_H            <freetype/internal/services/svkern.h>
--- a/modules.cfg
+++ b/modules.cfg
@@ -152,6 +152,11 @@
 # See include/freetype/ftbdf.h for the API.
 BASE_EXTENSIONS += ftbdf.c
 
+# Access CID font information.
+#
+# See include/freetype/ftcid.h for the API.
+BASE_EXTENSIONS += ftcid.c
+
 # Utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp bitmaps into
 # 8bpp format, and for emboldening of bitmap glyphs.
 #
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -22,6 +22,7 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_SFNT_H
 #include FT_TRUETYPE_IDS_H
+#include FT_SERVICE_CID_H
 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
 #include FT_SERVICE_POSTSCRIPT_INFO_H
 #include FT_SERVICE_POSTSCRIPT_NAME_H
@@ -420,6 +421,66 @@
   };
 
 
+  /*
+   * CID INFO SERVICE
+   *
+   */
+  static FT_Error
+  cff_get_ros( CFF_Face      face,
+               const char*  *registry,
+               const char*  *ordering,
+               FT_Int       *supplement )
+  {
+    FT_Error  error = CFF_Err_Ok;
+    CFF_Font  cff   = (CFF_Font)face->extra.data;
+
+
+    if ( cff )
+    {
+      CFF_FontRecDict     dict    = &cff->top_font.font_dict;
+      FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)cff->psnames;
+
+
+      if ( dict->cid_registry == 0xFFFFU )
+      {
+        error = CFF_Err_Invalid_Argument;
+        goto Fail;
+      }
+
+      if ( registry )
+      {
+        if ( cff->registry == NULL )
+          cff->registry = cff_index_get_sid_string( &cff->string_index,
+                                                    dict->cid_registry,
+                                                    psnames );
+        *registry = cff->registry;
+      }
+      
+      if ( ordering )
+      {
+        if ( cff->ordering == NULL )
+          cff->ordering = cff_index_get_sid_string( &cff->string_index,
+                                                    dict->cid_ordering,
+                                                    psnames );
+        *ordering = cff->ordering;
+      }
+
+      if ( supplement )
+        *supplement = dict->cid_supplement;
+
+    }
+      
+    Fail:
+      return error;
+  }
+
+
+  static const FT_Service_CIDRec  cff_service_cid_info =
+  {
+    (FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros
+  };
+
+
   /*************************************************************************/
   /*************************************************************************/
   /*************************************************************************/
@@ -441,6 +502,7 @@
     { FT_SERVICE_ID_GLYPH_DICT,           &cff_service_glyph_dict },
 #endif
     { FT_SERVICE_ID_TT_CMAP,              &cff_service_get_cmap_info },
+    { FT_SERVICE_ID_CID,                  &cff_service_cid_info },
     { NULL, NULL }
   };
 
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1590,6 +1590,9 @@
       FT_FREE( font->font_info );
     }
 
+    FT_FREE( font->registry );
+    FT_FREE( font->ordering );
+
     FT_FREE( font->global_subrs );
     FT_FREE( font->font_name );
   }
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -259,6 +259,10 @@
     /* since version 2.3.0 */
     PS_FontInfoRec*  font_info;   /* font info dictionary */
 
+    /* since version 2.3.6 */
+    FT_String*       registry;
+    FT_String*       ordering;
+      
   } CFF_FontRec, *CFF_Font;