重新加载 /etc/fonts/conf.d 中的设置

重新加载 /etc/fonts/conf.d 中的设置

我正在 Arch Linux 中调整一些字体设置。我在 中创建了一个新.conf文件/etc/fonts/conf.avail/并将其符号链接到/etc/fonts/conf.d.我现在想测试这些更改。我尝试过运行fc-cache -rv并重新启动终端。据我所知,我的更新没有被应用。

Arch Linux wiki 指出:

Fontconfig 将其所有配置收集在一个中央文件 (/etc/fonts/fonts.conf) 中。该文件在 fontconfig 更新期间被替换,并且不应被编辑。支持 Fontconfig 的应用程序通过此文件来了解可用字体以及它们的渲染方式。该文件是全局配置 (/etc/fonts/local.conf)、/etc/fonts/conf.d/ 中配置的预设以及用户配置文件 ($XDG_CONFIG_HOME/fontconfig/fonts.conf) 中的规则的组合)。 fc-cache 可用于重建 fontconfig 的配置,尽管更改仅在新启动的应用程序中可见。

然而,我的fonts.conf像一个集团。

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>

<!--
    DO NOT EDIT THIS FILE.
    IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
    LOCAL CHANGES BELONG IN 'local.conf'.

    The intent of this standard configuration file is to be adequate for
    most environments.  If you have a reasonably normal environment and
    have found problems with this configuration, they are probably
    things that others will also want fixed.  Please submit any
    problems to the fontconfig bugzilla system located at fontconfig.org

    Note that the normal 'make install' procedure for fontconfig is to
    replace any existing fonts.conf file with the new version.  Place
    any local customizations in local.conf which this file references.

    Keith Packard
-->

<!-- Font directory list -->

    <dir>/usr/share/fonts</dir>
    <dir>/usr/share/fonts</dir>
    <dir prefix="xdg">fonts</dir>
    <!-- the following element will be removed in the future -->
    <dir>~/.fonts</dir>

<!--
  Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
    <match target="pattern">
        <test qual="any" name="family">
            <string>mono</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>monospace</string>
        </edit>
    </match>

<!--
  Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
    <match target="pattern">
        <test qual="any" name="family">
            <string>sans serif</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>sans-serif</string>
        </edit>
    </match>

<!--
  Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
    <match target="pattern">
        <test qual="any" name="family">
            <string>sans</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>sans-serif</string>
        </edit>
    </match>

<!--
  Load local system customization file
-->
    <include ignore_missing="yes">conf.d</include>

<!-- Font cache directory list -->

    <cachedir>/var/cache/fontconfig</cachedir>
    <cachedir prefix="xdg">fontconfig</cachedir>
    <!-- the following element will be removed in the future -->
    <cachedir>~/.fontconfig</cachedir>

    <config>
<!--
  Rescan configuration every 30 seconds when FcFontSetList is called
 -->
        <rescan>
            <int>30</int>
        </rescan>
    </config>

</fontconfig>

我希望它能让我看到最终组合的字体设置是什么。

答案1

我尝试运行 fc-cache -rv 并重新启动终端。据我所知,我的更新没有被应用。

重新启动应用程序应该足以重新加载更改。一些应用程序甚至会定期重新加载配置,而无需重新启动。

fc-cache据我所知,通常对于配置更改来说毫无用处。

如果您的更改似乎没有应用,可能是因为没有任何匹配,或者如果匹配,则规则不够强大,无法应用。

我建议添加类似这样的内容,以实现无条件的、强约束的、非常明显的变化:

<match target="pattern">
    <edit name="family" mode="prepend" binding="strong">
        <string>Comic Sans MS</string>
    </edit>
</match>

当你的眼睛开始流血时,你就知道它起作用了。

请注意,即使如此,在此规则之后评估的规则也可能会进一步修改此模式。

我还使用了rejectfont块,它似乎比其他任何东西都有更高的优先级,但是处理特定的TTF文件,所以你需要知道匹配的是什么(FC_DEBUG=1就足够了)

<selectfont>
    <rejectfont>
        <glob>/usr/share/fonts/TTF/DejaVuSans.ttf</glob>
    </rejectfont>
</selectfont>

问题的另一部分:

然而,我的fonts.conf看起来并不像一个集团。

神奇之处就在于它<include ignore_missing="yes">conf.d</include>包含了其他一切。

这就是我的系统中的样子:

$ FC_DEBUG=1024 leafpad
    Loading config file /etc/fonts/fonts.conf
    Scanning config dir /etc/fonts/conf.d
    Loading config file /etc/fonts/conf.d/10-hinting-slight.conf
    Loading config file /etc/fonts/conf.d/10-scale-bitmap-fonts.conf
    Loading config file /etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf
    Loading config file /etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf
    Loading config file /etc/fonts/conf.d/20-unhint-small-dejavu-serif.conf
    Loading config file /etc/fonts/conf.d/20-unhint-small-vera.conf
    Loading config file /etc/fonts/conf.d/30-metric-aliases.conf
    Loading config file /etc/fonts/conf.d/30-urw-aliases.conf
    Loading config file /etc/fonts/conf.d/30-win32-aliases.conf
    Loading config file /etc/fonts/conf.d/40-nonlatin.conf
    Loading config file /etc/fonts/conf.d/45-latin.conf
    Loading config file /etc/fonts/conf.d/49-sansserif.conf
    Loading config file /etc/fonts/conf.d/50-user.conf
    Scanning config dir /home/dx/.config/fontconfig/conf.d
    Loading config file /home/dx/.config/fontconfig/conf.d/10-powerline-symbols.conf
    Loading config file /home/dx/.config/fontconfig/fonts.conf
    Loading config file /home/dx/.fonts.conf
    Loading config file /etc/fonts/conf.d/51-local.conf
    Loading config file /etc/fonts/local.conf
    Loading config file /etc/fonts/conf.d/57-dejavu-sans-mono.conf
    Loading config file /etc/fonts/conf.d/57-dejavu-sans.conf
    Loading config file /etc/fonts/conf.d/57-dejavu-serif.conf
    Loading config file /etc/fonts/conf.d/60-latin.conf
    Loading config file /etc/fonts/conf.d/65-fonts-persian.conf
    Loading config file /etc/fonts/conf.d/65-nonlatin.conf
    Loading config file /etc/fonts/conf.d/69-unifont.conf
    Loading config file /etc/fonts/conf.d/75-fix-calibri.conf
    Loading config file /etc/fonts/conf.d/80-delicious.conf
    Loading config file /etc/fonts/conf.d/90-synthetic.conf

相关内容