47

Starting earlier today I am getting font rendering issues with rxvt-unicode. Specifically with many fonts I get an abundance of extra space between characters. In other fonts rxvt refuses to change sizes.

Here is an example of the spacing issue between urxvt and xterm.

The fonts resources:

URxvt*font:     xft:Terminus:medium:size=10
xterm*faceName: xft:Terminus:medium:size=10

And the renderings

  • urxvt bad fonts
  • xterm good fonts

I have tried all permutations of hinting and antialiasing. Changing size or pixelsize does resize the font in urxvt but this also increases the extra spacing.

Does anyone have ideas I can try to fix this?

4
  • 1
    I don't think xterm is actually using the same font. The J and the 0 are distinctly different. You might confirm this by using a non-existent font in the resource file (xterm*faceName: xft:Nosuchfont:medium:size=10). If it still looks the same, it obviously isn't Terminus.
    – goldilocks
    Mar 7, 2014 at 21:26
  • @goldilocks It appears you are right. Urxvt is picking the wrong font and rendering it terribly.
    – casey
    Mar 7, 2014 at 21:32
  • 1
    I've noticed this before w/ gvim when using my configuration on a system where the font I wanted wasn't installed. xft or something falls back on a non-monospace font and that's how they appear.
    – goldilocks
    Mar 7, 2014 at 21:36
  • 2
    @goldilocks It turns out a bad fontconfig rule slipped in during an update and was blocking all bitmapped fonts from being available. I nuked it and I'm back to normal.
    – casey
    Mar 8, 2014 at 1:43

5 Answers 5

24

Urxvt has an option for basic kerning: letterSpace. See man urxvt:

-letsp number
Compile frills: 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 letterSpace.

So you can adjust the spacing by adding a line to your ~/.Xresources, like so:

URxvt.letterSpace: -1

Note: it is difficult to tell from your first screenshot, but it looks like Urxvt is falling back to the default font as it can't find or load Terminus, hence the wide spacing. Terminus is a bitmap font (which is likely disabled by default), so you should use xfontsel to copy the correct font string into your definition.

See the Arch Wiki page on X Logical Font Description for a detailed description of how this system works.

3
  • 3
    I had this issue as well and found that urxvt -letsp -2 was necessary for me. Using -1 was better, but I didn't initially realize that since it wasn't enough.
    – Adam Katz
    Sep 29, 2016 at 0:41
  • 1
    Also you can use the fc-match <font-name> instead of xfontsel if it's not installed (font-name is the expression given in your URxvt*font line's font name). If this shows up with a value matching the expression, the font will be loaded correctly. e.g., if fc-match "Noto Mono" gives DejaVuSans.ttf: "DejaVu Sans" "Book" then it can be considered to be an incorrect font expression.
    – Avinash R
    Apr 11, 2018 at 7:35
  • It seems to be a floating point value, -1 wasn't enough but -2 seemed a bit tight, went with -1.7. Apr 20 at 21:09
8

It turns out a rule was enabled on my system that blocked bitmapped fonts such as Terminus.

This rule (on my system) was in /etc/fonts/conf.d/70-no-bitmap-fonts and contained:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Reject bitmap fonts -->
 <selectfont>
  <rejectfont>
   <pattern>
     <patelt name="scalable"><bool>false</bool></patelt>
   </pattern>
  </rejectfont>
 </selectfont>
</fontconfig>

I removed this from the conf.d directory and my fonts are once again rendering properly in urxvt.

5

Please note that there's a bug report regarding letter spacing.

I had similar issues. Following the recommendations of the bug discussion, I set Xft.rgba: none and Xft.hintstyle: hintfull in ~/.Xdefaults (instead of Xft.rgba: rgb and Xft.hintstyle: hintslight). This fixed it for me – I used Ubuntu Mono as font, though.

1
  • It seems to me that just by setting Xft.rgba: none, the problem gets resolved. This also happens to be mentioned in the comments of the bug report that is linked in this answer.
    – Ombrophile
    Apr 4, 2020 at 20:16
5

My solution was simple:

URxvt*font:     xft:mono:medium:size=10
xterm*faceName: xft:mono:medium:size=10

Now it works perfectly.

3

This might arise from actual font file (Monospace in my case) more likely than from anything in the urxvt. If the font (errorneously) declares some glyphs too wide, urxvt is forced to make the grid wide as well.

In my case, the "OK" font I found was Bitstream Vera Sans Mono.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .