Fonts (简体中文)
引自维基百科:“计算机字体被实现为包含一组图形相关字形的数字数据文件。使用字体编辑器设计和创建计算机字体。专为计算机屏幕而非打印而设计的计算机字体是屏幕字体。”
注意部分字体许可协议可能会规定一些法律限制。
字体格式
现在使用的计算机字体绝大多数都属于点阵或轮廓数据格式。
- 点阵字体
- 用点或者像素组成的矩阵代表每种字形的每种形式和尺寸的图像。
- 轮廓字体,或称矢量字体
- 使用贝塞尔曲线、绘图指令和数学公式描述每种字形,使得字体轮廓可以适应各种尺寸。
点阵格式
- Bitmap Distribution Format(BDF)- 来自 Adobe
- Portable Compiled Format(PCF)- 来自 Xorg
- PC Screen Font(PSF)内核控制台字体,不受 Xorg 支持(Unicode PSF 文件的扩展名是
psfu
)
这些格式也可以被 gzip 压缩。可用的点阵字体请参见#点阵。
轮廓格式
- PostScript 字体 由 Adobe 定义——包含多种格式,如打印机 ASCII 字体(Printer Font ASCII,PFA)和打印机二进制字体(Printer Font Binary,PFB)
- TrueType —— 由 Apple 和 Microsoft 定义(扩展名为
ttf
) - OpenType —— 由 Microsoft 定义,基于 TrueType(扩展名为
otf
或ttf
)
在大多数情况下都可以忽略 TrueType 和 OpenType 之间的技术差异。
其它格式
排版程序 TeX 和配套的字体软件 Metafont 传统上用它们自己的方法渲染字体。部分用于这两个程序的字体的文件后缀有 *pk
、*gf
、mf
与 vf
。现在的版本也支持 TrueType 和 OpenType 字体。
FontForge(fontforge)是一个字体编辑程序,可以以自己的文本格式 sfd
(spline font database)储存字体。
SVG 格式也有自己的字体描述方法。
安装
可以使用多种方法安装字体。
Pacman
可以使用 pacman 安装启用的软件源中的字体和字体集。
可以通过查询包查找可用的字体(比如以 font
或 ttf
作为关键字查找)。
创建软件包
应该让 pacman 管理字体,这可以通过创建 Arch 软件包完成。也可以在 AUR 中与社区分享。安装字体的包非常相似;请参见字体打包指引。
可以用 fc-query
查看字体的字体系列,例如:fc-query -f '%{family[0]}\n' 文件路径
。FcPatternFormat(3) 中描述了输出的格式。
手动安装
要安装不在源中的字体,推荐的方法是#创建软件包。这使得 pacman 在以后能够更新或者移除它们。
字体也可以手动安装:
- 要为单个用户安装,安装到
~/.local/share/fonts/
。- 多数时候这就足够了,除非以其他用户的身份运行图形程序。
- 之前曾使用过
~/.fonts/
,但现在已被弃用。
- 要为系统(所有用户)安装,安装到
/usr/local/share/fonts/
。- 可能需要先创建该目录:
mkdir -p /usr/local/share/fonts
。 /usr/share/fonts/
由包管理器管理,请勿手动修改。
- 可能需要先创建该目录:
是否要创建子目录由用户决定,各发行版也有不同。为明晰起见,可将每个字体族放在单独的目录里。fontconfig 将递归搜索默认路径,可查找到子目录下的文件。
以下是一个示例:
/usr/local/share/fonts/ ├── otf │ └── SourceCodeVariable │ ├── SourceCodeVariable-Italic.otf │ └── SourceCodeVariable-Roman.otf └── ttf ├── AnonymousPro │ ├── Anonymous-Pro-B.ttf │ ├── Anonymous-Pro-I.ttf │ └── Anonymous-Pro.ttf └── CascadiaCode ├── CascadiaCode-Bold.ttf ├── CascadiaCode-Light.ttf └── CascadiaCode-Regular.ttf
请确保所有用户都有读取字体文件的权限,即至少 chmod 文件为 444
,目录为 555
。
要让 Xserver 直接载入字体(而不是使用某些字体服务),就需要将新增字体的目录加入到 FontPath 中。它位于 Xorg 设置文件(例如 /etc/X11/xorg.conf
或 /etc/xorg.conf
) 中。更多详细内容请参见#较旧的应用程序。
最后,更新 fontconfig 的缓存(通常不需要,因为使用 fontconfig 库的软件会这样做):
$ fc-cache
较旧的应用程序
对于不支持 fontconfig 的旧应用程序(例如 GTK 1.x 应用程序和 xfontsel
),需要在字体目录中创建索引:
$ mkfontscale $ mkfontdir
或在一条命令中包含多个目录:
$ for dir in /font/dir1/ /font/dir2/; do xset +fp $dir; done && xset fp rehash
或者,如果字体被安装在不同的子文件夹中,比如在 /usr/share/fonts
下:
$ for dir in * ; do if [ -d "$dir" ]; then cd "$dir";xset +fp "$PWD" ;mkfontscale; mkfontdir;cd .. ;fi; done && xset fp rehash
有时 X 服务器可能无法加载字体目录,这时需要重新扫描所有 fonts.dir
文件:
# xset +fp /usr/share/fonts/misc # 将新目录告诉 X 服务器 # xset fp rehash # 强制重新扫描
查询字体是否已经生效:
$ xlsfonts | grep fontname
这也可以在 /etc/X11/xorg.conf
或 /etc/X11/xorg.conf.d
中全局设置。
这个例子演示了必须加入到 /etc/X11/xorg.conf
中的一节内容。请根据实际需要添加或删除路径。
# 让 X.Org 知道自定义字体目录 Section "Files" FontPath "/usr/share/fonts/100dpi" FontPath "/usr/share/fonts/75dpi" FontPath "/usr/share/fonts/cantarell" FontPath "/usr/share/fonts/cyrillic" FontPath "/usr/share/fonts/encodings" FontPath "/usr/share/fonts/misc" FontPath "/usr/share/fonts/truetype" FontPath "/usr/share/fonts/TTF" FontPath "/usr/share/fonts/util" EndSection
Pango 警告
如果系统使用 Pango,那它就会读取 fontconfig 来查找字体来源。
(process:5741): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='common' (process:5741): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='latin'
如果看到类似上面的错误,或在应用程序中看到方块而不是文字,就需要添加字体并更新字体缓存。以下示例以 ttf-liberation 字体为例讲解(成功安装软件包后)如何解决这个问题并使用 root 权限运行如来使字体在系统范围内生效。
# fc-cache
/usr/share/fonts: caching, new cache contents: 0 fonts, 3 dirs /usr/share/fonts/TTF: caching, new cache contents: 16 fonts, 0 dirs /usr/share/fonts/encodings: caching, new cache contents: 0 fonts, 1 dirs /usr/share/fonts/encodings/large: caching, new cache contents: 0 fonts, 0 dirs /usr/share/fonts/util: caching, new cache contents: 0 fonts, 0 dirs /var/cache/fontconfig: cleaning cache directory fc-cache: succeeded
可以这样测试设置的默认字体:
$ fc-match
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
字体包
以下是一个有选择的列表,其中包括 AUR 以及官方存储库中的许多字体包。标记为“Unicode”的字体具有广泛的 Unicode 支持。
点阵
- Default 8x16
- Berry (pcf-spectrum-berryAUR) – 8px
- Dina (dina-font) – 6pt, 8pt, 9pt, 10pt, monospaced, based on Proggy
- Efont (efont-unicode-bdfAUR) – 10px, 12px, 14px, 16px, 24px, normal, bold and italic
- Gohu (gohufontAUR) – 11px, 14px, normal and bold
- Lime (artwiz-fontsAUR)
- ProFont (ttf-profont-iixAUR) – 10px, 11px, 12px, 15px, 17px, 22px, 29px, normal
- Proggy (proggyfontsAUR) —— 有不同的变体
- Tamsyn (tamsyn-font)
- Terminus (terminus-font)
- Tewi (bdf-tewi-gitAUR)
- Unifont (most extensive Unicode coverage of any font) (bdf-unifontAUR)
适用于 Pango 1.44:
- ProFont (profont-otbAUR) – OpenType Bitmap (OTB) variant of ProFont
- Misc Fixed xorg-fonts-misc-otbAUR
- Gohufont (gohufont-otbAUR)
- Cozette (cozette-otbAUR)
- Terminus (terminus-font)
- AUR 中的其他 OTB 字体
拉丁文字
字体族
Packages providing a base font set:
- Bitstream Vera (ttf-bitstream-vera) – 包含无衬线、衬线和等宽字体。Bitstream Vera Sans is metrically compatible with Verdana.
- Croscore fonts (ttf-croscore) – Metric-compatible fonts for Helvetica, Times, and Courier, shipped with Chrome OS
- DejaVu fonts (ttf-dejavu) – Bitstream Vera modified for greater Unicode coverage
- Droid (ttf-droid) – Default font for older Android versions with wide Unicode coverage including CJK but not symbols and emojis
- GNU FreeFont (gnu-free-fonts) – Includes three fonts that are open-source clones of Helvetica, Times, and Courier, but are metrically slightly different. Most Latin characters are from URW fonts (e.g., Nimbus Roman, Nimbus Sans), good Unicode coverage but does not include CJK
- IBM Plex (ttf-ibm-plex) – Serif, sans-serif, condensed sans-serif and monospace with true italics
- Liberation fonts (ttf-liberation) – Metric-compatible fonts for Helvetica, Times, and Courier, but are visually different
- Linux Libertine (ttf-linux-libertine) – Serif (Libertine) and sans serif (Biolinum) fonts with large Unicode coverage
- Microsoft fonts(ttf-ms-win11AUR)—— Windows 11 字体(需要 Windows 11 安装或安装介质)
- Noto fonts (noto-fonts) – Google font family with full Unicode coverage if installed with its emoji and CJK optional dependencies
Packages not providing a base font set:
- B612 (ttf-b612AUR) ——由 Airbus 赞助的开源字体系列(无衬线和等宽),专为在飞机驾驶舱屏幕上阅读而设计
- Luxi fonts (font-bh-ttfAUR) ——类似 Lucida 的 X.Org 字体族
- Roboto (ttf-roboto) – Default font for newer Android versions where it is complemented by Noto fonts for languages not supported like CJK
- TeX Gyre fonts (tex-gyre-fonts) – Metric-compatible fonts for Helvetica, Times, and Courier by the Polish GUST association of TeX users. They have their own math companion fonts, see #Math.
- Ubuntu 字体族 (ttf-ubuntu-font-family)
旧版 Microsoft 字体包:
- Microsoft 字体 (ttf-ms-fontsAUR) – Andalé Mono, Courier New, Arial, Arial Black, Comic Sans, Impact, Lucida Sans, Microsoft Sans Serif, Trebuchet, Verdana, Georgia, Times New Roman
- Vista 字体 (ttf-vista-fontsAUR) – Consolas, Calibri, Candara, Corbel, Cambria, Constantia
等宽
支持 编程连字的字体标有 ⟶ 符号。更多等宽字体参见#点阵和#字体族。
- Anonymous Pro (ttf-anonymous-pro, included in ttf-google-fonts-gitAUR)
- Cascadia Code (ttf-cascadia-code) ⟶ – Designed to enhance the look of the Windows Terminal, with programming ligatures, released by Microsoft under the Open Font License.
- Courier Prime (ttf-courier-primeAUR) – Courier alternative which has been supplemented by a sans serif font and a version optimized for programming, released under the Open Font License.
- Envy Code R (ttf-envy-code-rAUR) – Font designed for programmers
- Fantasque Sans Mono (ttf-fantasque-sans-mono, otf-fantasque-sans-mono)
- Fira Mono (ttf-fira-mono, otf-fira-mono) – Font optimized for small screens and adopted by Mozilla for the Firefox OS
- Fira Code (ttf-fira-code) ⟶ – Extension of Fira Mono with programming ligatures for common programming multi-character combinations
- Hack (ttf-hack) - Open source monospaced font, used as the default in KDE Plasma
- Hasklig (otf-haskligAUR) - 具有等宽连字的代码字体
- Hermit (otf-hermit) - 由程序员为程序员设计的字体
- Inconsolata(ttf-inconsolata,包含在 ttf-google-fonts-gitAUR 中)——为显示源代码设计,灵感来自 Consolas 和 Letter Gothic
- Inconsolata-g(ttf-inconsolata-gAUR)——添加一些对程序员友好的修改
- Iosevka (ttc-iosevka) ⟶ – Slender sans-serif and slab-serif typeface inspired by Pragmata Pro, M+ and PF DIN Mono, designed to be the ideal font for programming; it supports programming ligatures and over 2000 latin, greek, cyrillic, phonetic and PowerLine glyphs
- JetBrains Mono (ttf-jetbrains-mono) ⟶ – JetBrains 开发的免费开源字体
- Lucida Typewriter(包含在 jreAUR 软件包中)
- Menlo (ttf-mesloAUR) – Customized version of Apple's Menlo Regular font for OS X with larger vertical gap spacing
- Monaco (ttf-monacoAUR) – Apple 为 OS X 设计的专有字体
- Monofur (ttf-monofur)
- Mononoki(ttf-mononokiAUR)——用于编程和 code review 的字体
- Source Code Pro(adobe-source-code-pro-fonts,包含在 ttf-google-fonts-gitAUR 中)
相关网站:
- Trevor Lowing 的字体清单
- Slant:最好的编程字体是什么?
- Stack Overflow:推荐编程字体
- 编程字体 - 试驾
- 编程字体比较
- Coding Font by Typogram
无衬线
- Andika (ttf-andikaAUR)
- Cantarell (cantarell-fonts) – Default font supplied with GNOME, it is required by the GNOME and GTK 3 related packages
- DMCA Sans Serif (ttf-dmcasansserifAUR) – General purpose sans serif font metric-compatible with Microsoft Consolas
- Fira Sans (ttf-fira-sans, otf-fira-sans) – Sans serif font designed by Erik Spiekermann for Mozilla and the Firefox OS. Fira Mono and Fira Code are monospaced companions of Fira Sans (see #Monospaced)
- FreeSans (gnu-free-fonts) – Visually similar to Helvetica but metrically different, see #Families
- Inter (inter-font) – A geometric neo-grotesque font designed for user interfaces
- Jost* (otf-jostAUR) – An open-source typeface based on Futura
- Liberation Sans (ttf-liberation) – Metric-compatible with Helvetica but visually distinct, see #Families
- Montserrat (montserrat-otfAUR) – An open source font that shares similarities with Gotham and Proxima Nova
- Nunito (ttf-nunitoAUR) – An open source font with rounded terminal, hence shares similarities with Gotham Rounded and Proxima Soft
- Open Sans (ttf-opensans) – Sans serif font commissioned by Google, based on Droid sans but slightly wider.
- PT Sans (ttf-google-fonts-gitAUR) – 3 major variations: normal, narrow, and caption - Unicode: Latin, Cyrillic
- Source Sans (adobe-source-sans-fonts) – Open source sans serif font from Adobe with a design based on News Gothic and Franklin Gothic
- Tahoma (Wine Replacement) (ttf-tahomaAUR) – Open source substitute for Tahoma developed by the Wine project. It was created because many Windows applications expected Tahoma to be available
衬线
- Bitstream Charter (ttf-bitstream-charterAUR, otf-bitstream-charterAUR) – Originally a commercial font designed by Matthew Carter. A version was released under a free license and later converted to modern formats (provided as the aforementioned packages).
- Bodoni* (otf-bodoniAUR) – An open-source Bodoni revival
- Crimson (otf-crimson) – An open-source font that shares similarities with Minion
- EB Garamond (ebgaramond-otfAUR) – An open-source Garamond revival, the aforementioned package is the version developed by Octavio Pardo
- FreeSerif (gnu-free-fonts) – Visually similar to Times New Roman but metrically different, see #Families
- Gentium (gentium-plus-font) – Unicode: Latin, Greek, Cyrillic, Phonetic Alphabet
- Heuristica (ttf-heuristicaAUR) – Based on a version of Utopia that was released under a free license
- Liberation Serif (ttf-liberation) – Metric-compatible with Times New Roman but visually distinct, see #Families
- Libre Baskerville (ttf-librebaskervilleAUR) – An open-source Baskerville revival designed by Impallari Type
- Libre Caslon (otf-libre-caslonAUR) – An open-source Caslon revival designed by Impallari Type
- Linux Libertine (ttf-linux-libertine) – Developed as a substitute of Times New Roman, but different both visually and metrically (the metric differences are more notable for italic and bold fonts)
- TeX Gyre Termes (tex-gyre-fonts) – Visually similar to Times New Roman (but there are some minor metric differences), see #Families
- Tinos (ttf-croscore) – Metric-compatible with Times New Roman but visually distinct (and looks similar to Liberation Serif), see #Families
非拉丁文字
古代文字
- ttf-ancient-fontsAUR —— 包含 Aegean、Egyptian、Cuneiform、Anatolian、Maya 和 Analecta 文字的 Unicode 符号的字体
阿拉伯文
- ttf-amiriAUR —— 一个典型的阿拉伯文誊抄体 (Naskh) 字体,一开始由 Amiria Press 采用。其拉丁字符基于 Crimson (otf-crimson) [1] [2]
- ttf-arabeyes-fontsAUR —— 自由的阿拉伯文字体集合
- ttf-qurancomplex-fontsAUR —— 位于麦地那的 King Fahd Glorious Quran Printing Complex 制作的字体
- ttf-sil-lateefAUR —— 来自 SIL 的 Unicode 阿拉伯文字体
- ttf-sil-scheherazadeAUR —— 来自 SIL 的 Unicode 阿拉伯文字体(传统阿拉伯文字体的替代品)
孟加拉文
详见 Localization/Bengali#Fonts。
盲文
- ttf-ubrailleAUR —— 包含 Unicode 盲文符号的字体。
中日韩越文字
泛 CJK
- 思源字体 —— 大量字体集合,全面支持简体中文、繁体中文、日文和韩文,具有一致的设计和外观。
- adobe-source-han-sans-otc-fonts —— 思源黑体,无衬线字体
- adobe-source-han-serif-otc-fonts —— 思源宋体,衬线字体
- noto-fonts-cjk —— 大量字体集合,全面支持简体中文、繁体中文、日文和韩文,具有一致的设计和外观。它目前是 adobe-source-han-sans-otc-fonts 重新贴标的版本。
中文
参见 Localization/Chinese#Fonts。
日文
参见 Localization/Japanese#Fonts。
韩文
越南语
- ttf-hannom – 用于喃字的越南语 TrueType 字体
西里尔文字
另请参阅#拉丁文字。
- ttf-paratypeAUR – Font family by ParaType: sans, serif, mono, extended cyrillic and latin, OFL 许可证
- otf-russkopisAUR – A free OpenType cursive font for Cyrillic script
希腊文字
几乎所有 Unicode 字体都包含希腊代码集 (也包含多调变音符号)。某些额外字体包虽然不包含完整的 Unicode 集,但拥有高质量的希腊字字形 (也包含拉丁字):
- otf-gfsAUR - 由 Greek Font Society 选用的 OpenType 字体
- ttf-mgopenAUR - 来自 Magenta 的专业 TrueType 字体
希伯来文字
- opensiddur-hebrew-fontsAUR – Large collection of Open-source licensed Hebrew fonts. There are also few Latin, Greek, Cyrillic, Arabic, and Amharic.
- culmusAUR —— 不错的自由的希伯来文字体集合。
- alefbetAUR – 2 Hebrew fonts (at the moment): the commonly used "David Libre", and the handwriting font "Gveret Levin".
- ttf-ms-fontsAUR —— 包含 Arial 和其他字体。
印地文字
另请参阅 Localization/Indic#Fonts。
高棉文字
- ttf-khmer - 涵盖高棉语 (Khmer) 文字的字体
- Hanuman (ttf-google-fonts-gitAUR)
蒙古语和通古斯语
- ttf-abkaiAUR – Fonts for Sibe, Manchu and Daur scripts (incomplete, currently in development)
波斯文字
- persian-fontsAUR – 用于安装 AUR 中所有波斯字体的元包。
- borna-fontsAUR – Borna Rayaneh Co. Persian B font series.
- iran-nastaliq-fontsAUR – 自由的 Unicode 书法波斯字体。
- iranian-fontsAUR – Iranian-Sans and Iranian-Serif Persian font family.
- ir-standard-fontsAUR – 伊朗信息与通信技术高级理事会(SCICT)的标准波斯字体。
- persian-hm-ftx-fontsAUR – A Persian font series derived from X Series 2, Metafont and FarsiTeX fonts with Kashida feature.
- persian-hm-xs2-fontsAUR – A Persian font series derived from X Series 2 fonts with Kashida feature.
- gandom-fontsAUR, parastoo-fontsAUR, sahel-fontsAUR, samim-fontsAUR, shabnam-fontsAUR, tanha-fontsAUR, vazirmatn-fontsAUR, vazir-code-fontsAUR – Beautiful Persian fonts made by Saber RastiKerdar.
- ttf-yasAUR – The Yas Persian font series (with hollow zero).
- ttf-x2AUR – Free fonts with support for Persian, Arabic, Urdu, Pashto, Dari, Uzbek, Kurdish, Uighur, old Turkish (Ottoman) and modern Turkish (Roman).
壮侗语系
- fonts-tlwgAUR – Collection of scalable Thai fonts
- ttf-laoAUR – Lao TTF font (Phetsarath_OT)
藏缅语族
- ttf-tibetan-machine —— 藏文 (Tibetan) Machine TTFont
- ttf-sil-padaukAUR —— 支持多种使用缅文的语言的 Unicode 字体
Emoji 和符号
Unicode 标准的一部分用于称为“emoji”的象形字符。
Emoji 字体有不同的格式:CBDT/CBLC (Google)、SBIX (Apple)、COLR/CPAL (Microsoft) 和 SVG (Mozilla/Adobe)。
Emojis should work without any configuration once you have at least one emoji font installed of supported format. Emoji font fallback according to the standard requires extra code to handle emoji.
有关 Emoji 的发现和输入,参见 List of applications/Utilities#Text input。
软件 | CBDT/CBLC | SBIX | COLR/CPAL | SVG | Emoji font fallback |
---|---|---|---|---|---|
Freetype | Yes | Yes | Yes | No | – |
Pango | Freetype | Yes | |||
WebKitGTK | Freetype | Yes | |||
Qt | Freetype | No [3] [4] [5] | |||
Chromium | Freetype | Yes | |||
Firefox | Freetype | Yes | No, see Firefox#Font troubleshooting for workaround. |
CBDT/CBLC:
- noto-fonts-emoji —— Google 的开源 Emoji 14.0。
- ttf-joypixels —— EmojiOne 创作者的专有 Emoji 13.1。
- ttf-twemojiAUR —— Twitter 的开源 Emoji 13.0。
SVG:
- otf-openmojiAUR – German University of Design in Schwäbisch Gmünd open-source Emoji 13.0.
- ttf-twemoji-colorAUR —— Twitter 的开源 Emoji 13.0。
Outline only:
- ttf-symbolaAUR —— 提供许多 Unicode 符号,包括 emoji。
Kaomoji are sometimes referred to as "Japanese emoticons" and are composed of characters from various character sets, including CJK and Indic fonts. For example, the following set of packages covers most of existing kaomoji: gnu-free-fonts, ttf-arphic-uming, and ttf-indic-otf.
数学
- Computer Modern (ttf-cm-unicodeAUR, otf-cm-unicodeAUR)
- Computer Modern (otf-latin-modern, otf-latinmodern-math) – LaTeX 中使用的改进版本
- STIX fonts (otf-stixAUR) – Released under a royalty-free license and designed to be a math compansion of Times New Roman. The current version is called STIX Two Math.
- TeX Gyre math fonts (tex-gyre-math-fontsAUR) – Math compansions of TeX Gyre fonts (see #Families). Notably, TeX Gyre Termes Math is a math compansion of Times New Roman.
- XITS fonts (otf-xitsAUR) – A fork of STIX and is therefore a math compansion of Times New Roman. XITS and STIX Two Math have similar levels of completeness for mathematical symbols and alphabets [7], but do have some visual differences.
此外,texlive-core 和 texlive-fontsextra 中包含许多数学字体,例如 Latin Modern Math 和 STIX 字体。有关配置参见 TeX Live#Making fonts available to Fontconfig。
其他操作系统字体
- ttf-mac-fontsAUR - Apple MacOS TrueType 字体
后备字体顺序
Fontconfig 会自动选择一个满足当前显示需求的字体。例如,如果浏览一个既有英文又有中文的窗口,而默认的字体不支持中文,它会自动用另外的字体显示中文。
Fontconfig 允许每个用户通过 $XDG_CONFIG_HOME/fontconfig/fonts.conf
调整字体的选择顺序。
如果要优先使用衬线字体,遇到中文再使用某个特定的中文字体,配置文件会是这样:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <alias> <family>serif</family> <prefer> <family>喜欢的拉丁衬线字体名称</family> <family>中文字体名称</family> </prefer> </alias> </fontconfig>
- 如果系统的 locale 是中文,请将
LC_LANG
设置为und
,否则中英文都会使用中文字体渲染。 - 修改配置后可以用
fc-match -a monospace | head
检查后备字体设置是否正确。
无衬线和等宽字体也可以增加一样的设置,更多信息请参考 fontconfig 手册。
另请参阅 Font configuration#Replace or set default fonts。
字体别名
有几种字体别名实际上代表着别的字体,以让应用程序可以使用类似的字体。最常见的别名是:serif
代表衬线字体(如 DejaVu Serif);sans-serif
代表无衬线字体(如 DejaVu Sans);以及 monospace
代表等宽字体(如 DejaVu Sans Mono)。然而,这些别名所代表的字体有可能会变化,但 KDE 和其他桌面环境的字体管理工具通常不会显示对应关系。
如果想通过别名反向查找是展现了哪种字体,请运行:
$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
在这种情况下 monospace 别名展现的是 DejaVuSansMono.ttf
字体。
提示与技巧
列出所有已安装的字体
可以使用以下命令列出系统上所有已安装且可用的 Fontconfig 字体。
$ fc-list
列出特定语言的已安装字体
应用程序和浏览器根据 fontconfig 首选项和 Unicode 文本的可用字体字形选择和显示字体。要列出特定语言的已安装字体,请使用命令 fc-list :lang="双字母语言代码"
。例如,要列出已安装的阿拉伯字体或支持阿拉伯字形的字体:
$ fc-list -f '%{file}\n' :lang=ar
/usr/share/fonts/TTF/FreeMono.ttf /usr/share/fonts/TTF/DejaVuSansCondensed.ttf /usr/share/fonts/truetype/custom/DroidKufi-Bold.ttf /usr/share/fonts/TTF/DejaVuSansMono.ttf /usr/share/fonts/TTF/FreeSerif.ttf
列出特定 Unicode 字符的已安装字体
要搜索支持特定 Unicode 码点的等宽字体:
$ fc-match -s monospace:charset=1F4A9
Set terminal font on-the-fly
For terminal emulators that use X resources, e.g. xterm or rxvt-unicode, fonts can be set by using escape sequences. Specifically, echo -e "\033]710;$font\007"
to change the normal font (*font
in ~/.Xresources
), and replace 710
with 711
, 712
, and 713
to change the *boldFont
, *italicFont
, and *boldItalicFont
, respectively.
$font
uses the same syntax as in ~/.Xresources
and can be anything the terminal emulator will support. (Example: xft:dejavu sans mono:size=9
)
应用程序专用的字体缓存
Matplotlib (python-matplotlib) 使用自己的字体缓存,因此更新字体后记得删除 $HOME/.matplotlib/fontList.cache
,$HOME/.cache/matplotlib/fontList.cache
, $HOME/.sage/matplotlib-1.2.1/fontList.cache
等文件,这样它才会重新生成缓存并找到新字体 [8]。
终端中的双向文本
要在终端中正确的显示阿拉伯语和希伯来语,请运行 BiCon(bicon-gitAUR)。
参见
- State of Text Rendering
- Font Library - Fonts under Free licenses
- Fonts on screenshots.debian.net