Difference between revisions of "Fonts (简体中文)"

From ArchWiki
Jump to: navigation, search
(Sync to latest English version.)
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[Category:简体中文|ZT]]
+
[[Category:简体中文]]
 
[[Category:Fonts (简体中文)]]
 
[[Category:Fonts (简体中文)]]
[[Category:Graphics and DTP (简体中文)]]
+
[[Category:Graphics and desktop publishing (简体中文)]]
[[Category:HOWTOs (简体中文)]]
+
[[cs:Fonts]]
[[Category:Eye candy (简体中文)]]
+
[[en:Fonts]]
{{i18n|Fonts}}
+
[[es:Fonts]]
{{Article summary start}}
+
[[it:Fonts]]
{{Article summary text|Covers the installation and use of fonts on Arch Linux.}}
+
[[ru:Fonts]]
{{Article summary heading|Legal}}
+
[[tr:Yazıtipleri]]
{{Article summary text|Certain font packages may impose ''some'' legal limitations.}}
+
[[zh-TW:Fonts]]
{{Article summary heading|Related articles}}
+
{{TranslationStatus (简体中文)|Fonts|2012-10-11|227928}}
{{Article summary wiki|Font Configuration}}
+
{{Translateme (简体中文)}}
 +
{{Article summary start|摘要}}
 +
{{Article summary text|包含了在 Arch Linux 中安装和使用字体的信息}}
 +
{{Article summary heading|合法性}}
 +
{{Article summary text|某些字体包可能会遇到一些法律限制。}}
 +
{{Article summary heading|相关页面}}
 +
{{Article summary wiki|Font Configuration (简体中文)}}
 
{{Article summary wiki|Java Fonts - Sun JRE}}
 
{{Article summary wiki|Java Fonts - Sun JRE}}
 
{{Article summary wiki|MS Fonts}}
 
{{Article summary wiki|MS Fonts}}
 
{{Article summary end}}
 
{{Article summary end}}
 +
From [[Wikipedia:Computer font|Wikipedia]]:
 +
:''A computer font (or font) is an electronic data file containing a set of glyphs, characters, or symbols such as dingbats.''
 +
== 字体类型 ==
  
=前言 :=
+
大多数当代电脑使用的不是点阵字体就是矢量字体。
 +
;点阵字体: 每种字形的每种形式和每种尺寸的图像都由点或者像素组成的矩阵构成。由于位图的原故,点阵字体很难进行缩放,特定的点阵字体只能清晰地显示在相应的字号下。但对于 12-16px 这样小的汉字,点阵字体常常比其它类型的字体在屏幕上更好的显示效果。常见的点阵字体有 bdf,pcf,fnt,hbf 等格式。
 +
;矢量字体: 使用贝塞尔曲线, 绘图指令和数学公式来描述每种字形,使得字体可以适应各种尺寸。
  
Arch Linux 是一个定制性很强的发行版,其设计的哲学决定了Arch Linux 不太可能像SUSE、Fedora、Mandriva等发行版一样预设了一套完善的字体配置,Arch 的设计哲学更像Gentoo Linux。Arch Linux需要用户进行一定的定制,用户在定制、配置过程中能学到更多的知识,这也是Arch Linux的设计哲学之一。
+
=== 通用类型 ===
  
=字体相关库的简介=
+
* {{ic|bdf}} and {{ic|bdf.gz}} – 点阵字体,“b”代表点阵,“d”代表布局,“f”代表形式,用gzip压缩 {{ic|bdf}}。
 +
* {{ic|pcf}} and {{ic|pcf.gz}} – 点阵字体,“p”代表可移植,“c”代表编译 “f”代表字体,用gzip压缩 {{ic|pcf}}。
 +
* {{ic|psf}},{{ic|psfu}},{{ic|psf.gz}} and {{ic|psfu.gz}} – 点阵字体,“PC”,“s”代表屏幕,“f”代表字体,“PC”,“s”代表屏幕,“f”代表字体,“U”代表Unicode,用gzip压缩(不适用于X.Org)。
 +
* {{ic|pfa}} and {{ic|pfb}} – 矢量字体,“P”代表PostScript,“f”代表字体,“A”代表ASCII。“P”代表PostScript,“f”代表字体,“b”代表二进制。PostScript字体包含内嵌打印令。
 +
* {{ic|ttf}} – outline,“T”rue“T”ype,“f”代表字体。作为PostScript字体的替代。
 +
* {{ic|otf}} – outline,“O”pen“T”ype,“f”代表字体。带有PostScript打印指令的TrueType字体。
  
==1 . LibXft ==
+
在多数情况下,TrueType和OpenType的技术差异可以忽略,一些带有{{ic|ttf}}扩展的字体实际上是OpenType字体。
  
libXft库是为了给X应用程序提供一个能访问FreeType字体光栅化引擎和X渲染扩展的、便于使用的接口,鉴于FreeType没有提供配置和定制 字体的功能,Xft也担负了这一任务。Xft提供了新的字体命名约定、复杂而精密的字体匹配和选择机制,并对相关功能进行充分的抽象,从而使得一般应用程 序既能够从使用X渲染扩展的文本输出获得益处,又能在不支持这一扩展的X服务器上正常工作。
+
=== 其它类型 ===
  
libXft 是画字函数库, 它使用 Fontconfig match 到了所要的字型之后, 来决定该如何画这些字。libXft 会看情况而决定要不要使用 core protocol 或 XRender 来画字。libXft 主要作GTK 2 (GTK < 2.8.0)程序,QT 程序的画字函数库。
+
排版程序“TeX”和配套的字体软件“Metafont”用它们自己的方法渲染字体。一些用于这两个程序的字体的文件后缀是{{ic|*pk}}, {{ic|*gf}}, {{ic|mf}} and {{ic|vf}}。
  
==2 .Cairo==
+
“FontForge”, 一个字体编辑程序,可能用自己的格式来储存字体,例如{{ic|sfd}}, “s”代表线条,“f”代表字体,“d”代表数据库。
  
