Commit 31654e1bed276b0e16c1a213735c18a905ad9f00

David Turner 2002-09-24T23:39:58

2002-09-25 David Turner <david@freetype.org> * src/autohint/ahtypes.h: disabling metrics hinting in the auto-hinter. this produces much better anti-aliased text 2002-09-25 Anthony Fok <anthony@thizlinux.com> * 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)

diff --git a/ChangeLog b/ChangeLog
index 07c110e..fc3228f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-09-25  David Turner  <david@freetype.org>
+
+        * src/autohint/ahtypes.h: disabling metrics hinting in the auto-hinter.
+        this produces much better anti-aliased text
+
+2002-09-25  Anthony Fok  <anthony@thizlinux.com>
+
+        * 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  <porthos.domroese@harz.de>
 
 	* src/truetype/ttdriver.c (Load_Glyph): Fourth parameter must be
diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h
index f492d7b..50d0f86 100644
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -92,7 +92,7 @@ FT_BEGIN_HEADER
   /* no reason to do this (at least for non-CJK scripts), except for       */
   /* experimentation.                                                      */
   /*                                                                       */
-#define AH_HINT_METRICS
+#undef  AH_HINT_METRICS
 
 
   /*************************************************************************/
diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c
index 3d0f0aa..30ef8b7 100644
--- 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;
@@ -895,6 +917,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;