--- local ti =
- p.xoffset= p.xoffset - fshift.left
- if mode or p.width ~= fwidth or p.height ~= fheight or p.depth ~= fdepth then
- local y_shift = - p.yoffset + (has_attr(p,attr_yablshift) or 0)
- p.yoffset = -fshift.down
- head, q = node.remove(head, p)
- local total = fwidth - p.width
- if total == 0 then
- h = p; p.next = nil
- else
- h = node_new(id_kern); h.subtype = 0
- if char_data.align=='right' then
- h.kern = total; p.next = nil; h.next = p
- elseif char_data.align=='middle' then
- h.kern = round(total/2); p.next = h
- h = node_new(id_kern); h.subtype = 0
- h.kern = total - round(total/2); h.next = p
- else -- left
- h.kern = total; p.next = h; h = p
- end
- end
- box = node_new(id_hlist);
- box.width = fwidth; box.height = fheight; box.depth = fdepth
- box.glue_set = 0; box.glue_order = 0; box.head = h
- box.shift = y_shift; box.dir = dir or 'TLT'
- set_attr(box, attr_icflag, PACKED)
- set_attr(box, attr_uniqid, has_attr(p, attr_uniqid) or 0)
- if q then
- head = node_insert_before(head, q, box)
+ if (mode or pwidth ~= fwidth or p.height ~= fheight or p.depth ~= fdepth) then
+ local y_shift, ca
+ = - p.yoffset + (has_attr(p,attr_ykblshift) or 0), char_data.align
+ local q; head, q = node.remove(head, p)
+ p.yoffset, p.next = -fshift.down, nil
+ if total ~= 0 and ca~='left' then
+ p.xoffset = p.xoffset - fshift.left
+ + (((ca=='right') and fwidth - pwidth) or round((fwidth - pwidth)*0.5))