1 \documentclass[DIV=13]{article}
5 \def\verbatim{\@verbatim \frenchspacing\@vobeyspaces\luatexlocalleftbox{\hskip3\zw} \@xverbatim}
9 \def\XeTeX{\hologo{XeTeX}}
10 \def\ConTeXt{Con\TeX t}
13 \usepackage{indentfirst}
14 \usepackage{luatexja-fontspec}
17 \setmainjfont{FandolSong}
18 \title{\textbf{\LuaTeX-ja简体中文字体配置}}
19 \author{马起园\hskip2.5\zw 苏 杰}
23 \section{\LuaTeX-ja项目简介}
24 \LuaTeX-ja项目旨在将\pTeX 处理汉字的机制及相关功能移植到\LuaTeX 下,当前项目
25 的成员有:北川弘典、前田一贵、八登崇之、黑木裕介 、阿部纪行、山本宗宏、本田知
28 \LuaTeX 虽然在编码上支持Unicode,但并不能直接处理汉字断行以及禁则应用,而
29 在\pTeX 系列中则能够处理断行并应用禁则,但并不支持PDF输出。\LuaTeX 下处理
30 汉字的断行和应用禁则需要使用其内建的诸多callback来进行。\pTeX 扩展TFM为JFM,
31 但是JFM抽象程度更高,该文件涉及到的内容是字体的标点压缩,可以用于多个汉字字体。
33 当前版本的\LuaTeX-ja 可以应用于\TeX\ Live和W32\TeX,在旧版本MikTeX下使用会
34 出问题,因为MikTeX下的\LuaTeX 存在编译上的bug。
38 \subsection{关于\LuaTeX-ja的字体调用}
40 \XeTeX 在调用字体的时候需要使用freetype和fontconfig库,所以需要更新字体缓
41 存,但是在\LuaTeX 下就不太一样。\LuaTeX 只需要在初次使用的时候刷新字体数据
42 库即可(此数据库是一个lua文件)。\LuaTeX 下的字体缓存实际上是将字体的各种
43 信息导出并保存的文件,在调用一个新字体的时候会生成一个。\LuaTeX 对于字体的
44 处理并没有使用freetype,而是使用了fontforge,不过可能由于该库的接口有一些
45 问题,导致部分字体无法在\LuaTeX 下使用。
47 在使用\LuaTeX-ja的时候,需要先刷新字体数据库,该命令的使用方法如下:
49 Usage: mkluatexfontdb [OPTION]...
51 Rebuild the LuaTeX font database.
54 -f --force force re-indexing all fonts
55 -q --quiet don't output anything
56 -v --verbose=LEVEL be more verbose (print the searched directories)
57 -vv print the loaded fonts
58 -vvv print all steps of directory searching
59 -V --version print version and exit
60 -h --help print this message
63 在新版本的\texttt{luaotfload}包中,提供了新的命令\texttt{luaotfload-tool},
64 但如上所述的\texttt{mkluatexfontdb}依然能够使用。
66 又是可能遇到通不过的字体,需要将这个字体的绝对路径添加到\texttt{luaotfload-blacklist.cnf}中,
70 LastResort.ttf % a MacOSX font, but also available for free from unicode.org
71 % Segfaults under LuaTeX 0.76
73 % http://tug.org/pipermail/luatex/2013-May/004239.html
81 如果你在\texttt{texmf-local}下添加了某些私有字体,请及时运行\texttt{texhash},
82 这样能够方便在运行\LuaTeX 的时候能够通过kpathsea库找到他们。
84 Lua\TeX 调用TrueType和OpenType字体并没有固定的方式,\XeTeX 使用了固定的接口,
85 而Lua\TeX 需要使用luaotfload包来进行字体的调用。这两种字体一般都有高级特性,
86 在\TeX\ Live或者W32\TeX 中可以使用\texttt{otfinfo}命令来查看相关的信息:
88 'Otfinfo' reports information about an OpenType font to standard output.
89 Options specify what information to print.
91 Usage: otfinfo [-sfzpg | OPTIONS] [OTFFILES...]
94 -s, --scripts Report font's supported scripts.
95 -f, --features Report font's GSUB/GPOS features.
96 -z, --optical-size Report font's optical size information.
97 -p, --postscript-name Report font's PostScript name.
98 -a, --family Report font's family name.
99 -v, --font-version Report font's version information.
100 -i, --info Report font's names and designer/vendor info.
101 -g, --glyphs Report font's glyph names.
102 -t, --tables Report font's OpenType tables.
103 -T, --dump-table NAME Output font's 'NAME' table.
106 --script=SCRIPT[.LANG] Set script used for --features [latn].
107 -V, --verbose Print progress information to standard error.
108 -h, --help Print this message and exit.
109 -q, --quiet Do not generate any error messages.
110 --version Print version number and exit.
112 Report bugs to <ekohler@gmail.com>.
117 目前\LuaTeX-ja支持在plain \TeX 和\LaTeX 下使用。如果你使用texinfo,那么很
118 不幸,你不太可能使用\LuaTeX-ja来处理中文,因为texinfo是针对pdf\TeX 设计的,
119 在\LuaTeX 下使用已经有了一定的不兼容现象,即使完全兼容也需要对texinfo中的
120 字体配置进行调整,如果你急需使用texinfo来处理中文,请尝试W32\TeX 下的texinfo,
121 这个发行版中的texinfo已经打了补丁。对于\ConTeXt 用户,请使用李延瑞的zhfonts模块
122 \footnote{见https://github.com/liyanrui/zhfonts}。
124 在plain \TeX 中使用Lua\TeX-ja可以在源文件中写入:
126 \input luatexja-core.sty
129 Lua\TeX-ja移植的了\verb!\jfont!命令,在plain \TeX 下需要通过该命令来
132 \jfont\song={name:SimSun:jfm=banjiao} at 10pt
136 上文中的\verb!jfm=banjiao!使用来控制标点压缩的,如果此项未设定,则
137 使用默认的\verb!ujis!压缩模式,对于简体中文来讲,可用的模式有:
138 \texttt{quanjiao,banjiao,kaiming, CCT}。
140 而在\LaTeX 下使用则较为简单,使用:
142 \usepackage{luatexja-fontspec}
144 这个包对fontspec包进行了封装,令其能够较为便利地设定汉字字体。
150 \multicolumn{1}{c}{\textbf{命令}} & \multicolumn{1}{c}{\textbf{用途}} \\
152 \verb!\jfontspec! & 改变当前汉字字体 \\
153 \verb!\setmainjfont! & 设定文档主汉字字体 \\
154 \verb!\setsansjfont! & 设定文档的无衬线汉字字体(黑体) \\
155 \verb!\newjfontfamily! & 设定新的汉字字体族命令 \\
156 \verb!\newjfontface! & 设定新的汉字字体命令 \\
157 \verb!\defaultjfontfeatures! & 默认汉字字体的特性 \\
158 \verb!\addjfontfeatures! & 设定当前字体的特性 \\
165 中文字体在丰度上与日文字体对比并不占优势,所以中文\TeX 文档在使用使用字体
166 上没有太大变化。当你想在\LuaTeX-ja下是有部分特色字体的时候,请做好此种字体
167 可能无法使用的准备。目前报错明显的字体有数个:
169 \item 灵格斯词典附带的音标字体,这些字体会安装到系统字体文件夹下,在更新
170 字体数据库的时候会出现程序崩溃的情况,这是字体本身的原因,需要添加到黑名单中
171 \item 康熙字典体,这是中国大陆一位业余字体设计者所设计的字体,由于该作者
172 缺乏相关技术知识,导致此字体的CMap出错,无论是完全版还是试用版都会出现
173 问题,此外该字体的boundingbox也是错误的,在嵌入pdf文档中十分影响阅读
174 \item 信黑体,这个字体也是CMap的问题,无法使用
176 \subsection{Fandol字体系列}
177 Fandol系列字体由本文档两位作者联合开发,含有数种样式。
184 \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{样例}} \\
186 FandolSong-Regular & \texttt{FandolSong-Regular.otf} & {我能吞下玻璃而不伤身体} \\
187 FandolSong-Bold & \texttt{FandolSong-Bold.otf} & {\bf 我能吞下玻璃而不伤身体} \\
188 FandolHei-Regular & \texttt{FandolHei-Regular.otf} & {\jfontspec{FandolHei-Regular}我能吞下玻璃而不伤身体} \\
189 FandolHei-Bold & \texttt{FandolHei-Bold.otf} & {\jfontspec{FandolHei-Bold}我能吞下玻璃而不伤身体} \\
190 FandolFang-Regular & \texttt{FandolFang-Regular.otf} & {\jfontspec{FandolFang-Regular}我能吞下玻璃而不伤身体}\\
191 FandolKai-Regular & \texttt{FandolKai-Regular} & {\jfontspec{FandolKai-Regular}我能吞下玻璃而不伤身体}\\
198 在微软提供的Office套装中附带了一定数量的中文字体,
199 这些字体是常州华文印刷新技术有限公司制造的。
200 这些字体安装在系统字体文件夹下,在使用\LuaTeX-ja 的时候
201 可以酌情使用。在本文档中,我们推荐简体中文用户使用
202 此套字体,从使用率上看,各大学都会装有微软的操作系统
203 和微软的Office,可以说已经相当普及,故做推荐。
207 \begin{tabular}{llll}
209 \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{PostScript名}} & \multicolumn{1}{c}{\textbf{样例}} \\
211 华文宋体 & \texttt{STSONG.TTF} & STSong & {\jfontspec{STSong}我能吞下玻璃而不伤身体} \\
212 华文中宋 & \texttt{STZHONGS.TTF} & STZhongsong & {\jfontspec{STZhongsong}我能吞下玻璃而不伤身体} \\
213 华文细黑 & \texttt{STXIHEI.TTF} & STXihei & {\jfontspec{STXihei}我能吞下玻璃而不伤身体} \\
214 华文楷体 & \texttt{STKAITI.TTF} & STKaiti & {\jfontspec{STKaiti}我能吞下玻璃而不伤身体} \\
215 华文仿宋 & \texttt{STFANGSO.TTF} & STFangsong & {\jfontspec{STFangsong}我能吞下玻璃而不伤身体} \\
221 在Windows系统简体中文版中,附带了数种中文字体。
222 这些字体为中易中标电子信息技术有限公司制造的。
223 同我们强烈推荐的第一种方案比较,没有中宋。
228 \begin{tabular}{llll}
230 \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{PostScript名}} & \multicolumn{1}{c}{\textbf{样例}} \\
232 宋体 & \texttt{simsun.ttc} & SimSun & {\jfontspec{SimSun}我能吞下玻璃而不伤身体} \\
233 黑体 & \texttt{simhei.ttf} & SimHei & {\jfontspec{SimHei}我能吞下玻璃而不伤身体} \\
234 楷体 & \texttt{simkai.ttf} & KaiTi & {\jfontspec{KaiTi}我能吞下玻璃而不伤身体} \\
235 仿宋 & \texttt{simkai.ttf} & FangSong & {\jfontspec{FangSong}我能吞下玻璃而不伤身体} \\
240 \subsection{Adobe字体系列}
241 在Adobe Reader简体中文版中,附带了宋体和黑体两种字体。
242 这两种字体实际上是华文字体,但是和华文字体不能混用,
243 因为Adobe Reader中的中文字体的基线都进行了调整,
244 不能互相匹配。在Adobe InDesign中还附带了楷体和仿宋体。
245 Adobe的中文字体的Postscript名即为文件名去掉后缀名。
251 \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{样例}} \\
253 Adobe 宋体 Std & \texttt{AdobeSongStd-Light.otf} & {\jfontspec{AdobeSongStd-Light}我能吞下玻璃而不伤身体} \\
254 Adobe 黑体 Std & \texttt{AdobeHeitiStd-Regular.otf} & {\jfontspec{AdobeHeitiStd-Regular}我能吞下玻璃而不伤身体} \\
255 Adobe 楷体 Std & \texttt{AdobeKaitiStd-Regular.otf} & {\jfontspec{AdobeKaitiStd-Regular}我能吞下玻璃而不伤身体} \\
256 Adobe 仿宋 Std & \texttt{AdobeFangsongStd-Regular.otf} & {\jfontspec{AdobeFangsongStd-Regular}我能吞下玻璃而不伤身体} \\
262 方正字体的来源有两种,第一种是使用方正的排版系统的时候会
263 安装到Windows系统的字体文件夹下,第二种是针对Linux系统
264 来说的,WPS for Linux附带了部分方正字体。
268 \begin{tabular}{llll}
270 \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{全名}} & \multicolumn{1}{c}{\textbf{样例}} \\
272 方正书宋\_GBK & \texttt{FZSSK.TTF} & FZShuSong-Z01 & {\jfontspec{FZShuSong-Z01}我能吞下玻璃而不伤身体} \\
273 方正小标宋\_GBK & \texttt{FZXBSK.TTF} & FZXiaoBiaoSong-B05 & {\jfontspec{FZXiaoBiaoSong-B05}我能吞下玻璃而不伤身体} \\
274 方正黑体\_GBK & \texttt{FZHTK.TTF} & FZHei-B01 & {\jfontspec{FZHei-B01}我能吞下玻璃而不伤身体} \\
275 方正楷体\_GBK & \texttt{FZKTK.TTF} & FZKai-Z03 & {\jfontspec{FZKai-Z03}我能吞下玻璃而不伤身体} \\
276 方正仿宋\_GBK & \texttt{FZFSK.TTF} & FZFangSong-Z02 & {\jfontspec{FZFangSong-Z02}我能吞下玻璃而不伤身体} \\