shithub: freetype+ttf2subf

Download patch

ref: a9cd856ee2cdd939ceca7e64f17fdd341e92fd1b
parent: 7f1458aaa389317124eb807e5b71f0fb9c0d3746
author: Werner Lemberg <[email protected]>
date: Thu Dec 18 03:18:37 EST 2003

* src/cff/cfftypes.h (CFF_FontRecDictRec): Change type of
`cid_count' to `FT_ULong'.

* src/cff/cffgload.c (cff_slot_load): Take care of empty `cids'
array.

* src/cff/cffload.c (cff_charset_done): Free `cids' array.
(cff_font_load): Create cids array only for CID-keyed fonts which
are subsetted.

* src/cff/cffobjs.c (cff_face_init): Check the availability of
the PSNames modules for non-pure CFFs also.
Set FT_FACE_FLAG_GLYPH_NAMES for a non-pure CFF also if it isn't
CID-keyed.

* src/cff/rules.mk (CFF_DRV_H): Add cfftypes.h.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-12-18  Werner Lemberg  <[email protected]>
+
+	* src/cff/cfftypes.h (CFF_FontRecDictRec): Change type of
+	`cid_count' to `FT_ULong'.
+
+	* src/cff/cffgload.c (cff_slot_load): Take care of empty `cids'
+	array.
+
+	* src/cff/cffload.c (cff_charset_done): Free `cids' array.
+	(cff_font_load): Create cids array only for CID-keyed fonts which
+	are subsetted.
+
+	* src/cff/cffobjs.c (cff_face_init): Check the availability of
+	the PSNames modules for non-pure CFFs also.
+	Set FT_FACE_FLAG_GLYPH_NAMES for a non-pure CFF also if it isn't
+	CID-keyed.
+
+	* src/cff/rules.mk (CFF_DRV_H): Add cfftypes.h.
+
 2003-12-17  Werner Lemberg  <[email protected]>
 
 	* src/sfnt/sfobjs.c (sfnt_init_face): Don't set
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -14,8 +14,8 @@
       correctly  treated as a CID,  similar to  FreeType's CID  driver
       module.  Note that CID CMaps support is still missing.
 
-    - SFNT  based fonts  no longer  set  the FT_FACE_FLAGS_GLYPH_NAMES
-      flag if a version 3.0 `post' table is present.
+    - The FT_FACE_FLAGS_GLYPH_NAMES is now  set correctly for all font
+      formats.
 
 
   II. IMPORTANT CHANGES
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2316,8 +2316,10 @@
 
 
       /* in a CID-keyed font, consider `glyph_index' as a CID and map */
-      /* it immediately to the real glyph_index                       */
-      if ( cff->top_font.font_dict.cid_registry != 0xFFFFU )
+      /* it immediately to the real glyph_index -- if it isn't a      */
+      /* subsetted font, glyph_indices and CIDs are identical, though */
+      if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
+           cff->charset.cids )
         glyph_index = cff->charset.cids[glyph_index];
 
       cff_decoder_init( &decoder, face, size, glyph, hinting,
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1501,6 +1501,7 @@
 
 
     FT_FREE( charset->sids );
+    FT_FREE( charset->cids );
     charset->format = 0;
     charset->offset = 0;
   }
@@ -1672,7 +1673,7 @@
       }
     }
 
-    /* we have to invert the `sids' array for CID-keyed fonts */
+    /* we have to invert the `sids' array for subsetted CID-keyed fonts */
     if ( invert )
     {
       FT_UInt    i;
@@ -2244,9 +2245,13 @@
     /* read the Charset and Encoding tables if available */
     if ( font->num_glyphs > 0 )
     {
+      FT_Bool  invert;
+
+
+      invert = dict->cid_registry != 0xFFFFU &&
+               font->charstrings_index.count != dict->cid_count;
       error = cff_charset_load( &font->charset, font->num_glyphs, stream,
-                                base_offset, dict->charset_offset,
-                                dict->cid_registry != 0xFFFFU );
+                                base_offset, dict->charset_offset, invert );
       if ( error )
         goto Exit;
 
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -337,10 +337,11 @@
 
     /* now load and parse the CFF table in the file */
     {
-      CFF_Font   cff;
-      FT_Memory  memory = face->root.memory;
-      FT_Face    root;
-      FT_Int32   flags;
+      CFF_Font         cff;
+      CFF_FontRecDict  dict;
+      FT_Memory        memory = face->root.memory;
+      FT_Face          root;
+      FT_Int32         flags;
 
 
       if ( FT_NEW( cff ) )
@@ -360,23 +361,24 @@
       root             = &face->root;
       root->num_glyphs = cff->num_glyphs;
 
+      dict = &cff->top_font.font_dict;
+
+      /* we need the `PSNames' module for CFF and CEF formats */
+      /* which aren't CID-keyed                               */
+      if ( dict->cid_registry == 0xFFFFU && !psnames )
+      {
+        FT_ERROR(( "cff_face_init:" ));
+        FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
+        FT_ERROR(( "              " ));
+        FT_ERROR(( " without the `PSNames' module\n" ));
+        goto Bad_Format;
+      }
+
       if ( pure_cff )
       {
-        CFF_FontRecDict  dict = &cff->top_font.font_dict;
-        char*            style_name;
+        char*  style_name;
 
 
-        /* we need the `PSNames' module for pure-CFF and CEF formats */
-        /* which aren't CID-keyed                                    */
-        if ( dict->cid_registry == 0xFFFFU && !psnames )
-        {
-          FT_ERROR(( "cff_face_init:" ));
-          FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
-          FT_ERROR(( "              " ));
-          FT_ERROR(( " without the `PSNames' module\n" ));
-          goto Bad_Format;
-        }
-
         /* Set up num_faces. */
         root->num_faces = cff->num_faces;
 
@@ -483,12 +485,6 @@
           flags |= FT_FACE_FLAG_KERNING;
 #endif
 
-#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
-        /* CID-keyed CFF fonts don't have glyph names */
-        if ( dict->cid_registry == 0xFFFFU )
-          flags |= FT_FACE_FLAG_GLYPH_NAMES;
-#endif
-
         root->face_flags = flags;
 
         /*******************************************************************/
@@ -514,6 +510,13 @@
 
         root->style_flags = flags;
       }
+
+#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
+      /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */
+      /* has unset this flag because of the 3.0 `post' table           */
+      if ( dict->cid_registry == 0xFFFFU )
+        root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
+#endif
 
       /*******************************************************************/
       /*                                                                 */
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -123,7 +123,7 @@
     FT_Long    cid_font_version;
     FT_Long    cid_font_revision;
     FT_Long    cid_font_type;
-    FT_Long    cid_count;
+    FT_ULong   cid_count;
     FT_ULong   cid_uid_base;
     FT_ULong   cid_fd_array_offset;
     FT_ULong   cid_fd_select_offset;
--- a/src/cff/rules.mk
+++ b/src/cff/rules.mk
@@ -34,6 +34,7 @@
 #
 CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \
              $(CFF_DIR)/cfftoken.h  \
+             $(CFF_DIR)/cfftypes.h  \
              $(CFF_DIR)/cfferrs.h