Flatpak 应用中文字体问题

封面图片来源:使用 Aseprite 制作(源文件, 遵循 CC BY-SA 4.0

配置 fontconfig

请确保 Linux 下使用传统包管理器安装的软件字体符合你的预期,可参考 Linux 下的字体调校指南 配置你的 ~/.config/fontconfig/fonts.conf

添加权限

使用命令

flatpak override --user --filesystem="xdg-config/fontconfig:ro" your.flatpak.app

使用图形界面

安装 Flatseal,在 All Aplication -> Filesystem -> Other files 中添加 xdg-config/fontconfig:ro

fonts.conf 样例参考

~/.config/fontconfig/fonts.conf
<?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig> <match target="font"> <edit mode="assign" name="rgba"> <const>rgb</const> </edit> </match> <match target="font"> <edit mode="assign" name="hintstyle"> <const>hintslight</const> </edit> </match> <!-- Map fonts that are commonly used by web pages to our preferred fonts --> <match target="pattern"> <test name="family" qual="any"> <string>Liberation Sans</string> </test> <edit binding="same" mode="assign" name="family"> <string>sans-serif</string> </edit> </match> <match target="pattern"> <test name="family" qual="any"> <string>Liberation Mono</string> </test> <edit binding="same" mode="assign" name="family"> <string>monospace</string> </edit> </match> <!-- Default font for the zh_CN locale (no fc-match pattern) --> <match> <test compare="contains" name="lang"> <string>zh_CN</string> </test> <edit mode="prepend" name="family"> <string>Noto Sans CJK SC</string> </edit> </match> <!-- Default sans-serif font --> <match target="pattern"> <test name="family" qual="any"> <string>sans-serif</string> </test> <edit binding="same" mode="prepend" name="family"> <string>Noto Sans</string> </edit> </match> <!-- Default serif fonts --> <match target="pattern"> <test name="family" qual="any"> <string>serif</string> </test> <edit binding="same" mode="prepend" name="family"> <string>Noto Serif</string> </edit> </match> <!-- Default monospace fonts --> <match target="pattern"> <test name="family" qual="any"> <string>monospace</string> </test> <edit binding="same" mode="prepend" name="family"> <string>Noto Sans Mono</string> </edit> </match> <!-- Fallback fonts preference order --> <alias> <family>sans-serif</family> <prefer> <family>Noto Sans</family> <family>Noto 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</family> <family>Noto Sans Mono CJK SC</family> <family>Noto Sans Mono CJK TC</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> <dir>~/.fonts</dir> <match target="font"> <edit mode="assign" name="hinting"> <bool>true</bool> </edit> </match> <match target="font"> <edit mode="assign" name="antialias"> <bool>true</bool> </edit> </match> </fontconfig>
知识共享许可协议
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

回复 glaumar 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

14 条评论 “Flatpak 应用中文字体问题”