微软字体
本文介绍了如何安装 TrueType Microsoft 字体并模拟 Windows 的字体渲染。
安装
自动安装
安装字体最简单的方法是安装以下软件包之一:
- ttf-ms-win11-autoAUR — Windows 11 字体
- ttf-ms-win10-autoAUR — Windows 10 字体
- ttf-vista-fontsAUR — Vista 和 Office 2007 字体
当前软件包
- ttf-ms-win11AUR / ttf-ms-win11-autoAUR — Windows 11 字体
- ttf-ms-win10AUR / ttf-ms-win10-autoAUR — Windows 10 字体
- ttf-ms-win8AUR — Windows 8.1 字体
- ttf-win7-fontsAUR — Windows 7 字体
- ttf-ms-office365AUR — Office 365 字体
- ttf-office-2007-fontsAUR — Office 2007 字体
使用 Windows 分区的字体
如果挂载了 Windows 分区,可以直接使用其中的字体。有几种实现方法(假设 Windows C:\ 盘挂载在 /windows)
- 使用符号链接 (symlink)
# ln -s /windows/Windows/Fonts /usr/local/share/fonts/WindowsFonts
- 将文件复制到
/usr/local/share/fonts/
# mkdir -p /usr/local/share/fonts/WindowsFonts # cp -r /windows/Windows/Fonts/* /usr/local/share/fonts/WindowsFonts/ # chmod -R 644 /usr/local/share/fonts/WindowsFonts/*
- 使用绑定挂载 (bind mount)
# mount --bind /windows/Windows/Fonts /usr/local/share/fonts/WindowsFonts
若要永久生效,请按如下方式编辑 fstab 文件
/etc/fstab
/windows/Windows/Fonts /usr/local/share/fonts/WindowsFonts none bind 0 0
更多详情请参阅 mount(8) § Bind mount operation。
请记住,为了能够读取字体文件,可能需要针对 系统压缩文件 应用解决方法。
选择其中一种方案后,重新生成 fontconfig 缓存
# fc-cache --force # fc-cache-32 --force
从 Windows ISO 提取字体
字体也可以在 Windows ISO 文件中找到。ISO 中包含字体的镜像文件格式:如果是从网上下载的 ISO 则是 WIM (Windows Imaging Format);如果是使用 Windows 的 Media Creation Tool 构建的则是 ESD (Windows Electronic Software Download)。从 .iso 中提取 sources/install.esd 或 sources/install.wim 文件,并在该文件中寻找 Windows/Fonts 目录。可以使用 7z 或 wimextract (包含在 wimlib 中) 进行提取。下面是一个使用 7z 的示例
$ 7z e WinXY_YYMM_English_x64.iso sources/install.wim
$ 7z e install.wim 1/Windows/{Fonts/"*".{ttf,ttc},System32/Licenses/neutral/"*"/"*"/license.rtf} -ofonts/
字体和许可文件将位于 fonts 目录中。
旧版软件包
ttf-ms-fontsAUR 包含:
- Andalé Mono
- Arial
- Arial Black
- Comic Sans
- Courier New
- Georgia
- Impact
- Lucida Sans
- Lucida Console
- Microsoft Sans Serif
- Times New Roman
- Trebuchet
- Verdana
- Webdings
你还可以安装 ttf-tahomaAUR,顾名思义,它包含 Tahoma 字体。
ttf-vista-fontsAUR 包含:
对 MS 字体有用的 Fontconfig 规则
相似字体的规则映射
网站经常使用通用名称(helvetica, courier, times 或 times new roman)来指定字体,而 fontconfig 中的一条规则会将这些名称映射到自由字体(Liberation, Google CrOS, GUST TeX Gyre...)。这些替换定义在 /etc/fonts/conf.d/30-metric-aliases.conf 中。
为了充分利用 MS Windows 字体,需要创建一条规则,将这些通用名称映射到上述各个软件包中包含的 MS Windows 特定字体。
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias binding="same">
<family>Helvetica</family>
<accept>
<family>Arial</family>
</accept>
</alias>
<alias binding="same">
<family>Times</family>
<accept>
<family>Times New Roman</family>
</accept>
</alias>
<alias binding="same">
<family>Courier</family>
<accept>
<family>Courier New</family>
</accept>
</alias>
</fontconfig>
将你常用浏览器中的 serif(衬线)、sans-serif(无衬线)、monospace(等宽)字体关联到 MS 字体同样很有用。
禁用内嵌点阵字体
一些 Microsoft TTF 字体(如 Calibri 和 Cambria)在特定的字体大小下包含内嵌的点阵字体,这些点阵字体没有抗锯齿处理。如果启用了内嵌点阵,字体在这些特定大小下将没有抗锯齿效果。可以通过 字体配置禁用 内嵌点阵字体。
已知问题
基于 Poppler 的 PDF 阅读器中符号显示不正常
Microsoft 的 Symbol 字体 (Wikipedia:Symbol (typeface)) 在 Poppler 中存在 Bug,数学符号在基于 Poppler 的 PDF 阅读器中可能无法正确显示。