Commit ba80d61c7ab146002db3a851dca39e5a02fbb7aa

Werner Lemberg 2004-04-16T09:56:30

* builds/unix/ftconfig.in, builds/vms/ftconfig.h: Define FT_CHAR_BIT. * src/base/ftobjs.c (FT_Load_Glyph): Don't apply autohinting if glyph is vertically distorted or mirrored. * src/cff/cffgload.c (cff_slot_load): Handle zero `size' properly for embedded bitmaps. * docs/CHANGES: Updated.

diff --git a/ChangeLog b/ChangeLog
index 47c2915..6ff5484 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-04-15  Werner Lemberg  <wl@gnu.org>
+
+	* builds/unix/ftconfig.in, builds/vms/ftconfig.h: Define
+	FT_CHAR_BIT.
+
+	* src/base/ftobjs.c (FT_Load_Glyph): Don't apply autohinting if
+	glyph is vertically distorted or mirrored.
+
+	* src/cff/cffgload.c (cff_slot_load): Handle zero `size' properly
+	for embedded bitmaps.
+
+	* docs/CHANGES: Updated.
+
 2004-04-15  bytesoftware  <bytesoftware@btinternet.com>
 
 	* include/freetype/config/ftconfig.h, src/base/ftstream.c
diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index 39205d6..6d8f1e8 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    UNIX-specific configuration file (specification only).               */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003 by                                     */
+/*  Copyright 1996-2001, 2002, 2003, 2004 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -67,6 +67,7 @@ FT_BEGIN_HEADER
 #define FT_SIZEOF_INT   SIZEOF_INT
 #define FT_SIZEOF_LONG  SIZEOF_LONG
 
+#define FT_CHAR_BIT  CHAR_BIT
 
   /* Preferred alignment of data */
 #define FT_ALIGNMENT  8
diff --git a/builds/vms/ftconfig.h b/builds/vms/ftconfig.h
index 795e757..dcce1e0 100644
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    VMS-specific configuration file (specification only).                */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003 by                                     */
+/*  Copyright 1996-2001, 2002, 2003, 2004 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -67,6 +67,8 @@ FT_BEGIN_HEADER
 #define FT_SIZEOF_INT   4
 #define FT_SIZEOF_LONG  4
 
+#define FT_CHAR_BIT  8
+
 
   /* Preferred alignment of data */
 #define FT_ALIGNMENT  8
diff --git a/docs/CHANGES b/docs/CHANGES
index 6ca0e1c..6f787b0 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -6,7 +6,7 @@ LATEST CHANGES BETWEEN 2.1.8 and 2.1.7
     - The native  TrueType hinter contained some  bugs which prevented
       some fonts to be rendered correctly, most notably Legendum.otf.
 
-    - The PostScript hinter now produces much improved results.
+    - The PostScript hinter now produces improved results.
 
     - The  linear advance  width  and height  values were  incorrectly
       rounded,  making  them virtually  unusable  if  not loaded  with
@@ -39,6 +39,10 @@ LATEST CHANGES BETWEEN 2.1.8 and 2.1.7
 
     - Metrics for BDF and PCF bitmap font formats have been fixed.
 
+    - Autohinting  is now  disabled for  glyphs  which  are vertically
+      distorted  or mirrored  (using a  transformation matrix).   This
+      fixes a bug which produced zero-height glyphs.
+
     - The   `freetype-config'   script   now  handles   --prefix   and
       --exec-prefix correctly; it also  returns the proper --rpath (or
       -R) value if FreeType has been built as a shared library.
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 3f27cd7..517e83e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -517,7 +517,10 @@
         autohint = 0;
     }
 
-    if ( autohint )
+    /* don't apply autohinting if glyph is vertically distorted or */
+    /* mirrored                                                    */
+    if ( autohint && !( face->internal->transform_matrix.yy <= 0 ||
+                        face->internal->transform_matrix.yx != 0 ) )
     {
       FT_AutoHinter_Service  hinting;
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index c5bf79e..c1339d8 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2292,11 +2292,6 @@
     FT_Error      error;
     CFF_Decoder   decoder;
     TT_Face       face     = (TT_Face)glyph->root.face;
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-    CFF_Face      cff_face = (CFF_Face)size->root.face;
-    SFNT_Service  sfnt     = (SFNT_Service)cff_face->sfnt;
-    FT_Stream     stream   = cff_face->root.stream;
-#endif
     FT_Bool       hinting;
     CFF_Font      cff      = (CFF_Font)face->extra.data;
 
@@ -2321,53 +2316,60 @@
     /*                                                 */
     /* XXX: The convention should be emphasized in     */
     /*      the documents because it can be confusing. */
-    if ( size                                    &&
-         size->strike_index != 0xFFFFU           &&
-         sfnt->load_sbits                        &&
-         ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
+    if ( size )
     {
-      TT_SBit_MetricsRec  metrics;
+      CFF_Face      cff_face = (CFF_Face)size->root.face;
+      SFNT_Service  sfnt     = (SFNT_Service)cff_face->sfnt;
+      FT_Stream     stream   = cff_face->root.stream;
 
 
-      error = sfnt->load_sbit_image( face,
-                                     (FT_ULong)size->strike_index,
-                                     (FT_UInt)glyph_index,
-                                     (FT_Int)load_flags,  
-                                     stream,
-                                     &glyph->root.bitmap,
-                                     &metrics );
-
-      if ( !error )
+      if ( size->strike_index != 0xFFFFU           &&
+           sfnt->load_sbits                        &&
+           ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
       {
-        glyph->root.outline.n_points   = 0;
-        glyph->root.outline.n_contours = 0;
+        TT_SBit_MetricsRec  metrics;
 
-        glyph->root.metrics.width  = (FT_Pos)metrics.width  << 6;
-        glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
 
-        glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
-        glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
-        glyph->root.metrics.horiAdvance  = (FT_Pos)metrics.horiAdvance  << 6;
+        error = sfnt->load_sbit_image( face,
+                                       (FT_ULong)size->strike_index,
+                                       (FT_UInt)glyph_index,
+                                       (FT_Int)load_flags,
+                                       stream,
+                                       &glyph->root.bitmap,
+                                       &metrics );
 
-        glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
-        glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
-        glyph->root.metrics.vertAdvance  = (FT_Pos)metrics.vertAdvance  << 6;
+        if ( !error )
+        {
+          glyph->root.outline.n_points   = 0;
+          glyph->root.outline.n_contours = 0;
 
-        glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
+          glyph->root.metrics.width  = (FT_Pos)metrics.width  << 6;
+          glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
 
-        if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
-        {
-          glyph->root.bitmap_left = metrics.vertBearingX;
-          glyph->root.bitmap_top  = metrics.vertBearingY;
-        }
-        else
-        {   
-          glyph->root.bitmap_left = metrics.horiBearingX;
-          glyph->root.bitmap_top  = metrics.horiBearingY;
+          glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
+          glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
+          glyph->root.metrics.horiAdvance  = (FT_Pos)metrics.horiAdvance  << 6;
+
+          glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
+          glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
+          glyph->root.metrics.vertAdvance  = (FT_Pos)metrics.vertAdvance  << 6;
+
+          glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
+
+          if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+          {
+            glyph->root.bitmap_left = metrics.vertBearingX;
+            glyph->root.bitmap_top  = metrics.vertBearingY;
+          }
+          else
+          {
+            glyph->root.bitmap_left = metrics.horiBearingX;
+            glyph->root.bitmap_top  = metrics.horiBearingY;
+          }
+          return error;
         }
-        return error;
       }
-    }  
+    }
 
 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */