codeblog code is freedom — patching my itch

6/22/2008

bold fonts in libvte (gnome-terminal, terminator)

Filed under: Ubuntu — kees @ 11:22 am

A while back I complained about terminal fonts. In the end, I was shown that the real source of my pain was a 7 year old gnome bug where vte did not attempt to use bold fonts and always used double-strike instead. For me, this was a show-stopper given my desire for using tiny bitmap fonts for my terminals. Double-strike bolding made things unreadable.

I finally had a solid chunk of time to dedicate to working on the plumbing needed for vte to support bold fonts sanely. (I’ve attached all my patches to the bug linked above.) I’m really quite happy — I can finally stop using “xterm” everywhere and fully switch to gnome-terminal and terminator for all their UTF8 goodness. Now I just need to tweak gnome-terminal’s colors — things seem slightly washed out.

For anyone else interested in using bitmap fonts in gnome-terminal, here is the final recipe (since digging through all the comments in the original blog post doesn’t make it entirely obvious):

$ mkdir -p ~/.fonts
$ cp /usr/share/fonts/X11/misc/7x14{,B}.pcf.gz ~/.fonts
$ cat > ~/.fonts.conf <<EOM
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

  <!-- /usr/share/fonts/X11/misc/7x14{,B}.pcf.gz copied to ~/.fonts/ -->
  <selectfont>
    <acceptfont>
      <pattern>
        <patelt name="family"><string>fixed</string></patelt>
        <patelt name="pixelsize"><int>14</int></patelt>
      </pattern>
    </acceptfont>
  </selectfont>

</fontconfig>
EOM

At this point, you can verify that fontconfig sees your bitmap fonts:

$ fc-list | grep Fixed
Fixed:style=Bold
Fixed:style=Regular

Now just close all your gnome-terminals to get vte to reload the new fonts, and configure it to use the newly available font:

$ gconftool-2 -s /apps/gnome-terminal/profiles/Default/font -t string "Fixed 14"
$ gconftool-2 -s /apps/gnome-terminal/profiles/Default/use_system_font -t bool false

Ta-da!

© 2008, Kees Cook. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Creative Commons License

1 Comment »

  1. Thanks for fixing it. It’s a bit sad that bugs in gnome-terminal don’t get fixed for 7 years though. Something I’m missing in gnome-terminal: it does not allow to change the color of the cursor. At least xterm and xfce4-terminal allow to customize the color of the cursor.

    Comment by dominiko — 6/22/2008 @ 11:54 am

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress