Skip to content

Instantly share code, notes, and snippets.

@aimerneige
Forked from rydesun/fonts.conf
Last active June 4, 2024 07:46
Show Gist options
  • Save aimerneige/4e1f6e14e449a77786b68099c8f1c329 to your computer and use it in GitHub Desktop.
Save aimerneige/4e1f6e14e449a77786b68099c8f1c329 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<!-- Default system-ui fonts -->
<match target="pattern">
<test name="family">
<string>system-ui</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>sans-serif</string>
</edit>
</match>
<!-- Default sans-serif fonts-->
<match target="pattern">
<test name="family">
<string>sans-serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Sans CJK SC</string>
<string>Noto Sans</string>
<string>Twitter Color Emoji</string>
</edit>
</match>
<!-- Default serif fonts-->
<match target="pattern">
<test name="family">
<string>serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Serif CJK SC</string>
<string>Noto Serif</string>
<string>Twitter Color Emoji</string>
</edit>
</match>
<!-- Default monospace fonts-->
<match target="pattern">
<test name="family">
<string>monospace</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Sans Mono CJK SC</string>
<string>Symbols Nerd Font</string>
<string>Twitter Color Emoji</string>
</edit>
</match>
<match target="pattern">
<test name="prgname" compare="not_eq">
<string>chrome</string>
</test>
<test name="family" compare="contains">
<string>Noto Sans Mono CJK</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Cascadia Code</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-HK</string>
</test>
<test name="family">
<string>Noto Sans CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans CJK HK</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-HK</string>
</test>
<test name="family">
<string>Noto Serif CJK SC</string>
</test>
<edit name="family" binding="strong">
<!-- not have HK -->
<string>Noto Serif CJK TC</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-HK</string>
</test>
<test name="family">
<string>Noto Sans Mono CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans Mono CJK HK</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-TW</string>
</test>
<test name="family">
<string>Noto Sans CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans CJK TC</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-TW</string>
</test>
<test name="family">
<string>Noto Serif CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Serif CJK TC</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-TW</string>
</test>
<test name="family">
<string>Noto Sans Mono CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans Mono CJK TC</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ja</string>
</test>
<test name="family">
<string>Noto Sans CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans CJK JP</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ja</string>
</test>
<test name="family">
<string>Noto Serif CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Serif CJK JP</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ja</string>
</test>
<test name="family">
<string>Noto Sans Mono CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans Mono CJK JP</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ko</string>
</test>
<test name="family">
<string>Noto Sans CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans CJK KR</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ko</string>
</test>
<test name="family">
<string>Noto Serif CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Serif CJK KR</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ko</string>
</test>
<test name="family">
<string>Noto Sans Mono CJK SC</string>
</test>
<edit name="family" binding="strong">
<string>Noto Sans Mono CJK KR</string>
</edit>
</match>
<!-- Replace monospace fonts -->
<match target="pattern">
<test name="family" compare="contains">
<string>Source Code</string>
</test>
<edit name="family" binding="strong">
<string>Cascadia Code</string>
</edit>
</match>
<match target="pattern">
<test name="lang" compare="contains">
<string>en</string>
</test>
<test name="family" compare="contains">
<string>Noto Sans CJK</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Sans</string>
</edit>
</match>
<match target="pattern">
<test name="lang" compare="contains">
<string>en</string>
</test>
<test name="family" compare="contains">
<string>Noto Serif CJK</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Serif</string>
</edit>
</match>
</fontconfig>
@aimerneige
Copy link
Author

aimerneige commented Jun 7, 2023

source

how to use

1. Install some essential fonts

2. Put this file in ~/.config/fontconfig/fonts.conf

3. Test page:

4. Script (global)

# Fix CJK fonts
sudo wget https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/master/Config/fonts.conf -O /etc/fonts/local.conf
wget -P /tmp https://gitlab.aiursoft.cn/anduin/anduinos/-/raw/master/Assets/fonts.zip
sudo unzip -o /tmp/fonts.zip -d /usr/share/fonts/
rm -f /tmp/fonts.zip
sudo fc-cache -fv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment