Fonts
如何使用 fontconfig 對字型系列的權重之一進行別名?
我的電腦上安裝了字型 Fira Code,但我無法像使用其他變體一樣使用 fontconfig 來定位它的粗體變體。這是
fc-match
給我的:$ fc-match "Fira Code" FiraCode_Regular.otf: "Fira Code" "Regular" $ fc-match "Fira Code Light" FiraCode_Light.otf: "Fira Code" "Light" $ fc-match "Fira Code Medium" FiraCode_Medium.otf: "Fira Code" "Medium" $ fc-match "Fira Code Bold" NotoSans-Regular.ttc: "Noto Sans" "Regular"
Noto Sans 是我的備份字型,我認為這意味著它
Fira Code Bold
與我的任何字型都不匹配。但是,如果我
fc-match
使用Fira Code:Bold
.$ fc-match "Fira Code:Bold" FiraCode_Bold.otf: "Fira Code" "Bold"
在這個問題之後,我創建了一個名為 inside 的文件
30-fira-code-bold.conf
,~/.config/fontconfig/conf.d/
其內容如下:<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <match target="pattern"> <test name="family"><string>Fira Code</string></test> <test name="weight" compare="more_eq"><const>bold</const></test> <edit name="family" mode="assign" binding="strong"><string>Fira Code Bold</string></edit> </match> </fontconfig>
然後我跑
fc-cache -rv
了出去,但如果我跑了,它仍然會給我 Noto Sans$ fc-match "Fira Code Bold"
。我注意到的唯一區別是,即使我跑步,它也會給我 Noto Sans$ fc-match "Fira Code:Bold"
;所以基本上我現在不能以任何方式針對 Fira Code 的粗體變體。我正在執行 Archlinux,如果它可以提供幫助,這是輸出
fc-list
:$ fc-list "Fira Code" | egrep -o 'FiraCode.*' FiraCode_Medium.otf: Fira Code,Fira Code Medium:style=Medium,Regular FiraCode_Light.otf: Fira Code,Fira Code Light:style=Light,Regular FiraCode_Regular.otf: Fira Code:style=Regular FiraCode_Bold.otf: Fira Code:style=Bold
誰能告訴我如何使用“Fira Code Bold”定位 Fira Code Bold?
通過從其他 fontconfig 文件進行測試,似乎可以正常工作的正確配置文件如下:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <match target="pattern"> <test qual="any" name="family"> <string>Fira Code Bold</string> </test> <edit name="family" binding="same" mode="prepend"> <string>Fira Code</string> </edit> <edit name="weight" binding="same" mode="prepend"> <const>bold</const> </edit> </match> </fontconfig>