1

I thought I had at least a conceptual understanding of fontconfig matching from reading man fonts.conf. But fc-match keeps behaving in ways that don't correspond to that supposed understanding.

My original goal was to list all monospaced fonts I have installed - or charcell, that distinction doesn't matter for now. I know know that original goal to be solved by question #363365, but the goal can be generalized to "Find all installed fonts with a particular property value". I just mention the more specific goal to avoid any chance of "XY problem".

In the manpage section FONT NAMES, I read:

The name needn't include either families or point sizes; they can be elided.

So I tried:

fc-match -s '-:spacing=mono'

and got:

fc-match: invalid option -- ':'
usage: fc-match [-savbVh] [-f FORMAT] [--sort] [--all] [--verbose] [--brief] [--format=FORMAT] [--version] [--help] [pattern] {element...}
List best font matching [pattern]

  -s, --sort           display sorted list of matches
  -a, --all            display unpruned sorted list of matches
  -v, --verbose        display entire font pattern verbosely
  -b, --brief          display entire font pattern briefly
  -f, --format=FORMAT  use the given output format
  -V, --version        display font config version and exit
  -h, --help           display this help and exit

Ok, that looks like the usual Unix problem with mistaking an argument starting with - for an option. Unfortunately man fc-match is no more detailed than the help output, so it is unclear how to work around it. Since it is the usual problem, I try the usual remedy:

fc-match -s -- '-:spacing=mono'

But now fc-match gives me a very long list, such that I wonder if it actually considers the pattern at all:

LiberationSans-Regular.ttf: "Liberation Sans" "Regular"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
NimbusSans-Regular.t1: "Nimbus Sans" "Regular"
FreeSans.ttf: "FreeSans" "Regular"
FreeMono.ttf: "FreeMono" "Regular"
FreeSerif.ttf: "FreeSerif" "Regular"
texgyreadventor-regular.otf: "TeX Gyre Adventor" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
texgyreschola-regular.otf: "TeX Gyre Schola" "Regular"
lmmono10-regular.otf: "Latin Modern Mono" "10 Regular"
lmsansquot8-regular.otf: "Latin Modern Sans Quotation" "8 Regular"
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
Arimo-Regular.ttf: "Arimo" "Regular"
DroidSansFallbackFull.ttf: "Droid Sans Fallback" "Regular"
pcrr8a.pfb: "Courier" "Regular"
StandardSymbolsPS.t1: "Standard Symbols PS" "Regular"
Symbola_hint.ttf: "Symbola" "Regular"
texgyrechorus-mediumitalic.otf: "TeX Gyre Chorus" "Regular"
cmunbmr.ttf: "CMU Bright" "Roman"
cmunorm.ttf: "CMU Concrete" "Roman"
cmunrm.ttf: "CMU Serif" "Roman"
cmuntt.ttf: "CMU Typewriter Text" "Regular"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
FiraCode-Regular.ttf: "Fira Code" "Regular"
unifont.ttf: "Unifont" "Medium"
unifont_csur.ttf: "Unifont CSUR" "Medium"
unifont_upper.ttf: "Unifont Upper" "Medium"

Maybe I need to indicate some kind of strict matching, and maybe I could figure how to do it with the fonconfig API, but how to indicate this on fc-match command line? Do I really have to write a program for this seemingly trivial task?

q.undertow
  • 518
  • 2
  • 10
  • 1
    See https://unix.stackexchange.com/questions/363365/command-to-list-all-monospace-fonts-known-to-fontconfig – catemperor Jul 28 '20 at 11:01
  • @contemplator : it works, thanks! Now, why does fc-match include all those other fonts in its reply? – q.undertow Jul 28 '20 at 14:46
  • Does this answer your question? [Command to list all monospace fonts known to fontconfig](https://unix.stackexchange.com/questions/363365/command-to-list-all-monospace-fonts-known-to-fontconfig) – smac89 Oct 16 '20 at 06:06
  • 1
    @smac89: it solved my problem (as I noted in my comment both here and on that question). But it doesn't answer my original question, which you may now consider academic, namely: why doesn't `fc-match` do the job, as documented? – q.undertow Oct 16 '20 at 15:43

0 Answers0