setsub(p, cjh_A(getsub(p), sty+1))
setsup(p, cjh_A(getsup(p), sty+1))
elseif pid == id_choice then
- setfield(p, 'display', cjh_A(getfield(p, 'display'), 0))
+ setfield(p, 'display', cjh_A(getfield(p, 'display'), -1))
setfield(p, 'text', cjh_A(getfield(p, 'text'), 0))
setfield(p, 'script', cjh_A(getfield(p, 'script'), 1))
setfield(p, 'scriptscript', cjh_A(getfield(p, 'scriptscript'), 2))
end
elseif pid == id_style then
local ps = getfield(p, 'style')
- if ps == "display'" or ps == 'display' or ps == "text'" or ps == 'text' then
+ if ps == "display'" or ps == 'display' then
+ sty = -1
+ elseif ps == "text'" or ps == 'text' then
sty = 0
elseif ps == "script'" or ps == 'script' then
sty = 1
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 * sty + fam, -1, getcount(cnt_stack))
+ local f = ltjs.get_stack_table(MJT + 0x100 * max(sty,0) + 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)
luatexja.setwidth.capsule_glyph_tate = capsule_glyph_tate
do
- local cap_math_aux = {[0]=1, [1]=0 }
- setmetatable(cap_math_aux, {__index=function() return 0.5 end})
+local font_getfont = font.getfont
+local cap_math_aux = {
+ [-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)
+ 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)
+ return font_getfont(ssf).size/font_getfont(tf).size
+ end
+}
+setmetatable(cap_math_aux, {__index=function(t,k) return t[2] end})
local function capsule_glyph_math(p, met, char_data, sty)
if not char_data then return nil end
local fwidth, pwidth = char_data.width, getwidth(p)
fshift.down = char_data.down; fshift.left = char_data.left
fshift = call_callback("luatexja.set_width", fshift, met, char_data)
local fheight, fdepth = char_data.height, char_data.depth
- print(utf.char(getchar(p)), get_attr(p,attr_ykblshift) or 0, get_attr(p,attr_yablshift) or 0, sty)
local y_shift = - getfield(p, 'yoffset')
- + cap_math_aux[sty]*((get_attr(p,attr_ykblshift) or 0) - (get_attr(p,attr_yablshift) or 0))
+ + cap_math_aux[sty]()*
+ ((get_attr(p,attr_ykblshift) or 0) - (get_attr(p,attr_yablshift) 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, nil, p);