From bf31041b7c358d12f4a50fa1df10a8ca3ff28e83 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Tue, 21 Apr 2020 12:23:14 +0900 Subject: [PATCH] jfm: new property "round_threshold" (only yoko direction now) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 文字クラス 0 でしか指定できない数値. もしこの数値 d が指定されており,かつ文字クラス 0 の文字 p に対して q = p.width / (JFM で指定された文字クラス 0 の文字の幅)が 整数から ±d 未満の範囲に収まっていたとしたら, 「JFM で指定された文字の幅」を q に最も近い整数倍にして処理する. 主な適用対象は #40431 で報告されたような「私用領域にある n 倍角の合字」. なお「ちょうど整数倍しか許さない」と 0 を指定するのは現実的ではない (sp 単位で計算することによる誤差が考えられるため). jfm-ujis.lua で指定した 0.01 とか,ひょっとしたら 0.001 とかが適当な値か? --- src/jfm-ujis.lua | 1 + src/ltj-jfont.lua | 7 +++++-- src/ltj-setwidth.lua | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/jfm-ujis.lua b/src/jfm-ujis.lua index 10b44d8..0d5da01 100644 --- a/src/jfm-ujis.lua +++ b/src/jfm-ujis.lua @@ -28,6 +28,7 @@ local t = { [8] = { 0, 0, 0, kanjiskip_shrink=1 }, }, kern = { [307] = 0 }, + round_threshold = 0.01, }, [1] = { -- 開き括弧類 diff --git a/src/ltj-jfont.lua b/src/ltj-jfont.lua index 2d73f5c..8d1ddc3 100644 --- a/src/ltj-jfont.lua +++ b/src/ltj-jfont.lua @@ -108,6 +108,8 @@ function luatexja.jfont.define_jfm(to) if type(v.down)~='number' then v.down = 0.0 end + v.round_threshold = ((t.version>=3)and(i==0)and(type(v.round_threshold)=='number')) + and v.round_threshold or nil if t.version>=2 then if v.end_stretch then defjfm_res= nil; return end if v.end_shrink then defjfm_res= nil; return end @@ -218,7 +220,8 @@ do width = w[1], stretch = w[2], shrink = w[3], kanjiskip_natural = w.kanjiskip_natural and w.kanjiskip_natural/sz, kanjiskip_stretch = w.kanjiskip_stretch and w.kanjiskip_stretch/sz, - kanjiskip_shrink = w.kanjiskip_shrink and w.kanjiskip_shrink/sz, + kanjiskip_shrink = w.kanjiskip_shrink and w.kanjiskip_shrink/sz, + round_threshold = w.round_threshold and w.round_threshold/zw, } end for k,w in pairs(v.kern) do @@ -331,7 +334,7 @@ do local fmtable = { jfm = j, size = f.size, var = jfm_var, with_kanjiskip = jfm_ksp, zw = sz.zw, zh = sz.zh, - chars = sz.chars, char_type = sz.char_type, + chars = sz.chars, char_type = sz.char_type, kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip, chars_cbcache = {}, vert_activated = vert_activated, diff --git a/src/ltj-setwidth.lua b/src/ltj-setwidth.lua index f21c005..0d684ef 100644 --- a/src/ltj-setwidth.lua +++ b/src/ltj-setwidth.lua @@ -87,7 +87,7 @@ local call_callback = luatexbase.call_callback local fshift = { down = 0, left = 0 } -local min, max = math.min, math.max +local min, max, floor, abs = math.min, math.max, math.floor, math.abs local rule_subtype = (status.luatex_version>=85) and 3 or 0 @@ -129,6 +129,11 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir) local q head, q = node_remove(head, p) + if char_data.round_threshold then + local frac = abs(pwidth / fwidth); + local quot = floor(frac) + if frac-quot