summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/luatex/luatexja/luatexja-zhfonts.tex
blob: e220c0de059606ace2e9ecaff780abe13da679ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
\documentclass[DIV=13]{article}
\usepackage{typearea}
\usepackage{hologo}
\makeatletter
\def\verbatim{\@verbatim \frenchspacing\@vobeyspaces\luatexlocalleftbox{\hskip3\zw} \@xverbatim}
\makeatother
\def\pTeX{p\TeX}
\def\LuaTeX{Lua\TeX}
\def\XeTeX{\hologo{XeTeX}}
\def\ConTeXt{Con\TeX t}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{indentfirst}
\usepackage{luatexja-fontspec}
\parindent2\zw
\linespread{1.25}
\setmainjfont{FandolSong}
\title{\textbf{\LuaTeX-ja简体中文字体配置}}
\author{马起园\hskip2.5\zw 苏 杰}
\date{2013年5月}
\begin{document}
\maketitle
\section{\LuaTeX-ja项目简介}
\LuaTeX-ja项目旨在将\pTeX 处理汉字的机制及相关功能移植到\LuaTeX 下,当前项目
的成员有:北川弘典、前田一贵、八登崇之、黑木裕介 、阿部纪行、山本宗宏、本田知
亮、斋藤修三郎和马起园。

\LuaTeX 虽然在编码上支持Unicode,但并不能直接处理汉字断行以及禁则应用,而
在\pTeX 系列中则能够处理断行并应用禁则,但并不支持PDF输出。\LuaTeX 下处理
汉字的断行和应用禁则需要使用其内建的诸多callback来进行。\pTeX 扩展TFM为JFM,
但是JFM抽象程度更高,该文件涉及到的内容是字体的标点压缩,可以用于多个汉字字体。

当前版本的\LuaTeX-ja 可以应用于\TeX\ Live和W32\TeX,在旧版本MikTeX下使用会
出问题,因为MikTeX下的\LuaTeX 存在编译上的bug。

\section{字体使用}

\subsection{关于\LuaTeX-ja的字体调用}

\XeTeX 在调用字体的时候需要使用freetype和fontconfig库,所以需要更新字体缓
存,但是在\LuaTeX 下就不太一样。\LuaTeX 只需要在初次使用的时候刷新字体数据
库即可(此数据库是一个lua文件)。\LuaTeX 下的字体缓存实际上是将字体的各种
信息导出并保存的文件,在调用一个新字体的时候会生成一个。\LuaTeX 对于字体的
处理并没有使用freetype,而是使用了fontforge,不过可能由于该库的接口有一些
问题,导致部分字体无法在\LuaTeX 下使用。

在使用\LuaTeX-ja的时候,需要先刷新字体数据库,该命令的使用方法如下:
\begin{verbatim}
Usage: mkluatexfontdb [OPTION]...
    
Rebuild the LuaTeX font database.

Valid options:
  -f --force                   force re-indexing all fonts
  -q --quiet                   don't output anything
  -v --verbose=LEVEL           be more verbose (print the searched directories)
  -vv                          print the loaded fonts
  -vvv                         print all steps of directory searching
  -V --version                 print version and exit
  -h --help                    print this message
\end{verbatim}

在新版本的\texttt{luaotfload}包中,提供了新的命令\texttt{luaotfload-tool},
但如上所述的\texttt{mkluatexfontdb}依然能够使用。

又是可能遇到通不过的字体,需要将这个字体的绝对路径添加到\texttt{luaotfload-blacklist.cnf}中,
这个文件的内容如下:
\begin{verbatim}
% Takes ages to load
LastResort.ttf % a MacOSX font, but also available for free from unicode.org 
% Segfaults under LuaTeX 0.76
lingoes.ttf
% http://tug.org/pipermail/luatex/2013-May/004239.html
Diablindall.ttf
spltfgbd.ttf
spltfgbi.ttf
spltfgit.ttf
spltfgrg.ttf
\end{verbatim}

