リビジョン | bf31041b7c358d12f4a50fa1df10a8ca3ff28e83 (tree) |
---|---|
日時 | 2020-04-21 12:23:14 |
作者 | Hironori Kitagawa <h_kitagawa2001@yaho...> |
コミッター | Hironori Kitagawa |
jfm: new property "round_threshold" (only yoko direction now)
@@ -28,6 +28,7 @@ local t = { | ||
28 | 28 | [8] = { 0, 0, 0, kanjiskip_shrink=1 }, |
29 | 29 | }, |
30 | 30 | kern = { [307] = 0 }, |
31 | + round_threshold = 0.01, | |
31 | 32 | }, |
32 | 33 | |
33 | 34 | [1] = { -- 開き括弧類 |
@@ -108,6 +108,8 @@ function luatexja.jfont.define_jfm(to) | ||
108 | 108 | if type(v.down)~='number' then |
109 | 109 | v.down = 0.0 |
110 | 110 | end |
111 | + v.round_threshold = ((t.version>=3)and(i==0)and(type(v.round_threshold)=='number')) | |
112 | + and v.round_threshold or nil | |
111 | 113 | if t.version>=2 then |
112 | 114 | if v.end_stretch then defjfm_res= nil; return end |
113 | 115 | if v.end_shrink then defjfm_res= nil; return end |
@@ -218,7 +220,8 @@ do | ||
218 | 220 | width = w[1], stretch = w[2], shrink = w[3], |
219 | 221 | kanjiskip_natural = w.kanjiskip_natural and w.kanjiskip_natural/sz, |
220 | 222 | kanjiskip_stretch = w.kanjiskip_stretch and w.kanjiskip_stretch/sz, |
221 | - kanjiskip_shrink = w.kanjiskip_shrink and w.kanjiskip_shrink/sz, | |
223 | + kanjiskip_shrink = w.kanjiskip_shrink and w.kanjiskip_shrink/sz, | |
224 | + round_threshold = w.round_threshold and w.round_threshold/zw, | |
222 | 225 | } |
223 | 226 | end |
224 | 227 | for k,w in pairs(v.kern) do |
@@ -331,7 +334,7 @@ do | ||
331 | 334 | local fmtable = { jfm = j, size = f.size, var = jfm_var, |
332 | 335 | with_kanjiskip = jfm_ksp, |
333 | 336 | zw = sz.zw, zh = sz.zh, |
334 | - chars = sz.chars, char_type = sz.char_type, | |
337 | + chars = sz.chars, char_type = sz.char_type, | |
335 | 338 | kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip, |
336 | 339 | chars_cbcache = {}, |
337 | 340 | vert_activated = vert_activated, |
@@ -87,7 +87,7 @@ local call_callback = luatexbase.call_callback | ||
87 | 87 | |
88 | 88 | local fshift = { down = 0, left = 0 } |
89 | 89 | |
90 | -local min, max = math.min, math.max | |
90 | +local min, max, floor, abs = math.min, math.max, math.floor, math.abs | |
91 | 91 | |
92 | 92 | local rule_subtype = (status.luatex_version>=85) and 3 or 0 |
93 | 93 |
@@ -129,6 +129,11 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir) | ||
129 | 129 | |
130 | 130 | local q |
131 | 131 | head, q = node_remove(head, p) |
132 | + if char_data.round_threshold then | |
133 | + local frac = abs(pwidth / fwidth); | |
134 | + local quot = floor(frac) | |
135 | + if frac-quot <char_data.round_threshold then fwidth = fwidth * quot end | |
136 | + end | |
132 | 137 | local xo, yo = getoffsets(p) |
133 | 138 | setoffsets(p, xo + char_data.align*(fwidth-pwidth) - fshift.left, |
134 | 139 | yo - fshift.down); |