On 04/20/11 03:11, Werner LEMBERG wrote:
>> Every user of FreeType that I know has once in their lifetime hit
>> the bug that with many common CJK fonts, non-CJK characters take
>> doublewidth where they should take a single one.  The fix always has
>> been to pass FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH to FreeType, as the
>> fonts have the bit set wrongly.  A "monospace" CJK font is never
>> monospace.  It has single-width glyphs, and double-width, hence
>> setting global-advance is wrong in the font.
>>
>> But since this is such a common issue, I wonder if FreeType should
>> simply ignore global advance by default.  Cairo and fontconfig
>> always pass that flag to FreeType.  I've seen this bug hit Qt
>> before.  And most recently I watched it hit Skia.
> 
> I've already pondered about this problem, but I've found no solution
> which guarantees backwards compatibility.  Your idea of completely
> ignoring this flag didn't come to my mind :-)
> 
> Since your suggestion sounds sensible, could you provide a patch?

Attached.  You also need to update the ft2demos that use it to remove the
option (ftdiff, etc).

behdad

>     Werner
commit 544aeed84bd287a6897e341025c8a15dcbc29361
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Wed Apr 20 14:52:12 2011 -0400

    Always ignore global advance
    
    This makes FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH redundant, deprecated,
    and ignored.  The new behavior is what every major user of FreeType
    has been requesting.  Global advance is broken in many CJK fonts.
    Just ignoring it by default makes most sense.

diff --git a/builds/unix/install-sh b/builds/unix/install-sh
old mode 100644
new mode 100755
index a5897de..6781b98
--- a/builds/unix/install-sh
+++ b/builds/unix/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2006-12-25.00
+scriptversion=2009-04-28.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -515,5 +515,6 @@ done
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index b9e34e2..3956676 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2444,13 +2444,7 @@ FT_BEGIN_HEADER
    *     in fonts.  By default, FreeType tries to handle broken fonts also.
    *
    *   FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
-   *     Indicates that the font driver should ignore the global advance
-   *     width defined in the font.  By default, that value is used as the
-   *     advance width for all glyphs when the face has
-   *     @FT_FACE_FLAG_FIXED_WIDTH set.
-   *
-   *     This flag exists for historical reasons (to support buggy CJK
-   *     fonts).
+   *     Ignored.  Deprecated.
    *
    *   FT_LOAD_NO_RECURSE ::
    *     This flag is only used internally.  It merely indicates that the
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index d723b57..fd30661 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -135,8 +135,6 @@
   {
     FT_UInt  nn;
     TT_Face  face  = (TT_Face) ttface;
-    FT_Bool  check = FT_BOOL(
-                       !( flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) );
 
 
     /* XXX: TODO: check for sbits */
@@ -149,7 +147,7 @@
         FT_UShort  ah;
 
 
-        TT_Get_VMetrics( face, start + nn, check, &tsb, &ah );
+        TT_Get_VMetrics( face, start + nn, &tsb, &ah );
         advances[nn] = ah;
       }
     }
@@ -161,7 +159,7 @@
         FT_UShort  aw;
 
 
-        TT_Get_HMetrics( face, start + nn, check, &lsb, &aw );
+        TT_Get_HMetrics( face, start + nn, &lsb, &aw );
         advances[nn] = aw;
       }
     }
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index b2cab01..7923c6b 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -65,22 +65,16 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* Returns the horizontal metrics in font units for a given glyph.  If   */
-  /* `check' is true, take care of monospaced fonts by returning the       */
-  /* advance width maximum.                                                */
+  /* Returns the horizontal metrics in font units for a given glyph.       */
   /*                                                                       */
   FT_LOCAL_DEF( void )
   TT_Get_HMetrics( TT_Face     face,
                    FT_UInt     idx,
-                   FT_Bool     check,
                    FT_Short*   lsb,
                    FT_UShort*  aw )
   {
     ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
 
-    if ( check && face->postscript.isFixedPitch )
-      *aw = face->horizontal.advance_Width_Max;
-
     FT_TRACE5(( "  advance width (font units): %d\n", *aw ));
     FT_TRACE5(( "  left side bearing (font units): %d\n", *lsb ));
   }
@@ -96,18 +90,12 @@
   /* apparently does: It uses the ppem value as the advance height, and    */
   /* sets the top side bearing to be zero.                                 */
   /*                                                                       */
-  /* The monospace `check' is probably not meaningful here, but we leave   */
-  /* it in for a consistent interface.                                     */
-  /*                                                                       */
   FT_LOCAL_DEF( void )
   TT_Get_VMetrics( TT_Face     face,
                    FT_UInt     idx,
-                   FT_Bool     check,
                    FT_Short*   tsb,
                    FT_UShort*  ah )
   {
-    FT_UNUSED( check );
-
     if ( face->vertical_info )
       ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
 
@@ -150,13 +138,9 @@
 
 
     TT_Get_HMetrics( face, glyph_index,
-                     (FT_Bool)!( loader->load_flags &
-                                 FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
                      &left_bearing,
                      &advance_width );
     TT_Get_VMetrics( face, glyph_index,
-                     (FT_Bool)!( loader->load_flags &
-                                 FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
                      &top_bearing,
                      &advance_height );
 
@@ -1655,23 +1639,7 @@
 
     /* get the device-independent horizontal advance; it is scaled later */
     /* by the base layer.                                                */
-    {
-      FT_Pos  advance = loader->linear;
-
-
-      /* the flag FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH was introduced to */
-      /* correctly support DynaLab fonts, which have an incorrect       */
-      /* `advance_Width_Max' field!  It is used, to my knowledge,       */
-      /* exclusively in the X-TrueType font server.                     */
-      /*                                                                */
-      if ( face->postscript.isFixedPitch                                     &&
-           ( loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
-        advance = face->horizontal.advance_Width_Max;
-
-      /* we need to return the advance in font units in linearHoriAdvance, */
-      /* it will be scaled later by the base layer.                        */
-      glyph->linearHoriAdvance = advance;
-    }
+    glyph->linearHoriAdvance = loader->linear;
 
     glyph->metrics.horiBearingX = bbox.xMin;
     glyph->metrics.horiBearingY = bbox.yMax;
@@ -2049,9 +2017,6 @@
           glyph->linearHoriAdvance = loader.linear;
           glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
                                        loader.vadvance;
-          if ( face->postscript.isFixedPitch                             &&
-               ( load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
-            glyph->linearHoriAdvance = face->horizontal.advance_Width_Max;
         }
 
         return TT_Err_Ok;
diff --git a/src/truetype/ttgload.h b/src/truetype/ttgload.h
index 958d67d..4477e6e 100644
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -37,14 +37,12 @@ FT_BEGIN_HEADER
   FT_LOCAL( void )
   TT_Get_HMetrics( TT_Face     face,
                    FT_UInt     idx,
-                   FT_Bool     check,
                    FT_Short*   lsb,
                    FT_UShort*  aw );
 
   FT_LOCAL( void )
   TT_Get_VMetrics( TT_Face     face,
                    FT_UInt     idx,
-                   FT_Bool     check,
                    FT_Short*   tsb,
                    FT_UShort*  ah );
 
_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to