How do I alias one of the weights of a font family with fontconfig?

brainplot

I have the font Fira Code installed on my computer but I can't target its bold variant using fontconfig in the same way I do with its other variants. Here's what fc-match gives me:

$ 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 is my fallback font which I think means that Fira Code Bold doesn't have any matches with any of my fonts.
However, it does match the right one if I run fc-match with Fira Code:Bold.

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

Following this question, I created a file called 30-fira-code-bold.conf within ~/.config/fontconfig/conf.d/ with the following content:

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

and then I ran fc-cache -rv and logged out but it still gives me Noto Sans if I run $ fc-match "Fira Code Bold". The only difference I have noticed is that it gives me Noto Sans even if I run $ fc-match "Fira Code:Bold"; so basically I can't target the bold variant of Fira Code in any way now.

I'm running Archlinux, if it can help, and this is the output of 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

Can anyone tell me how I can target Fira Code Bold using "Fira Code Bold"?

brainplot

By testing around from other fontconfig files, the right configuration file which seems to be working is the one below:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I alias the bold weight of a font family to the bold weight of another font family?

From Dev

fontconfig: cannot change font family

From Dev

Postscript: How can I alias or substitute one font for another?

From Dev

How do I get the font style (font-family) from an element

From Dev

How to set the font family I want in css?

From Dev

Changing font family for characters of a certain language/script using fontconfig?

From Dev

How do I figure out which font file is chosen for a system generic font alias?

From Dev

How do I figure out which font file is chosen for a system generic font alias?

From Dev

How can i get list of font family(or Name of Font) in matplotlib

From Dev

How can i get list of font family(or Name of Font) in matplotlib

From Dev

How do I generate a filtered set of available font family names? (like in Pages or TextEdit)

From Dev

How do I now which font family is used for text on web-page

From Dev

More than 2 font weights per font family?

From Dev

Using one from the "grep" family. How do I get the lines I omitting the search term?

From Dev

How can I set android font family to make the width the same?

From Dev

What is the default font family in HTML and how can I check this?

From Dev

How can I fix matplotlib detecting wrong font weights?

From Dev

How can I fix matplotlib detecting wrong font weights?

From Java

How do I find the duplicate companies and merge them into one and add together their weights

From Dev

In python pandas, how do i merge two dataframes while spreading values in one using weights of another?

From Dev

How do I alias this in PowerShell

From Dev

How do I find out if one Python function is an alias for another one?

From Dev

How to change levelplot font family?

From Dev

How to change the font family of Highchart to Bootstrap css default font family

From Dev

How can I set the font-family & font-size inside of a div?

From Dev

How can I determine which font in font-family my browser has matched?

From Dev

Installed entire font family, but only one appears

From Dev

Packaging multiple weights into one web font

From Dev

Adding a custom font to fontconfig

Related Related

  1. 1

    How do I alias the bold weight of a font family to the bold weight of another font family?

  2. 2

    fontconfig: cannot change font family

  3. 3

    Postscript: How can I alias or substitute one font for another?

  4. 4

    How do I get the font style (font-family) from an element

  5. 5

    How to set the font family I want in css?

  6. 6

    Changing font family for characters of a certain language/script using fontconfig?

  7. 7

    How do I figure out which font file is chosen for a system generic font alias?

  8. 8

    How do I figure out which font file is chosen for a system generic font alias?

  9. 9

    How can i get list of font family(or Name of Font) in matplotlib

  10. 10

    How can i get list of font family(or Name of Font) in matplotlib

  11. 11

    How do I generate a filtered set of available font family names? (like in Pages or TextEdit)

  12. 12

    How do I now which font family is used for text on web-page

  13. 13

    More than 2 font weights per font family?

  14. 14

    Using one from the "grep" family. How do I get the lines I omitting the search term?

  15. 15

    How can I set android font family to make the width the same?

  16. 16

    What is the default font family in HTML and how can I check this?

  17. 17

    How can I fix matplotlib detecting wrong font weights?

  18. 18

    How can I fix matplotlib detecting wrong font weights?

  19. 19

    How do I find the duplicate companies and merge them into one and add together their weights

  20. 20

    In python pandas, how do i merge two dataframes while spreading values in one using weights of another?

  21. 21

    How do I alias this in PowerShell

  22. 22

    How do I find out if one Python function is an alias for another one?

  23. 23

    How to change levelplot font family?

  24. 24

    How to change the font family of Highchart to Bootstrap css default font family

  25. 25

    How can I set the font-family & font-size inside of a div?

  26. 26

    How can I determine which font in font-family my browser has matched?

  27. 27

    Installed entire font family, but only one appears

  28. 28

    Packaging multiple weights into one web font

  29. 29

    Adding a custom font to fontconfig

HotTag

Archive