如果你在\texttt{texmf-local}下添加了某些私有字体,请及时运行\texttt{texhash},
这样能够方便在运行\LuaTeX 的时候能够通过kpathsea库找到他们。

Lua\TeX 调用TrueType和OpenType字体并没有固定的方式,\XeTeX 使用了固定的接口,
而Lua\TeX 需要使用luaotfload包来进行字体的调用。这两种字体一般都有高级特性,
在\TeX\ Live或者W32\TeX 中可以使用\texttt{otfinfo}命令来查看相关的信息:
\begin{verbatim}
'Otfinfo' reports information about an OpenType font to standard output.
Options specify what information to print.

Usage: otfinfo [-sfzpg | OPTIONS] [OTFFILES...]

Query options:
  -s, --scripts                Report font's supported scripts.
  -f, --features               Report font's GSUB/GPOS features.
  -z, --optical-size           Report font's optical size information.
  -p, --postscript-name        Report font's PostScript name.
  -a, --family                 Report font's family name.
  -v, --font-version           Report font's version information.
  -i, --info                   Report font's names and designer/vendor info.
  -g, --glyphs                 Report font's glyph names.
  -t, --tables                 Report font's OpenType tables.
  -T, --dump-table NAME        Output font's 'NAME' table.

Other options:
      --script=SCRIPT[.LANG]   Set script used for --features [latn].
  -V, --verbose                Print progress information to standard error.
  -h, --help                   Print this message and exit.
  -q, --quiet                  Do not generate any error messages.
      --version                Print version number and exit.

Report bugs to <ekohler@gmail.com>.
\end{verbatim}

\subsection{使用字体的方法}

目前\LuaTeX-ja支持在plain \TeX 和\LaTeX 下使用。如果你使用texinfo,那么很
不幸,你不太可能使用\LuaTeX-ja来处理中文,因为texinfo是针对pdf\TeX 设计的,
在\LuaTeX 下使用已经有了一定的不兼容现象,即使完全兼容也需要对texinfo中的
字体配置进行调整,如果你急需使用texinfo来处理中文,请尝试W32\TeX 下的texinfo,
这个发行版中的texinfo已经打了补丁。对于\ConTeXt 用户,请使用李延瑞的zhfonts模块
\footnote{见https://github.com/liyanrui/zhfonts}。

在plain \TeX 中使用Lua\TeX-ja可以在源文件中写入:
\begin{verbatim}
\input luatexja-core.sty
\end{verbatim}

Lua\TeX-ja移植的了\verb!\jfont!命令,在plain \TeX 下需要通过该命令来
控制输出的汉字字体,例如:
\begin{verbatim}
\jfont\song={name:SimSun:jfm=banjiao} at 10pt
\song 我能吞下玻璃而不伤身体。
\end{verbatim}

上文中的\verb!jfm=banjiao!使用来控制标点压缩的,如果此项未设定,则
使用默认的\verb!ujis!压缩模式,对于简体中文来讲,可用的模式有:
\texttt{quanjiao,banjiao,kaiming, CCT}。

而在\LaTeX 下使用则较为简单,使用:
\begin{verbatim}
\usepackage{luatexja-fontspec}
\end{verbatim}
这个包对fontspec包进行了封装,令其能够较为便利地设定汉字字体。
这个包提供的命令如下:
\begin{table}[htbp]
  \centering
    \begin{tabular}{ll}
    \toprule
    \multicolumn{1}{c}{\textbf{命令}} & \multicolumn{1}{c}{\textbf{用途}} \\
    \midrule
    \verb!\jfontspec! & 改变当前汉字字体 \\
    \verb!\setmainjfont! & 设定文档主汉字字体 \\
    \verb!\setsansjfont! & 设定文档的无衬线汉字字体(黑体) \\
    \verb!\newjfontfamily! & 设定新的汉字字体族命令 \\
    \verb!\newjfontface! & 设定新的汉字字体命令 \\
    \verb!\defaultjfontfeatures! & 默认汉字字体的特性 \\
    \verb!\addjfontfeatures! & 设定当前字体的特性 \\
    \bottomrule
    \end{tabular}%
\end{table}%

\subsection{不可用字体系列}

中文字体在丰度上与日文字体对比并不占优势,所以中文\TeX 文档在使用使用字体
上没有太大变化。当你想在\LuaTeX-ja下是有部分特色字体的时候,请做好此种字体
可能无法使用的准备。目前报错明显的字体有数个:
\begin{itemize}
\item 灵格斯词典附带的音标字体,这些字体会安装到系统字体文件夹下,在更新
   字体数据库的时候会出现程序崩溃的情况,这是字体本身的原因,需要添加到黑名单中
\item 康熙字典体,这是中国大陆一位业余字体设计者所设计的字体,由于该作者
   缺乏相关技术知识,导致此字体的CMap出错,无论是完全版还是试用版都会出现
   问题,此外该字体的boundingbox也是错误的,在嵌入pdf文档中十分影响阅读
\item 信黑体,这个字体也是CMap的问题,无法使用
\end{itemize}
\subsection{Fandol字体系列}
Fandol系列字体由本文档两位作者联合开发,含有数种样式。
该套字体可以在TeXLive下进行更新。

\begin{table}[htbp]
  \centering
    \begin{tabular}{lll}
    \toprule
    \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{样例}} \\
    \midrule
    FandolSong-Regular & \texttt{FandolSong-Regular.otf} & {我能吞下玻璃而不伤身体} \\
    FandolSong-Bold & \texttt{FandolSong-Bold.otf} & {\bf 我能吞下玻璃而不伤身体} \\
    FandolHei-Regular & \texttt{FandolHei-Regular.otf} & {\jfontspec{FandolHei-Regular}我能吞下玻璃而不伤身体} \\
    FandolHei-Bold & \texttt{FandolHei-Bold.otf} & {\jfontspec{FandolHei-Bold}我能吞下玻璃而不伤身体} \\
    FandolFang-Regular & \texttt{FandolFang-Regular.otf} & {\jfontspec{FandolFang-Regular}我能吞下玻璃而不伤身体}\\
    FandolKai-Regular & \texttt{FandolKai-Regular} & {\jfontspec{FandolKai-Regular}我能吞下玻璃而不伤身体}\\
    \bottomrule
    \end{tabular}%
