4

我在带有 XFCE4 桌面的 Debian 系统上使用 Iceweasel 浏览器(Firefox 衍生产品)。

我没有在 ~/.config/fontconfig/fonts.conf 中定义任何自定义字体替换。

这是 fc-match 目前告诉我的。

lone@debian:~$ fc-match "Liberation Mono"
n022003l.pfb: "Nimbus Mono L" "Regular"
lone@debian:~$ fc-match Courier
n022003l.pfb: "Nimbus Mono L" "Regular"
lone@debian:~$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

所以我希望当我有一个 HTML 时,使用“Liberation Mono”字体应该提供与使用“Courier”相同的结果。但从下面的截图中可以看出,情况并非如此(JSFiddle:http: //jsfiddle.net/8L3rmyxn/)。

在此处输入图像描述

我点击了“检查元素”并找到了实际使用的字体。

对于CSS中使用'Liberation Mono'的文本,浏览器使用'DejaVu Serif'代替,这与fc-math的输出不一致。

对于 CSS 中使用“Courier”的文本,浏览器使用“Nimbus Mono L”,这与 fc-match 的输出一致。

对于 CSS 中使用“monospace”的文本,浏览器使用“DejaVu Sans Mono”,这再次与 fc-match 的输出一致。

问题

为什么在“Liberation Mono”字体的情况下,浏览器不使用“Nimbus Mono L”而是使用“DejaVu Serif”字体?

已知分辨率

请注意,我知道解决此问题的方法。如果我在 ~/.config/fontconfig/fonts.conf 中明确定义“Liberation Mono”的别名,那么我会得到所需的结果,即“Liberation Mono”字体中的文本和“Courier”字体中的文本看起来相似。

lone@debian:~$ cat ~/.config/fontconfig/fonts.conf 
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <alias>
        <family>Liberation Mono</family>
        <prefer><family>Nimbus Mono L</family></prefer>
    </alias>
</fontconfig>
lone@debian:~$ fc-match "Liberation Mono"
n022003l.pfb: "Nimbus Mono L" "Regular

在此处输入图像描述

再次提问

但我的问题仍然存在。为什么在 fonts.conf 中没有这个明确的别名,当我在 CSS 中指定“Liberation Mono”字体时,浏览器不使用“Nimbus Mono L”而是使用“DejaVu Serif”字体,即使fc-match "Liberation Mono"输出相同不管我是否在 fonts.conf 中定义了别名?

4

1 回答 1

2

默认情况下,Firefox 最多只允许通过 fontconfig 进行 3 次替换。

您可以gfx.font_rendering.fontconfig.max_generic_substitutions在 about:config 中设置以增加此限制。允许的最大值是 127。

于 2016-11-28T06:18:57.403 回答