end
local cjhh_A
--- sty : 0 (display or text), 1 (script), >=2 (scriptscript)
+local max, min = math.max, math.min
+-- sty : -1 (display), 0 (text), 1 (script), >=2 (scriptscript)
local function conv_jchar_to_hbox(head, sty)
for p in node_traverse(head) do
local pid = getid(p)
else
setnucleus(p, cjh_A(getnucleus(p), sty))
end
- setsub(p, cjh_A(getsub(p), sty+1))
- setsup(p, cjh_A(getsup(p), sty+1))
+ setsub(p, cjh_A(getsub(p), max(sty+1,1)))
+ setsup(p, cjh_A(getsup(p), max(sty+1,1)))
elseif pid == id_choice then
setfield(p, 'display', cjh_A(getfield(p, 'display'), -1))
setfield(p, 'text', cjh_A(getfield(p, 'text'), 0))
setfield(p, 'denom', cjh_A(getfield(p, 'denom'), sty+1))
elseif pid == id_radical then
setnucleus(p, cjh_A(getnucleus(p), sty))
- setsub(p, cjh_A(getsub(p), sty+1))
- setsup(p, cjh_A(getsup(p), sty+1))
+ setsub(p, cjh_A(getsub(p), max(sty+1,1)))
+ setsup(p, cjh_A(getsup(p), max(sty+1,1)))
if getfield(p, 'degree') then
- setfield(p, 'degree', cjh_A(getfield(p, 'degree'), sty + 1))
+ setfield(p, 'degree', cjh_A(getfield(p, 'degree'), 2))
end
elseif pid == id_style then
local ps = getfield(p, 'style')
local setfont = node.direct.setfont
local setchar = node.direct.setchar
-local max = math.max
cjh_A = function (p, sty)
if not p then return nil
else
elseif pid == id_mchar then
local pc, fam = getchar (p), get_attr(p, attr_jfam) or -1
if (not is_math_letters[pc]) and is_ucs_in_japanese_char(p) and fam>=0 then
- local f = ltjs.get_stack_table(MJT + 0x100 * max(sty,0) + fam, -1, getcount(cnt_stack))
+ local f = ltjs.get_stack_table(MJT + 0x100 * min(max(sty,0),2) + fam, -1, getcount(cnt_stack))
if f ~= -1 then
local q = node_new(id_sub_box)
local r = node_new(id_glyph, 256); setnext(r, nil); setfont(r, f, pc)
end
do
- local function mlist_callback_ltja(n)
+ local function mlist_callback_ltja(n, display_type)
local n = to_direct(n); list_dir = ltjd_get_dir_count()
if getid(n)==id_whatsit and getsubtype(n)==sid_user and getfield(n, 'user_id') == DIR then
local old_n = n; n = node_remove(n, n)
node_free(old_n); if not n then return nil end
end
- return to_node(conv_jchar_to_hbox(n, 0))
+ return to_node(conv_jchar_to_hbox(n, (display_type=='display') and -1 or 0))
end
-- LaTeX 2020-02-02 seems to have pre_mlist_to_hlist_filter callback
if luatexbase.callbacktypes['pre_mlist_to_hlist_filter'] then
luatexja.setwidth.capsule_glyph_tate = capsule_glyph_tate
do
-local font_getfont = font.getfont
+local font_getfont, famfont = font.getfont, node.family_font
local cap_math_aux = {
- [-1]=function() return 1 end,
- [0]=function() return 1 end,
+ [-1]=function() return 1 end, [0]=function() return 1 end,
[1]=function()
- local sf, tf = node.family_font(2,1), node.family_font(2,0)
+ local sf, tf = famfont(2,1), famfont(2,0)
return font_getfont(sf).size/font_getfont(tf).size
end,
[2]=function()
- local ssf, tf = node.family_font(2,2), node.family_font(2,0)
+ local ssf, tf = famfont(2,2), famfont(2,0)
return font_getfont(ssf).size/font_getfont(tf).size
end
}