\end{table}%


\subsection{华文字体系列}
在微软提供的Office套装中附带了一定数量的中文字体,
这些字体是常州华文印刷新技术有限公司制造的。
这些字体安装在系统字体文件夹下,在使用\LuaTeX-ja 的时候
可以酌情使用。在本文档中,我们推荐简体中文用户使用
此套字体,从使用率上看,各大学都会装有微软的操作系统
和微软的Office,可以说已经相当普及,故做推荐。

\begin{table}[htbp]
  \centering
    \begin{tabular}{llll}
    \toprule
    \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{PostScript名}} & \multicolumn{1}{c}{\textbf{样例}} \\
    \midrule
    华文宋体  & \texttt{STSONG.TTF} & STSong & {\jfontspec{STSong}我能吞下玻璃而不伤身体} \\
    华文中宋  & \texttt{STZHONGS.TTF} & STZhongsong & {\jfontspec{STZhongsong}我能吞下玻璃而不伤身体} \\
    华文细黑  & \texttt{STXIHEI.TTF} & STXihei & {\jfontspec{STXihei}我能吞下玻璃而不伤身体} \\
    华文楷体  & \texttt{STKAITI.TTF} & STKaiti & {\jfontspec{STKaiti}我能吞下玻璃而不伤身体} \\
    华文仿宋  & \texttt{STFANGSO.TTF} & STFangsong & {\jfontspec{STFangsong}我能吞下玻璃而不伤身体} \\
    \bottomrule
    \end{tabular}%
\end{table}

\subsection{中易字体系列}
在Windows系统简体中文版中,附带了数种中文字体。
这些字体为中易中标电子信息技术有限公司制造的。
同我们强烈推荐的第一种方案比较,没有中宋。
如果按照CCT的传统,一般使用黑体替换。

