在 fonts.conf 中设置字体的默认样式

在 fonts.conf 中设置字体的默认样式

我正在尝试设置字体的默认样式,fonts.conf因为无论出于何种原因,粗体版本始终会匹配:

$ fc-match monospace
LigaOperatorMonoSSm-Bold.otf: "Liga Operator Mono SSm" "Bold"

这是我的fonts.conf

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <edit name="antialias" mode="assign"><bool>true</bool></edit>

  <match target="pattern">
    <test qual="any" name="family"><string>Liga Operator Mono SSm</string></test>
    <edit name="style" mode="assign" binding="same"><string>Medium</string></edit>
  </match>

  <alias>
    <family>serif</family>
    <prefer><family>Circular Std</family></prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer><family>Circular Std</family></prefer>
  </alias>
  <alias>
    <family>sans</family>
    <prefer><family>Circular Std</family></prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer><family>Liga Operator Mono SSm</family></prefer>
  </alias>
  <alias>
    <family>terminal</family>
    <prefer><family>Liga Operator Mono SSm</family></prefer>
  </alias>
</fontconfig>

正如您所看到的,我尝试将默认宽度设置为,Medium但不幸的是它不起作用。这些是可用的样式:

/usr/share/fonts/OTF/LigaOperatorMonoSSm-LightItalic.otf: Liga Operator Mono SSm:style=Light Italic,Italic
/usr/share/fonts/OTF/LigaOperatorMonoSSm-MediumItalic.otf: Liga Operator Mono SSm:style=Medium Italic,Italic
/usr/share/fonts/OTF/LigaOperatorMonoSSm-Medium.otf: Liga Operator Mono SSm:style=Medium,Regular
/usr/share/fonts/OTF/LigaOperatorMonoSSm-BoldItalic.otf: Liga Operator Mono SSm:style=Bold Italic,Italic
/usr/share/fonts/OTF/LigaOperatorMonoSSm-Book.otf: Liga Operator Mono SSm:style=Book,Regular
/usr/share/fonts/OTF/LigaOperatorMonoSSm-Bold.otf: Liga Operator Mono SSm:style=Bold,Regular
/usr/share/fonts/OTF/LigaOperatorMonoSSm-BookItalic.otf: Liga Operator Mono SSm:style=Book Italic,Italic
/usr/share/fonts/OTF/LigaOperatorMonoSSm-Light.otf: Liga Operator Mono SSm:style=Light,Regular

有人看出错误在哪里吗?谢谢!

答案1

以下是我用来修复 Operator Mono 中错误元数据的方法:

 <!-- Fixup Operator Mono weights -->
 <match target="scan">
   <test name="family">
     <string>Operator Mono Bold</string>
   </test>
   <edit name="weight">
     <const>bold</const>
   </edit>
 </match>
 <match target="scan">
   <test name="family">
     <string>Operator Mono Book</string>
   </test>
   <edit name="weight">
     <const>book</const>
   </edit>
 </match>
 <match target="scan">
   <test name="family">
     <string>Operator Mono XLight</string>
   </test>
   <edit name="weight">
     <const>extralight</const>
   </edit>
 </match>

不要忘记替换字体名称和fc-cache -f之后。

答案2

我遇到了同样的问题(使用不同的字体)。这种事情对我有用:

<match target="pattern">
    <test name="family" compare="eq">
        <string>Liga Operator Mono SSm</string>
    </test>
    <edit name="style" mode="append">
        <string>Medium</string>
    </edit>
</match>

基本上,这表示每当搜索“Liga Operator Mono SSm”系列时,请将“Medium”添加到要搜索的样式列表的末尾。因此,如果指定了其他样式,则该样式将优先,但如果没有,则将使用“Medium”来查找字体。

...我认为。说实话,fontconfig 文档有点令人困惑。

相关内容