I am writing a script that will create an image, with imagemagick:
plain text from a command output, rendered in a random font & colors.
the script is working well, but my brain is running hot on how to get a (fairly) reliable list of fonts matching the following criteria:
- support for latin 1 charset at the very least - this means to exclude symbolic fonts and all non-latin fonts
- NOT monospaced
- scalable (basically, not a bitmap font)
- outline (basically, not a bitmap font)
which should leave me with a sane choice of sans & serif fonts.
what i tried so far:
Code:
fc-match -s Sans family scalable|grep 'scalable=True'
fc-match -s Serif family scalable|grep 'scalable=True'
works, but does not exclude monospaced and non-latin fonts.
Code:
fc-list :lang=de:outline=True:scalable=True family spacing | grep -vE 'Mono|Symbol|Courier|:spacing='
trickier to explain.
returns a list of font's family, and its 'spacing' attribute.
the spacing attribute is usually only defined on monospaced fonts (or so i assume from what i see), so inverse grepping for that should eliminate some monospaced fonts already.
however, quite a few monospaced fonts are still left. I'm trying - very inelegantly - to filter them out by reverse grepping for telltale names, like 'Mono' or 'Courier'.
Similarly for symbolic/wingdings etc. fonts, by reverse grepping 'Symbol'.
Very inelegant, and doesn't work as expected anyway.
I am mostly working with man pages here; web searches were unsuccesful so far.
fontconfig:
I don't know how to define a "pattern" that would
a) list all fonts that match the "Sans" criterium
AND
b) filter out unwanted fonts, see above.
???
so, in effect, a combination of both approaches outlined above.
Anything else besides fontconfig and its fc-* utilities?
thanks.