shithub: freetype+ttf2subf

Download patch

ref: 03e8b2f763ea0368e714345d98c534226915adc6
parent: 17904a107a6cb6e5ba7999e3b25f38919d7e86e5
author: John Tytgat <[email protected]>
date: Tue Sep 1 04:10:24 EDT 2009

Fix custom cmap for empty Type 1 font (Savannah bug #27294).

* include/freetype/internal/t1types.h (T1_EncodingRecRec_): Update
comment to reflect revised code_last meaning.
* src/type1/t1load.c (T1_Open_Face), src/type42/t42objs.c
(T42_Open_Face): Assign max_char as highest character code + 1 and
use this for T1_EncodingRecRec_::code_last.
* src/psaux/t1cmap.c (t1_cmap_custom_init): Follow revised
T1_EncodingRecRec_::code_last meaning.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-09-01  John Tytgat <[email protected]>
+
+	Fix custom cmap for empty Type 1 font (Savannah bug #27294).
+
+	* include/freetype/internal/t1types.h (T1_EncodingRecRec_): Update
+	comment to reflect revised code_last meaning.
+	* src/type1/t1load.c (T1_Open_Face), src/type42/t42objs.c
+	(T42_Open_Face): Assign max_char as highest character code + 1 and
+	use this for T1_EncodingRecRec_::code_last.
+	* src/psaux/t1cmap.c (t1_cmap_custom_init): Follow revised
+	T1_EncodingRecRec_::code_last meaning.
+
 2009-08-25  Werner Lemberg  <[email protected]>
 
 	Fix rendering of horizontally compressed CFFs.
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -58,7 +58,9 @@
   /*                                                                       */
   /*    code_first :: The lowest valid character code in the encoding.     */
   /*                                                                       */
-  /*    code_last  :: The highest valid character code in the encoding.    */
+  /*    code_last  :: The highest valid character code in the encoding     */
+  /*                  + 1. When equal to code_first there are no valid     */
+  /*                  character codes.                                     */
   /*                                                                       */
   /*    char_index :: An array of corresponding glyph indices.             */
   /*                                                                       */
--- a/src/psaux/t1cmap.c
+++ b/src/psaux/t1cmap.c
@@ -179,7 +179,7 @@
 
 
     cmap->first   = encoding->code_first;
-    cmap->count   = (FT_UInt)( encoding->code_last - cmap->first + 1 );
+    cmap->count   = (FT_UInt)( encoding->code_last - cmap->first );
     cmap->indices = encoding->char_index;
 
     FT_ASSERT( cmap->indices != NULL );
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -2182,8 +2182,8 @@
       /* the index is then stored in type1.encoding.char_index, and */
       /* a the name to type1.encoding.char_name                     */
 
-      min_char = +32000;
-      max_char = -32000;
+      min_char = 0;
+      max_char = 0;
 
       charcode = 0;
       for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
@@ -2209,23 +2209,12 @@
               {
                 if ( charcode < min_char )
                   min_char = charcode;
-                if ( charcode > max_char )
-                  max_char = charcode;
+                if ( charcode >= max_char )
+                  max_char = charcode + 1;
               }
               break;
             }
           }
-      }
-
-      /*
-       *  Yes, this happens: Certain PDF-embedded fonts have only a
-       *  `.notdef' glyph defined!
-       */
-
-      if ( min_char > max_char )
-      {
-        min_char = 0;
-        max_char = loader.encoding_table.max_elems;
       }
 
       type1->encoding.code_first = min_char;
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -100,8 +100,8 @@
       /* The index is then stored in type1.encoding.char_index, and  */
       /* the name in type1.encoding.char_name                        */
 
-      min_char = +32000;
-      max_char = -32000;
+      min_char = 0;
+      max_char = 0;
 
       charcode = 0;
       for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
@@ -127,13 +127,14 @@
               {
                 if ( charcode < min_char )
                   min_char = charcode;
-                if ( charcode > max_char )
-                  max_char = charcode;
+                if ( charcode >= max_char )
+                  max_char = charcode + 1;
               }
               break;
             }
           }
       }
+
       type1->encoding.code_first = min_char;
       type1->encoding.code_last  = max_char;
       type1->encoding.num_chars  = loader.num_chars;