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((