OSDN Git Service

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