What I learned about fonts

I started on this because I wanted to use unicode characters for LemonBoy’s bar. I wanted to display funky symbols without installing a new font, so I decided to use Dejavu Sans Mono to display them.

I had to get bar to find my font, and that is the gist of this post. In X, a font is specified in a funny way. Here’s an example:

-misc-dejavu sans mono-medium-r-normal--17-120-100-100-m-100-iso10646-1

Most of the time though, we will not need to be so specific, can this will do:

-*-dejavu sans mono-medium-r-normal--17-*-*-*-*-*-iso10646-1

If you’re as curious as me you’ll probably want to find out what all those numbers as me, and if you’re as stupid too, you’ld probably spend an entire afternoon finding out.

If you’re just interested in the answer jump to the bottom, ’cos I will be going though steps to find this information yourself.

  1. xlsfonts is is the server font list displayer for X (man xlsfonts) This is the most crucial thing we need. Get it from your distribution’s package manager, I’m on arch so I just had to

pacman -S xlsfonts

  1. skim through

xlsfonts --help

  1. try this:

    xlsfonts

You should see a bunch of fonts displayed similar to what I showed you above.

  1. If you have DejaVu Sans already installed you can probably try this:

    xlsfonts -l -fn -misc-dejavu sans mono-medium-r-normal–17-120-100-100-m-100-iso10646-1

Make sure you type the backslash as well, you have to escape the spaces.

  1. If not you, pick a font from the list generated by xlsfonts, and do:

    xlsfonts -l -fn -the-font-you-picked-some-numbers-blah-blah111

Or if you’re lazy to type we can just select the first font in the list:

xlsfonts -l -fn $(xlsfonts | head -1)
  1. Now thats not very interesting, a bunch of short cryptic headings, so lets try this:

    xlsfonts -ll -fn $(xlsfonts | head -1)

Note the 2 l’s this time. So this gets much more interesting, lots of information, not that difficult to understand. Most are self-explanatory, such as direction, rows, columns. To go more in-depth, try these search terms: character encoding, character map, fonts in x.

  1. Now things become clearer, lets separate the full font name by hypens, and match them to the properties in the output:
misc FOUNDRY
dejavu sans mono FAMILY_NAME
medium WEIGHT NAME
r SLANT
normal SETWIDTH_NAME
ADD_STYLE_NAME
17 PIXEL_SIZE
120 POINT_SIZE
100 RESOLUTION_X
100 RESOLUTION_Y
m SPACING
100 AVERAGE_WIDTH
iso10646 CHARSET_REGISTRY
1 CHARSET_ENCODING

SLANT has to do with the italics, r stands for Roman, there is also o for Oblique. Mystery solved! I don’t know what every property means, but I guess you can probably find out if you want to

This worked for bar, with the specific full font name. I also learned that the PIXEL_SIZE and POINT_SIZE should not both be set at the same time. For example, looking at the information above, you can set PIXEL_SIZE and POINT_SIZE to 17 and 120 respectively, but 12 and 120 will fail.

I suppose this has something to do with font rasterizing, so setting one will optimize the other for you. As such I chose to fidget with PIXEL_SIZE and leave POINT_SIZE as *.

What I’m using now is this:

-misc-dejavu sans mono-medium-r-normal--11-*-*-*-m-*-iso10646-1"

Which ensures that I get the correct font family, weight, encoding, which I guess are the most important parts, just leave the rest to the computer!

Notes: xlsfonts has a -lll flag to, shows you every character in the font, pretty crazy and useful at the same time! And guess what I think I’ll be back to stlarch so it looks so much better.