fontconfig 中的 target="font" 和 target="pattern" 有什么区别?

Fen*_*kso 5 fonts

我试图理解为什么我fonts.conf工作中的一些测试使用<match target="pattern">(默认),另一个使用<match target="font">,而不是其他的。例如:

<match>
    <test name="family"><string>monospace</string></test>        
    <edit name="family"><string>Cousine</string></edit>
</match>

<match>
    <test name="family"><string>Cousine</string></test>
    <test name="pixelsize" compare="more"><double>17.5</double></test>
    <edit name="family" binding="strong"><string>Liberation Mono</string></edit>
</match>

<match target="font">
    <test name="family"><string>Overpass</string></test>        
    <edit name="hintstyle"><const>hintslight</const></edit>
</match>
Run Code Online (Sandbox Code Playgroud)

这是为什么?我已经阅读了文档,它只说If 'target' is set to "font" instead of the default "pattern", then this element applies to the font name resulting from a match rather than a font pattern to be matched.我不明白措辞,有人可以解释一下区别吗?

小智 5

从:

https://lists.freedesktop.org/archives/fontconfig/2007-December/002787.html

应用程序通常是这样工作的:

  1. 将用户的字体请求转换为fontconfig模式;
  2. 使用 target="pattern" 应用 fontconfig 配置;
  3. 从 fontconfig 获取与该模式匹配的字体排序列表。该列表本身作为一组 fontconfig 模式返回;
  4. 选择要使用的字体(通常是第一个具有所需字符的字体);
  5. 使用 target="font" 在字体模式上应用 fontconfig 配置。

因此,这意味着,例如,如果您想在 Bitstream Vera Sans 上关闭尺寸小于 7.5 的抗锯齿功能,则应该使用 target="font" 来实现。如果您使用 target="pattern" 执行此操作,如果请求是 Bitstream Vera Sans,它将关闭所有字体的 aa,无论您是否安装了该字体。

如果您想编写后备规则,以便用 DejaVu Sans 替换 Bitstream Vera Sans,则可以使用 target="pattern" 来完成,因为您想修改请求。

也来自:

https://lists.freedesktop.org/archives/fontconfig/2003-March/000128.html

使用字体目标来更改特定字体的呈现方式,使用模式目标来更改如何从可用字体中选择字体。