一个支持多种输出的向量图形库,也就是说,cairo是种画图的工具库,他可以向多种设备上画图.可以输出到pdf,ps,xlib,XCB,win32,svg。基于GTK ( = >  2.8.0)的程序用cairo 画字而不再使用libXft 。
+
[http://www.w3.org/TR/SVG/fonts.html SVG]格式也有自己的字体描述方法
  
==3 .Fontconfig==
+
== Installation ==
  
Fontconfig 包含两个基本的模块,即读取XML文件并建立内部配置的配置模块和接受请求的字体样板并返回最接近所需字体的匹配模块。
+
There are various methods for installing fonts.
  
==4 .Freetype==
+
=== Pacman ===
  
Freetype库是一个完全免费 ( 开源 ) 的、高质量的且可移植的字体
+
Fonts and font collections in the enabled repositories can be installed using [[Pacman|pacman]]. Available fonts may be found by using:
引擎,它提供统一的接口来访问多种字体格式文件,包括TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT,X11 PCF 等。支持单色位图 (homochromous bitmap) 、反走样位图( anti-alias bitmap )的渲染。 Freetype 是高度模块化设计的程序库。Freetype 提供 libXft/cairo 如何画字的信息,包括处理 anti-aliasing 或 hinting. 因此 freetype 的改变会影响到 libXft/cairo 画出来的字,而 Fontconfig 的改变会影响到 libXft/cario 如何去选字来画。
+
$ pacman -Ss font
 +
Or to search for {{ic|ttf}} fonts only:
 +
$ pacman -Ss ttf
  
==5 .Pango ==
+
Some fonts like terminus are installed in {{ic|/usr/share/fonts/local}}, which is not added to the font path by default. By adding the following lines to {{ic|~/.xinitrc}} the fonts can be used in X11:
 +
{{bc|
 +
xset +fp /usr/share/fonts/local
 +
xset fp rehash
 +
}}
  
Pango 是个开源的整合到GTK+2的渲染国际化文本文件的库,pango 的名字是由 希腊语 "Pan" (Παν; lit. all) + 日语 "Go" (語; lit. language)组合成。也就是All language,Pango负责多国语言文本(如同一个文本文件中由英文,日文,中文等不同的语系组成)的渲染。需要注意的是Pango属于高级的库,不参加画字的过程。
+
=== Creating a package ===
  
 +
If you want to give pacman the ability to manage your fonts, you can create an Arch package.  These can also be shared with the community in the [[AUR]].  Here is an example of how to create a basic package.  To learn more about building packages, read [[PKGBUILD]].
  
 +
{{bc|<nowiki>
 +
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()
参考及引用文献: [http://groups.google.com/group/nirvanastudio/browse_thread/thread/7a5c28b44b887e58/bd3a800bf7f15ef8?#bd3a800bf7f15ef8 关于字体的一些基本概念] 、 [http://baike.baidu.com/view/755824.html?fromTaglist 中文CleraType字体] 和 [http://www.hudong.com/wiki/CleraType%E6%8A%80%E6%9C%AF CleraType技术]。
+
{
 +
  mkdir -p $pkgdir/usr/share/fonts/TTF
 +
  cp $srcdir/$pkgname/*.ttf $pkgdir/usr/share/fonts/TTF
 +
}
 +
</nowiki>}}
  
==1. '''点阵字体''' 与 '''矢量字体'''==
+
This PKGBUILD assumes the fonts are TrueType. An install file ({{ic|ttf-fontname.install}}) will also need to be created to update the font cache:
  
'''点阵字体'''也叫位图字体,其中每个字形都以一组二维像素 信息表示。由于位图的原故,点阵字体很难进行缩放,特定的点阵字体只能清晰地显示在相应的字号下。但对于 12-16px 这样小的汉字,点阵字体常常比其它类型的字体在屏幕上更好的显示效果。常见的点阵字体有 bdf,pcf,fnt,hbf 等格式。
+
{{bc|<nowiki>
 +
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"
 +
}
  
对于常见的计算机操作系统,字体的显示算法需要一些字体的信息来优化屏幕显示效果,英文称为 hinting。汉字由于笔画复杂,所以 hinting 的方式与西文截然不同。使用在汉字字体中嵌入预先制作的点阵位图既可以有效地避免 hinting 算法带来的计算开销,同时屏幕上显示的汉字边缘清晰,易于阅读。
+
post_upgrade() {
 +
  post_install
 +
}
  
 +
post_remove() {
 +
  post_install
 +
}
 +
</nowiki>}}
  
'''矢量字体'''中每一个字形是通过数学曲线来描述的,它包含了字形边界上的关键点,连线的导数信息等,字体的渲染引擎通过读取这些数学矢量,然后 进行一定的数学运算来进行渲染。这类字体的好处是字体可以无限放大而不产生变形。矢量字体主要包括 Type1 和 TrueType 等几类。
+
=== Manual installation ===
  
=='''2. 内嵌点阵字的字体''' ==
+
The recommended way of adding fonts that are not in the repositories to your system is described in [[#Creating a package]].  This gives pacman the ability to remove or update them at a later time.  Fonts can alternately be installed manually as well.
  
由于CJK字体的结构复杂,在小号字体只有使用点阵才能有清晰的显示效果,但是点阵字体很难进行缩,而且线条单一,在大号字体显示时就显得苍白无力。把点阵字体内嵌到矢量字体就能发挥两者的优点,并且也弥补了两者的不足。小号字体时清晰明朗,大号字体时字型饱满,形态丰富。常见的内嵌点阵字的字体有:北京中易电子公司宋体SimSun 、方正宋体(FZSongti)、文鼎PL上海宋(Uming)、Firefly的文鼎PL新宋(AR PL New Sung)等。
+
To install fonts system-wide (available for all users), move the folder to the {{ic|/usr/share/fonts/}} directory.  To install fonts for only a single user, use {{ic|~/.fonts/}} instead.
  
==3. Hinting 与 Autohinter==
+
Also you may need to update {{ic|/etc/X11/xorg.conf}} or {{ic|/etc/xorg.conf}} with the new directory. Search for {{ic|FontPath}} to find the correct location within the file to add your new path. See [[#Fonts with X.Org]] for more detail.
  
Hinting (字体微调) 是用来最佳化字型显示的方法。由于屏幕的像素有限,向量字型的缩放需要有更多的考虑, 例如当一条线位在两个像素格子中间时, 该取左边的格子还是右边的格子? 如果这方面的控制没有做好,就常常会出现字型的衬线没有对齐,或是小字歪七扭八的情况。 Hinting 是额外的信息, 它告诉 renderer 该如何处理这些细节的部份,使得向量字在小字的时候能够好看。也因此 Hinting 是非常费时费人力的工作,TrueType 字型很多,但是有良好 Hinting 的字型不多。拙劣的 Hinting 就会让字变得很难看。
+
Then update the fontconfig font cache:
  
为了稍微改善这个问题,freetype 有 autohint 的功能,可以自动为没有 hint 的字型做 hinting 的工作。另外由于 TrueType 的 hinting 是有专利的,不能完全自由地使用, autohint 就不受这个限制。autohint 自然无法做得像人力的 hint 一样好,不过至少比没有 hint 要好些。话虽如此,对于许多笔划复杂的文字 (如中文) 目前 freetype 的 autohint 还做得不甚完美,而因为建立完整的 hinting 的难度,即使是英文字,原本就很高,内建有 hinting 的中文字型就少之又少了。所以常常有人抱怨中文字在屏幕上很难看,就是没有理想 hinting, 或者是使用了 autohinter 所造成的一些反效果。
+
$ fc-cache -vf
  
==4. AA(Anti-aliasing)==
+
==== Older applications ====
  
Anti-aliasing (字体抗锯齿) 是将字体在后台先以数倍的大小来绘画,然后再缩成想要的大小,未满一格的格子用灰阶补点。由于原本 X 所支持的 logic 运算不敷使用,所以才用 XRender 的 extension 来达成目的。
+
With older applications that do not support fontconfig (e.g. GTK+ 1.x applications, and {{ic|xfontsel}}) the index will need to be created in the font directory:
  
Anti-aliasing 会给人一种朦胧的感觉,习惯了Windows XP 下清晰,锐利的字体显示时,Anti-aliasing 会让人不太适应,会让用户觉得Linux下的字体显示不如Windows XP。但是,其实 Anti-aliasing是一种很先进的显示技术 ,当长时间显示器上阅读的时候,Windows XP 下的锐利的字体显示风格,会让眼睛更加容易疲劳,使用Anti-aliasing,字体的显示更加柔和,更加适合长时间的在显示器上阅读文档,减少眼睛的疲劳。
+
$ mkfontscale
 +
$ mkfontdir
  
==5. Windows&reg; 下的 ClearType 效果==
+
Or to include more than one folder with one command:
微软提出和改善了 ClearType 技术(字体平滑),归因于液晶显示器的普及,以及苹果公司和 Linux 的竞争。
+
  
和 CRT显示器相比,液晶显示器的最大缺点是:插值显示效果惨不忍睹。要达到最好的显示效果,液晶必须显示于屏幕的特定分辨率下,就是对应于它原始发光点大小的显示分辨率,即最大分辨率。而在最大分辨率下,文字都变得很小,这对于长时间的阅读是一种灾难。而原来 Windows 下未经优化的点阵大字体方案明显粗糙而难看,令人无法接受。于是微软推出了 ClearType。
+
$ for dir in /font/dir1/ /font/dir2/; do xset +fp $dir; done && xset fp rehash
  
Windows&reg; 下的 ClearType 技术相当于 Linux 下的 Hinting 和 Anti-aliasing,也相当于苹果公司的 Apple Advanced Typography (AAT) 技术。它也是一种字体渲染技术。
+
At times the X server may fail to load the fonts directory and you will need to rescan all the {{ic|fonts.dir}} files:
  
Windows Vista 和 Windows 7 已用 ClearType 来取代传统的黑白、锐利的英文字体显示和点阵CJK 显示。
+
# xset +fp /usr/share/fonts/misc # Inform the X server of new directories
 +
# xset fp rehash                # Forces a new rescan
  
当前,Linux 下也可尝试使用 ClearType 显示效果。参看 [[Xorg Font Configuration#Cleartype|Cleartype]]。
+
To check that the font(s) is included:
  
=字体简介=
+
$ xlsfonts | grep fontname
  
 +
=== Pango Warnings ===
 +
When [http://www.pango.org/ Pango] is in use on your system it will read from [http://www.freedesktop.org/wiki/Software/fontconfig fontconfig] to sort out where to source fonts.
  
=='''1 自由(free)的英文字体'''==
+
(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'
  
 +
If you are seeing errors similar to this and/or seeing blocks instead of characters in your application then you need to add fonts and update the font cache.  This example uses the {{Pkg|ttf-liberation}} fonts to illustrate the solution and runs as root to enable them system-wide.
  
Bitstream vera fonts,DejaVu fonts,MS True Type core fonts 等.
+
# 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
  
DejaVu fonts[community repo]是在Bitstream vera fonts release 1.10 的基础上进行不断扩充的字体。
+
You can test for a default font being set like so:
  
MS True Type core fonts[ttf-ms-fonts]包含了Arial, Courier New, Times New Roman, Verdana等系列字体的总称。MS True Type core fonts 的licence 是EULA,可以合法的免费使用(感谢微软,嘿嘿!)。
+
# fc-match
 +
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
  
 +
=== Fonts with X.Org ===
  
=='''2 自由中文字体'''==
+
In order for [[Xorg]] to find and use your newly installed fonts, you must add the font paths to {{ic|/etc/X11/xorg.conf}} (another X.Org configuration file may work too).
wqy-bitmapfont
+
  
wqy-zenhei
+
Here is an example of the section that must be added to {{ic|/etc/X11/xorg.conf}}. Add or remove paths based on your particular font requirements.
 +
# Let X.Org know about the custom font directories
 +
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
  
ttf-arphic-ukai
+
==Font packages==
 +
This is a selective list that includes many font packages from the [[AUR]] along with those in the official repositories. Fonts are tagged "Unicode" if they have wide Unicode support, see the project or Wikipedia pages for detail.
  
ttf-arphic-uming
+
===Braille===
 +
*{{Pkg|ttf-ubraille}} - Font containing Unicode symbols for ''braille''
  
ttf-fireflysung
+
===International users===
  
=='''3 不合版权的中文字体'''==
+
====Arabic====
 +
*{{AUR|ttf-sil-lateef}} - Unicode Arabic font from SIL ''(AUR)''
 +
*{{AUR|ttf-sil-scheherazade}} - Unicode Arabic font from SIL ''(AUR)''
 +
*{{AUR|ttf-arabeyes-fonts}} - Collection of free Arabic fonts ''(AUR)''
  
 +
====Birman====
 +
*{{AUR|ttf-myanmar3}} - Font for Myanmar/Burmese script ''(AUR)''
  
'''LingSong :'''Tahoma+Simsun的“杂交”字体,Tahoma版权属于微软,Simsun字体的版权属于 北京中易电子公司。
+
====Chinese, Japanese, Korean, Vietnamese====
  
'''Vera Sans YuanTi:'''Bitstream Vera+simsun点阵+方正准圆+方正粗圆的“杂交”字体。
+
=====(Mainly) Chinese=====
 +
*{{AUR|ttf-tw}} -(繁體字)國字標準字體(楷書/宋體)母稿——中華民國教育部''(AUR)''.
 +
*{{AUR|wqy-microhei}} - 一种Sans-Serif风格的高质量CJK轮廓字体。"(AUR)''
 +
*{{Pkg|wqy-zenhei}} - 嵌入点阵宋体的黑体风格(sans-serif)中文轮廓字体(也支持部分日文和韩文).
 +
*{{Pkg|ttf-arphic-ukai}} -  楷體 Kaiti (brush stroke) unicode TTFonts  (建议开启抗锯齿)
 +
*{{Pkg|ttf-arphic-uming}} -  明體 Mingti (打印) unicode TTFonts 
 +
*{{Pkg|opendesktop-fonts}} - ''新宋'' 字体, 之前是 ttf-fireflysung 软件包
 +
*{{Pkg|wqy-bitmapfont}} - 中文点阵宋体(serif)
 +
*{{Pkg|ttf-hannom}} - 中文和越南文TrueType字体
  
=设置实例=
+
=====Japanese=====
 +
*{{AUR|otf-ipafont}} - Formal style Japanese Gothic (sans-serif) and Mincho (serif) fonts set; one of the highest quality open source font. Default of openSUSE-ja. ''(AUR)''
 +
*{{AUR|ttf-vlgothic}} - Japanese Gothic fonts. Default of Debian/Fedora/Vine Linux ''(AUR)''
 +
*{{AUR|ttf-mplus}} - 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).
 +
*{{AUR|ttf-ipa-mona}}, {{AUR|ttf-monapo}} - Japanese fonts to show [http://en.wikipedia.org/wiki/2channel_Shift_JIS_art 2channel Shift JIS art] properly. ''(AUR)''
 +
*{{Pkg|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=====
 +
*{{Pkg|ttf-baekmuk}} - Collection of Korean TrueType fonts
 +
*{{AUR|ttf-alee}} - Set of free Hangul TrueType fonts (''AUR'')
 +
*{{AUR|ttf-unfonts-core}} - Un fonts (default Baekmuk fonts may be unsatisfactory) (''AUR'')
 +
*{{AUR|ttf-nanum}} - Nanum series TrueType fonts (''AUR'')
 +
*{{AUR|ttf-nanumgothic_coding}} - Nanum series fixed width TrueType fonts (''AUR'')
  
==1 开启/关闭 AA ,Autohint 与 Hinting==
+
====Cyrillic====
+
''Also see [[#Monospace]], [[#Sans]] and [[#Serif]]''
 +
*{{AUR|font-arhangai}} - Mongolian Cyrillic (''AUR'')
 +
*{{AUR|ttf-pingwi-typography}} - PingWi Typography (PWT) fonts (''AUR'')
  
a. 全部的字体使用autohint 和 antialiasing,渲染度为 hintfull ,通常这是一个很好的全局默认设置。也可以根据个人喜好使用渲染度为hintslight。
+
====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:
 +
*{{AUR|otf-gfs}} - Selection of OpenType fonts from the Greek Font Society ''(AUR)''
 +
*{{AUR|ttf-mgopen}} - Professional TrueType fonts from Magenta ''(AUR)''
  
 +
====Hebrew====
 +
*{{AUR|culmus}} - Nice collection of free Hebrew fonts
  
<pre>
+
====Indic====
      <match target="font">
+
*{{Pkg|ttf-freebanglafont}} - Font for Bangla
                <edit name="autohint">
+
*{{Pkg|ttf-indic-otf}} - Indic OpenType Fonts collection (containing ttf-freebanglafont)
                        <bool>true</bool>
+
:(This one contains a "look of disapproval" that might be more to your liking than the {{Pkg|bdf-unifont}} one mentioned elsewhere in this document)
                </edit>
+
* {{Pkg|lohit-font}} - Indic TrueType fonts from Fedora Project (containing Oriya Fonts and more) ''(AUR)''
                <edit name="hintstyle">
+
                        <const>hintfull</const>
+
                </edit>
+
                <edit name="antialias">
+
                        <bool>true</bool>
+
                </edit>
+
        </match>
+
  
</pre>
+
====Khmer====
 +
*{{Pkg|ttf-khmer}} - Font covering glyphs for Khmer language
 +
*[http://code.google.com/webfonts/family?family=Hanuman&subset=khmer Hanuman] ({{AUR|ttf-google-webfonts}})
  
 +
====Sinhala====
 +
*{{AUR|ttf-lklug}} - Sinhala Unicode font (''AUR'')
  
b. 小于16号的MS core fonts,关闭Antialiasing 和  Autohint,(使用hinting) 。可以根据个人喜欢调节字号的大小。
+
====Tamil====
 +
*{{AUR|ttf-tamil}} - Tamil Unicode fonts (''AUR'')
  
 +
====Thai====
 +
*{{Pkg|ttf-thai}} - Font covering glyphs for Thai
 +
====Tibetan====
 +
*{{Pkg|ttf-tibetan-machine}} - Tibetan Machine TTFont
  
<pre>
+
===Math===
        <match target="font">
+
*{{Pkg|font-mathematica}} - Mathematica fonts by Wolfram Research, Inc.
                <test name="family">
+
*{{AUR|ttf-mathtype}} - MathType fonts ''(AUR)''
                        <string>Andale Mono</string>
+
*{{AUR|ttf-computer-modern-fonts}} - ''(AUR)''
                        <string>Arial</string>
+
                        <string>Comic Sans MS</string>
+
                        <string>Georgia</string>
+
                        <string>Impact</string>
+
                        <string>Trebuchet MS</string>
+
                        <string>Verdana</string>
+
                        <string>Courier New</string>
+
                        <string>Times New Roman</string>
+
                        <string>Tahoma</string>
+
                        <string>Webdings</string>
+
                        <string>Albany AMT</string>
+
                        <string>Thorndale AMT</string>
+
                        <string>Cumberland AMT</string>
+
                        <string>Andale Sans</string>
+
                        <string>Andy MT</string>
+
                        <string>Bell MT</string>
+
                        <string>Monotype Sorts</string>
+
                </test>
+
<test name="pixelsize" compare="less_eq">
+
<double>16</double>
+
</test>
+
                <edit name="autohint">
+
                        <bool>false</bool>
+
                </edit>
+
                <edit name="antialias">
+
                        <bool>false</bool>
+
                </edit>
+
        </match>
+
</pre>
+
  
==2 英文字和中文字等宽==
+
===Microsoft fonts===
 +
See [[MS Fonts]].
  
 +
===Apple Mac OS X fonts===
 +
*{{AUR|ttf-mac}} - 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: [http://hivelogic.com/articles/top-10-programming-fonts ''Top 10 Programming Fonts''].
 +
 +
Here's a long list of fonts by Trevor Lowing: http://www.lowing.org/fonts/.
 +
 +
====TrueType====
 +
* [[Wikipedia:Andalé Mono|Andalé Mono]] ({{AUR|ttf-ms-fonts}})
 +
* Anka/Coder ({{AUR|ttf-anka-coder}})
 +
* Anonymous Pro ({{AUR|ttf-anonymous-pro}}, included in {{AUR|ttf-google-webfonts}})
 +
* [[Wikipedia:Bitstream Vera|Bitstream Vera Mono]] ({{Pkg|ttf-bitstream-vera}})
 +
* [[Wikipedia:Consolas|Consolas]] ({{AUR|ttf-vista-fonts}})
 +
* [[Wikipedia:Courier New|Courier New]] ({{AUR|ttf-ms-fonts}})
 +
* Cousine ({{AUR|ttf-google-webfonts}}) - Chrome/Chromium OS replacement for Courier New (metric-compatible)
 +
* [[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}})
 +
* Envy Code R ({{AUR|ttf-envy-code-r}})
 +
* [[Wikipedia:GNU FreeFont|FreeMono]] ({{Pkg|ttf-freefont}}) - Unicode
 +
* [[Wikipedia:Inconsolata|Inconsolata]] ({{Pkg|ttf-inconsolata}})
 +
* [[Wikipedia:Inconsolata|Inconsolata-g]] ({{AUR|ttf-inconsolata-g}}) - adds some programmer-friendly modifications
 +
* [[Wikipedia:Liberation fonts|Liberation Mono]] ({{Pkg|ttf-liberation}}) - Alternative to Courier New (metric-compatible)
 +
* [[Wikipedia:Lucida Console|Lucida Console]] ({{AUR|ttf-ms-fonts}})
 +
* [[Wikipedia:Lucida Typewriter|Lucida Typewriter]] (included in package {{Pkg|jre}})
 +
* [[Wikipedia:Monaco (typeface)|Monaco]] ({{Pkg|monaco-linux-font}})
 +
* Monofur ({{AUR|ttf-monofur}})
 +
 +
====Bitmap====
 +
*Default 8x16
 +
*Dina ({{Pkg|dina-font}})
 +
*Lime ({{Pkg|artwiz-fonts}})
 +
*[[Wikipedia:ProFont|ProFont]] ({{Pkg|profont}})
 +
*[[Wikipedia:Proggy Programming Fonts|Proggy Programming Fonts]] ({{AUR|proggyfonts}})
 +
*Proggy opti cyrillic ({{AUR|proggyopticyr-font}})
 +
*Tamsyn ({{AUR|tamsyn-font}})
 +
*[[Wikipedia:Terminus (typeface)|Terminus]] ({{Pkg|terminus-font}})
 +
*Unifont (glyphs like (look of disapproval)) ({{Pkg|bdf-unifont}})
 +
 +
===Sans-serif===
 +
 +
*[http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=andika Andika] ({{AUR|ttf-andika}}, included in {{AUR|ttf-sil-fonts}})
 +
*[[Wikipedia:Arial|Arial]] ({{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)
 +
*[[Wikipedia:Calibri|Calibri]] ({{AUR|ttf-vista-fonts}})
 +
*[[Wikipedia:Candara|Candara]] ({{AUR|ttf-vista-fonts}})
 +
*[[Wikipedia:Constantia (typeface)|Constantia]] ({{AUR|ttf-vista-fonts}})
 +
*[[Wikipedia:Corbel (typeface)|Corbel]] ({{AUR|ttf-vista-fonts}})
 +
*[[Wikipedia:DejaVu fonts|DejaVu Sans]] ({{Pkg|ttf-dejavu}}) - Unicode
 +
*[[Wikipedia:Droid (font)|Droid Sans]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts}})
 +
*[[Wikipedia:GNU FreeFont|FreeSans]] ({{Pkg|ttf-freefont}}) - Unicode
 +
*[[Wikipedia:Impact (typeface)|Impact]] ({{AUR|ttf-ms-fonts}})
 +
*[[Wikipedia:Liberation fonts|Liberation Sans]] ({{Pkg|ttf-liberation}}, improved/reworked Cyrillic: {{Pkg|ttf-liberastika}}) - Alternative to Arial  (metric-compatible)
 +
*[[Wikipedia:Liberation fonts|Liberation Sans Narrow]] ({{Pkg|ttf-liberation}}) - Alternative to Arial Narrow (metric-compatible)
 +
*[[Wikipedia:Linux Libertine|Linux Biolinum]] ({{Pkg|ttf-linux-libertine}})
 +
*[[Wikipedia:Lucida Sans|Lucida Sans]] ({{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:Tahoma (typeface)|Tahoma]] ({{AUR|ttf-tahoma}})
 +
*[[Wikipedia:Trebuchet MS|Trebuchet]] ({{AUR|ttf-ms-fonts}})
 +
*[[Wikipedia:Ubuntu-Title|Ubuntu-Title]] ({{AUR|ttf-ubuntu-title}})
 +
*[[Wikipedia:Ubuntu Font Family|Ubuntu Font Family]] ({{Pkg|ttf-ubuntu-font-family}})
 +
*[[Wikipedia:Verdana|Verdana]] ({{AUR|ttf-ms-fonts}})
 +
 +
===Script===
 +
 +
*[[Wikipedia:Comic Sans|Comic Sans]] ({{AUR|ttf-ms-fonts}})
 +
 +
===Serif===
 +
*[[Wikipedia:Cambria (typeface)|Cambria]] ({{AUR|ttf-vista-fonts}})
 +
*[[Wikipedia:Charis SIL|Charis]] ({{AUR|ttf-charis}}, included in {{AUR|ttf-sil-fonts}}) - Unicode: Latin, Cyrillic
 +
*[[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:Droid (font)|Droid Serif]] ({{Pkg|ttf-droid}}, included in {{AUR|ttf-google-webfonts}})
 +
*[[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:Georgia (typeface)|Georgia]] ({{AUR|ttf-ms-fonts}})
 +
*[[Wikipedia:Liberation fonts|Liberation Serif]] ({{Pkg|ttf-liberation}}) - Alternative to Times New Roman (metric-compatible)
 +
*[[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}})
 +
*Tinos ({{AUR|ttf-google-webfonts}}) - Chrome/Chromium OS replacement for Times New Roman (metric-compatible)
 +
 +
===Unsorted===
 +
<!--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)''
 +
*{{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-sil-fonts}} — Gentium, Charis, Doulos, Andika and Abyssinica from SIL ''(AUR)''
 +
*{{Pkg|font-bh-ttf}} — X.Org Luxi fonts
 +
*{{Pkg|ttf-cheapskate}} — Font collection from ''dustismo.com''
 +
*{{Pkg|ttf-isabella}} — Calligraphic font based on the ''Isabella Breviary'' of 1497
 +
*{{Pkg|ttf-junicode}} — Junius font containing almost complete medieval latin script glyphs
 +
*arkpandorafonts {{AUR|ttf-arkpandora}} — Alternative to Arial and Times New Roman fonts ''(AUR)''
 +
*{{Pkg|xorg-fonts-type1}} — IBM Courier and Adobe Utopia sets of [[Wikipedia:PostScript fonts|PostScript fonts]]
 +
 +
==Console fonts==
 +
 +
The console, meaning a terminal running with no ''X'' Window System, uses the ASCII character set as the default. This font and the keymap used are easily changed.
 +
 +
A console font is limited to either 256 or 512 characters. The fonts are found in {{ic|/usr/share/kbd/consolefonts/}}.
 +
 +
''Keymaps, ''the connection between the key pressed and the character used by the computer, are found in the subdirectories of {{ic|/usr/share/kbd/keymaps/}}.
 +
 +
=== Previewing and testing ===
 +
 +
An organized library of images for previewing is available at http://alexandre.deverteuil.net/consolefonts/consolefonts.html.
 +
 +
Moreover, the user can use {{ic|setfont}} to temporarily change the font and be able to consider its use as the default. The available ''glyphs ''or letters in the font can also be viewed as a table with the command {{ic|showconsolefont}}.
 +
 +
If the newly changed font is not suitable, a return to the default font is done by issuing the command {{ic|setfont}} without any arguments. If the console display is totally unreadable, this command will still work—the user just types in {{ic|setfont}} while "working blind."
 +
 +
Note that {{ic|setfont}} only works on the console currently being used. Any other consoles, active or inactive, remain unaffected.
 +
 +
==== Examples ====
 +
 +
Change the font. This example is distinctive:
 +
$ setfont /usr/share/kbd/consolefonts/gr737b-9x16-medieval.psfu.gz
 +
 +
Or change the font to one with 512 glyphs and set the keymap to ''ISO 8859-5'' using the {{ic|-m}} option:
 +
$ setfont /usr/share/kbd/consolefonts/LatArCyrHeb-16.psfu.gz -m 8859-5
 +
 +
Then issue commands that send text to the display, perhaps view a ''manpage'' and try ''vi'' or ''nano'', and view the table of glyphs with the command, {{ic|showconsolefont}}.
 +
 +
Return to the default font with:
 +
$ setfont
 +
 +
=== Changing the default font ===
 +
 +
To change the default font, the {{ic|FONT<nowiki>=</nowiki>}} and {{ic|FONT_MAP<nowiki>=</nowiki>}} settings in {{ic|/etc/vconsole.conf}} (this file may need to be created) must be altered. Again, the fonts can be found in {{ic|/usr/share/kbd/consolefonts/}} directory and keymaps can be found in the subdirectories of {{ic|/usr/share/kbd/keymaps/}}.
 +
 +
==== Examples ====
 +
For displaying characters such as ''Č, ž, đ, š'' or ''Ł, ę, ą, ś'' using the font {{ic|lat2-16.psfu.gz}}:
 +
FONT=lat2-16
 +
It means that second part of ISO/IEC 8859 characters are used with size 16. You can change font size using other values like lat2-08...16. For the regions determined by 8859 specification, look at the [http://en.wikipedia.org/wiki/ISO/IEC_8859#The_Parts_of_ISO.2FIEC_8859 Wikipedia]. You can use a Terminus font which is recommended if you work a lot in console without X server. ter-216b for example is latin-2 part, size 16, bold. ter-216n is the same but normal weight. Terminus fonts have sizes up to 32.
 +
 +
Now, set the proper keymap, for lat2-16 it will be:
 +
FONT_MAP=8859-2
 +
 +
To use the specified font in early userspace, that is, early in the bootup process, add the {{ic|consolefont}} hook to {{ic|/etc/mkinitcpio.conf}}:
 +
HOOKS="base udev autodetect pata scsi sata filesystems '''consolefont''' '''keymap'''"
 +
 +
Then rebuild the image:
 +
# mkinitcpio -p linux
 +
 +
{{Note|The above steps must be repeated for each kernel if more than one kernel package is installed.}}
 +
 +
See [[Mkinitcpio#HOOKS]] for more information.
 +
 +
If the fonts seems to not change on boot, or change only temporarily, it is most likely that they got reset when graphics driver was initialized and console was switched to framebuffer. To avoid this, load your graphics driver earlier. See for example [[KMS#Early_KMS_start]] or other ways to setup your framebuffer before {{ic|/etc/vconsole.conf}} gets applied.
 +
 +
==== Boot Error ====
 +
 +
If "Loading Console Font" fails at boot time, this is probably because you didn't choose a valid font during your Arch Linux install.
 +
 +
To get rid of this message, simply empty the {{ic|CONSOLEFONT}} variable in {{ic|/etc/rc.conf}}. It will fallback on default font at boot.
 +
 +
== Fallback font order with X11 ==
 +
Fontconfig automatically chooses a font that matches the current requirement. That is to say, if one is looking at a window containing English and Chinese for example, it will switch to another font for the Chinese text if the default one doesn't support it.
 +
 +
Fontconfig lets every user configure the order they want via {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}}.
 +
If you want a particular Chinese font to be selected after your favorite Serif font, your file would look like this:
 +
<?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>
 +
 +
You can add a section for Sans-serif and monospaced as well. For more informations, have a look at the fontconfig manual.
 +
 +
== Font alias ==
 +
In Linux there are several font aliases which represent other fonts in order that applications may use similar fonts. The most common aliases are: {{ic|serif}} for a font of the serif type (e.g. DejaVu Serif); {{ic|sans-serif}} for a font of the sans-serif type (e.g. DejaVu Sans); and {{ic|monospace}} for a monospaced font (e.g. DejaVu Sans Mono). However, the fonts which these aliases represent may vary and the relationship is often not shown in font management tools such as those found in KDE and other desktop environments.
 +
 +
To reverse an alias and find which font it is representing, run:
 +
$ fc-match monospace
 +
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
 +
 +
In this case DejaVuSansMono.ttf is the font represented by the monospace alias.
 +
 +
==2 英文字和中文字等宽==
 +
{{Merge|Font Configuration (简体中文)|配置方法应该放入字体配置页面.}}
 
TrueType 字体分成两种,一种是可变字距,也就是每个字符宽度不一样,比如 "x" 与 "i",这两个字符就不等宽,它是在每个字符中记录该字符的宽度,大多数的 TrueType 字体都是这种格式。  
 
TrueType 字体分成两种,一种是可变字距,也就是每个字符宽度不一样,比如 "x" 与 "i",这两个字符就不等宽,它是在每个字符中记录该字符的宽度,大多数的 TrueType 字体都是这种格式。  
  
Line 230: Line 502:
  
 
</pre>
 
</pre>
 
 
  
 
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中的内嵌点阵更加完善,美观。
 
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中的内嵌点阵更加完善,美观。
Line 289: Line 559:
 
         </match>
 
         </match>
  
</pre>
 
 
 
==中文字体配置==
 
 
中文用户可以使用文泉驿出品的字体配置工具来很容易地配置替代字体的优先级。进入[http://wenq.org/cloud/fcdesigner.html],选择好自己的优先级候,单机“生成”,用生成的文本替换
 
* ~/.fonts.conf
 
文件夹的内容即可。
 
 
 
=添加字体=
 
{{Out of date}}
 
 
现在为 Linux 系统添加字体要比以前容易得多。下面我帖一篇小技巧,以便帮助一般用户更好地理解如何为自己的 Linux 系统添加字体。
 
首先必须要了解我们把字体放在了哪里。通常我们会把它们放在:
 
* /usr/share/fonts
 
* /usr/X11R6/libs/X11/fonts
 
这将会让每一个系统用户都可以使用它们, 当然这需要使用根用户权限。将它们拷贝到:
 
* ~/.fonts
 
目录也不失为一个好主意。
 
 
有一些字体已经为使用 Arch Linux 的用户预先做好了 pkg 包,可以通过以下命令来搜索它们:
 
<pre>pacman -Ss fonts</pre>
 
如果你需要安装它们,则运行:
 
<pre>pacman -S artwiz-fonts ttf-cheapskate ttf-ms-fonts</pre>
 
这些字体将会被安装到 <code>/usr/X11R6/libs/X11/fonts</code> 目录。
 
为了能够正确显示字符,推荐CJK(中文/日语/韩语)用户同时安装“ttf-arphic-uming”和“ttf-arphic-ukai”字体。
 
 
另一种选择是使用KDE控制中心里的KDE字体安装。如果你正在使用KDE,它的效果将非常完美。
 
 
当然你也可以手动将字体拷贝到上述三个目录,然后以根用户身份运行: <pre>fc-cache -vf</pre>
 
 
一般来说,你可以方便地在诸如 Gnome、Xfce4及KDE等 X 窗口环境中使用这些字体。然而,一些 GTK1 和旧的程序不支持 fontconfig 。(是否真的如此呢?希望大家可以查阅一下相关资料并指正。)你需要在你的字体目录中运行如下命令(当然需要启动终端来运行):
 
  <pre>
 
  mkfontscale
 
  mkfontdir
 
  ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir yourfontdirectory/encodings.dir
 
  </pre>
 
之后通常你需要重启 X。
 
 
如果你想分享你的字体或不希望进行上述手工操作,那么你可以自行制作 Arch 安装包。首先以 tar.bz2 格式打包你需要安装的字体,然后修改下面的 PKGBUILD 和 .install 文件,通过 ABS 方式来完成安装:
 
<pre># PKGBUILD
 
  pkgname=fonts-extra
 
  pkgver=1.0
 
  pkgrel=1
 
  depends=('xfree86')
 
  pkgdesc=\"Fonts extra\"
 
  source=(fonts-extra.tar.bz2)
 
  install=fonts-extra.install
 
  build()        {
 
    mkdir -p $startdir/pkg/usr/X11R6/lib/X11/fonts/local
 
    mv $startdir/src/*.ttf $startdir/pkg/usr/X11R6/lib/X11/fonts/local
 
  }
 
</pre>
 
<pre># fonts-extra.install:
 
  # arg 1:  the new package version
 
  post_install() {
 
    echo -n \"updating font cache... \"
 
    /usr/bin/fc-cache
 
    cd /usr/X11R6/lib/X11/fonts/local
 
    /usr/X11R6/bin/mkfontscale
 
    /usr/X11R6/bin/mkfontdir
 
    ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir /usr/X11R6/lib/X11/fonts/local/encodings.dir
 
    echo \"done.\"
 
  }
 
 
  # arg 1:  the new package version
 
  # arg 2:  the old package version
 
  post_upgrade() {
 
    post_install $1
 
  }
 
 
  # arg 1:  the old package version
 
  pre_remove() {
 
    /bin/true
 
  }
 
 
  op=$1
 
  shift
 
 
  $op $*
 
 
</pre>
 
</pre>

Revision as of 08:44, 11 October 2012

翻译状态: 本文是英文页面 Fonts翻译,最后翻译时间:2012-10-11,点击这里可以查看翻译后英文页面的改动。

Tango-preferences-desktop-locale.png本页面需要更新翻译,内容可能已经与英文脱节。要贡献翻译,请访问简体中文翻译组Tango-preferences-desktop-locale.png

附注: please use the first argument of the template to provide more detailed indications.
摘要 help replacing me
包含了在 Arch Linux 中安装和使用字体的信息
合法性
某些字体包可能会遇到一些法律限制。
相关页面
Font Configuration (简体中文)
Java Fonts - Sun JRE
MS Fonts

From Wikipedia:

A computer font (or font) is an electronic data file containing a set of glyphs, characters, or symbols such as dingbats.

字体类型

大多数当代电脑使用的不是点阵字体就是矢量字体。

点阵字体
每种字形的每种形式和每种尺寸的图像都由点或者像素组成的矩阵构成。由于位图的原故,点阵字体很难进行缩放,特定的点阵字体只能清晰地显示在相应的字号下。但对于 12-16px 这样小的汉字,点阵字体常常比其它类型的字体在屏幕上更好的显示效果。常见的点阵字体有 bdf,pcf,fnt,hbf 等格式。
矢量字体
使用贝塞尔曲线, 绘图指令和数学公式来描述每种字形,使得字体可以适应各种尺寸。

通用类型

  • bdf and bdf.gz – 点阵字体,“b”代表点阵,“d”代表布局,“f”代表形式,用gzip压缩 bdf
  • pcf and pcf.gz – 点阵字体,“p”代表可移植,“c”代表编译 “f”代表字体,用gzip压缩 pcf
  • psfpsfupsf.gz and psfu.gz – 点阵字体,“PC”,“s”代表屏幕,“f”代表字体,“PC”,“s”代表屏幕,“f”代表字体,“U”代表Unicode,用gzip压缩(不适用于X.Org)。
  • pfa and pfb – 矢量字体,“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格式也有自己的字体描述方法

Installation

There are various methods for installing fonts.

Pacman

Fonts and font collections in the enabled repositories can be installed using pacman. Available fonts may be found by using:

$ pacman -Ss font

Or to search for ttf fonts only:

$ pacman -Ss ttf

Some fonts like terminus are installed in /usr/share/fonts/local, which is not added to the font path by default. By adding the following lines to ~/.xinitrc the fonts can be used in X11:

xset +fp /usr/share/fonts/local
xset fp rehash

Creating a package

If you want to give pacman the ability to manage your fonts, you can create an Arch package. These can also be shared with the community in the AUR. Here is an example of how to create a basic package. To learn more about building packages, read 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
}

This PKGBUILD assumes the fonts are TrueType. An install file (ttf-fontname.install) will also need to be created to update the font cache:

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
}

Manual installation

The recommended way of adding fonts that are not in the repositories to your system is described in #Creating a package. This gives pacman the ability to remove or update them at a later time. Fonts can alternately be installed manually as well.

To install fonts system-wide (available for all users), move the folder to the /usr/share/fonts/ directory. To install fonts for only a single user, use ~/.fonts/ instead.

Also you may need to update /etc/X11/xorg.conf or /etc/xorg.conf with the new directory. Search for FontPath to find the correct location within the file to add your new path. See #Fonts with X.Org for more detail.

Then update the fontconfig font cache:

$ fc-cache -vf

Older applications

With older applications that do not support fontconfig (e.g. GTK+ 1.x applications, and xfontsel) the index will need to be created in the font directory:

$ mkfontscale
$ mkfontdir

Or to include more than one folder with one command:

$ for dir in /font/dir1/ /font/dir2/; do xset +fp $dir; done && xset fp rehash

At times the X server may fail to load the fonts directory and you will need to rescan all the fonts.dir files:

# xset +fp /usr/share/fonts/misc # Inform the X server of new directories
# xset fp rehash                # Forces a new rescan

To check that the font(s) is included:

$ xlsfonts | grep fontname

Pango Warnings

When Pango is in use on your system it will read from fontconfig to sort out where to source fonts.

(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'

If you are seeing errors similar to this and/or seeing blocks instead of characters in your application then you need to add fonts and update the font cache. This example uses the ttf-liberation fonts to illustrate the solution and runs as root to enable them system-wide.

# 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

You can test for a default font being set like so:

# fc-match
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"

Fonts with X.Org

In order for Xorg to find and use your newly installed fonts, you must add the font paths to /etc/X11/xorg.conf (another X.Org configuration file may work too).

Here is an example of the section that must be added to /etc/X11/xorg.conf. Add or remove paths based on your particular font requirements.

# Let X.Org know about the custom font directories
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

Font packages

This is a selective list that includes many font packages from the AUR along with those in the official repositories. Fonts are tagged "Unicode" if they have wide Unicode support, see the project or Wikipedia pages for detail.

Braille

International users

Arabic

Birman

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

Cyrillic

Also see #Monospace, #Sans and #Serif

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

(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

Sinhala

Tamil

Thai

  • ttf-thai - Font covering glyphs for Thai

Tibetan

Math

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

Bitmap

Sans-serif

Script

Serif

Unsorted

Console fonts

The console, meaning a terminal running with no X Window System, uses the ASCII character set as the default. This font and the keymap used are easily changed.

A console font is limited to either 256 or 512 characters. The fonts are found in /usr/share/kbd/consolefonts/.

Keymaps, the connection between the key pressed and the character used by the computer, are found in the subdirectories of /usr/share/kbd/keymaps/.

Previewing and testing

An organized library of images for previewing is available at http://alexandre.deverteuil.net/consolefonts/consolefonts.html.

Moreover, the user can use setfont to temporarily change the font and be able to consider its use as the default. The available glyphs or letters in the font can also be viewed as a table with the command showconsolefont.

If the newly changed font is not suitable, a return to the default font is done by issuing the command setfont without any arguments. If the console display is totally unreadable, this command will still work—the user just types in setfont while "working blind."

Note that setfont only works on the console currently being used. Any other consoles, active or inactive, remain unaffected.

Examples

Change the font. This example is distinctive:

$ setfont /usr/share/kbd/consolefonts/gr737b-9x16-medieval.psfu.gz

Or change the font to one with 512 glyphs and set the keymap to ISO 8859-5 using the -m option:

$ setfont /usr/share/kbd/consolefonts/LatArCyrHeb-16.psfu.gz -m 8859-5

Then issue commands that send text to the display, perhaps view a manpage and try vi or nano, and view the table of glyphs with the command, showconsolefont.

Return to the default font with:

$ setfont

Changing the default font

To change the default font, the FONT= and FONT_MAP= settings in /etc/vconsole.conf (this file may need to be created) must be altered. Again, the fonts can be found in /usr/share/kbd/consolefonts/ directory and keymaps can be found in the subdirectories of /usr/share/kbd/keymaps/.

Examples

For displaying characters such as Č, ž, đ, š or Ł, ę, ą, ś using the font lat2-16.psfu.gz:

FONT=lat2-16

It means that second part of ISO/IEC 8859 characters are used with size 16. You can change font size using other values like lat2-08...16. For the regions determined by 8859 specification, look at the Wikipedia. You can use a Terminus font which is recommended if you work a lot in console without X server. ter-216b for example is latin-2 part, size 16, bold. ter-216n is the same but normal weight. Terminus fonts have sizes up to 32.

Now, set the proper keymap, for lat2-16 it will be:

FONT_MAP=8859-2

To use the specified font in early userspace, that is, early in the bootup process, add the consolefont hook to /etc/mkinitcpio.conf:

HOOKS="base udev autodetect pata scsi sata filesystems consolefont keymap"

Then rebuild the image:

# mkinitcpio -p linux
Note: The above steps must be repeated for each kernel if more than one kernel package is installed.

See Mkinitcpio#HOOKS for more information.

If the fonts seems to not change on boot, or change only temporarily, it is most likely that they got reset when graphics driver was initialized and console was switched to framebuffer. To avoid this, load your graphics driver earlier. See for example KMS#Early_KMS_start or other ways to setup your framebuffer before /etc/vconsole.conf gets applied.

Boot Error

If "Loading Console Font" fails at boot time, this is probably because you didn't choose a valid font during your Arch Linux install.

To get rid of this message, simply empty the CONSOLEFONT variable in /etc/rc.conf. It will fallback on default font at boot.

Fallback font order with X11

Fontconfig automatically chooses a font that matches the current requirement. That is to say, if one is looking at a window containing English and Chinese for example, it will switch to another font for the Chinese text if the default one doesn't support it.

Fontconfig lets every user configure the order they want via $XDG_CONFIG_HOME/fontconfig/fonts.conf. If you want a particular Chinese font to be selected after your favorite Serif font, your file would look like this:

<?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>

You can add a section for Sans-serif and monospaced as well. For more informations, have a look at the fontconfig manual.

Font alias

In Linux there are several font aliases which represent other fonts in order that applications may use similar fonts. The most common aliases are: serif for a font of the serif type (e.g. DejaVu Serif); sans-serif for a font of the sans-serif type (e.g. DejaVu Sans); and monospace for a monospaced font (e.g. DejaVu Sans Mono). However, the fonts which these aliases represent may vary and the relationship is often not shown in font management tools such as those found in KDE and other desktop environments.

To reverse an alias and find which font it is representing, run:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

In this case DejaVuSansMono.ttf is the font represented by the monospace alias.

2 英文字和中文字等宽

Merge-arrows-2.pngThis article or section is a candidate for merging with Font Configuration (简体中文).Merge-arrows-2.png

Notes: 配置方法应该放入字体配置页面. (Discuss in Talk:Fonts (简体中文)#)

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>