1

I really like the default font used by xterm.

Xterm using its default font

By running xterm -report-fonts, I glean that this font is -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 written in the old XLFD descriptor format (plus the bold version, -Misc-Fixed-bold-R-*-*-13-120-75-75-C-60-ISO10646-1.)

However, st expects a font described in a way friendly to the fontconfig library, which looks more like, Noto Sans Mono:pixelsize=12:antialias=false:autohint=false.

How can I specify the font I want in st?

Thank you, Richard

2 Answers 2

3

The difference isn't only in syntax, but also in the actual font renderer – st does not use X server-based text rendering; it relies on FreeType/Xft to draw text client-side (which directly loads a .ttf file and draws the text into a pixmap for the X server to display). Therefore the fonts it uses have no direct correspondence to the fonts you specify through XLFD.

FreeType still has support for using .bdf/.pcf bitmap fonts1, so Xft-based apps can still use the X fonts directly, as long as they have direct access to the font files.2

The font you want is actually called 6x13 and is stored in 6x13*.pcf(.gz) files, according to the X11 font lookup cache:

$ grep -r 'misc-fixed-medium-r-semicondensed--13' /usr/share/fonts misc/fonts.dir:113:6x13.pcf.gz -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 

So first ask FontConfig to list all fonts it knows, to check if it has detected that file:

$ fc-list | grep 6x13 /usr/share/fonts/misc/6x13.pcf.gz: Misc Fixed:style=SemiCondensed 

This gives you the "base" font name – narrow it down to the variant you need:

$ fc-match -a "Misc Fixed:style=SemiCondensed:pixelsize=13" | head 6x13-ISO8859-1.pcf.gz: "Misc Fixed" "SemiCondensed" 6x13.pcf.gz: "Misc Fixed" "SemiCondensed" 

See also the output of fc-cat | grep ^\"6x13 to get the complete FontConfig font specification that the pattern will be matched against.

You shouldn't need to specify that you need the Unicode or ISO 10646 version – the above pattern already matches both versions, and Xft should automatically fall back to the 2nd, 3rd, … matching font if necessary to render a character that the 1st font does not support (the same as with TTF/OTF fonts, as most of them do not provide full Unicode coverage).

If it doesn't work, then your /etc/fonts/conf.d or ~/.config/fontconfig may be set up to exclude bitmap fonts. See fc-conflist for the config file processing order.


1 (Pango-based apps would additionally need conversion into .otb format. Pango can still draw bitmap fonts, but it uses Harfbuzz as the font file parser instead of FreeType, and because of that it no longer supports the traditional X11 .pcf/.bdf format fonts.)

2 (In case you're using X11 over network, this means the font files need to be present on the system where the 'st' process is running, not on the system where the Xorg/Xwin/&c. display server is rendering it – unlike traditional X fonts which were provided by the display server.)

1

Thank you, grawity. That's exactly what I needed.

Here's what I did:

  1. Deleted /etc/fonts/conf.d/70-no-bitmaps-except-emoji.conf

  2. Refreshed the font cache with fc-cache -f

  3. Configured st with "Misc Fixed:style=SemiCondensed:fullname=Misc Fixed SemiCondensed:pixelsize=13"

It works perfectly, even the bold variant. Thank you!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.