我在我的计算机上安装了 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"
Run Code Online (Sandbox Code Playgroud)
Noto Sans 是我的后备字体,我认为这意味着它Fira Code Bold
与我的任何字体都不匹配。
但是,如果我fc-match
使用Fira Code:Bold
.
$ fc-match "Fira Code:Bold"
FiraCode_Bold.otf: "Fira Code" "Bold"
Run Code Online (Sandbox Code Playgroud)
在此问题之后,我创建了一个名为 inside 的文件30-fira-code-bold.conf
,~/.config/fontconfig/conf.d/
其中包含以下内容:
$ 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"
Run Code Online (Sandbox Code Playgroud)
然后我跑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
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何使用“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>
Run Code Online (Sandbox Code Playgroud)