Commit 25f845aa64d720052c92d6f524af7d8eae13db27

David Turner 2002-09-09T23:45:29

* src/cache/ftccache.i: fixed a bug that prevented compilation in debug mode of template instantiation * src/cff/cffparse.c: fixed the CFF table loader. It didn't accept empty arrays, and this prevented the loading of certain fonts. * src/pshinter/pshalgo2.c, src/pshinter/pshalgo3.c: adding fix to prevent seg fault when hints are provided in an empty glyph !! * include/freetype/ftimage.h: removed incorrect "zft_" definitions and updated constants documentation comments * include/freetype/freetype.h (FT_FaceRec): updating documentation comment. The "descender" value is always *negative*, not positive !

diff --git a/ChangeLog b/ChangeLog
index 7e5821f..55b67b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2002-09-09  David Turner  <david@freetype.org>
+
+        * src/cache/ftccache.i: fixed a bug that prevented compilation in
+        debug mode of template instantiation
+
+        * src/cff/cffparse.c: fixed the CFF table loader. It didn't accept
+        empty arrays, and this prevented the loading of certain fonts.
+
+        * src/pshinter/pshalgo2.c, src/pshinter/pshalgo3.c: adding fix to
+        prevent seg fault when hints are provided in an empty glyph !!
+
+2002-09-09  Owen Taylor  <owen@redhat.com>
+
+        * src/pcf/pcfdriver.c (PCF_Glyph_Load): fixing incorrect computation
+        of bitmap metrics.
+
 2002-09-08  David Turner  <david@freetype.org>
 
         * src/smooth/ftsmooth.c, src/base/ftobjs.c,
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 32f03c0..57581f8 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -746,9 +746,9 @@ FT_BEGIN_HEADER
   /*    descender           :: The face's descender is the vertical        */
   /*                           distance from the baseline to the           */
   /*                           bottommost point of any glyph in the face.  */
-  /*                           This field's value is positive, expressed   */
+  /*                           This field's value is *negative*, expressed */
   /*                           in font units.  Some font designs use a     */
-  /*                           value different from `-bbox.yMin'.  Only    */
+  /*                           value different from `bbox.yMin'.  Only     */
   /*                           relevant for scalable formats.              */
   /*                                                                       */
   /*    height              :: The face's height is the vertical distance  */
diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h
index 099fcd3..b150e3c 100644
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -422,25 +422,25 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
-  /*    FT_OUTLINE_NONE                                                    */
+  /*    ft_outline_none                                                    */
   /*                                                                       */
   /* <Description>                                                         */
   /*    This constant is deprecated.  Please use @FT_OUTLINE_NONE          */
   /*    instead.                                                           */
   /*                                                                       */
-#define zft_outline_none  FT_OUTLINE_NONE
+#define ft_outline_none  FT_OUTLINE_NONE
 
 
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
-  /*    FT_OUTLINE_OWNER                                                   */
+  /*    ft_outline_owner                                                   */
   /*                                                                       */
   /* <Description>                                                         */
   /*    This constant is deprecated.  Please use @FT_OUTLINE_OWNER         */
   /*    instead.                                                           */
   /*                                                                       */
-#define zft_outline_owner  FT_OUTLINE_OWNER
+#define ft_outline_owner  FT_OUTLINE_OWNER
 
 
   /*************************************************************************/
@@ -452,55 +452,55 @@ FT_BEGIN_HEADER
   /*    This constant is deprecated.  Please use @FT_OUTLINE_EVEN_ODD_FILL */
   /*    instead.                                                           */
   /*                                                                       */
-#define zft_outline_even_off_fill  FT_OUTLINE_EVEN_ODD_FILL
+#define ft_outline_even_off_fill  FT_OUTLINE_EVEN_ODD_FILL
 
 
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
-  /*    FT_OUTLINE_REVERSE_FILL                                            */
+  /*    ft_outline_reverse_fill                                            */
   /*                                                                       */
   /* <Description>                                                         */
   /*    This constant is deprecated.  Please use @FT_OUTLINE_REVERSE_FILL  */
   /*    instead.                                                           */
   /*                                                                       */
-#define zft_outline_reverse_fill  FT_OUTLINE_REVERSE_FILL
+#define ft_outline_reverse_fill  FT_OUTLINE_REVERSE_FILL
 
 
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
-  /*    FT_OUTLINE_IGNORE_DROPOUTS                                         */
+  /*    ft_outline_ignore_dropouts                                         */
   /*                                                                       */
   /* <Description>                                                         */
   /*    This constant is deprecated.  Please use                           */
   /*    @FT_OUTLINE_IGNORE_DROPOUTS instead.                               */
   /*                                                                       */
