gpt4 book ai didi

css - 为什么我在CSS中指定了 'DejaVu Serif'却选择了 'Liberation Mono'?

转载 作者:行者123 更新时间:2023-11-28 08:46:34 25 4
gpt4 key购买 nike

我在带有 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/)。

enter image description here

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

对于在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

enter image description here

再次提问

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

最佳答案

默认情况下,Firefox 仅允许通过 fontconfig 最多替换 3 个。

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

关于css - 为什么我在CSS中指定了 'DejaVu Serif'却选择了 'Liberation Mono'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30961732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com