Fontconfigを使用してフォントコレクションの重みの1つにエイリアスを追加するにはどうすればよいですか?

Fontconfigを使用してフォントコレクションの重みの1つにエイリアスを追加するにはどうすればよいですか?

マイコンピュータにFira Codeフォントがインストールされていますが、他のバリエーションと同様に、フォント構成を使用して太字フォントをターゲットにすることはできません。これは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私のフォントに一致するものがないという意味だと思います。ただし、
using を実行すると正しいものと一致します。 fc-matchFira Code:Bold

$ fc-match "Fira Code:Bold"
FiraCode_Bold.otf: "Fira Code" "Bold"

次のようなこの問題30-fira-code-bold.conf~/.config/fontconfig/conf.d/、次の内容でinsideというファイルを作成しました。

<?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をターゲティングする方法を教えてください。

ベストアンサー1

他のフォント設定ファイルでテストした場合、動作すると思われる正しい設定ファイルは次のとおりです。

<?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>

おすすめ記事