Commit ef915c36f45ee58c5b6b09814d13d918563aa1b3

Werner Lemberg 2007-07-16T20:46:05

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

diff --git a/ChangeLog b/ChangeLog
index 59986bd..3079fed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2007-07-16  Werner Lemberg  <wl@gnu.org>
+
+	* docs/CHANGES: Updated.
+
+2007-07-16  Derek Clegg  <dclegg@apple.com>
+
+	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  <dclegg@apple.com>
 
 	Add support for postscript name service to CFF driver.
diff --git a/docs/CHANGES b/docs/CHANGES
index 79fd778..1c42b86 100644
--- 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
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index b957d05..31aa3d5 100644
--- 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:
diff --git a/include/freetype/ftchapters.h b/include/freetype/ftchapters.h
index bd812c8..9f1eb3f 100644
--- 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                                                         */
diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h
index 45d2fa9..2db3e87 100644
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -301,6 +301,7 @@ FT_BEGIN_HEADER
    */
 
 #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>
diff --git a/modules.cfg b/modules.cfg
index 6d8a95e..525866a 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -152,6 +152,11 @@ BASE_EXTENSIONS += ftbbox.c
 # 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.
 #
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 99740d1..d2f0a4d 100644
--- 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 }
   };
 
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index dd2f113..242c06a 100644
--- 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 );
   }
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index 306e5aa..b5e5115 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -259,6 +259,10 @@ FT_BEGIN_HEADER
     /* 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;