urxvt incorrectly treats XGlyphInfo
Dmitry Bukin
D.A.Bukin at inp.nsk.su
Fri Nov 30 10:10:03 CET 2007
Hi,
I used an urxvt quite a while with xft fonts, and found an interesting
thing: with the same font (in my case it was Redhat's Liberation Mono)
the urxvt terminal is about 10% wider than gnome-terminal.
Then I examined the code src/rxvtfont.C
and I have found that rxvt incorrectly treat
the structure XGlyphInfo when it tests for the glyph widths.
In particular the width (including the spacing)
of the character is returned in the xOff member of the struct.
Please see, e.g. http://keithp.com/~keithp/render/Xft.tutorial for details.
So, here is my patch which fix this problem:
--- src/rxvtfont.C.bukind 2007-11-30 14:36:33.000000000 +0600
+++ src/rxvtfont.C 2007-11-30 14:39:29.000000000 +0600
@@ -1171,12 +1171,21 @@
XGlyphInfo g;
XftTextExtents16 (disp, f, &ch, 1, &g);
+/*
+ * bukind: don't use g.width as a width of a character!
+ * instead use g.xOff, see e.g.: http://keithp.com/~keithp/render/Xft.tutorial
+
g.width -= g.x;
int wcw = WCWIDTH (ch);
if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
if (width < g.width ) width = g.width;
+ */
+ int wcw = WCWIDTH (ch);
+ if (wcw > 1) g.xOff = g.xOff / wcw;
+ if (width < g.xOff) width = g.xOff;
+
if (height < g.height ) height = g.height;
if (glheight < g.height - g.y) glheight = g.height - g.y;
}
WBR, Dima.
--
Dmitry Bukin.
pgp key is here: http://wwwsnd.inp.nsk.su/~bukind/bukind-pgp-key.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/rxvt-unicode/attachments/20071130/a4a81fff/attachment.sig>
More information about the rxvt-unicode
mailing list