codeblog code is freedom — patching my itch

December 12, 2007

search for a crisp monospace true-type font

Filed under: Blogging,Ubuntu — kees @ 9:36 am

I’ve been using xterms forever. Whenever I try to switch to using a terminal with a true-type font, my eyes hurt after a few hours. I’ve tried changing the various font-rendering options, and gone through lots of monospaced fonts — nothing gives the same clarity as the fixed raster fonts. I suspect this is basically the same problem as Icon Scaling. Things don’t work correctly when trying to line up a vector image against hard pixel edges. I wish I could find a workable fix for this.

© 2007, Kees Cook. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 License.
CC BY-SA 4.0

15 Comments

  1. Why the need to use a true type font? Is it because you want to use gnome terminal? If so, check out this tip:

    http://www.ubuntutips.net/node/11

    Comment by puntium — December 12, 2007 @ 11:26 am

  2. Hi Kees,

    I think there’s a few problems here — though I suspect you know most of this stuff already:
    * font-hinting, which Ubuntu Gutsy now seems to do almost perfectly
    * font-antialiasing, which Ubuntu Gutsy also seems to do almost perfectly, but is never done for raster fonts.
    * serifs, which your standard raster font doesn’t have, which your standard monospace font often does have, and which cannot be lined up well with pixel boundaries
    * curved lines in general (which are affected directly by anti-aliasing)

    Font-hinting is meant to line up vertical & horizontal lines in any given letter. For years, linux had problems with this, but the last few versions of Ubuntu have done it perfectly, I’ve found.

    Antialiasing is done for non-raster fonts to make curved lines look smooth. It sortof “blurs” the pixels around the curve, so that you can’t see the lines. It makes everything look much, much nicer, but at the slight expense of making your text slightly fuzzy. You can turn this off in Ubuntu Gutsy by going to System->Preferences->Appearance and clicking on the fonts tab. If you click the “Details” button, you can control whether or not hinting & anti-aliasing is used. If you turn hinting off, it’ll look extremely ugly — you want full hinting. However, if you turn anti-aliasing off, it might just give you what you want. Just be aware that it’ll make your fonts look a bit more jagged — non-raster fonts will *never* rasterize as well as hand-rastered fonts.

    Serifs can be a problem on screen — at relatively low resolution (90dpi, compared to > 600dpi on most printed paper), the little notches and flicks don’t show up that well. What’s worse is that in most non-raster fonts, serifs tend to be slightly curved, which means they’ll cross pixel boundaries, and therefore need to be antialiased, or suffer from jaggedness. Try and find a non-raster monospace font without serifs (the font called “Monospace” installed by default on my Ubuntu is perfect in that regard.)

    The Icon Scaling problem you mentioned is indeed closely related. Ted is basically describing the problem which is solved by font hinting (although, to a lesser degree, anti-aliasing is also a problem at small sizes). On my wishlist for Inkscape: some sort of “hinting” for vector lines, so you don’t need to always manually snap your vectors to the pixel grid to make sure the render ok. More important (because it’s currently almost impossible in inkscape), I’d like to see inkscape supporting font hinting. Fonts *always* look blurry in an inkscape-rendered bitmap, and the only way to fix it is with hours of painstaking vector-editing on each letter you type….

    Comment by Bryan Hoyt — December 12, 2007 @ 11:42 am

  3. woot! You guys rock! I toyed with the antialiasing, but it was system-wide, so that wouldn’t file. However, by defining a filter, it worked perfectly! I’ve now got my normal bitmap font in gnome-terminal, and I’m able to finally have unicode. Sweet.

    For those following along, I started with the ubuntutips link above, and did:

    sudo dpkg-reconfigure fontconfig-config (*enter* *enter* *tab* *enter*)
    sudo fc-cache -fv
    cat >> ~/.fonts.conf <<EOM
    <match target=”pattern”>
    <test name=”family”><string>MiscFixed14</string></test>
    <edit name=”foundry”><string>misc</string></edit>
    <edit name=”family”><string>fixed</string></edit>
    <edit name=”style”><string>normal</string></edit>
    <edit name=”pixelsize”><int>14</int></edit>
    <edit name=”dpi”><int>75</int></edit>
    </match>
    EOM
    gconftool-2 -s /apps/gnome-terminal/profiles/Default/font -t string “MiscFixed14 10”
    gconftool-2 -s /apps/gnome-terminal/profiles/Default/use_system_font -t bool false

    This is very close to perfect. There does appear to be some subtle difference in widths that I’ll have to play with. Illustrated here (xterm on top, gnome-terminal on bottom, note the “CAP” letters):

    font comparison

    Comment by kees — December 12, 2007 @ 12:28 pm

  4. http://mihmo.livejournal.com/50738.html

    There a link to a nice little font that was recently freed under an open license. And you can keep some anti-aliasing :)

    Comment by Ted Gould — December 12, 2007 @ 6:24 pm

  5. Pfft — I’ve just been using a ttf version of the jno font for years now!

    Comment by Aaron — December 12, 2007 @ 6:53 pm

  6. The reason for the differences is because of the bold characters.

    xterm tries finds a similar font that has the bold attribute.. what it picks I think is essentially the same 7×14 font that was desinged for bold.

    Gnome terminal tries to find the bold version of the font pattern you specified (MiscFixed14) but fails, so it results to double striking (a way to emulate bold). I haven’t yet figured out how to make gnome-terminal find the bold version of the font as well.

    btw, your captcha thing is a little weird.. I wish it wouldn’t let me submit until I typed the code in, instead of sending me to a wierd 404-looking page if I forget to do it.

    Comment by puntium — December 12, 2007 @ 7:16 pm

  7. Try Terminus :-)

    Comment by John Doe — December 12, 2007 @ 9:14 pm

  8. I agree 100%. Default gnome terminal fonts and other available fonts in terminal are all ugly. And why even propose variable size fonts for a terminal? It’s beyond me.

    I had opened a bug for this a while ago (bug #165039). It contains screenshots of gnome-terminal with non anti-aliased font which look a lot nicer:

    https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/165039

    I downloaded the MiscFixed font, which is small and looks good. Also, non anti-aliased font makes the terminal significantly faster. I had to reconfigure something to have non antialiased fonts available. I don’t remember well, but a google search should give what you’re looking for.

    Comment by dominiko — December 13, 2007 @ 2:57 am

  9. As for me, I stand firmly for my Fixed 9 with the following in my ~/.fonts.conf (which allows all Fixeds):

    Fixed

    Comment by Shot — December 13, 2007 @ 4:49 am

  10. Erm, right.

    <?xml version=”1.0″?>
    <!DOCTYPE fontconfig SYSTEM “fonts.dtd”>
    <fontconfig>
    <selectfont>
    <acceptfont>
    <pattern>
    <patelt name=”family”><string>Fixed</string></patelt>
    </pattern>
    </acceptfont>
    </selectfont>
    </fontconfig>

    Comment by Shot — December 13, 2007 @ 4:50 am

  11. Aaargh. With straight double-quotes, not the curly ones…

    Comment by Shot — December 13, 2007 @ 4:51 am

  12. (Ok, this is not a good commenting day for me.)

    …with the results of http://shot.pl/fixed-9.png

    Comment by Shot — December 13, 2007 @ 4:55 am

  13. Try the Terminus font (xfonts-terminus package), it’s great, monospace and doesn’t need/use hinting.

    Here’s a screenshot of how it looks:

    http://777.damnsite.net/bilder/terminusfont.png

    Comment by Robin — December 13, 2007 @ 7:42 am

  14. It seems my entire problem is antialiasing. That’s what causes a given TTF to look really bad in a terminal. I’ve tried terminus before, but I find it hard to read quickly, but this is probably just my preference.

    Since I haven’t figured out a way to turn off antialiasing for just one font, I’ve switched to bitmap fonts (as detailed above). I actually ended up turning off the “use bitmap fonts by default” option again, and just explicitly copied the font I wanted into ~/.fonts/ and “accept”ed it as Shot mentioned above.

    This still causes problems with bolding, unfortunately. And it seems that this has been an open bug against libvte for 6 years now. :P I guess I know what I’m going to try to do this weekend…

    Comment by kees — December 13, 2007 @ 10:17 am

  15. > Since I haven’t figured out a way to turn off antialiasing for just one font […]

    IIRC, you can do this with some proper ~/.fonts.conf XML magic. You can try googling for the proper XML for setting certain font sizes as not-anitaliased (or create such config file with KDE’s font dialogs) and craft your ~/.fonts.conf based on that.

    Comment by Shot — December 13, 2007 @ 11:29 am

Powered by WordPress