本文介绍如何安装微软 TrueType 字体并模拟 Windows 渲染设置。
安装
自动安装
安装字体的最简单方法是安装以下其中一种:
- ttf-ms-win10-autoAUR - Windows 10 字体
- ttf-ms-win11-autoAUR - Windows 11 字体
从 Windows 使用字体
如果有一个安装了 Windows 的分区,可以通过链接它们来使用其字体。若不能读取字体文件,可以参见 NTFS-3G (简体中文)#已压缩的文件。
例如,Windows 的C:\盘被挂载在/windows:
# ln -s /windows/Windows/Fonts /usr/share/fonts/WindowsFonts
然后重新生成字体缓存:
# fc-cache -f
或者,将 Windows 的字体复制到/usr/share/fonts:
# mkdir /usr/share/fonts/WindowsFonts # cp /windows/Windows/Fonts/* /usr/share/fonts/WindowsFonts # chmod 644 /usr/share/fonts/WindowsFonts/*
然后重新生成字体缓存:
# fc-cache -f
从 Windows ISO 中提取字体
在 Windows ISO 文件中也可以找到字体。若 ISO 是在网络上下载的,则包含字体的文件格式为 WIM (Windows Imaging Format);若 ISO 是使用 Windows 介质创建工具创建的,则对应文件格式为 ESD (Windows Electronic Software Download)。从 ISO 文件中提取 sources/install.esd 或 sources/install.wim 文件并从中找到 Windows/Fonts 目录。它可以用 7z (p7zip) 或 wimextract (wimlib) 提取。以下是一个使用 7z 的示例:
$ 7z e Win10_1709_English_x64.iso sources/install.wim
$ 7z e install.wim 1/Windows/{Fonts/"*".{ttf,ttc},System32/Licenses/neutral/"*"/"*"/license.rtf} -ofonts/
$ 7z e install.wim Windows/{Fonts/"*".{ttf,ttc},System32/Licenses/neutral/"*"/"*"/license.rtf} -ofonts/ # Windows 7
字体和许可证将位于 fonts 目录。
当前软件包
- ttf-office-2007-fontsAUR - Microsoft Office 2007 字体
- ttf-win7-fontsAUR - Windows 7 字体
- ttf-ms-win8AUR - Windows 8.1 字体
- ttf-ms-win10AUR — Windows 10 字体
- ttf-ms-win11AUR — Windows 11 字体
旧软件包
ttf-ms-fontsAUR 包含:
- Andalé Mono
- Arial
- Arial Black
- Comic Sans
- Courier New
- Georgia
- Impact
- Lucida Sans
- Lucida Console
- Microsoft Sans Serif
Symbol- Times New Roman
- Trebuchet
- Verdana
- Webdings
Wingdings
ttf-tahomaAUR 包含 Tahoma。
ttf-vista-fontsAUR包括:
微软字体适用的 Fontconfig 规则
网站通常使用字体的通用名称 (helvetica, courier, times 或 times new roman),fontconfig 的一个规则文件/etc/fonts/conf.d/30-metric-aliases.conf将其替换为免费字体(Liberation, Google CrOS, GUST TeX Gyre...)。
要使用微软字体,需要将通用名称映射到微软的字体:
<?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 字体。
已知问题
基于 Poppler 的 PDF 阅读器无法正确显示符号
TrueType Microsoft 字体"symbol.ttf"在 Poppler 上有 Bug,数学符号可能无法在基于 Poppler 的 PDF 阅读器中正确显示。