Re: [PATCH] option to tweak letter spacing
On Thu, May 07, 2009 at 10:20:33AM +0100, "Mark H. Wilkinson" wrote: > So I've implemented an option to allow people to work around these > variations in font metrics. In the same way that the lineSpace option Thanks, this patch/option is now available in current CVS, if anybody wants to try. -- The choice of a Deliantra, the free code+content MORPG -==- _GNU_ http://www.deliantra.net ==-- _ generation ---==---(_)__ __ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=/_/_//_/\_,_/ /_/\_\ ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Marc Lehmann wrote: [Mon May 11 2009, 11:11:45PM EDT] > But it does - the code is obviously the same everyhwree, so it is > consistent. What's not consistent is ther width of the characters another > library hands out, which has nothing to do with urxvt. > > > which is easily understood by the context of the rest of the > > thread leading up to this point. > > Based on that, one could just as well claim gnome-terminal doesn't work > consistently, because it uses different on-screen widths for the same > character widths. Well, I'm not sure I agree, but I think we understand each other's point in any case. > > > > the wider urxvt font spacing. But if gnome-terminal's > > > > method makes sense, maybe it would be appropriate for > > > > urxvt too. > > > > > > gnome-terminal doesn't care much about correct layout (or > > > speed). it can simply redraw everything from scratch and > > > stop caring if some fonts don't fit into the character > > > cells. > > > > This sounds like a giant assumption and copout. > > Yeah, it might sound like that to you, but it is a well-established fact. > Some people even offered bounties for somebody copying the urxvt code > into gnome-terminal, so their kernel compiles aren't slowed down by 30% > anymore. Well, you are certainly right here. However is it truly necessary to maintain the wider font width in order for this to remain the case, or are you simply making a general point? > (gnome-terminal has improved over the years, but is still orders of > magnitude slower than urxvt or even xterm). Actually xterm with xft fonts is the worst of the lot! It's unusably slow over remote X, which is how I work all the time. urxvt does by far the best in this case. (Thanks!) > In any case, I don't like your tone - if you don't believe > something, you are free to ask for clarification, but don't > make stupid comments such as my statement being a "giant > copout" - that's needlessly insulting and will cause me to > simply ignore you. I apologize. Aron ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Marc Lehmann wrote: [Mon May 11 2009, 11:06:08PM EDT] > On Mon, May 11, 2009 at 05:41:21PM -0400, Aron Griffis > wrote: > > The current behavior of urxvt is to produce terminals of > > different widths depending on underlying xft libraries, whereas > > So it seems waht is inconsisitent is the underlying xft (or freetype) > libraries. Yes, I agree, except that somehow gnome-terminal copes. Possibly its method is wallpapering over a problem that should be fixed elsewhere, but I'm not sure yet. > On Mon, May 11, 2009 at 07:57:02PM -0400, Aron Griffis > wrote: > > Note this is different from rxvt-unicode which includes > > double-width fonts in the rendering test, despite the comment in > > rxvtfont.C: > > Can you explain the "despite the comment"? The comment doesn't claim pango > uses double-width characters. (assuming you mean characters when you say > fonts, as only one font is involved). Sorry, the comment refers to pango and I was thinking of libvte, and clearly the methods are different between those two. My mistake. > The problem is that when you ask freetype for a width, you sometimes get > the width of a double-wide character as base width, and sometimes that of > a single-width character. This is why urxvt has to measure it. *nod* > It doesn't help that many gnome programs, xterm and some terminal apps use > their own hardcoded table of character widths instead of relying on the > user-configured locale, as urxvt (and again, others) do. > > I don't think this makes for the difference, however. Most likely urxvt > uses the spacing, while gnome-terminal the glyph width (both of which have > advantages and disadvantages). Could you elaborate on the advantages/disadvantages? > > properly on my one system (Debian). On my other system (Ubuntu > > Jaunty) I can't figure out the correspondance between the font > > sizes I request in gnome-terminal and the font sizes I request > > with size= or pixelsize= in urxvt. :-( > > The letter spacing has nothing to do with font sizes. I would *expect* > gnome-terminal to use the equivalent of "size=", though, and wold be > surprised if it used it's own I think it must, based on my experimentation. > In any case, your problem likely boils down to using a low-quality font that > is not suitable for charcell displays. Font quality plays a big role with > xft. I was testing with DejaVu Mono, which I thought was high-quality but I could be mistaken. Do you have another suggestion? Aron ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
On Mon, May 11, 2009 at 11:05:02PM -0400, Aron Griffis wrote: > > > Hi Mark, > > Still Marc. > > Actually I was writing to Mark. Sorry! > > > The only question I have about this issue is: How does > > > gnome-terminal work consistently? > > > > urxvt works consistently as well. > > This statement is meaninglessly defensive. urxvt doesn't work > consistently in the way that gnome-terminal works consistently, But it does - the code is obviously the same everyhwree, so it is consistent. What's not consistent is ther width of the characters another library hands out, which has nothing to do with urxvt. > which is easily understood by the context of the rest of the > thread leading up to this point. Based on that, one could just as well claim gnome-terminal doesn't work consistently, because it uses different on-screen widths for the same character widths. > > > the wider urxvt font spacing. But if gnome-terminal's method > > > makes sense, maybe it would be appropriate for urxvt too. > > > > gnome-terminal doesn't care much about correct layout (or speed). it can > > simply redraw everything from scratch and stop caring if some fonts don't > > fit into the character cells. > > This sounds like a giant assumption and copout. Yeah, it might sound like that to you, but it is a well-established fact. Some people even offered bounties for somebody copying the urxvt code into gnome-terminal, so their kernel compiles aren't slowed down by 30% anymore. (gnome-terminal has improved over the years, but is still orders of magnitude slower than urxvt or even xterm). In any case, I don't like your tone - if you don't believe something, you are free to ask for clarification, but don't make stupid comments such as my statement being a "giant copout" - that's needlessly insulting and will cause me to simply ignore you. -- The choice of a Deliantra, the free code+content MORPG -==- _GNU_ http://www.deliantra.net ==-- _ generation ---==---(_)__ __ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=/_/_//_/\_,_/ /_/\_\ ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
On Mon, May 11, 2009 at 05:41:21PM -0400, Aron Griffis wrote: > The current behavior of urxvt is to produce terminals of > different widths depending on underlying xft libraries, whereas So it seems waht is inconsisitent is the underlying xft (or freetype) libraries. On Mon, May 11, 2009 at 07:57:02PM -0400, Aron Griffis wrote: > Note this is different from rxvt-unicode which includes > double-width fonts in the rendering test, despite the comment in > rxvtfont.C: Can you explain the "despite the comment"? The comment doesn't claim pango uses double-width characters. (assuming you mean characters when you say fonts, as only one font is involved). The problem is that when you ask freetype for a width, you sometimes get the width of a double-wide character as base width, and sometimes that of a single-width character. This is why urxvt has to measure it. It doesn't help that many gnome programs, xterm and some terminal apps use their own hardcoded table of character widths instead of relying on the user-configured locale, as urxvt (and again, others) do. I don't think this makes for the difference, however. Most likely urxvt uses the spacing, while gnome-terminal the glyph width (both of which have advantages and disadvantages). > properly on my one system (Debian). On my other system (Ubuntu > Jaunty) I can't figure out the correspondance between the font > sizes I request in gnome-terminal and the font sizes I request > with size= or pixelsize= in urxvt. :-( The letter spacing has nothing to do with font sizes. I would *expect* gnome-terminal to use the equivalent of "size=", though, and wold be surprised if it used it's own In any case, your problem likely boils down to using a low-quality font that is not suitable for charcell displays. Font quality plays a big role with xft. -- The choice of a Deliantra, the free code+content MORPG -==- _GNU_ http://www.deliantra.net ==-- _ generation ---==---(_)__ __ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=/_/_//_/\_,_/ /_/\_\ ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Marc Lehmann wrote: [Mon May 11 2009, 10:58:24PM EDT] > On Mon, May 11, 2009 at 08:53:14AM -0400, Aron Griffis > wrote: > > Hi Mark, > > Still Marc. Actually I was writing to Mark. > > The only question I have about this issue is: How does > > gnome-terminal work consistently? > > urxvt works consistently as well. This statement is meaninglessly defensive. urxvt doesn't work consistently in the way that gnome-terminal works consistently, which is easily understood by the context of the rest of the thread leading up to this point. > > the wider urxvt font spacing. But if gnome-terminal's method > > makes sense, maybe it would be appropriate for urxvt too. > > gnome-terminal doesn't care much about correct layout (or speed). it can > simply redraw everything from scratch and stop caring if some fonts don't > fit into the character cells. This sounds like a giant assumption and copout. ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
On Mon, May 11, 2009 at 08:53:14AM -0400, Aron Griffis wrote: > Hi Mark, Still Marc. > The only question I have about this issue is: How does > gnome-terminal work consistently? urxvt works consistently as well. > the wider urxvt font spacing. But if gnome-terminal's method > makes sense, maybe it would be appropriate for urxvt too. gnome-terminal doesn't care much about correct layout (or speed). it can simply redraw everything from scratch and stop caring if some fonts don't fit into the character cells. -- The choice of a Deliantra, the free code+content MORPG -==- _GNU_ http://www.deliantra.net ==-- _ generation ---==---(_)__ __ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=/_/_//_/\_,_/ /_/\_\ ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Aron Griffis wrote: [Mon May 11 2009, 07:57:02PM EDT] > Note this is different from rxvt-unicode which includes > double-width fonts in the rendering test, despite the comment in > rxvtfont.C: Sorry, I didn't mean that the code does something different from what the comment says, just that it mentions similarity to pango... which might be different from what libvte9 does... so nevermind my statement. :-) Aron ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Here is how gnome-terminal (libvte9) determines the width of an
xft font with pango in vtepangocairo.c:
367 static void
368 font_info_measure_font (struct font_info *info)
369 {
370 PangoRectangle logical;
371
372 /* Estimate for ASCII characters. */
373 pango_layout_set_text (info->layout,
VTE_DRAW_SINGLE_WIDE_CHARACTERS, -1);
374 pango_layout_get_extents (info->layout, NULL, &logical);
375 /* We don't do CEIL for width since we are averaging;
376 * rounding is more accurate */
377 info->width = PANGO_PIXELS (howmany (logical.width,
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS)));
378 info->height = PANGO_PIXELS_CEIL (logical.height);
379 info->ascent = PANGO_PIXELS_CEIL (pango_layout_get_baseline
(info->layout));
Here is the definition of VTE_DRAW_SINGLE_WIDE_CHARACTERS in
vtedraw.h:
33 #define VTE_DRAW_SINGLE_WIDE_CHARACTERS \
34 " !\"#$%&'()*+,-./" \
35 "0123456789" \
36 ":;<=>?@" \
37 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
38 "[\\]^_`" \
39 "abcdefghijklmnopqrstuvwxyz" \
40 "{|}~" \
41 ""
and here is the definition of PANGO_PIXELS from
/usr/include/pango-1.0/pango/pango-types.h:
48 #define PANGO_PIXELS(d) (((int)(d) + 512) >> 10)
49 #define PANGO_PIXELS_FLOOR(d) (((int)(d)) >> 10)
50 #define PANGO_PIXELS_CEIL(d) (((int)(d) + 1023) >> 10)
Note this is different from rxvt-unicode which includes
double-width fonts in the rendering test, despite the comment in
rxvtfont.C:
152 // these characters are used to guess the font height and width
153 // pango uses a similar algorithm and doesn't trust the font either.
154 static uint16_t extent_test_chars[] = {
155 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
156 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ
157 0x304c, 0x672c, // が本
158 };
I would test changing this but frankly, it's already working
properly on my one system (Debian). On my other system (Ubuntu
Jaunty) I can't figure out the correspondance between the font
sizes I request in gnome-terminal and the font sizes I request
with size= or pixelsize= in urxvt. :-(
Aron
___
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Mark H. Wilkinson wrote: [Mon May 11 2009, 04:17:38PM EDT] > I don't know, and I don't really have the inclination to dig > into it to find out where the code is that handles the > calculations. Understandable. > It might be > part of Pango, which does text layout for many Gtk applications, or > gnome-terminal might do it itself. Suggestions have been made in the > past for how rxvt-unicode could be changed to render Xft fonts in ways > that mimic Gnome applications (see > http://lists.schmorp.de/pipermail/rxvt-unicode/2007q4/000514.html for > example), but there's disagreement over what behaviour would be > 'correct'. Interesting. > Applying a positive or negative adjustment to the letter > spacing has the benefit of defaulting to not changing the current > behaviour. The current behavior of urxvt is to produce terminals of different widths depending on underlying xft libraries, whereas gnome-terminal seems to maintain consistency across library versions. IMHO your patch is a good one but would be better if urxvt provided a consistent starting point, otherwise the user has to adjust preferences every time they update their system. In other words, while I understand your reluctance to dig further into gnome-terminal's behavior, I think it would be worth someone's while... Regards, Aron ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
On Mon, 2009-05-11 at 08:53 -0400, Aron Griffis wrote: > The only question I have about this issue is: How does > gnome-terminal work consistently? That's unfortunately been my > fallback when the mix of library versions on my system produces > the wider urxvt font spacing. But if gnome-terminal's method > makes sense, maybe it would be appropriate for urxvt too. I don't know, and I don't really have the inclination to dig into it to find out where the code is that handles the calculations. It might be part of Pango, which does text layout for many Gtk applications, or gnome-terminal might do it itself. Suggestions have been made in the past for how rxvt-unicode could be changed to render Xft fonts in ways that mimic Gnome applications (see http://lists.schmorp.de/pipermail/rxvt-unicode/2007q4/000514.html for example), but there's disagreement over what behaviour would be 'correct'. Applying a positive or negative adjustment to the letter spacing has the benefit of defaulting to not changing the current behaviour. -Mark. ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
Hi Mark, The only question I have about this issue is: How does gnome-terminal work consistently? That's unfortunately been my fallback when the mix of library versions on my system produces the wider urxvt font spacing. But if gnome-terminal's method makes sense, maybe it would be appropriate for urxvt too. Thanks, Aron ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
Re: [PATCH] option to tweak letter spacing
On Thu, May 07, 2009 at 10:20:33AM +0100, "Mark H. Wilkinson" wrote: > The patch makes no changes to rxvt's existing font metric computation The patch looks great (including documentation and pelr etc. updates). > Thoughts? I think it's a pretty good idea to have this tunable, and expect it to show up in the next release. Thanks! -- The choice of a Deliantra, the free code+content MORPG -==- _GNU_ http://www.deliantra.net ==-- _ generation ---==---(_)__ __ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=/_/_//_/\_,_/ /_/\_\ ___ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
[PATCH] option to tweak letter spacing
Looking back through the archives there's a recurring theme of people having problems with the letter spacing of xft fonts when used with rxvt-unicode. The root cause of this seems to be variability in the metrics reported by different versions of xft - having just upgraded from Ubuntu 8.10 to 9.04 I found the rxvt was spacing the same font out by a couple of pixels extra compared to the previous version, and rxvt's font metric code doesn't appear to have changed between the two releases. So I've implemented an option to allow people to work around these variations in font metrics. In the same way that the lineSpace option allows extra pixels to be added between lines of text, I've added a letterSpace option that allows extra pixels to be added (or removed) between columns. If the font you prefer has metrics that result in rxvt spacing it out more than you'd like you can use the letterSpace option to squeeze the characters together again. The patch makes no changes to rxvt's existing font metric computation code, and the default letter spacing adjustment is 0 so the patch has no effect unless the user explicitly adjusts the letter spacing, either on the command line or in X resources. Thoughts? -Mark. From 26cf73f0168f335d946b9e3ef56815937099e775 Mon Sep 17 00:00:00 2001 From: Mark H. Wilkinson Date: Wed, 6 May 2009 17:57:56 +0100 Subject: [PATCH] Add letterSpace option to adjust character letter spacing. --- doc/rxvt.1.man.in |6 + doc/rxvt.1.pod|7 ++ src/feature.h |5 src/init.C|4 +++ src/main.C|1 + src/rsinc.h |1 + src/rxvt.h|1 + src/rxvtperl.xs | 62 +++- src/urxvt.pm |6 ++-- src/xdefaults.C |1 + 10 files changed, 61 insertions(+), 33 deletions(-) diff --git a/doc/rxvt.1.man.in b/doc/rxvt.1.man.in index 37a548f..e795ce1 100644 --- a/doc/rxvt.1.man.in +++ b/doc/rxvt.1.man.in @@ -456,6 +456,12 @@ resource \fBskipBuiltinGlyphs\fR. Compile \fIfrills\fR: Lines (pixel height) to insert between each row of the display. Useful to work around font rendering problems; resource \&\fBlineSpace\fR. +.IP "\fB\-letsp\fR \fInumber\fR" 4 +.IX Item "-letsp number" +Compile \fIfrills\fR: Amount to adjust the computed character width by +to control overall letter spacing. Negative values will tighten up the +letter spacing, positive values will space letters out more. Useful to +work around odd font metrics; resource \&\fBletterSpace\fR. .IP "\fB\-tn\fR \fItermname\fR" 4 .IX Item "-tn termname" This option specifies the name of the terminal type to be set in the diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod index 841c0b3..3de6766 100644 --- a/doc/rxvt.1.pod +++ b/doc/rxvt.1.pod @@ -369,6 +369,13 @@ Compile I: Lines (pixel height) to insert between each row of the display. Useful to work around font rendering problems; resource B. +=item B<-letsp> I + +Compile I: Amount to adjust the computed character width by +to control overall letter spacing. Negative values will tighten up the +letter spacing, positive values will space letters out more. Useful to +work around odd font metrics; resource B. + =item B<-tn> I This option specifies the name of the terminal type to be set in the diff --git a/src/feature.h b/src/feature.h index df1af13..3507cca 100644 --- a/src/feature.h +++ b/src/feature.h @@ -379,6 +379,11 @@ #define LINESPACE 0 /* + * Default number of extra dots between columns + */ +#define LETTERSPACE 0 + +/* * Default number of lines in the scrollback buffer */ #define SAVELINES 1000 diff --git a/src/init.C b/src/init.C index 6c9e640..e0142c3 100644 --- a/src/init.C +++ b/src/init.C @@ -295,6 +295,7 @@ rxvt_term::init_vars () int_bwidth = INTERNALBORDERWIDTH; ext_bwidth = EXTERNALBORDERWIDTH; lineSpace = LINESPACE; + letterSpace = LETTERSPACE; saveLines = SAVELINES; refresh_type = SLOW_REFRESH; @@ -450,6 +451,9 @@ rxvt_term::init_resources (int argc, const char *const *argv) if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) lineSpace = min (i, std::numeric_limits::max ()); + + if (rs[Rs_letterSpace]) +letterSpace = atoi (rs[Rs_letterSpace]); #endif #ifdef POINTER_BLANK diff --git a/src/main.C b/src/main.C index fd126ff..aa96337 100644 --- a/src/main.C +++ b/src/main.C @@ -690,6 +690,7 @@ rxvt_term::set_fonts () prop = (*fs)[1]->properties (); prop.height += lineSpace; + prop.width += letterSpace; fs->set_prop (prop, false); diff --git a/src/rsinc.h b/src/rsinc.h index 903a771..0667bf8 100644 --- a/src/rsinc.h +++ b/src/rsinc.h @@ -75,6 +75,7 @@ def (int_bwidth) def (borderLess) def (lineSpace) + def (letterSpace) def (cursorUnderline) def (urgentOnBell) #endif diff --git a/src/rxvt.h b/src/rxvt.h index e19f201..39a313e 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -849,6 +849,7 @@ struct TermWin_t intint_bwidth;/* internal border width
