return false-- それ以外は対象外.
end
local xk = ltjf_font_metric_table[getfont(xc)]
- xk = xk.char_type[has_attr(xc, attr_jchar_class) or 0]
- xk = xk['end_' .. res.name] or 0
+ .char_type[has_attr(xc, attr_jchar_class) or 0]['end_' .. res.name] or 0
if xk>0 and total>=xk then
total = total - xk
local kn = node_new(id_kern)
setfield(kn, 'kern', (res.name=='shrink' and -1 or 1) * xk)
set_attr(kn, attr_icflag, FROM_JFM)
- insert_after(head, x, kn)
+ insert_after(p, x, kn)
return true
else return false
end
return check_next_ickern(lp)
end
-
+local ltjw_apply_ashift_math = ltjw.apply_ashift_math
local function calc_np_aux_glyph_common(lp)
Np.nuc = lp
local npi = (getfont(lp) == (has_attr(lp, attr_curjfnt) or -1))
Np.first, Np.nuc = (Np.first or lp), lp;
set_attr(lp, attr_icflag, PROCESSED)
set_np_xspc_alchar(Np, -1, lp)
- lp = node_end_of_math(lp)
- set_attr(lp, attr_icflag, PROCESSED)
- Np.last, Np.id = lp, id_math;
- return true, node_next(lp);
+ local end_math = node_end_of_math(lp)
+ ltjw_apply_ashift_math(lp, end_math, attr_ablshift)
+ set_attr(end_math, attr_icflag, PROCESSED)
+ Np.last, Np.id = end_math, id_math;
+ return true, node_next(end_math);
end,
discglue = function(lp)
Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
local m = ltjf_font_metric_table[getfont(x)]
local cls, c = slow_find_char_class(has_attr(x, attr_orig_char), m, getchar(x))
Nx.met, Nx.char = m, c; Nx.class = cls;
- --if cls~=0 then set_attr(x, attr_jchar_class, cls) end
+ if cls~=0 then set_attr(x, attr_jchar_class, cls) end
Nx.pre = table_current_stack[PRE + c] or 0
Nx.post = table_current_stack[POST + c] or 0
Nx.xspc = table_current_stack[XSP + c] or 3
cls = ltjf_find_char_class(c, m)
if cls==0 then cls = slow_find_char_class(c2, m, c1) end
Nx.met, Nx.char = m, c; Nx.class = cls;
- --if cls~=0 then set_attr(x, attr_jchar_class, cls) end
+ if cls~=0 then set_attr(x, attr_jchar_class, cls) end
Nx.pre = table_current_stack[PRE + c] or 0
Nx.post = table_current_stack[POST + c] or 0
Nx.xspc = table_current_stack[XSP + c] or 3
local sid_matrix = node.subtype('pdf_setmatrix')
local dir_tate = luatexja.dir_table.dir_tate
-local attr_jchar_class = luatexbase.attributes['ltj@charclass']
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
-local attr_yablshift = luatexbase.attributes['ltj@yablshift']
local attr_ykblshift = luatexbase.attributes['ltj@ykblshift']
-local attr_tablshift = luatexbase.attributes['ltj@tablshift']
local attr_tkblshift = luatexbase.attributes['ltj@tkblshift']
local attr_icflag = luatexbase.attributes['ltj@icflag']
setfield(box, 'shift', y_shift)
setfield(box, 'dir', dir)
- --local k1 = node_new(id_kern)
- --setfield(k1, 'kern',
- -- getfield(p, 'xoffset') + ascent
- -- + char_data.align*(fwidth-pwidth) - fshift.left)
setfield(p, 'xoffset', -fshift.down)
setfield(p, 'yoffset', - (getfield(p, 'xoffset') + ascent
+ char_data.align*(fwidth-pwidth) - fshift.left) )
local k2 = node_new(id_kern); setfield(k2, 'kern', - 0.5*getfield(p, 'width'))
local k3 = node_copy(k2)
local wr = node_new(id_whatsit, sid_restore)
- --setfield(box, 'head', k1); setfield(k1, 'next', ws)
setfield(box, 'head', ws)
setfield(ws, 'next', wm); setfield(wm, 'next', k2);
setfield(k2, 'next', p); setfield(p, 'next', k3);
end
luatexja.setwidth.capsule_glyph_math = capsule_glyph_math
-local tex_set_attr = tex.setattribute
-function luatexja.setwidth.set_ja_width(head)
- local attr_ablshift = (ltjs.list_dir==dir_tate) and attr_tablshift or attr_yablshift
- for m in node_traverse_id(id_math, head) do
- if getsubtype(m)==0 then
- -- 数式の位置補正
- for p in node_traverse(m) do
- local pid = getid(p)
- if pid==id_math and getsubtype(p)==1 then
- break
- elseif pid==id_hlist or pid==id_vlist then
- if (has_attr(p, attr_icflag) or 0) ~= PROCESSED then
- setfield(p, 'shift', getfield(p, 'shift') + (has_attr(p,attr_ablshift) or 0))
- end
- elseif pid==id_rule then
- if (has_attr(p, attr_icflag) or 0) ~= PROCESSED then
- local v = has_attr(p,attr_yablshift) or 0
- setfield(p, 'height', getfield(p, 'height')-v)
- setfield(p, 'depth', getfield(p, 'depth')+v)
- set_attr(p, attr_icflag, PROCESSED)
- end
- end
+-- 数式の位置補正
+function luatexja.setwidth.apply_ashift_math(head, last, attr_ablshift)
+ for p in node_traverse(head) do
+ local pid = getid(p)
+ if p==last then
+ return
+ elseif (has_attr(p, attr_icflag) or 0) ~= PROCESSED then
+ if pid==id_hlist or pid==id_vlist then
+ setfield(p, 'shift', getfield(p, 'shift') + (has_attr(p,attr_ablshift) or 0))
+ elseif pid==id_rule then
+ local v = has_attr(p,attr_ablshift) or 0
+ setfield(p, 'height', getfield(p, 'height')-v)
+ setfield(p, 'depth', getfield(p, 'depth')+v)
+ set_attr(p, attr_icflag, PROCESSED)
+ elseif pid==id_glyph then
+ -- 欧文文字; 和文文字は pid == i_hlist の場合で処理される
+ -- (see conv_jchar_to_hbox_A in ltj-math.lua)
+ setfield(p, 'yoffset',
+ getfield(p, 'yoffset') - (has_attr(p,attr_ablshift) or 0))
end
end
end
- -- adjust attr_icflag
- tex_set_attr('global', attr_icflag, 0)
- return head
end
tex_set_attr('global', attr_icflag, 0)
if gc == 'fin_row' then return head
else
- local p = to_direct(head)
start_time_measure('jfmglue')
- p = ltjj.main(p,mode, dir)
- if p then p = ltjw.set_ja_width(p, dir) end
+ local p = ltjj.main(to_direct(head),mode, dir)
stop_time_measure('jfmglue')
return to_node(p)
end
return (has_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG
end
-local debug_depth
+local prefix, inner_depth
-local function debug_show_node_X(p,print_fn)
- local k = debug_depth
+local function debug_show_node_X(p,print_fn, limit)
+ local k = prefix
local s
local pt=node_type(p.id)
- local base = debug_depth .. string.format('%X', get_attr_icflag(p))
+ local base = prefix .. string.format('%X', get_attr_icflag(p))
.. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' '
if pt == 'glyph' then
s = base .. ' ' .. utf.char(p.char) .. ' '
if get_attr_icflag(p) == icflag_table.PACKED then
s = s .. ' (packed)'
end
- print_fn(s); debug_depth=debug_depth.. '.'
- for q in node.traverse(p.head) do
- debug_show_node_X(q, print_fn)
+ print_fn(s);
+ local bid = inner_depth
+ prefix, inner_depth = prefix.. '.', inner_depth + 1
+ if inner_depth < limit then
+ for q in node.traverse(p.head) do
+ debug_show_node_X(q, print_fn, limit)
+ end
end
- debug_depth=k
+ prefix=k
elseif pt == 'glue' then
s = base .. ' ' .. print_spec(p.spec)
if get_attr_icflag(p)>icflag_table.KINSOKU
s = s .. ' dir: ' .. tostring(node.has_attribute(p, attr_dir))
end
print_fn(s)
- debug_depth=debug_depth.. '.'
- for q in node.traverse(p.value) do
- debug_show_node_X(q, print_fn)
- end
- debug_depth=k
+ local bid = inner_depth
+ prefix, inner_depth =prefix.. '.', inner_depth + 1
+ if inner_depth < limit then
+ for q in node.traverse(p.value) do
+ debug_show_node_X(q, print_fn, limit)
+ end
+ end
+ prefix, inner_depth = k, bid
end
else
s = s .. node.subtype(p.subtype)
elseif pt=='noad' then
s = base ; print_fn(s)
if p.nucleus then
- debug_depth = k .. 'N'; debug_show_node_X(p.nucleus, print_fn);
+ prefix = k .. 'N'; debug_show_node_X(p.nucleus, print_fn);
end
if p.sup then
- debug_depth = k .. '^'; debug_show_node_X(p.sup, print_fn);
+ prefix = k .. '^'; debug_show_node_X(p.sup, print_fn);
end
if p.sub then
- debug_depth = k .. '_'; debug_show_node_X(p.sub, print_fn);
+ prefix = k .. '_'; debug_show_node_X(p.sub, print_fn);
end
- debug_depth = k;
+ prefix = k;
elseif pt=='math_char' then
s = base .. ' fam: ' .. p.fam .. ' , char = ' .. utf.char(p.char)
print_fn(s)
elseif pt=='sub_box' or pt=='sub_mlist' then
print_fn(base)
if p.head then
- debug_depth = k .. '.';
+ prefix = k .. '.';
for q in node.traverse(p.head) do
debug_show_node_X(q, print_fn)
end
end
p=node_next(p)
end
-function luatexja.ext_show_node_list(head,depth,print_fn)
- debug_depth = depth
+function luatexja.ext_show_node_list(head,depth,print_fn, lim)
+ prefix = depth
+ inner_depth = 0
if head then
while head do
- debug_show_node_X(head, print_fn); head = node_next(head)
+ debug_show_node_X(head, print_fn, lim or 1/0); head = node_next(head)
end
else
- print_fn(debug_depth .. ' (null list)')
+ print_fn(prefix .. ' (null list)')
end
end
-function luatexja.ext_show_node(head,depth,print_fn)
- debug_depth = depth
+function luatexja.ext_show_node(head,depth,print_fn, lim)
+ prefix = depth
+ inner_depth = 0
if head then
- debug_show_node_X(head, print_fn)
+ debug_show_node_X(head, print_fn, lim or 1/0)
else
- print_fn(debug_depth .. ' (null list)')
+ print_fn(prefix .. ' (null list)')
end
end