Difference between revisions of "Fonts (简体中文)"
Flockyrocky (talk | contribs) (→Previewing and testing) |
m (updated AUR package name) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
[[es:Fonts]] | [[es:Fonts]] | ||
[[it:Fonts]] | [[it:Fonts]] | ||
+ | [[ja:Fonts]] | ||
[[ru:Fonts]] | [[ru:Fonts]] | ||
[[tr:Yazıtipleri]] | [[tr:Yazıtipleri]] | ||
Line 244: | Line 245: | ||
====Khmer==== | ====Khmer==== | ||
*{{Pkg|ttf-khmer}} - Font covering glyphs for Khmer language | *{{Pkg|ttf-khmer}} - Font covering glyphs for Khmer language | ||
− | *[http://code.google.com/webfonts/family?family=Hanuman&subset=khmer Hanuman] ({{AUR|ttf-google-webfonts}}) | + | *[http://code.google.com/webfonts/family?family=Hanuman&subset=khmer Hanuman] ({{AUR|ttf-google-webfonts-hg}} or {{AUR|ttf-google-webfonts-git}}) |
====Sinhala==== | ====Sinhala==== | ||
Line 277: | Line 278: | ||
* [[Wikipedia:Andalé Mono|Andalé Mono]] ({{AUR|ttf-ms-fonts}}) | * [[Wikipedia:Andalé Mono|Andalé Mono]] ({{AUR|ttf-ms-fonts}}) | ||
* Anka/Coder ({{AUR|ttf-anka-coder}}) | * Anka/Coder ({{AUR|ttf-anka-coder}}) | ||
− | * Anonymous Pro ({{AUR|ttf-anonymous-pro}}, included in {{AUR|ttf-google-webfonts}}) | + | * Anonymous Pro ({{AUR|ttf-anonymous-pro}}, included in {{AUR|ttf-google-webfonts-hg}} and {{AUR|ttf-google-webfonts-git}}) |
* [[Wikipedia:Bitstream Vera|Bitstream Vera Mono]] ({{Pkg|ttf-bitstream-vera}}) | * [[Wikipedia:Bitstream Vera|Bitstream Vera Mono]] ({{Pkg|ttf-bitstream-vera}}) | ||
* [[Wikipedia:Consolas|Consolas]] ({{AUR|ttf-vista-fonts}}) | * [[Wikipedia:Consolas|Consolas]] ({{AUR|ttf-vista-fonts}}) | ||
* [[Wikipedia:Courier New|Courier New]] ({{AUR|ttf-ms-fonts}}) | * [[Wikipedia:Courier New|Courier New]] ({{AUR|ttf-ms-fonts}}) | ||
− | * Cousine ({{AUR|ttf-google-webfonts}}) - Chrome/Chromium OS replacement for Courier New (metric-compatible) | + | * Cousine ({{AUR|ttf-google-webfonts-hg}} or {{AUR|ttf-google-webfonts-git}}) - Chrome/Chromium OS replacement for Courier New (metric-compatible) |
* [[Wikipedia:DejaVu fonts|DejaVu Sans Mono]] ({{Pkg|ttf-dejavu}}) - Unicode | * [[Wikipedia:DejaVu fonts|DejaVu Sans Mono]] ({{Pkg|ttf-dejavu}}) - Unicode | ||
− | * [[Wikipedia:Droid (font)|Droid Sans Mono]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts}}) | + | * [[Wikipedia:Droid (font)|Droid Sans Mono]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts-hg}} and {{AUR|ttf-google-webfonts-git}}) |
* Envy Code R ({{AUR|ttf-envy-code-r}}) | * Envy Code R ({{AUR|ttf-envy-code-r}}) | ||
* [[Wikipedia:GNU FreeFont|FreeMono]] ({{Pkg|ttf-freefont}}) - Unicode | * [[Wikipedia:GNU FreeFont|FreeMono]] ({{Pkg|ttf-freefont}}) - Unicode | ||
Line 310: | Line 311: | ||
*[[Wikipedia:Arial|Arial]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Arial|Arial]] ({{AUR|ttf-ms-fonts}}) | ||
*[[Wikipedia:Arial Black|Arial Black]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Arial Black|Arial Black]] ({{AUR|ttf-ms-fonts}}) | ||
− | *Arimo ({{AUR|ttf-google-webfonts}}) - Chrome/Chromium OS replacement for Arial (metric-compatible) | + | *Arimo ({{AUR|ttf-google-webfonts-hg}} or {{AUR|ttf-google-webfonts-git}}) - Chrome/Chromium OS replacement for Arial (metric-compatible) |
*[[Wikipedia:Calibri|Calibri]] ({{AUR|ttf-vista-fonts}}) | *[[Wikipedia:Calibri|Calibri]] ({{AUR|ttf-vista-fonts}}) | ||
*[[Wikipedia:Candara|Candara]] ({{AUR|ttf-vista-fonts}}) | *[[Wikipedia:Candara|Candara]] ({{AUR|ttf-vista-fonts}}) | ||
Line 316: | Line 317: | ||
*[[Wikipedia:Corbel (typeface)|Corbel]] ({{AUR|ttf-vista-fonts}}) | *[[Wikipedia:Corbel (typeface)|Corbel]] ({{AUR|ttf-vista-fonts}}) | ||
*[[Wikipedia:DejaVu fonts|DejaVu Sans]] ({{Pkg|ttf-dejavu}}) - Unicode | *[[Wikipedia:DejaVu fonts|DejaVu Sans]] ({{Pkg|ttf-dejavu}}) - Unicode | ||
− | *[[Wikipedia:Droid (font)|Droid Sans]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts}}) | + | *[[Wikipedia:Droid (font)|Droid Sans]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts-hg}} and {{AUR|ttf-google-webfonts-git}}) |
*[[Wikipedia:GNU FreeFont|FreeSans]] ({{Pkg|ttf-freefont}}) - Unicode | *[[Wikipedia:GNU FreeFont|FreeSans]] ({{Pkg|ttf-freefont}}) - Unicode | ||
*[[Wikipedia:Impact (typeface)|Impact]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Impact (typeface)|Impact]] ({{AUR|ttf-ms-fonts}}) | ||
Line 324: | Line 325: | ||
*[[Wikipedia:Lucida Sans|Lucida Sans]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Lucida Sans|Lucida Sans]] ({{AUR|ttf-ms-fonts}}) | ||
*[[Wikipedia:Microsoft Sans Serif|Microsoft Sans Serif]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Microsoft Sans Serif|Microsoft Sans Serif]] ({{AUR|ttf-ms-fonts}}) | ||
− | *[[Wikipedia:PT Sans|PT Sans]] ({{AUR|ttf-google-webfonts}}) - 3 major variations: normal, narrow, and caption - Unicode: Latin, Cyrillic | + | *[[Wikipedia:PT Sans|PT Sans]] ({{AUR|ttf-google-webfonts-hg}} or {{AUR|ttf-google-webfonts-git}}) - 3 major variations: normal, narrow, and caption - Unicode: Latin, Cyrillic |
*[[Wikipedia:Tahoma (typeface)|Tahoma]] ({{AUR|ttf-tahoma}}) | *[[Wikipedia:Tahoma (typeface)|Tahoma]] ({{AUR|ttf-tahoma}}) | ||
*[[Wikipedia:Trebuchet MS|Trebuchet]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Trebuchet MS|Trebuchet]] ({{AUR|ttf-ms-fonts}}) | ||
Line 340: | Line 341: | ||
*[[Wikipedia:DejaVu fonts|DejaVu Serif]] ({{Pkg|ttf-dejavu}}) - Unicode | *[[Wikipedia:DejaVu fonts|DejaVu Serif]] ({{Pkg|ttf-dejavu}}) - Unicode | ||
*[[Wikipedia:Doulos SIL|Doulos]] ({{AUR|doulos-sil}}, included in {{AUR|ttf-sil-fonts}}) - Unicode: Latin, Cyrillic | *[[Wikipedia:Doulos SIL|Doulos]] ({{AUR|doulos-sil}}, included in {{AUR|ttf-sil-fonts}}) - Unicode: Latin, Cyrillic | ||
− | *[[Wikipedia:Droid (font)|Droid Serif]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts}}) | + | *[[Wikipedia:Droid (font)|Droid Serif]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts-hg}} and {{AUR|ttf-google-webfonts-git}}) |
*[[Wikipedia:GNU FreeFont|FreeSerif]] ({{Pkg|ttf-freefont}}) - Unicode | *[[Wikipedia:GNU FreeFont|FreeSerif]] ({{Pkg|ttf-freefont}}) - Unicode | ||
*[[Wikipedia:Gentium|Gentium]] ({{Pkg|ttf-gentium}}, included in {{AUR|ttf-sil-fonts}}) - Unicode: Latin, Greek, Cyrillic, Phonetic Alphabet | *[[Wikipedia:Gentium|Gentium]] ({{Pkg|ttf-gentium}}, included in {{AUR|ttf-sil-fonts}}) - Unicode: Latin, Greek, Cyrillic, Phonetic Alphabet | ||
Line 347: | Line 348: | ||
*[[Wikipedia:Linux Libertine|Linux Libertine]] ({{Pkg|ttf-linux-libertine}}) - Unicode: Latin, Greek, Cyrillic, Hebrew | *[[Wikipedia:Linux Libertine|Linux Libertine]] ({{Pkg|ttf-linux-libertine}}) - Unicode: Latin, Greek, Cyrillic, Hebrew | ||
*[[Wikipedia:Times New Roman|Times New Roman]] ({{AUR|ttf-ms-fonts}}) | *[[Wikipedia:Times New Roman|Times New Roman]] ({{AUR|ttf-ms-fonts}}) | ||
− | *Tinos ({{AUR|ttf-google-webfonts}}) - Chrome/Chromium OS replacement for Times New Roman (metric-compatible) | + | *Tinos ({{AUR|ttf-google-webfonts-hg}} or {{AUR|ttf-google-webfonts-git}}) - Chrome/Chromium OS replacement for Times New Roman (metric-compatible) |
===Unsorted=== | ===Unsorted=== | ||
<!--This section should be absorbed into the Monospace/Serif/Sans-Serif structure--> | <!--This section should be absorbed into the Monospace/Serif/Sans-Serif structure--> | ||
− | *{{AUR|ttf-google-webfonts}} and {{AUR|ttf-google-webfonts-hg}} — a huge collection of free fonts (including ubuntu, inconsolata, droid, etc.) - Note: Your font dialog might get very long as >100 fonts will be added ''(AUR)'' | + | *{{AUR|ttf-google-webfonts-git}} and {{AUR|ttf-google-webfonts-hg}} — a huge collection of free fonts (including ubuntu, inconsolata, droid, etc.) - Note: Your font dialog might get very long as >100 fonts will be added. {{AUR|ttf-google-webfonts-hg}} pulls down the entire Mercurial repository from the upstream Web Fonts project. {{AUR|ttf-google-webfonts-git}} pulls from a much smaller and leaner unofficial repository hosted on GitHub. ''(AUR)'' |
*{{Pkg|ttf-mph-2b-damase}} — Covers full plane 1 and several scripts | *{{Pkg|ttf-mph-2b-damase}} — Covers full plane 1 and several scripts | ||
*{{AUR|ttf-symbola}} — Provides emoji and many many other symbols. ''(AUR)'' | *{{AUR|ttf-symbola}} — Provides emoji and many many other symbols. ''(AUR)'' | ||
Line 362: | Line 363: | ||
*{{Pkg|xorg-fonts-type1}} — IBM Courier and Adobe Utopia sets of [[Wikipedia:PostScript fonts|PostScript fonts]] | *{{Pkg|xorg-fonts-type1}} — IBM Courier and Adobe Utopia sets of [[Wikipedia:PostScript fonts|PostScript fonts]] | ||
− | == | + | ==控制台字体== |
− | + | 控制台,即没有运行X窗口系统的终端,默认使用ASCII字符集。这种字体和按键映射可以很容易地改变。 | |
− | + | 控制台字体被限制为256到512个字符。这些字体可以在{{ic|/usr/share/kbd/consolefonts/}}中找到。 | |
− | '' | + | ''按键映射,''电脑在按下键和得到字符之间的对应关系,可以在{{ic|/usr/share/kbd/keymaps/}}的子目录中找到。 |
=== 预览和测试 === | === 预览和测试 === | ||
Line 393: | Line 394: | ||
$ setfont | $ setfont | ||
− | === | + | === 修改默认字体 === |
− | + | 要修改默认字体,需要修改{{ic|/etc/vconsole.conf}}中的{{ic|FONT<nowiki>=</nowiki>}}和{{ic|FONT_MAP<nowiki>=</nowiki>}}配置节(如果不存在则需要新建)。再次说明,字体可以在{{ic|/usr/share/kbd/consolefonts/}}目录中找到,键盘映射可以在{{ic|/usr/share/kbd/keymaps/}}的子目录中找到。 | |
− | ==== | + | ==== 示例 ==== |
− | + | 为了显示如''Č, ž, đ, š'' or ''Ł, ę, ą, ś''一类的字符,需要使用字体{{ic|lat2-16.psfu.gz}}: | |
FONT=lat2-16 | FONT=lat2-16 | ||
− | + | 这意味着ISO/IEC 8859的第二部分字符,并且使用16号字。你可以通过修改字号来改变字体大小,如lat2-08...16。8859规范指定的区域请参考[http://en.wikipedia.org/wiki/ISO/IEC_8859#The_Parts_of_ISO.2FIEC_8859 Wikipedia]。如果你经常在没有X Server的控制台工作,推荐使用Terminus字体。例如ter-216b是一种latin-2字体,16号,黑体。ter-216n是同样的字体但是正常体。Terminus字体最多有32号字。 | |
− | + | 现在需要设置正确的字符映射。lat2-16应该使用: | |
FONT_MAP=8859-2 | FONT_MAP=8859-2 | ||
− | + | 为了在早先的用户空间中使用指定的字体,即在引导过程中使用,可以添加{{ic|consolefont}}钩子到{{ic|/etc/mkinitcpio.conf}}: | |
HOOKS="base udev autodetect pata scsi sata filesystems '''consolefont''' '''keymap'''" | HOOKS="base udev autodetect pata scsi sata filesystems '''consolefont''' '''keymap'''" | ||
− | + | 然后重建Linux映像: | |
# mkinitcpio -p linux | # mkinitcpio -p linux | ||
− | {{ | + | {{注意|如果安装了多于一个内核,则以上步骤必须为每个内核执行一次。}} |
− | + | 查阅[[Mkinitcpio#HOOKS]]以获得更多信息。 | |
− | + | 如果字体在引导时仍然没有改变,或只是临时改变了,则最有可能是图形驱动初始化,控制台切换到帧缓存时字体被重置了。为了避免这种情况,需要在更早的阶段加载图形驱动。查阅[[KMS#Early_KMS_start]]或其他方法以便在{{ic|/etc/vconsole.conf}}之前设置帧缓存并应用。 | |
− | ==== | + | ==== 引导错误 ==== |
− | + | 如果"加载控制台字体"在引导时失败,这最有可能是你你在安装Arch Linux时没有选择有效的字体。 | |
− | + | 要避免这个错误,只需要简单地清空{{ic|CONSOLEFONT}}变量,它位于{{ic|/etc/rc.conf}}。这样引导时就会回滚到使用默认字体。 | |
− | == | + | == X11中的字体回滚顺序 == |
− | Fontconfig | + | Fontconfig 会自动选择一个符合当前场景的字体。也就是说,如果有人正在浏览一个既有英文又有中文的窗口,而默认的字体不支持中文,它会自动切换到另一种字体以便显示中文。 |
− | Fontconfig | + | Fontconfig 让每个用户能够通过{{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}来决定字体使用的顺序。 |
− | + | 如果你想要在最喜欢的Serif字体之后使用某个特定的中文字体,你的配置文件看起来会是这样: | |
<?xml version="1.0"?> | <?xml version="1.0"?> | ||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | ||
Line 440: | Line 441: | ||
</fontconfig> | </fontconfig> | ||
− | + | 当然你也可以为Sans-serif和monospaced字体添加一个配置节。更多信息请参考fontconfig说明。 | |
− | == | + | == 字体别名 == |
− | + | 在Linux系统中有几种字体别名,它们实际代表着别的字体,这样以达到让应用程序的字体看起来类似。最常见的别名有:{{ic|serif}}代表一种衬线体(关于衬线体与非衬线体概念请参考[http://hanyu.iciba.com/wiki/2198016.shtml 这里]——译注)(例如DejaVu Serif);{{ic|sans-serif}}代表一种非衬线体(例如DejaVu Sans);而{{ic|monospace}} 则代表等宽字体(例如DejaVu Sans Mono)。 然而,这些别名所代表的字体有可能会变化,而且通常KDE和其他桌面环境中的字体管理工具不会显示其内在联系。 | |
− | + | 如果想通过别名反向查找是哪种字体被展现出来,运行: | |
$ fc-match monospace | $ fc-match monospace | ||
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book" | DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book" | ||
− | + | 在这种情况下Monospace别名展现的是DejaVuSansMono.ttf字体。 | |
==2 英文字和中文字等宽== | ==2 英文字和中文字等宽== |
Revision as of 21:43, 7 April 2013
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end From Wikipedia:
- A computer font (or font) is an electronic data file containing a set of glyphs, characters, or symbols such as dingbats.
Contents
字体类型
大多数当代电脑使用的不是点阵字体就是矢量字体。
- 点阵字体
- 每种字形的每种形式和每种尺寸的图像都由点或者像素组成的矩阵构成。由于位图的原故,点阵字体很难进行缩放,特定的点阵字体只能清晰地显示在相应的字号下。但对于 12-16px 这样小的汉字,点阵字体常常比其它类型的字体在屏幕上更好的显示效果。常见的点阵字体有 bdf,pcf,fnt,hbf 等格式。
- 矢量字体
- 使用贝塞尔曲线, 绘图指令和数学公式来描述每种字形,使得字体可以适应各种尺寸。
通用类型
-
bdf
andbdf.gz
– 点阵字体,“b”代表点阵,“d”代表布局,“f”代表形式,用gzip压缩bdf
。 -
pcf
andpcf.gz
– 点阵字体,“p”代表可移植,“c”代表编译 “f”代表字体,用gzip压缩pcf
。 -
psf
,psfu
,psf.gz
andpsfu.gz
– 点阵字体,“PC”,“s”代表屏幕,“f”代表字体,“PC”,“s”代表屏幕,“f”代表字体,“U”代表Unicode,用gzip压缩(不适用于X.Org)。 -
pfa
andpfb
– 矢量字体,“P”代表PostScript,“f”代表字体,“A”代表ASCII。“P”代表PostScript,“f”代表字体,“b”代表二进制。PostScript字体包含内嵌打印令。 -
ttf
– outline,“T”rue“T”ype,“f”代表字体。作为PostScript字体的替代。 -
otf
– outline,“O”pen“T”ype,“f”代表字体。带有PostScript打印指令的TrueType字体。
在多数情况下,TrueType和OpenType的技术差异可以忽略,一些带有ttf
扩展的字体实际上是OpenType字体。
其它类型
排版程序“TeX”和配套的字体软件“Metafont”用它们自己的方法渲染字体。一些用于这两个程序的字体的文件后缀是*pk
, *gf
, mf
and vf
。
“FontForge”, 一个字体编辑程序,可能用自己的格式来储存字体,例如sfd
, “s”代表线条,“f”代表字体,“d”代表数据库。
SVG格式也有自己的字体描述方法
安装
你可以使用多种方法安装字体。
Pacman
有效的源中的字体和字体集可以使用pacman来安装。 可以使用以下方式查找字体:
$ pacman -Ss font
或者也可以只查找ttf
字体:
$ pacman -Ss ttf
一些字体(例如Terminus)被安装在/usr/share/fonts/local
中,这个路径默认没有被加入字体搜索路径中。通过在~/.xinitrc
中加入以下命令将可以在X11中使用这些字体:
xset +fp /usr/share/fonts/local xset fp rehash
创建字体包
如果想让pacman能够管理你自己的字体,可以创建一个Arch软件包。这些包也可以在AUR中与社区成员分享. 以下是一个怎样创建软件包的基本样例。需要了解更多如何创建软件包的内容,请参考PKGBUILD.
pkgname=ttf-fontname pkgver=1.0 pkgrel=1 depends=('fontconfig' 'xorg-font-utils') pkgdesc="custom fonts" arch=('any') source=(http://someurl.org/$pkgname.tar.bz2) install=$pkgname.install build() { mkdir -p $pkgdir/usr/share/fonts/TTF cp $srcdir/$pkgname/*.ttf $pkgdir/usr/share/fonts/TTF }
这个PKGBUILD推断这些字体是TrueType字体。需要创建一个安装文件(ttf-fontname.install
)以便更新字体缓存:
post_install() { echo -n "Updating font cache... " fc-cache -fs >/dev/null mkfontscale /usr/share/fonts/TTF /usr/share/fonts/Type1 mkfontdir /usr/share/fonts/TTF /usr/share/fonts/Type1 echo "done" } post_upgrade() { post_install } post_remove() { post_install }
手工安装字体
要安装不在源中的字体,推荐的方法请参考#创建字体包。这样使得pacman在以后能够移除或者更新它们。当然字体也可以通过手工方式安装。
要在系统范围内(对所有用户有效)安装字体,请将文件夹移动到 /usr/share/fonts/
目录。要为单个用户安装字体,请使用 ~/.fonts/
。
同样你可能需要更新/etc/X11/xorg.conf
或/etc/xorg.conf
来指明新目录。查找字符串FontPath
以便在这些文件中找到正确的位置来插入你的新路径。查看#X.Org的字体以了解更多信息.
然后更新fontconfig的字体缓存:
$ fc-cache -vf
过老的应用程序
过老而不支持fontconfig的应用程序(例如GTK+ 1.x应用,及xfontsel
),需要在字体目录创建索引:
$ mkfontscale $ mkfontdir
或在一条命令中包含多于一个目录:
$ for dir in /font/dir1/ /font/dir2/; do xset +fp $dir; done && xset fp rehash
有时候X server可能会不能成功加载字体目录,这时你需要重新扫描fonts.dir
文件:
# xset +fp /usr/share/fonts/misc # Inform the X server of new directories # xset fp rehash # Forces a new rescan
查询字体是否已经生效,可以使用:
$ xlsfonts | grep fontname
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权限运行如下命令可以使字体在系统范围内生效。
# pacman -S ttf-liberation -- output abbreviated, assumes installation succeeded -- # fc-cache -vfs /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"
X.Org中的字体
为了让Xorg找到并使用你新安装的字体,你必须把字体路径加入到/etc/X11/xorg.conf
(另一个X.Org配置文件可能也可以)。
这个例子演示了必须加入到/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/local" FontPath "/usr/share/fonts/misc" FontPath "/usr/share/fonts/truetype" FontPath "/usr/share/fonts/TTF" FontPath "/usr/share/fonts/util" EndSection
字体包
以下是官方源和AUR中提供的安装包列表以保参考。支持Unicode的字体都标注上了“Unicode”字样。欲知详情请查看具体项目或维基百科。
Braille
- ttf-ubraille - Font containing Unicode symbols for braille
International users
Arabic
- ttf-sil-lateefAUR - Unicode Arabic font from SIL (AUR)
- ttf-sil-scheherazadeAUR - Unicode Arabic font from SIL (AUR)
- ttf-arabeyes-fontsAUR - Collection of free Arabic fonts (AUR)
Birman
- ttf-myanmar3AUR - Font for Myanmar/Burmese script (AUR)
Chinese, Japanese, Korean, Vietnamese
(Mainly) Chinese
- ttf-twAUR -(繁體字)國字標準字體(楷書/宋體)母稿——中華民國教育部(AUR).
- wqy-microheiAUR - 一种Sans-Serif风格的高质量CJK轮廓字体。"(AUR)
- wqy-zenhei - 嵌入点阵宋体的黑体风格(sans-serif)中文轮廓字体(也支持部分日文和韩文).
- ttf-arphic-ukai - 楷體 Kaiti (brush stroke) unicode TTFonts (建议开启抗锯齿)
- ttf-arphic-uming - 明體 Mingti (打印) unicode TTFonts
- opendesktop-fonts - 新宋 字体, 之前是 ttf-fireflysung 软件包
- wqy-bitmapfont - 中文点阵宋体(serif)
- ttf-hannom - 中文和越南文TrueType字体
Japanese
- otf-ipafontAUR - Formal style Japanese Gothic (sans-serif) and Mincho (serif) fonts set; one of the highest quality open source font. Default of openSUSE-ja. (AUR)
- ttf-vlgothicAUR - Japanese Gothic fonts. Default of Debian/Fedora/Vine Linux (AUR)
- ttf-mplusAUR - Modern Gothic style Japanese outline fonts. It includes all of Japanese Hiragana/Katakana, Basic Latin, Latin-1 Supplement, Latin Extended-A, IPA Extensions and most of Japanese Kanji, Greek, Cyrillic, Vietnamese with 7 weights (proportional) or 5 weights (monospace).
- ttf-ipa-monaAUR, ttf-monapoAUR - Japanese fonts to show 2channel Shift JIS art properly. (AUR)
- ttf-sazanami - Japanese free TrueType font. This is outdated and not maintained any more, but may be defined as a fallback font on several environment.
Korean
- ttf-baekmuk - Collection of Korean TrueType fonts
- ttf-aleeAUR - Set of free Hangul TrueType fonts (AUR)
- ttf-unfonts-coreAUR - Un fonts (default Baekmuk fonts may be unsatisfactory) (AUR)
- ttf-nanumAUR - Nanum series TrueType fonts (AUR)
- ttf-nanumgothic_codingAUR - Nanum series fixed width TrueType fonts (AUR)
Cyrillic
Also see #Monospace, #Sans and #Serif
- font-arhangaiAUR - Mongolian Cyrillic (AUR)
- ttf-pingwi-typographyAUR - PingWi Typography (PWT) fonts (AUR)
Greek
Almost all Unicode fonts contain the Greek character set (polytonic included). Some additional font packages, which might not contain the complete Unicode set but utilize high quality Greek (and Latin, of course) typefaces are:
- otf-gfsAUR - Selection of OpenType fonts from the Greek Font Society (AUR)
- ttf-mgopenAUR - Professional TrueType fonts from Magenta (AUR)
Hebrew
- culmusAUR - Nice collection of free Hebrew fonts
Indic
- ttf-freebanglafont - Font for Bangla
- ttf-indic-otf - Indic OpenType Fonts collection (containing ttf-freebanglafont)
- (This one contains a "look of disapproval" that might be more to your liking than the bdf-unifont one mentioned elsewhere in this document)
- lohit-font - Indic TrueType fonts from Fedora Project (containing Oriya Fonts and more) (AUR)
Khmer
- ttf-khmer - Font covering glyphs for Khmer language
- Hanuman (ttf-google-webfonts-hgAUR or ttf-google-webfonts-gitAUR)
Sinhala
- ttf-lklugAUR - Sinhala Unicode font (AUR)
Tamil
- ttf-tamilAUR - Tamil Unicode fonts (AUR)
Thai
- ttf-thai - Font covering glyphs for Thai
Tibetan
- ttf-tibetan-machine - Tibetan Machine TTFont
Math
- font-mathematica - Mathematica fonts by Wolfram Research, Inc.
- ttf-mathtypeAUR - MathType fonts (AUR)
- ttf-computer-modern-fontsAUR - (AUR)
Microsoft fonts
See MS Fonts.
Apple Mac OS X fonts
- ttf-macAUR - Mac OS X TrueType fonts. (AUR)
Monospaced
Here are some suggestions. Every user has their own favorite, so experiment to find yours. If you're in a hurry, you read Dan Benjamin's blog post: Top 10 Programming Fonts.
Here's a long list of fonts by Trevor Lowing: http://www.lowing.org/fonts/.
TrueType
- Andalé Mono (ttf-ms-fontsAUR)
- Anka/Coder (ttf-anka-coderAUR)
- Anonymous Pro (ttf-anonymous-proAUR, included in ttf-google-webfonts-hgAUR and ttf-google-webfonts-gitAUR)
- Bitstream Vera Mono (ttf-bitstream-vera)
- Consolas (ttf-vista-fontsAUR)
- Courier New (ttf-ms-fontsAUR)
- Cousine (ttf-google-webfonts-hgAUR or ttf-google-webfonts-gitAUR) - Chrome/Chromium OS replacement for Courier New (metric-compatible)
- DejaVu Sans Mono (ttf-dejavu) - Unicode
- Droid Sans Mono (ttf-droid, included in ttf-google-webfonts-hgAUR and ttf-google-webfonts-gitAUR)
- Envy Code R (ttf-envy-code-rAUR)
- FreeMono (ttf-freefont) - Unicode
- Inconsolata (ttf-inconsolata)
- Inconsolata-g (ttf-inconsolata-gAUR) - adds some programmer-friendly modifications
- Liberation Mono (ttf-liberation) - Alternative to Courier New (metric-compatible)
- Lucida Console (ttf-ms-fontsAUR)
- Lucida Typewriter (included in package jre)
- Monaco (monaco-linux-font)
- Monofur (ttf-monofurAUR)
Bitmap
- Default 8x16
- Dina (dina-font)
- Lime (artwiz-fonts)
- ProFont (profont)
- Proggy Programming Fonts (proggyfontsAUR)
- Proggy opti cyrillic (proggyopticyr-fontAUR)
- Tamsyn (tamsyn-fontAUR)
- Terminus (terminus-font)
- Unifont (glyphs like (look of disapproval)) (bdf-unifont)
Sans-serif
- Andika (ttf-andikaAUR, included in ttf-sil-fontsAUR)
- Arial (ttf-ms-fontsAUR)
- Arial Black (ttf-ms-fontsAUR)
- Arimo (ttf-google-webfonts-hgAUR or ttf-google-webfonts-gitAUR) - Chrome/Chromium OS replacement for Arial (metric-compatible)
- Calibri (ttf-vista-fontsAUR)
- Candara (ttf-vista-fontsAUR)
- Constantia (ttf-vista-fontsAUR)
- Corbel (ttf-vista-fontsAUR)
- DejaVu Sans (ttf-dejavu) - Unicode
- Droid Sans (ttf-droid, included in ttf-google-webfonts-hgAUR and ttf-google-webfonts-gitAUR)
- FreeSans (ttf-freefont) - Unicode
- Impact (ttf-ms-fontsAUR)
- Liberation Sans (ttf-liberation, improved/reworked Cyrillic: ttf-liberastika) - Alternative to Arial (metric-compatible)
- Liberation Sans Narrow (ttf-liberation) - Alternative to Arial Narrow (metric-compatible)
- Linux Biolinum (ttf-linux-libertine)
- Lucida Sans (ttf-ms-fontsAUR)
- Microsoft Sans Serif (ttf-ms-fontsAUR)
- PT Sans (ttf-google-webfonts-hgAUR or ttf-google-webfonts-gitAUR) - 3 major variations: normal, narrow, and caption - Unicode: Latin, Cyrillic
- Tahoma (ttf-tahomaAUR)
- Trebuchet (ttf-ms-fontsAUR)
- Ubuntu-Title (ttf-ubuntu-titleAUR)
- Ubuntu Font Family (ttf-ubuntu-font-family)
- Verdana (ttf-ms-fontsAUR)
Script
- Comic Sans (ttf-ms-fontsAUR)
Serif
- Cambria (ttf-vista-fontsAUR)
- Charis (ttf-charisAUR, included in ttf-sil-fontsAUR) - Unicode: Latin, Cyrillic
- DejaVu Serif (ttf-dejavu) - Unicode
- Doulos (doulos-silAUR, included in ttf-sil-fontsAUR) - Unicode: Latin, Cyrillic
- Droid Serif (ttf-droid, included in ttf-google-webfonts-hgAUR and ttf-google-webfonts-gitAUR)
- FreeSerif (ttf-freefont) - Unicode
- Gentium (ttf-gentium, included in ttf-sil-fontsAUR) - Unicode: Latin, Greek, Cyrillic, Phonetic Alphabet
- Georgia (ttf-ms-fontsAUR)
- Liberation Serif (ttf-liberation) - Alternative to Times New Roman (metric-compatible)
- Linux Libertine (ttf-linux-libertine) - Unicode: Latin, Greek, Cyrillic, Hebrew
- Times New Roman (ttf-ms-fontsAUR)
- Tinos (ttf-google-webfonts-hgAUR or ttf-google-webfonts-gitAUR) - Chrome/Chromium OS replacement for Times New Roman (metric-compatible)
Unsorted
- ttf-google-webfonts-gitAUR and ttf-google-webfonts-hgAUR — a huge collection of free fonts (including ubuntu, inconsolata, droid, etc.) - Note: Your font dialog might get very long as >100 fonts will be added. ttf-google-webfonts-hgAUR pulls down the entire Mercurial repository from the upstream Web Fonts project. ttf-google-webfonts-gitAUR pulls from a much smaller and leaner unofficial repository hosted on GitHub. (AUR)
- ttf-mph-2b-damase — Covers full plane 1 and several scripts
- ttf-symbolaAUR — Provides emoji and many many other symbols. (AUR)
- ttf-sil-fontsAUR — Gentium, Charis, Doulos, Andika and Abyssinica from SIL (AUR)
- font-bh-ttf — X.Org Luxi fonts
- ttf-cheapskate — Font collection from dustismo.com
- ttf-isabella — Calligraphic font based on the Isabella Breviary of 1497
- ttf-junicode — Junius font containing almost complete medieval latin script glyphs
- arkpandorafonts ttf-arkpandoraAUR — Alternative to Arial and Times New Roman fonts (AUR)
- xorg-fonts-type1 — IBM Courier and Adobe Utopia sets of PostScript fonts
控制台字体
控制台,即没有运行X窗口系统的终端,默认使用ASCII字符集。这种字体和按键映射可以很容易地改变。
控制台字体被限制为256到512个字符。这些字体可以在/usr/share/kbd/consolefonts/
中找到。
按键映射,电脑在按下键和得到字符之间的对应关系,可以在/usr/share/kbd/keymaps/
的子目录中找到。
预览和测试
你可以从http://alexandre.deverteuil.net/consolefonts/consolefonts.html看到所有字体的图片预览。
甚至,你还可以使用setfont
命令临时改变字体来考虑要不要使用它作为默认字体。而使用showconsolefont
命令可以以表格形式查看字体中的字母或符号。
如果新换上的字体不适用,可以通过不带任何参数的setfont
命令来回滚到默认字体。即使控制台因字体改变而完全无法阅读,这条命令仍然可以起作用,用户只需要在看不见的情况下输入setfont
。
请注意setfont
只对当前正在运行的命令行起作用。其他命令行无论是否激活都不受影响。
示例
改变字体。这是一个很有代表性的示例:
$ setfont /usr/share/kbd/consolefonts/gr737b-9x16-medieval.psfu.gz
或者使用-m
选项把字体改为有512个符号的字体,并且把键盘映射改为ISO 8859-5:
$ setfont /usr/share/kbd/consolefonts/LatArCyrHeb-16.psfu.gz -m 8859-5
然后执行一条能在命令行显示字符的命令,如manpage,并且试用vi或nano,使用命令showconsolefont
查看符号表。
用命令回滚到默认字体:
$ setfont
修改默认字体
要修改默认字体,需要修改/etc/vconsole.conf
中的FONT=
和FONT_MAP=
配置节(如果不存在则需要新建)。再次说明,字体可以在/usr/share/kbd/consolefonts/
目录中找到,键盘映射可以在/usr/share/kbd/keymaps/
的子目录中找到。
示例
为了显示如Č, ž, đ, š or Ł, ę, ą, ś一类的字符,需要使用字体lat2-16.psfu.gz
:
FONT=lat2-16
这意味着ISO/IEC 8859的第二部分字符,并且使用16号字。你可以通过修改字号来改变字体大小,如lat2-08...16。8859规范指定的区域请参考Wikipedia。如果你经常在没有X Server的控制台工作,推荐使用Terminus字体。例如ter-216b是一种latin-2字体,16号,黑体。ter-216n是同样的字体但是正常体。Terminus字体最多有32号字。
现在需要设置正确的字符映射。lat2-16应该使用:
FONT_MAP=8859-2
为了在早先的用户空间中使用指定的字体,即在引导过程中使用,可以添加consolefont
钩子到/etc/mkinitcpio.conf
:
HOOKS="base udev autodetect pata scsi sata filesystems consolefont keymap"
然后重建Linux映像:
# mkinitcpio -p linux
查阅Mkinitcpio#HOOKS以获得更多信息。
如果字体在引导时仍然没有改变,或只是临时改变了,则最有可能是图形驱动初始化,控制台切换到帧缓存时字体被重置了。为了避免这种情况,需要在更早的阶段加载图形驱动。查阅KMS#Early_KMS_start或其他方法以便在/etc/vconsole.conf
之前设置帧缓存并应用。
引导错误
如果"加载控制台字体"在引导时失败,这最有可能是你你在安装Arch Linux时没有选择有效的字体。
要避免这个错误,只需要简单地清空CONSOLEFONT
变量,它位于/etc/rc.conf
。这样引导时就会回滚到使用默认字体。
X11中的字体回滚顺序
Fontconfig 会自动选择一个符合当前场景的字体。也就是说,如果有人正在浏览一个既有英文又有中文的窗口,而默认的字体不支持中文,它会自动切换到另一种字体以便显示中文。
Fontconfig 让每个用户能够通过$XDG_CONFIG_HOME/fontconfig/fonts.conf
来决定字体使用的顺序。
如果你想要在最喜欢的Serif字体之后使用某个特定的中文字体,你的配置文件看起来会是这样:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <alias> <family>serif</family> <prefer> <family>Your favorite Latin Serif font name</family> <family>Your Chinese font name</family> </prefer> </alias> </fontconfig>
当然你也可以为Sans-serif和monospaced字体添加一个配置节。更多信息请参考fontconfig说明。
字体别名
在Linux系统中有几种字体别名,它们实际代表着别的字体,这样以达到让应用程序的字体看起来类似。最常见的别名有:serif
代表一种衬线体(关于衬线体与非衬线体概念请参考这里——译注)(例如DejaVu Serif);sans-serif
代表一种非衬线体(例如DejaVu Sans);而monospace
则代表等宽字体(例如DejaVu Sans Mono)。 然而,这些别名所代表的字体有可能会变化,而且通常KDE和其他桌面环境中的字体管理工具不会显示其内在联系。
如果想通过别名反向查找是哪种字体被展现出来,运行:
$ fc-match monospace DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
在这种情况下Monospace别名展现的是DejaVuSansMono.ttf字体。
2 英文字和中文字等宽
TrueType 字体分成两种,一种是可变字距,也就是每个字符宽度不一样,比如 "x" 与 "i",这两个字符就不等宽,它是在每个字符中记录该字符的宽度,大多数的 TrueType 字体都是这种格式。
另一种就是固定字距。也就是每个字符宽度都一样,这样显示或打印時,用会有对齐效果,比较美观,在英语环境中,不会有任何问题,但是CJK 的等宽字体,包含『半角英数字符』与『全角 CJK 字符』,字体引擎会把全角字宽度套用在半角字上,造成半宽字看起来间距太大。
a. 让字体引擎(FreeType)取消CJK字体的指定宽度
<match target="font"> <test target="pattern" name="lang" compare="contains"> <string>zh</string> <string>ja</string> <string>ko</string> </test> <edit name="spacing"> <const>proportional</const> </edit> <edit name="globaladvance"> <bool>false</bool> </edit> </match>
3 字体替换
一些网页编写时候,对使用的字体预先设定,(如英文部分使用了simsun,使得英文显示很不美观)所以可以使用字体替换使得字体显示更美观。
a. 把Simsun , SimSun-18030 , AR PL ShanHeiSun Uni等这个几个中文字体的英文部分,用 Tahoma,Arial 等替换。
<match target="pattern"> <test name="family"> <string>SimSun</string> <string>SimSun-18030</string> <string>AR PL ShanHeiSun Uni</string> <string>AR PL New Sung</string> <string>MingLiU</string> <string>PMingLiU</string> </test> <edit binding="strong" mode="prepend" name="family"> <string>Tahoma</string> <string>Arial</string> <string>Verdana</string> <string>DejaVu Sans</string> <string>Bitstream Vera Sans</string> </edit> </match>
b. 把 AR PL ShanHeiSun Uni , AR PL New Sung 字体中12~16号的中文字用 WenQuanYi Bitmap Song 点阵字替换, WenQuanYi Bitmap Song 比 AR PL ShanHeiSun Uni , AR PL New Sung中的内嵌点阵更加完善,美观。
<match target="pattern"> <test name="family" qual="any"> <string>AR PL ShanHeiSun Uni</string> <string>AR PL New Sung</string> </test> <test compare="more_eq" name="pixelsize" > <double>12</double> </test> <test compare="less_eq" name="pixelsize" > <double>16</double> </test> <edit name="family" mode="prepend" binding="strong"> <string>WenQuanYi Bitmap Song</string> </edit> </match>
4 使用内嵌点阵字
a. 当字体有内嵌字体时,优先使用内嵌字体。
<match target="font"> <edit name="embeddedbitmap" mode="assign"> <bool>true</bool> </edit> </match>
注意:libXft 还没有embeddedbitmap选项的支持。可以到这里得到libXft2.1.8.2的embeddedbitmap patch,通过ABS重新编译安装libXft 。
5 必须使用hinting的字体
a. 有些 CJK 字体要the byte code interpreter (hinting)才能正确的显示,因为这些字体使用了hinting的一些技术制作。常见的MingLiu 就是这类字体。
<match target="font"> <test name="family"> <string>MingLiU</string> <string>PMingLiU</string> </test> <edit name="autohint"> <bool>false</bool> </edit> <edit name="hinting"> <bool>true</bool> </edit> </match>