\begin{table}[htbp]
  \centering
    \begin{tabular}{llll}
    \toprule
    \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{PostScript名}} & \multicolumn{1}{c}{\textbf{样例}} \\
    \midrule
    宋体    & \texttt{simsun.ttc} & SimSun & {\jfontspec{SimSun}我能吞下玻璃而不伤身体} \\
    黑体    & \texttt{simhei.ttf} & SimHei & {\jfontspec{SimHei}我能吞下玻璃而不伤身体} \\
    楷体    & \texttt{simkai.ttf} & KaiTi & {\jfontspec{KaiTi}我能吞下玻璃而不伤身体} \\
    仿宋    & \texttt{simkai.ttf} & FangSong & {\jfontspec{FangSong}我能吞下玻璃而不伤身体} \\
    \bottomrule
    \end{tabular}%
\end{table}%

\subsection{Adobe字体系列}
在Adobe Reader简体中文版中,附带了宋体和黑体两种字体。
这两种字体实际上是华文字体,但是和华文字体不能混用,
因为Adobe Reader中的中文字体的基线都进行了调整,
不能互相匹配。在Adobe InDesign中还附带了楷体和仿宋体。
Adobe的中文字体的Postscript名即为文件名去掉后缀名。

\begin{table}[htbp]
  \centering
    \begin{tabular}{lll}
    \toprule
    \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{样例}} \\
    \midrule
    Adobe 宋体 Std & \texttt{AdobeSongStd-Light.otf} & {\jfontspec{AdobeSongStd-Light}我能吞下玻璃而不伤身体} \\
    Adobe 黑体 Std & \texttt{AdobeHeitiStd-Regular.otf} & {\jfontspec{AdobeHeitiStd-Regular}我能吞下玻璃而不伤身体} \\
    Adobe 楷体 Std & \texttt{AdobeKaitiStd-Regular.otf} & {\jfontspec{AdobeKaitiStd-Regular}我能吞下玻璃而不伤身体} \\
    Adobe 仿宋 Std & \texttt{AdobeFangsongStd-Regular.otf} & {\jfontspec{AdobeFangsongStd-Regular}我能吞下玻璃而不伤身体} \\
    \bottomrule
    \end{tabular}%
\end{table}%

\subsection{方正字体系列}
方正字体的来源有两种,第一种是使用方正的排版系统的时候会
安装到Windows系统的字体文件夹下,第二种是针对Linux系统
来说的,WPS for Linux附带了部分方正字体。

\begin{table}[htbp]
  \centering
    \begin{tabular}{llll}
    \toprule
    \multicolumn{1}{c}{\textbf{字体名}} & \multicolumn{1}{c}{\textbf{文件名}} & \multicolumn{1}{c}{\textbf{全名}} & \multicolumn{1}{c}{\textbf{样例}} \\
    \midrule
    方正书宋\_GBK & \texttt{FZSSK.TTF} & FZShuSong-Z01 & {\jfontspec{FZShuSong-Z01}我能吞下玻璃而不伤身体} \\
    方正小标宋\_GBK & \texttt{FZXBSK.TTF} & FZXiaoBiaoSong-B05 & {\jfontspec{FZXiaoBiaoSong-B05}我能吞下玻璃而不伤身体} \\
    方正黑体\_GBK & \texttt{FZHTK.TTF} & FZHei-B01 & {\jfontspec{FZHei-B01}我能吞下玻璃而不伤身体} \\
    方正楷体\_GBK & \texttt{FZKTK.TTF} & FZKai-Z03 & {\jfontspec{FZKai-Z03}我能吞下玻璃而不伤身体} \\
    方正仿宋\_GBK & \texttt{FZFSK.TTF} & FZFangSong-Z02 & {\jfontspec{FZFangSong-Z02}我能吞下玻璃而不伤身体} \\
    \bottomrule
    \end{tabular}%
\end{table}%
\end{document}