OSDN Git Service

jfm: new property "round_threshold" (only yoko direction now)
[luatex-ja/luatexja.git] / src / ltj-setwidth.lua
index 4dad2d2..0d684ef 100644 (file)
@@ -1,5 +1,5 @@
 --
--- src/ltj-setwidth.lua
+-- ltj-setwidth.lua
 --
 
 luatexja.load_module('base');      local ltjb = luatexja.base
@@ -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 <char_data.round_threshold then fwidth = fwidth * quot end
+   end
    local xo, yo = getoffsets(p)
    setoffsets(p, xo + char_data.align*(fwidth-pwidth) - fshift.left,
               yo - fshift.down);
@@ -188,8 +193,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
               0.5*(get_ascender(pf)-get_descender(pf)))
         end
       end
-      pwidth = ltju.get_vheight(pf, pc, met.size)
-      ascender = feir.vorigin[pc] and (feir.vorigin[pc] * met.size) or get_ascender(pf)
+      pwidth, ascender = feir.vheight[pc]*met.size, feir.vorigin[pc]*met.size
    end
    fwidth = fwidth or pwidth
    fshift.down = char_data.down; fshift.left = char_data.left