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