Skip to content

Instantly share code, notes, and snippets.

@plumlis
Last active May 28, 2024 14:56
Show Gist options
  • Save plumlis/32ed3e293e6be2386715d69fb25a7878 to your computer and use it in GitHub Desktop.
Save plumlis/32ed3e293e6be2386715d69fb25a7878 to your computer and use it in GitHub Desktop.
Fontconfig
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<!-- 设置字体渲染方式,使用灰度,不使用 rgb -->
<match target="font">
<edit mode="assign" name="rgba">
<const>none</const>
</edit>
</match>
<match target="font">
<edit name="autohint" mode="assign">
<bool>false</bool>
</edit>
</match>
<match target="font">
<edit name="hinting" mode="assign">
<bool>true</bool>
</edit>
</match>
<!-- 设置字体渲染方式,可以使用 none,也可以使用 slight,我喜欢 none-->
<match target="font">
<edit mode="assign" name="hintstyle">
<const>hintnone</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
</match>
<!-- 针对 Emoji 字体单独设置,防止无法显示的问题,emoji 字体不能使用 none 渲染 -->
<match target="font">
<test name="family" qual="any">
<string>Noto Color Emoji</string>
</test>
<edit name="rgba" mode="assign">
<const>none</const>
</edit>
<edit name="embolden" mode="assign">
<bool>false</bool>
</edit>
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
<edit name="scalable" mode="assign">
<bool>true</bool>
</edit>
<edit name="embeddedbitmap" mode="assign">
<bool>true</bool>
</edit>
<edit name="hinting" mode="assign">
<bool>true</bool>
</edit>
<edit name="autohint" mode="assign">
<bool>false</bool>
</edit>
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
<edit name="hintstyle" mode="assign">
<const>hintslight</const>
</edit>
</match>
<!-- 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>
<!-- 默认 emoji 字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>emoji</string>
</test>
<edit name="family" mode="prepend" binding="same">
<string>Noto Color Emoji</string>
</edit>
</match>
<!-- 替换 Apple Color Emoji 字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>Apple Color Emoji</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Noto Sans</string>
</edit>
</match>
<!--
替换 Apple Color Emoji 字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>SF Pro Icons</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Noto Color Emoji</string>
</edit>
</match>
<!-- 替换 Apple 字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>PingFang SC</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Noto Sans CJK SC</string>
</edit>
</match>
<!-- 替换 Windows 字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>Microsoft Yahei</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Noto Sans CJK SC</string>
</edit>
</match>
<!-- 替换 MS 字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>arial</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Noto Sans</string>
</edit>
</match>
<!-- 替换 Apple字体。 -->
<match target="pattern">
<test name="family" qual="any">
<string>SF Pro</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Noto Sans</string>
</edit>
</match>
<!-- Map fonts that are commonly used by web pages to our preferred fonts -->
<match target="pattern">
<test qual="any" name="family"><string>Liberation Sans</string></test>
<edit name="family" mode="assign" binding="same"><string>sans-serif</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>Tahoma</string></test>
<edit name="family" mode="assign" binding="same"><string>sans-serif</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>Arial</string></test>
<edit name="family" mode="assign" binding="same"><string>sans-serif</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>Liberation Mono</string></test>
<edit name="family" mode="assign" binding="same"><string>monospace</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>Noto 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>Noto 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</string>
<string>Noto Sans Mono CJK SC</string>
<string>Noto Color Emoji</string>
</edit>
</match>
<!-- Default font for the zh_CN locale (no fc-match pattern) -->
<match target="pattern">
<test name="lang" compare="contains">
<string>en</string>
</test>
<test name="family" compare="contains">
<string>Noto Sans CJK SC</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>HarmonyOS Sans SC</string>
<string>Noto Sans CJK SC</string>
<string>Noto Sans</string>
<string>Noto Color Emoji</string>
</edit>
</match>
<match target="pattern">
<test name="lang" compare="contains">
<string>en</string>
</test>
<test name="family" compare="contains">
<string>Noto Serif CJK SC</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Serif CJK SC</string>
<string>Noto Serif</string>
<string>Noto Color Emoji</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-CN</string>
</test>
<test name="family">
<string>Noto Sans CJK SC</string>
</test>
</match>
<match target="pattern">
<test name="lang">
<string>zh-CN</string>
</test>
<test name="family">
<string>Noto Serif CJK SC</string>
</test>
</match>
<match target="pattern">
<test name="lang">
<string>zh-CN</string>
</test>
<test name="family">
<string>Noto Sans Mono CJK SC</string>
</test>
</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>
<!-- Fallback fonts preference order -->
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
<family>Noto Sans CJK SCNoto Sans CJK SC</family>
<family>Noto Sans CJK TC</family>
<family>Noto Sans CJK JP</family>
<family>Noto Sans CJK KR</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif</family>
<family>Noto Serif CJK SC</family>
<family>Noto Serif CJK TC</family>
<family>Noto Serif CJK JP</family>
<family>Noto Serif CJK KR</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Noto Sans Mono CJK SC</family>
<family>Noto Sans Mono CJK HK</family>
<family>Noto Sans Mono CJK JP</family>
<family>Noto Sans Mono CJK KR</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
<selectfont>
<rejectfont>
<pattern>
<patelt name="family" >
<!-- This font is causing problem with GitHub -->
<string>Nimbus Sans</string>
</patelt>
</pattern>
</rejectfont>
</selectfont>
</fontconfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment