You are not logged in.

#1 2018-04-17 16:52:56

ralph_13
Member
Registered: 2015-02-06
Posts: 73

[SOLVED] What am I supposed to call fonts in configuration files?

I've used Arch for a few years now and this is something that always had me stumped. I know about xfontsel and how it gives the names for the fonts that the X server expects, but this is not what a lot of configuration files expect.

I always have a hard time doing this and I always forget to note down how I succeed, this time I'm trying to set up dunst on this fresh install. The default font on dunstrc is "Monospace 8", which I suppose is an alias for "Inconsolata". I'm at first trying to set up ohsnap (a bitmap font). I've tried "Ohsnapu 11", which is how applications with a configuration GUI see it, and if I remember correctly it's more or less how I got it to work the last time. But obviously I'm doing something wrong, since it falls back to a TTF font. So, two questions:

1. How to find the font names in this format?

2. How to change the default font that the system falls back to? I'd love to completely disable non-bitmap fonts/replace them with bitmap equivalents, if that's at all possible.

Thanks a lot you guys for always being so helpful!

EDIT: Also, if someone could be kind enough to list their personal favorite bitmap fonts, or if there's a list of the ones in the repos/aur, that would be also very helpful.

EDIT2: Ok, I got it, it was actually supposed to be "Misc Ohsnapu 11", but the question still stands.

Last edited by ralph_13 (2018-04-25 18:05:43)

Offline

#2 2018-04-17 17:36:01

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: [SOLVED] What am I supposed to call fonts in configuration files?

ralph_13 wrote:

How to find the font names in this format?

fc-match -a | grep -i ohsnap

^ I would run that command and use whatever is between the quotation marks in fonts.conf

How to change the default font that the system falls back to?

If you mean the "monospace" font (`fc-match mono`) then use ~/.config/fontconfig/fonts.conf to declare an alias, like this:

<fontconfig>
  <alias>
    <family>monospace</family>
    <prefer><family>$font</family></prefer>
  </alias>
</fontconfig>

Replace $font with the name of the actual font.

Offline

#3 2018-04-21 16:20:35

ubone
Member
Registered: 2014-08-31
Posts: 47

Re: [SOLVED] What am I supposed to call fonts in configuration files?

A nice bitmap is terminus. See the link in my signature for quite a few examples.

Offline

#4 2018-04-21 17:46:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [SOLVED] What am I supposed to call fonts in configuration files?

Xfontsel and related tools work with XLFDs (X Logical Font Descriptors, the strings with lots of dashes and often with asterisk wildcards).

Fontconfig and related tools came along with an effort to make everything related to fonts idiot-proof - meaning it's easy for idiots to use and a pain in the ass for anyone who actually knows what they want.  While I suspect fontconfigs behavior is, in reality, deterministic, nothing about the way it functions would really suggest that.  `fc-match`, noted above, is a very handy tool to ask font-config what it thinks about various strings (it's a tool that allows you to do lots of guess and check or trial and error as that seems the only option we have to figure out it's behavior).

Frustrations aside, the one thing fontconfig is really good at is letting a user or program specify what variety of font they want.  You can say "serif" or "sans" or "monospace" or "cursive" or any number of other vague descriptions and fontconfig will identify a font on your system that satisfies that vague goal.  Unfortunately it is utter crap at going the other direction: if you know exactly which font on your system you want to use there's no really clean way that I know of to ask fontconfig what vauge text string would cause it to use that font[1] (the strategy in the previous post of grepping through the results of fc's listing of all fonts it knows about is the only option I know of).

So hopefully that answers your first question of how to find the fc-approved name for a specific font: guess and check.  Sadly, this is only really half of it as this only gives the font face but nothing about size.  Bitmap fonts come in different sizes.  So if you know you want to use ter-x28n.pcf telling fontconfig to use "xos4 Terminus" will not get you there, it will just use any ter-x*.pcf it wants.  So you could specify "xos4 Terminus:size=28" but I don't think that'd actually work as fontconfigs sizes are not pixels but points.  I think there is a pixel size specifier, but you'd have to double check this: "xos4 Terminux:pixelsize=28" should do it.  (edit: this is no longer correct on my system, it seems at the moment that "size=28" does get the ter-x28n.pcf as a result, but it did not used to be this way and I'd not assume it will continue to be this way for long.)

As for your second question, it's possible, but not really practical.  If you use programs that don't use fontconfig, it's easy.  But (quite sadly in my view) most software now does use fontconfig (even suckless's 'st' terminal which totally baffled me).  But if you are using software that relies on font-config, I'd advise against removing *all* non-bitmap fonts.  You can prioritize bitmap fonts, but you want others lower in the fallback list to or you'll likely end up with a lot of missing glyphs.

However, this will only allow you to use bitmap fonts as if they were TTF or related fonts.  It will not make fontconfig understand XLFD font strings.  There is no way to do that.  I think I once found a reference on how to specify a specific font file in a fontconfig string, but never an XLFD.

---

[1] Pretty clear evidence of this point for me:

$ fc-match Terminus
DejaVuSans.ttf: "DejaVu Sans" "Book"

$ fc-match "xos4 Terminus"
ter-x12n.pcf.gz: "xos4 Terminus" "Regular"

And before anyone tries to explain that, I am aware of the mechanics of the name change, but that does nothing to dampen the absurdity of it.

Last edited by Trilby (2018-04-22 12:30:41)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-04-25 18:03:25

ralph_13
Member
Registered: 2015-02-06
Posts: 73

Re: [SOLVED] What am I supposed to call fonts in configuration files?

Oh wow, thanks Trilby, that was pretty much all I wanted to know. About specifying the size: it seems that just putting the number next to it does alternate between sizes, just not exactly like one would expect. It alternates between different widths and heights for the smaller numbers, and after 13 it just scales up the biggest one available.

I agree with you on XFCD probably being better, but the only piece of software I actively use that's still on XFCD is the original xmms.

Anyway, marking this as solved, thanks everyone.

Offline

Board footer

Powered by FluxBB