在 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 文件有點令人困惑。

相關內容