shithub: freetype+ttf2subf

Download patch

ref: ba80d61c7ab146002db3a851dca39e5a02fbb7aa
parent: 8a803a6c2bc952d85f47df07f4d01c879987898b
author: Werner Lemberg <[email protected]>
date: Fri Apr 16 05:56:30 EDT 2004

* 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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-04-15  Werner Lemberg  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* include/freetype/config/ftconfig.h, src/base/ftstream.c
--- 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 @@
 #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
--- 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,       */
@@ -66,6 +66,8 @@
 
 #define FT_SIZEOF_INT   4
 #define FT_SIZEOF_LONG  4
+
+#define FT_CHAR_BIT  8
 
 
   /* Preferred alignment of data */
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -6,7 +6,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
@@ -38,6 +38,10 @@
       rendered correctly in some cases.
 
     - 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
--- 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;
 
--- 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;
+          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;
         }
-        else
-        {   
-          glyph->root.bitmap_left = metrics.horiBearingX;
-          glyph->root.bitmap_top  = metrics.horiBearingY;
-        }
-        return error;
       }
-    }  
+    }
 
 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */