OSDN Git Service

wip (#45664)
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Tue, 20 Sep 2022 08:59:39 +0000 (17:59 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Tue, 20 Sep 2022 08:59:39 +0000 (17:59 +0900)
src/ltj-math.lua
src/ltj-setwidth.lua
test/test07-math.tex

index 26cd9ef..28a8fb0 100644 (file)
@@ -151,13 +151,11 @@ cjh_A = function (p, sty)
             local f = ltjs.get_stack_table(MJT + 0x100 * sty + 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)
-               local ks = (get_attr(r,attr_ykblshift) or 0) -- - (get_attr(r, attr_yablshift) or 0)
-               set_attr(r, attr_ykblshift, 0); --set_attr(r, attr_yablshift, 0)
+               local r = node_new(id_glyph, 256); setnext(r, nil); setfont(r, f, pc)
                local met = ltjf_font_metric_table[f]
-               r = capsule_glyph_math(r, met, met.char_type[ltjf_find_char_class(pc, met)]);
-               setlist(q, r); node_free(p); p=q; setshift(r, ks);
+               r = capsule_glyph_math(
+                 r, met, met.char_type[ltjf_find_char_class(pc, met)], sty)
+               setlist(q, r); node_free(p); p=q;
             end
          end
       elseif pid == id_sub_box and getlist(p) then
index bc48fd8..3009433 100644 (file)
@@ -58,6 +58,7 @@ local sid_restore = node.subtype 'pdf_restore'
 local sid_matrix  = node.subtype 'pdf_setmatrix'
 local dir_tate = luatexja.dir_table.dir_tate
 
+local attr_yablshift = luatexbase.attributes['ltj@yablshift']
 local attr_ykblshift = luatexbase.attributes['ltj@ykblshift']
 local attr_tkblshift = luatexbase.attributes['ltj@tkblshift']
 local attr_icflag = luatexbase.attributes['ltj@icflag']
@@ -242,15 +243,19 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
 end
 luatexja.setwidth.capsule_glyph_tate = capsule_glyph_tate
 
-local function capsule_glyph_math(p, met, char_data)
+do
+    local cap_math_aux = {[0]=1, [1]=0 }
+    setmetatable(cap_math_aux, {__index=function() return 0.5 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)
    fwidth = fwidth or pwidth
    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
-   local y_shift
-      = - getfield(p, 'yoffset') + (get_attr(p,attr_ykblshift) or 0)
+   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))
    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);
@@ -261,6 +266,7 @@ local function capsule_glyph_math(p, met, char_data)
    return box
 end
 luatexja.setwidth.capsule_glyph_math = capsule_glyph_math
+end
 
 -- 数式の位置補正
 function luatexja.setwidth.apply_ashift_math(head, last, attr_ablshift)
index 3409f26..55f5a49 100644 (file)
@@ -60,8 +60,14 @@ mathmc: $\mathmc{あいうえおabcde}$
 
 mathgt: $\mathgt{あいうえおabcde}$
 
-\ltjsetparameter{yalbaselineshift=4pt}
+\ltjsetparameter{yalbaselineshift=2pt,yjabaselineshift=10pt}
+\leavevmode
+\vrule height 0.1pt width 200pt depth 0pt\kern-200pt%
 あs$t漢\hbox{dき}\underline{aイ\hbox{bあ}}\overline{Aく\hbox{cう}}$
 
+\leavevmode
+\vrule height 0.1pt width 200pt depth 0pt\kern-200pt%
+あs${\scriptstyle 漢X}{漢Y^{うE}_{えO}}A^E_O12=a\pi \dfrac{aあ}{iい}$
+
 \end{document}