如何在 fontconfig、fc-match 中使用通配符系列和大小

如何在 fontconfig、fc-match 中使用通配符系列和大小

我认为我至少对阅读中的 fontconfig 匹配有了概念性的了解man fonts.conf。但fc-match他的行为方式却一直与这种所谓的理解不相符。

我最初的目标是列出我安装的所有等宽字体 - 或 charcell,这种区别现在并不重要。我知道问题#363365 可以解决最初的目标,但目标可以概括为“查找具有特定属性值的所有已安装字体”。我只是提到更具体的目标,以避免任何“XY 问题”的可能性。

在联机帮助页部分FONT NAMES,我读到:

名称不必包含族或磅值;它们可以被忽略。

所以我尝试:

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

并得到:

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

好吧,这看起来就像常见的 Unix 问题,将以 开头的参数误认为-是选项。不幸的是,man fc-match它并不比帮助输出更详细,因此尚不清楚如何解决它。由于这是常见问题,我尝试了通常的补救措施:

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

但现在fc-match给了我一个很长的列表,所以我想知道它是否真的考虑了该模式:

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"

也许我需要指示某种严格匹配,也许我可以弄清楚如何使用 fonconfig API 来做到这一点,但如何在fc-match命令行上指示这一点?我真的需要为这个看似微不足道的任务编写一个程序吗?

相关内容