OSDN Git Service

6c36bc24942786193e0c0aba7cd75d3a7a073ef0
[luatex-ja/luatexja.git] / src / jfm-zh_CN.lua
1 local is_vt, is_qj, is_bj, is_km, is_hwcl
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     is_hwcl = luatexja.jfont.jfm_feature.hwcl
9 end
10
11 if is_hwcl then
12     if not is_vt then
13         tex.error('JFM feature "hwcl" can only be used in vertical mode')
14     end
15 end
16
17 if
18     not ((is_qj and not (is_bj or is_km)) or (is_bj and not (is_qj or is_km)) or
19         (is_km and not (is_qj or is_bj)))
20  then
21     tex.error(
22         'You must specify ONLY ONE feature among "quanjiao", "banjiao" and ' ..
23             '"kaiming"'
24     )
25 end
26
27 local function aki(wd, pr, km)
28     -- 插入空白量
29     local p = pr or 0
30     return km and
31         (is_bj and {0, wd, 0, priority = {p, -p}} or
32             {wd, 0, wd, priority = {p, -p}}) or
33         (is_qj and {wd, 0, wd, priority = {p, -p}} or
34             {0, wd, 0, priority = {p, -p}})
35 end
36
37 luatexja.jfont.define_jfm {
38     version = 3,
39     dir = is_vt and 'tate' or 'yoko',
40     zw = 1,
41     zh = 1,
42     kanjiskip = {0.0, 0.25, 0},
43     xkanjiskip = {0.25, 0.25, 0.125},
44     [0] = {
45         align = 'middle',
46         left = 0,
47         down = 0,
48         width = 1,
49         height = is_vt and 0.5 or 0.88,
50         depth = is_vt and 0.5 or 0.12,
51         italic = 0,
52         glue = {
53             [1] = aki(0.5, -1),
54             [3] = aki(0.25, -1)
55         }
56     },
57     [1] = {
58         -- 开括号
59         chars = {
60             '‘',
61             '“',
62             '〈',
63             '《',
64             '「',
65             '『',
66             '【',
67             '〔',
68             '〖',
69             '〘',
70             '〝',
71             '(',
72             '[',
73             '{',
74             '⦅'
75         },
76         align = 'right',
77         left = 0,
78         down = 0,
79         width = 0.5,
80         height = is_vt and 0.5 or 0.88,
81         depth = is_vt and 0.5 or 0.12,
82         italic = 0,
83         glue = {
84             [3] = aki(0.25, -1)
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             [3] = aki(0.5, -1),
118             [5] = aki(0.5, -1),
119             [51] = aki(0.5, -1),
120             [52] = aki(0.5, -1)
121         }
122     },
123     [21] = {
124         -- 逗号、顿号
125         chars = {'、', ','},
126         align = 'left',
127         left = 0,
128         down = 0,
129         width = 0.5,
130         height = is_vt and 0.5 or 0.88,
131         depth = is_vt and 0.5 or 0.12,
132         italic = 0,
133         glue = {
134             [0] = aki(0.5),
135             [1] = aki(0.5),
136             [3] = aki(0.5),
137             [5] = aki(0.5),
138             [51] = aki(0.5),
139             [52] = aki(0.5)
140         }
141     },
142     [22] = {
143         -- 冒号、分号
144         chars = {':', ';'},
145         align = 'left',
146         left = 0,
147         down = 0,
148         width = is_vt and (is_hwcl and 0.5 or 1) or 0.5,
149         height = is_vt and 0.5 or 0.88,
150         depth = is_vt and 0.5 or 0.12,
151         italic = 0,
152         glue = {
153             [0] = is_vt and (is_hwcl and aki(0.5) or {}) or aki(0.5),
154             [1] = is_vt and (is_hwcl and aki(0.5) or {}) or aki(0.5),
155             [3] = is_vt and (is_hwcl and aki(0.5) or aki(0.25, 1)) or aki(0.5),
156             [5] = is_vt and (is_hwcl and aki(0.5) or {}) or aki(0.5),
157             [51] = is_vt and (is_hwcl and aki(0.5) or {}) or aki(0.5),
158             [52] = is_vt and (is_hwcl and aki(0.5) or {}) or aki(0.5)
159         }
160     },
161     [3] = {
162         -- 间隔号
163         chars = {'・', '·'},
164         align = 'middle',
165         left = 0,
166         down = 0,
167         width = 0.5,
168         height = is_vt and 0.5 or 0.88,
169         depth = is_vt and 0.5 or 0.12,
170         italic = 0,
171         glue = {
172             [0] = aki(0.25, -1),
173             [1] = aki(0.5, -1),
174             [2] = aki(0.25, -1),
175             [21] = aki(0.25, -1),
176             [22] = aki(0.25, -1),
177             [3] = aki(0.5, -1),
178             [4] = aki(0.25, -1),
179             [41] = aki(0.25, -1),
180             [42] = aki(0.25, -1),
181             [5] = aki(0.25, -1)
182         }
183     },
184     [4] = {
185         -- 句号
186         chars = {'。', '.'},
187         align = 'left',
188         left = 0,
189         down = 0,
190         width = 0.5,
191         height = is_vt and 0.5 or 0.88,
192         depth = is_vt and 0.5 or 0.12,
193         italic = 0,
194         glue = {
195             [0] = aki(0.5, 1, true),
196             [1] = aki(0.5, 1, true),
197             [3] = aki(0.5, 1, true),
198             [5] = aki(0.5, 1, true),
199             [51] = aki(0.5, 1, true),
200             [52] = aki(0.5, 1, true)
201         }
202     },
203     [41] = {
204         -- 叹号、问号
205         chars = {'!', '?'},
206         align = is_vt and 'middle' or 'left',
207         left = 0,
208         down = 0,
209         width = is_vt and 1 or 0.5,
210         height = is_vt and 0.5 or 0.88,
211         depth = is_vt and 0.5 or 0.12,
212         italic = 0,
213         glue = {
214             [0] = is_vt and {} or aki(0.5, 1, true),
215             [1] = is_vt and {} or aki(0.5, 1, true),
216             [3] = is_vt and aki(0.25, -1) or aki(0.5, 1, true),
217             [5] = is_vt and {} or aki(0.5, 1, true),
218             [51] = is_vt and {} or aki(0.5, 1, true),
219             [52] = is_vt and {} or aki(0.5, 1, true)
220         }
221     },
222     [42] = {
223         -- 复合/连用叹号问号
224         chars = {'‼', '⁇', '⁈', '⁉'},
225         align = 'middle',
226         left = 0,
227         down = 0,
228         width = 1,
229         height = is_vt and 0.5 or 0.88,
230         depth = is_vt and 0.5 or 0.12,
231         italic = 0,
232         glue = {
233             [3] = aki(0.25, -1)
234         }
235     },
236     [5] = {
237         -- 一字线、省略号、波浪线
238         chars = {
239             '—', -- U+2014
240             '―', -- U+2015
241             '‥',
242             '…',
243             '〜', -- U+301C
244             '~' -- U+FF5E
245         },
246         align = 'middle',
247         left = 0,
248         down = 0,
249         width = 1,
250         height = is_vt and 0.5 or 0.88,
251         depth = is_vt and 0.5 or 0.12,
252         italic = 0,
253         glue = {
254             [1] = aki(0.5, -1),
255             [3] = aki(0.25, -1)
256         },
257         kern = {
258             [5] = 0,
259             [51] = 0,
260             [52] = 0
261         }
262     },
263     [51] = {
264         -- U+2E3A TWO-EM DASH
265         chars = {'⸺'},
266         align = 'middle',
267         left = 0,
268         down = 0,
269         width = 2,
270         height = is_vt and 0.5 or 0.88,
271         depth = is_vt and 0.5 or 0.12,
272         italic = 0,
273         glue = {
274             [1] = aki(0.5, -1),
275             [3] = aki(0.25, -1)
276         },
277         kern = {
278             [5] = 0,
279             [51] = 0,
280             [52] = 0
281         }
282     },
283     [52] = {
284         -- U+2E3B THREE-EM DASH
285         chars = {'⸻'},
286         align = 'middle',
287         left = 0,
288         down = 0,
289         width = 3,
290         height = is_vt and 0.5 or 0.88,
291         depth = is_vt and 0.5 or 0.12,
292         italic = 0,
293         glue = {
294             [1] = aki(0.5, -1),
295             [3] = aki(0.25, -1)
296         },
297         kern = {
298             [5] = 0,
299             [51] = 0,
300             [52] = 0
301         }
302     },
303     [6] = {
304         -- box end
305         chars = {'boxbdd', 'parbdd', 'glue'}
306     }
307 }