Skip to content

Instantly share code, notes, and snippets.

@KhashayarDanesh
Last active April 18, 2020 09:48
Show Gist options
  • Save KhashayarDanesh/e4258e32b41338b7f13bee76e0c4126d to your computer and use it in GitHub Desktop.
Save KhashayarDanesh/e4258e32b41338b7f13bee76e0c4126d to your computer and use it in GitHub Desktop.
Fontconfig

Fontconfig

In this short guide, you will be referenced to installation of two typefaces and configuring fontconfig to use them system wide.

Selected Typefaces

You can find the Vazir Typeface in here: Github Repository

Cantarell Typeface is included in your distro's packages, just lookup the package name and install it

Config File

Create a file, with the name .fonts.conf in your home directory and then populate that file with the following lines.

you can also create a file with your desired name in the ~.config/fontconfig/ directory with .conf extension.

After doing this, Just log out of your user and login again, there you should see the font changes.

If the fonts are not looking as they should, maybe the fallback fonts are being used, then checking if the fonts are listed as installed in the font utility and wether if the names in the config file are correct.

For more details, Such as advanced configuration, alternative configuration paths etc. have a look at the Fontconfig Documentation in Freedesktop.org

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="pattern">
        <test name="lang" compare="contains">
            <string>en</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Cantarell</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>en</string>
        </test>
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Cantarell</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>en</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Cantarell</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>standard</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="lang" compare="contains">
            <string>az</string>
        </test>
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>az</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Vazir</string>
        </edit>
    </match>
</fontconfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment