这是我的 ~/.config/fontconfig/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
<edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
<edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
<alias>
<family>monospace</family>
<prefer>
<family>Meslo LG S DZ Regular for Powerline</family>
<family>Inconsolata</family>
<family>Menlo</family>
<family>DejaVu Sans Mono</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>DejaVu Sans</family>
<family>Droid Sans</family>
<family>Ubuntu</family>
<family>Helvetica</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>DejaVu Serif</family>
<family>Bitstream Vera Serif</family>
<family>Times New Roman</family>
</prefer>
</alias>
</fontconfig>
如您所见,我希望 Meslo 作为我的首选等宽字体。我从以下网址获取了该名称fc-list | grep Meslo
:
/usr/share/fonts/OTF/Meslo LG M DZ Regular for Powerline.otf: Meslo LG M DZ for Powerline:style=RegularForPowerline
/usr/share/fonts/OTF/Meslo LG L DZ Regular for Powerline.otf: Meslo LG L DZ for Powerline:style=RegularForPowerline
/usr/share/fonts/OTF/Meslo LG L Regular for Powerline.otf: Meslo LG L for Powerline:style=RegularForPowerline
/usr/share/fonts/OTF/Meslo LG S DZ Regular for Powerline.otf: Meslo LG S DZ for Powerline:style=RegularForPowerline
/usr/share/fonts/OTF/Meslo LG M Regular for Powerline.otf: Meslo LG M for Powerline:style=RegularForPowerline
/usr/share/fonts/OTF/Meslo LG S Regular for Powerline.otf: Meslo LG S for Powerline:style=RegularForPowerline
配置文件在 /etc/fonts/conf.d/50-user.conf 中启用:
<include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include>
我运行fc-cache -vf
并重新启动,然后尝试fc-match monospace
并期待 Meslo,但却得到了 Inconsolata。为什么?
答案1
显然我的姓氏写错了,我将fc-list | grep Meslo
粗体部分复制粘贴到了<family>
标签中:
/usr/share/fonts/OTF/Meslo LG M DZ Regular for Powerline.otf:Meslo LG M DZ 电力线:style=RegularForPowerline
我的配置现在如下:
<alias>
<family>monospace</family>
<prefer>
<family>Meslo LG M DZ for Powerline</family>
<family>DejaVu Sans Mono</family>
<family>Inconsolata</family>
</prefer>
</alias>
并且它按预期工作
答案2
我以前曾成功使用过此代码片段,
<!-- Scaling a chosen font with Fontconfig.
By poige, 2008.
-->
<match target="font">
<test name="family">
<string>Liberation Sans</string>
</test>
<edit name="pixelsize" mode="assign">
<times><name>pixelsize</name>, <double>1.1</double></times>
</edit>
</match>
以下是该片段的来源,但使用俄语。