OSDN Git Service

added \ltjghostjachar
[luatex-ja/luatexja.git] / src / ltj-setwidth.lua
index 372a0e0..a407393 100644 (file)
@@ -33,7 +33,6 @@ local getoffsets = node.direct.getoffsets or function(n)
 
 local node_traverse_id = node.direct.traverse_id
 local node_traverse = node.direct.traverse
-local node_new = node.direct.new
 local node_copy = node.direct.copy
 local node_remove = node.direct.remove
 local node_tail = node.direct.tail
@@ -43,6 +42,7 @@ local set_attr = node.direct.set_attribute
 local node_insert_before = node.direct.insert_before
 local node_insert_after = node.direct.insert_after
 local round = tex.round
+local node_new = luatexja.dnode_new
 
 local id_glyph  = node.id 'glyph'
 local id_kern   = node.id 'kern'
@@ -76,6 +76,7 @@ do
    end
 end
 
+
 local ltjw = {} --export
 luatexja.setwidth = ltjw
 
@@ -114,7 +115,7 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir)
          setoffsets(p, xo - fshift.left, yo - kbl - fshift.down)
          return node_next(p), head, p
       elseif ht_diff >= 0 and dp_diff >=0 then -- rule
-         local box = node_new(id_rule,rule_subtype)
+         local box = node_new(id_rule, rule_subtype, p)
          local xo, yo = getoffsets(p)
          setoffsets(p, xo, yo - kbl - fshift.down)
          setwhd(box, 0, fheight - kbl, fdepth + kbl)
@@ -140,7 +141,7 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir)
    setoffsets(p, xo + char_data.align*(fwidth-pwidth) - fshift.left,
               yo - fshift.down);
    setnext(p, nil)
-   local box = node_new(id_hlist)
+   local box = node_new(id_hlist, nil, p)
    setwhd(box, fwidth, fheight, fdepth)
    setfield(box, 'head', p)
    setfield(box, 'shift', kbl)
@@ -170,7 +171,7 @@ local function capsule_glyph_tate_rot(p, met, char_data, head, dir, asc)
    setoffsets(p, xo + char_data.align*(fwidth-pwidth) - fshift.left,
               yo - fshift.down - asc);
    setnext(p, nil)
-   local box = node_new(id_hlist)
+   local box = node_new(id_hlist, nil, p)
    setwhd(box, fwidth, fheight, fdepth)
    setfield(box, 'head', p)
    setfield(box, 'shift', kbl)
@@ -189,14 +190,20 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
    do
       local pf, pc = getfont(p), getchar(p)
       local feir = ltjf_font_extra_info[pf]
-      if feir and feir.rotation and met.vert_activated then
-         if feir.rotation[pc] and (has_attr(p, attr_vert_ori) or 0)<=0 then
+      if met.rotation and met.vert_activated then
+          local f = font_getfont(pf)
+          local r, l = met.rotation[pc], f.properties and f.properties.language
+          if ((r==true) or (type(r)=="table" and not r[l])) and (has_attr(p, attr_vert_ori) or 0)<=0 then
             return capsule_glyph_tate_rot(p, met, char_data, head, dir, 
               0.5*(get_ascender(pf)-get_descender(pf)))
-         end
-     end
-     pwidth, ascender = feir.vheight[pc]*met.size, feir.vorigin[pc]*met.size
+          end
+      end
+      pwidth, ascender = feir.vheight[pc]*met.size, feir.vorigin[pc]*met.size
+     -- print(pwidth/65536.,ascender/65536.)
    end
+   -- luatexja.ext_show_node(node.direct.tonode(p), 'B> ', print)
+   local xo, yo = getoffsets(p)
+   --pwidth = pwidth - yo
    fwidth = fwidth or pwidth
    if pwidth>fwidth and char_data.round_threshold then
       local frac = pwidth / fwidth
@@ -207,15 +214,14 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
    fshift = call_callback("luatexja.set_width", fshift, met, char_data)
    local fheight = char_data.height or 0
    local fdepth  = char_data.depth or 0
-   local xo, yo = getoffsets(p)
    local y_shift = xo + (has_attr(p,attr_tkblshift) or 0)
    local q
    head, q = node_remove(head, p)
-   local box = node_new(id_hlist)
+   local box = node_new(id_hlist, nil, p)
    setwhd(box, fwidth, fheight, fdepth)
    setfield(box, 'shift', y_shift)
    setdir(box, dir)
-
+   -- print(yo, ascender, char_data.align, fwidth-pwidth)
    setoffsets(p, -fshift.down,
               yo -(ascender + char_data.align*(fwidth-pwidth) - fshift.left) )
    local ws = node_new(id_whatsit, sid_save)
@@ -231,6 +237,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
    setnext(k3, wr);
 
    set_attr(box, attr_icflag, PACKED)
+   -- luatexja.ext_show_node(node.direct.tonode(box), 'A> ', print)
    head = q and node_insert_before(head, q, box)
       or node_insert_after(head, node_tail(head), box)
    return q, head, box
@@ -248,7 +255,7 @@ local function capsule_glyph_math(p, met, char_data)
       = - getfield(p, 'yoffset') + (has_attr(p,attr_ykblshift) or 0)
    setfield(p, 'yoffset', -fshift.down)
    setfield(p, 'xoffset', getfield(p, 'xoffset') + char_data.align*(fwidth-pwidth) - fshift.left)
-   local box = node_new(id_hlist);
+   local box = node_new(id_hlist, nil, p);
    setwhd(box, fwidth, fheight, fdepth)
    setfield(box, 'head', p)
    setfield(box, 'shift', y_shift)
@@ -301,7 +308,7 @@ do
          setfield(lp, 'yoffset', getfield(lp, 'yoffset') - y_adjust)
       end
       if adj_depth>node_depth then
-         local r = node_new(id_rule,rule_subtype)
+         local r = node_new(id_rule,rule_subtype, head)
          setwhd(r, 0, 0, adj_depth); setdir(r, tex_dir)
          set_attr(r, attr_icflag, PROCESSED)
          if field=='post' then