Debian Codegraph @

texmf-dist/tex/luatex/chinese-jfm/jfm-zh_TW.lua

raw
1 -- Chinese JFM for Traditional Chinese fonts (zh_TW)
2 -- v1.1.1, 2021/02/15
3 -- Copyright (c) 2020 -- 2021 ListLee.
4
5 local is_vt, is_qj, is_bj, is_km
6
7 if luatexja.jfont.jfm_feature then
8 is_vt = luatexja.jfont.jfm_feature.vert
9 is_qj = luatexja.jfont.jfm_feature.quanjiao
10 is_bj = luatexja.jfont.jfm_feature.banjiao
11 is_km = luatexja.jfont.jfm_feature.kaiming
12 end
13
14 if
15 not ((is_qj and not (is_bj or is_km)) or (is_bj and not (is_qj or is_km)) or
16 (is_km and not (is_qj or is_bj)))
17 then
18 tex.error(
19 'You must specify ONLY ONE feature among "quanjiao", "banjiao" and ' ..
20 '"kaiming"'
21 )
22 end
23
24 local function aki(wd, pr, km)
25 -- 插入空白量
26 local p = pr or 0
27 return km and
28 (is_bj and {0, wd, 0, priority = {p, -p}} or
29 {wd, 0, wd, priority = {p, -p}}) or
30 (is_qj and {wd, 0, wd, priority = {p, -p}} or
31 {0, wd, 0, priority = {p, -p}})
32 end
33
34 luatexja.jfont.define_jfm {
35 version = 3,
36 dir = is_vt and 'tate' or 'yoko',
37 zw = 1,
38 zh = 1,
39 kanjiskip = {0.0, 0.25, 0},
40 xkanjiskip = {0.25, 0.25, .125},
41 [0] = {
42 align = 'middle',
43 left = 0,
44 down = 0,
45 width = 1,
46 height = is_vt and 0.5 or 0.88,
47 depth = is_vt and 0.5 or 0.12,
48 italic = 0,
49 glue = {
50 [1] = aki(0.5, -1),
51 [21] = aki(0.25),
52 [22] = is_vt and {} or aki(0.25),
53 [3] = aki(0.25, -1),
54 [4] = aki(0.25, 1, true)
55 },
56 round_threshold = 0.01
57 },
58 [1] = {
59 -- 开括号
60 chars = {
61 '‘',
62 '“',
63 '〈',
64 '《',
65 '「',
66 '『',
67 '【',
68 '〔',
69 '〖',
70 '〘',
71 '〝',
72 '(',
73 '[',
74 '{',
75 '⦅'
76 },
77 align = 'right',
78 left = 0,
79 down = 0,
80 width = 0.5,
81 height = is_vt and 0.5 or 0.88,
82 depth = is_vt and 0.5 or 0.12,
83 italic = 0,
84 glue = {
85 [21] = aki(0.25),
86 [22] = is_vt and {} or aki(0.25),
87 [3] = aki(0.25, -1),
88 [4] = aki(0.25, 1, true)
89 }
90 },
91 [2] = {
92 -- 闭括号
93 chars = {
94 '’',
95 '”',
96 '〉',
97 '》',
98 '」',
99 '』',
100 '】',
101 '〕',
102 '〗',
103 '〙',
104 '〞',
105 '〟',
106 ')',
107 ']',
108 '}',
109 '⦆'
110 },
111 align = 'left',
112 left = 0,
113 down = 0,
114 width = 0.5,
115 height = is_vt and 0.5 or 0.88,
116 depth = is_vt and 0.5 or 0.12,
117 italic = 0,
118 glue = {
119 [0] = aki(0.5, -1),
120 [1] = aki(0.5, -1),
121 [21] = aki(0.25),
122 [22] = is_vt and {} or aki(0.25),
123 [3] = aki(0.25, -1),
124 [4] = aki(0.25, 1, true),
125 [5] = aki(0.25, -1),
126 [51] = aki(0.25, -1),
127 [52] = aki(0.25, -1)
128 }
129 },
130 [21] = {
131 -- 逗号、顿号
132 chars = {'、', ','},
133 align = 'middle',
134 left = 0,
135 down = 0,
136 width = 0.5,
137 height = is_vt and 0.5 or 0.88,
138 depth = is_vt and 0.5 or 0.12,
139 italic = 0,
140 glue = {
141 [0] = aki(0.25),
142 [1] = aki(0.25),
143 [2] = aki(0.25),
144 [21] = aki(0.5),
145 [22] = is_vt and aki(0.5) or aki(0.25),
146 [3] = aki(0.5, -1),
147 [4] = is_qj and {0.5, 0, 0.5, priority = {1, -1}} or
148 (is_bj and {0, 0.5, 0, priority = {1, -1}} or
149 {0.25, 0.25, 0.25, priority = {1, -1}}),
150 [41] = aki(0.25),
151 [5] = aki(0.25),
152 [51] = aki(0.25),
153 [52] = aki(0.25),
154 [6] = aki(0.25)
155 }
156 },
157 [22] = {
158 -- 冒号、分号
159 chars = {':', ';'},
160 align = 'middle',
161 left = 0,
162 down = 0,
163 width = is_vt and 1 or 0.5,
164 height = is_vt and 0.5 or 0.88,
165 depth = is_vt and 0.5 or 0.12,
166 italic = 0,
167 glue = {
168 [0] = is_vt and {} or aki(0.25),
169 [1] = is_vt and {} or aki(0.25),
170 [2] = is_vt and {} or aki(0.25),
171 [21] = is_vt and aki(0.25) or aki(0.5),
172 [22] = is_vt and {} or aki(0.5),
173 [3] = is_vt and aki(0.25, -1) or aki(0.5, -1),
174 [4] = is_vt and aki(0.25, 1, true) or
175 (is_qj and {0.5, 0, 0.5, priority = {1, -1}} or
176 (is_bj and {0, 0.5, 0, priority = {1, -1}} or
177 {0.25, 0.25, 0.25, priority = {1, -1}})),
178 [41] = is_vt and {} or aki(0.25),
179 [5] = is_vt and {} or aki(0.25),
180 [51] = is_vt and {} or aki(0.25),
181 [52] = is_vt and {} or aki(0.25),
182 [6] = is_vt and {} or aki(0.25)
183 }
184 },
185 [3] = {
186 -- 间隔号
187 chars = {'・', '·'},
188 align = 'middle',
189 left = 0,
190 down = 0,
191 width = 0.5,
192 height = is_vt and 0.5 or 0.88,
193 depth = is_vt and 0.5 or 0.12,
194 italic = 0,
195 glue = {
196 [0] = aki(0.25, -1),
197 [1] = aki(0.25, -1),
198 [2] = aki(0.25, -1),
199 [21] = aki(0.5, -1),
200 [22] = is_vt and aki(0.25, -1) or aki(0.5, -1),
201 [3] = aki(0.5, 1),
202 [4] = is_qj and {0.5, 0, 0.5, priority = {1, -1}} or
203 (is_bj and {0, 0.5, 0, priority = {1, -1}} or
204 {0.25, 0.25, 0.25, priority = {1, -1}}),
205 [41] = aki(0.25, -1),
206 [5] = aki(0.25, -1),
207 [51] = aki(0.25, -1),
208 [52] = aki(0.25, -1),
209 [6] = aki(0.25, -1)
210 }
211 },
212 [4] = {
213 -- 句号
214 chars = {'。', '.'},
215 align = 'middle',
216 left = 0,
217 down = 0,
218 width = 0.5,
219 height = is_vt and 0.5 or 0.88,
220 depth = is_vt and 0.5 or 0.12,
221 italic = 0,
222 glue = {
223 [0] = aki(0.25, 1, true),
224 [1] = aki(0.25, 1, true),
225 [2] = aki(0.25, 1, true),
226 [21] = aki(0.5, 1, true),
227 [22] = is_vt and aki(0.25, 1, true) or aki(0.5, 1, true),
228 [3] = is_qj and {0.5, 0, 0.5, priority = {1, -1}} or
229 (is_bj and {0, 0.5, 0, priority = {1, -1}} or
230 {0.25, 0.25, 0.25, priority = {1, -1}}),
231 [4] = is_qj and {0.5, 0, 0.5, priority = {1, -1}} or
232 (is_bj and {0, 0.5, 0, priority = {1, -1}} or
233 {0.25, 0.25, 0.25, priority = {1, -1}}),
234 [41] = aki(0.25, 1, true),
235 [5] = aki(0.25, 1, true),
236 [51] = aki(0.25, 1, true),
237 [52] = aki(0.25, 1, true),
238 [6] = aki(0.25, 1, true)
239 }
240 },
241 [41] = {
242 -- 问号、感叹号
243 chars = {'?', '!', '‼', '⁇', '⁈', '⁉'},
244 align = 'middle',
245 left = 0,
246 down = 0,
247 width = 1,
248 height = is_vt and 0.5 or 0.88,
249 depth = is_vt and 0.5 or 0.12,
250 italic = 0,
251 glue = {
252 [21] = aki(0.25),
253 [22] = is_vt and {} or aki(0.25),
254 [3] = aki(0.25, -1),
255 [4] = aki(0.25, 1, true)
256 }
257 },
258 [5] = {
259 -- 一字线、省略号、波浪线
260 chars = {
261 '—', -- U+2014
262 '―', -- U+2015
263 '‥',
264 '…',
265 '〜', -- U+301C
266 '~' -- U+FF5E
267 },
268 align = 'middle',
269 left = 0,
270 down = 0,
271 width = 1,
272 height = is_vt and 0.5 or 0.88,
273 depth = is_vt and 0.5 or 0.12,
274 italic = 0,
275 glue = {
276 [1] = aki(0.5, -1),
277 [21] = aki(0.25),
278 [22] = is_vt and {} or aki(0.25),
279 [3] = aki(0.25, -1),
280 [4] = aki(0.25, -1, true)
281 },
282 kern = {
283 [5] = 0,
284 [51] = 0,
285 [52] = 0
286 }
287 },
288 [51] = {
289 -- U+2E3A TWO-EM DASH
290 chars = {'⸺'},
291 align = 'middle',
292 left = 0,
293 down = 0,
294 width = 2,
295 height = is_vt and 0.5 or 0.88,
296 depth = is_vt and 0.5 or 0.12,
297 italic = 0,
298 glue = {
299 [1] = aki(0.5, -1),
300 [21] = aki(0.25),
301 [22] = is_vt and {} or aki(0.25),
302 [3] = aki(0.25, -1),
303 [4] = aki(0.25, -1, true)
304 },
305 kern = {
306 [5] = 0,
307 [51] = 0,
308 [52] = 0
309 }
310 },
311 [52] = {
312 -- U+2E3B THREE-EM DASH
313 chars = {'⸻'},
314 align = 'middle',
315 left = 0,
316 down = 0,
317 width = 3,
318 height = is_vt and 0.5 or 0.88,
319 depth = is_vt and 0.5 or 0.12,
320 italic = 0,
321 glue = {
322 [1] = aki(0.5, -1),
323 [21] = aki(0.25),
324 [22] = is_vt and {} or aki(0.25),
325 [3] = aki(0.25, -1),
326 [4] = aki(0.25, -1, true)
327 },
328 kern = {
329 [5] = 0,
330 [51] = 0,
331 [52] = 0
332 }
333 },
334 [6] = {
335 -- box end
336 chars = {'boxbdd', 'parbdd', 'glue'},
337 glue = {
338 [21] = aki(0.25),
339 [22] = is_vt and {} or aki(0.25),
340 [3] = aki(0.25, -1),
341 [4] = aki(0.25, 1, true)
342 }
343 }
344 }