Hello,

I was assigned with the task of dealing with "s p a c e d - o u t " CJK
"fixedPitch" font issue in konsole.  There are quite a few modern CJK
TrueType fonts with the "fixedPitch" flag set to "true" to mean that:

   * All CJK glyphs have the same "fullwidth"
   * The ASCII glyphs and other special glyphs have the same "halfwidth"

I have submitted a small patch to the FreeType mailing list to deal with the
"halfwidth" monospace font issue, and it turns out that Xft has the same
issue.  It took me a while to figure out that it was not konsole or Qt.  :-)

Anyhow, to demonstrate the issue, the following screenshot was taken after
patching FreeType and before patching Xft:

    http://anthony.homelinux.net/~foka/xft/halfwidth-rendered-as-fullwidth.png

The font therein is a popular "fixedPitch" Chinese TrueType font.

After applying the patch to Xft, it looks much nicer:

    http://anthony.homelinux.net/~foka/xft/halfwidth-even-advance.png

Note that this is the case when the "fullwidth" (or full advance width) is
an *even* number, say "16", so that the halfwidth would be "8".

How, when the fullwidth is an *odd* number, say "15", the halfwidth would be
rounded off to "7", but 7 + 7 = 14.  And as you can see from the following
screenshot, the text aren't as nicely aligned:

    http://anthony.homelinux.net/~foka/xft/halfwidth-odd-advance.png

(but of course, still much better than before.  :-)

Any idea on how to deal with the "15 / 2 = 7;  7 + 7 = 14" issue?  :-)

Oh yes, please let me know if the attached patch is okay.  Many thanks!

Cheer,

Anthony

-- 
Anthony Fok Tung-Ling
ThizLinux Laboratory   <[EMAIL PROTECTED]> http://www.thizlinux.com/
Debian Chinese Project <[EMAIL PROTECTED]>       http://www.debian.org/intl/zh/
Come visit Our Lady of Victory Camp!           http://www.olvc.ab.ca/
--- Xft~/xftglyphs.c    2002-10-12 01:53:02.000000000 +0800
+++ Xft/xftglyphs.c     2002-12-09 01:42:56.000000000 +0800
@@ -298,6 +298,13 @@
                    xftg->metrics.yOff = 0;
                }
            }
+
+           /*
+            * Halfwidth characters in fixed-width CJK fonts
+            */
+           if (TRUNC(ROUND(glyphslot->advance.x)) <= (font->public.max_advance_width 
+>> 1) + 1
+                   && xftg->metrics.xOff > 1)
+               xftg->metrics.xOff = xftg->metrics.xOff >> 1;
        }
        else
        {

Reply via email to