Skip to content

Instantly share code, notes, and snippets.

@plumlis
Created April 16, 2024 10:45
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>Source Han Sans CN</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>Source Han Sans CN</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>Source Han Serif CN</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>Source Han Mono 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>Source Han Sans CN</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>HarmonyOS Sans SC</string>
<string>Source Han Sans CN</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>Source Han Serif CN</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Source Han Serif CN</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>Source Han Sans CN</string>
</test>
</match>
<match target="pattern">
<test name="lang">
<string>zh-CN</string>
</test>
<test name="family">
<string>Source Han Serif CN</string>
</test>
</match>
<match target="pattern">
<test name="lang">
<string>zh-CN</string>
</test>
<test name="family">
<string>Source Han Mono SC</string>
</test>
</match>
<match target="pattern">
<test name="lang">
<string>zh-HK</string>
</test>
<test name="family">
<string>Source Han Sans CN</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>Source Han Serif CN</string>
</test>
<edit name="family" binding="strong">
<!-- not have HK -->
<string>Source Han Serif TW</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-HK</string>
</test>
<test name="family">
<string>Source Han Mono 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>Source Han Sans CN</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Sans TW</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-TW</string>
</test>
<test name="family">
<string>Source Han Serif CN</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Serif TW</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>zh-TW</string>
</test>
<test name="family">
<string>Source Han Mono SC</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Mono TC</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ja</string>
</test>
<test name="family">
<string>Source Han Sans CN</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Sans JP</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ja</string>
</test>
<test name="family">
<string>Source Han Serif CN</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Serif JP</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ja</string>
</test>
<test name="family">
<string>Source Han Mono SC</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Code JP</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ko</string>
</test>
<test name="family">
<string>Source Han Sans CN</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Sans KR</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ko</string>
</test>
<test name="family">
<string>Source Han Serif CN</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Serif KR</string>
</edit>
</match>
<match target="pattern">
<test name="lang">
<string>ko</string>
</test>
<test name="family">
<string>Source Han Mono SC</string>
</test>
<edit name="family" binding="strong">
<string>Source Han Mono K</string>
</edit>
</match>
<!-- Fallback fonts preference order -->
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
<family>Source Han Sans CN</family>
<family>Source Han Sans TW</family>
<family>Source Han Sans JP</family>
<family>Source Han Sans KR</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif</family>
<family>Source Han Serif CN</family>
<family>Source Han Serif TW</family>
<family>Source Han Serif JP</family>
<family>Source Han Serif KR</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Source Han Mono SC</family>
<family>Source Han Mono TC</family>
<family>Source Han Code JP</family>
<family>Source Han Mono K</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