shithub: freetype+ttf2subf

Download patch

ref: 31654e1bed276b0e16c1a213735c18a905ad9f00
parent: e59dc91ff444faa51cbee538fbb3dfa1ebae5edf
author: David Turner <[email protected]>
date: Tue Sep 24 19:39:58 EDT 2002

2002-09-25  David Turner  <[email protected]>

        * src/autohint/ahtypes.h: disabling metrics hinting in the auto-hinter.
        this produces much better anti-aliased text

2002-09-25  Anthony Fok  <[email protected]>

        * src/sfnt/ttcmap0.c: added support for opens___.ttf (it contains
        a charmap that uses offset=0xFFFFU instead of 0x0000 to indicate a
        missing glyph)

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-09-25  David Turner  <[email protected]>
+
+        * src/autohint/ahtypes.h: disabling metrics hinting in the auto-hinter.
+        this produces much better anti-aliased text
+
+2002-09-25  Anthony Fok  <[email protected]>
+
+        * src/sfnt/ttcmap0.c: added support for opens___.ttf (it contains
+        a charmap that uses offset=0xFFFFU instead of 0x0000 to indicate a
+        missing glyph)
+
 2002-09-21  Wolfgang Domr�se  <[email protected]>
 
 	* src/truetype/ttdriver.c (Load_Glyph): Fourth parameter must be
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -92,7 +92,7 @@
   /* no reason to do this (at least for non-CJK scripts), except for       */
   /* experimentation.                                                      */
   /*                                                                       */
-#define AH_HINT_METRICS
+#undef  AH_HINT_METRICS
 
 
   /*************************************************************************/
--- a/src/sfnt/ttcmap0.c
+++ b/src/sfnt/ttcmap0.c
@@ -579,6 +579,12 @@
   /* Otherwise, a glyph index is taken from the glyph ids sub-array for    */
   /* the segment, and the value of `idDelta' is added to it.               */
   /*                                                                       */
+  /*                                                                       */
+  /* Finally, note that certain fonts contain invalid charmaps that        */
+  /* contain end=0xFFFF, start=0xFFFF, delta=0x0001, offset=0xFFFF at the  */
+  /* of their charmaps (e.g. opens___.ttf which comes with OpenOffice.org) */
+  /* we need special code to deal with them correctly...                   */
+  /*                                                                       */
 
 #ifdef TT_CONFIG_CMAP_FORMAT_4
 
@@ -680,7 +686,7 @@
             FT_INVALID_DATA;
         }
 
-        if ( offset )
+        if ( offset && offset != 0xFFFFU )
         {
           p += offset;  /* start of glyph id array */
 
@@ -692,10 +698,10 @@
           /* check glyph indices within the segment range */
           if ( valid->level >= FT_VALIDATE_TIGHT )
           {
-            FT_UInt  idx;
+            FT_UInt  i, idx;
 
 
-            for ( ; start < end; )
+            for ( i = start; i < end; i++ )
             {
               idx = FT_NEXT_USHORT( p );
               if ( idx != 0 )
@@ -708,6 +714,16 @@
             }
           }
         }
+        else if ( offset == 0xFFFFU )
+        {
+          /* Some fonts (erroneously?) use a range offset of 0xFFFF */
+          /* to mean missing glyph in cmap table                    */
+          /*                                                        */
+          if ( valid->level >= FT_VALIDATE_PARANOID                     ||
+               n != num_segs - 1                                        ||
+               !( start == 0xFFFFU && end == 0xFFFFU && delta == 0x1U ) )
+            FT_INVALID_DATA;
+        }
 
         last = end;
       }
@@ -769,6 +785,9 @@
             p += num_segs2;
             offset = TT_PEEK_USHORT( p );
 
+            if ( offset == 0xFFFFU )
+              goto Exit;
+
             if ( offset != 0 )
             {
               p  += offset + 2 * ( idx - start );
@@ -813,6 +832,9 @@
             p += num_segs2;
             offset = TT_PEEK_USHORT( p );
 
+            if ( offset == 0xFFFFU )
+              goto Exit;
+
             if ( offset != 0 )
             {
               p  += offset + 2 * ( idx - start );
@@ -879,7 +901,7 @@
           p += num_segs2;
           offset = TT_PEEK_USHORT( p );
 
-          if ( offset != 0 )
+          if ( offset != 0 && offset != 0xFFFFU )
           {
             /* parse the glyph ids array for non-0 index */
             p += offset + ( code - start ) * 2;
@@ -894,6 +916,12 @@
               }
               code++;
             }
+          }
+          else if ( offset == 0xFFFFU )
+          {
+            /* an offset of 0xFFFF means an empty glyph in certain fonts !! */
+            code = end;
+            break;
           }
           else
             gindex = (FT_UInt)( code + delta ) & 0xFFFFU;