-#define zft_outline_ignore_dropouts  FT_OUTLINE_IGNORE_DROPOUTS
+#define ft_outline_ignore_dropouts  FT_OUTLINE_IGNORE_DROPOUTS
 
 
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
-  /*    FT_OUTLINE_HIGH_PRECISION                                          */
+  /*    ft_outline_high_precision                                          */
   /*                                                                       */
   /* <Description>                                                         */
   /*    This constant is deprecated.  Please use                           */
   /*    @FT_OUTLINE_HIGH_PRECISION instead.                                */
   /*                                                                       */
-#define zft_outline_high_precision  FT_OUTLINE_HIGH_PRECISION
+#define ft_outline_high_precision  FT_OUTLINE_HIGH_PRECISION
 
 
   /*************************************************************************/
   /*                                                                       */
   /* <Const>                                                               */
-  /*    FT_OUTLINE_SINGLE_PASS                                             */
+  /*    ft_outline_single_pass                                             */
   /*                                                                       */
   /* <Description>                                                         */
   /*    This constant is deprecated.  Please use @FT_OUTLINE_SINGLE_PASS   */
   /*    instead.                                                           */
   /*                                                                       */
-#define zft_outline_single_pass  FT_OUTLINE_SINGLE_PASS
+#define ft_outline_single_pass  FT_OUTLINE_SINGLE_PASS
 
   /* */
 
diff --git a/src/cache/ftccache.i b/src/cache/ftccache.i
index 8ecf395..bb6e631 100644
--- a/src/cache/ftccache.i
+++ b/src/cache/ftccache.i
@@ -89,16 +89,6 @@
         bucket  = cache->buckets + idx;
       }
 
-#ifdef FT_DEBUG_LEVEL_ERROR
-      if ( query->family     != family                        ||
-           family->fam_index >= cache->manager->families.size )
-      {
-        FT_ERROR((
-          "ftc_cache_lookup: invalid query (bad 'family' field)\n" ));
-        return FTC_Err_Invalid_Argument;
-      }
-#endif
-
       pnode = bucket;
 
       for ( ;; )
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index b2c089b..43cc559 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -542,16 +542,15 @@
         const CFF_Field_Handler*  field;
 
 
-        /* first of all, a trivial check */
-        if ( num_args < 1 )
-          goto Stack_Underflow;
-
         *parser->top = p;
         code = v;
         if ( v == 12 )
         {
           /* two byte operator */
           p++;
+          if ( p >= limit )
+            goto Syntax_Error;
+
           code = 0x100 | p[0];
         }
         code = code | parser->object_code;
@@ -565,6 +564,11 @@
             FT_Byte*  q = (FT_Byte*)parser->object + field->offset;
 
 
+            /* check that we have enough arguments -- except for */
+            /* delta encoded arrays, which can be empty          */
+            if ( field->kind != cff_kind_delta && num_args < 1 )
+              goto Stack_Underflow;
+
             switch ( field->kind )
             {
             case cff_kind_bool:
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index cdaadb5..74e96ba 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -414,7 +414,8 @@ THE SOFTWARE.
     slot->metrics.horiAdvance  = metric->characterWidth << 6 ;
     slot->metrics.horiBearingX = metric->leftSideBearing << 6 ;
     slot->metrics.horiBearingY = metric->ascent << 6 ;
-    slot->metrics.width        = metric->characterWidth << 6 ;
+    slot->metrics.width        = ( metric->rightSideBearing -
+                                   metric->leftSideBearing ) << 6;
     slot->metrics.height       = bitmap->rows << 6;
 
     slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16;
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index 372ff28..c0a9265 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -1128,7 +1128,7 @@
 
 
       /* process secondary hints to "selected" points */
-      if ( num_masks > 1 )
+      if ( num_masks > 1 && glyph->num_points > 0 )
       {
         first = mask->end_point;
         mask++;
diff --git a/src/pshinter/pshalgo3.c b/src/pshinter/pshalgo3.c
index bd65068..6174553 100644
--- a/src/pshinter/pshalgo3.c
+++ b/src/pshinter/pshalgo3.c
@@ -1297,7 +1297,7 @@
 
 
       /* process secondary hints to "selected" points */
-      if ( num_masks > 1 )
+      if ( num_masks > 1 && glyph->num_points > 0 )
       {
         first = mask->end_point;
         mask++;
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index e982c53..636d32f 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -720,7 +720,7 @@
       sbit_metrics->y_scale     = 1 << 16;
 #endif
 
-      sbit_metrics->ascender    = strike->hori.ascender << 6;
+      sbit_metrics->ascender    = strike->hori.ascender  << 6;
       sbit_metrics->descender   = strike->hori.descender << 6;
 
       /* XXX: Is this correct? */