X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-jfmglue.lua;h=ef05a671686e642c88e09be9292193557f128f6a;hb=d177010c46e52e722b4752eded1ae4a6807953df;hp=531a5c75433fb9a9871e0cd4176c3d6f67073923;hpb=786434b34a66995d5dedaedaf12c5c922cc263d6;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index 531a5c7..ef05a67 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -127,19 +127,24 @@ end -- penalty 値の計算 -local function add_penalty(p,e) - local pp = getfield(p, 'penalty') - if pp>=10000 then - if e<=-10000 then setfield(p, 'penalty', 0) end - elseif pp<=-10000 then - if e>=10000 then setfield(p, 'penalty', 0) end - else - pp = pp + e - if pp>=10000 then setfield(p, 'penalty', 10000) - elseif pp<=-10000 then setfield(p, 'penalty', -10000) - else setfield(p, 'penalty', pp) end +local add_penalty +do +local setpenalty = node.direct.setpenalty or function(n, a) setfield(n,'penalty',a) end +local getpenalty = node.direct.getpenalty or function(n) return getfield(n,'penalty') end +function add_penalty(p,e) + local pp = getpenalty(p) + if (pp>-10000) and (pp<10000) then + if e>=10000 then setpenalty(p, 10000) + elseif e<=-10000 then setpenalty(p, -10000) + else + pp = pp + e + if pp>=10000 then setpenalty(p, 10000) + elseif pp<=-10000 then setpenalty(p, -10000) + else setpenalty(p, pp) end + end end end +end -- 「異なる JFM」の間の調整方法 diffmet_rule = math.two_paverage @@ -267,12 +272,12 @@ do local traverse = node.direct.traverse local function check_next_ickern(lp) - if lp and getid(lp) == id_kern and ( getsubtype(lp)==3 or ITALIC == get_attr_icflag(lp)) then - set_attr(lp, attr_icflag, IC_PROCESSED); - Np.last = lp; return node_next(lp) - else - Np.last = Np.nuc; return lp + local lx = Np.nuc + while lp and getid(lp) == id_kern and ( getsubtype(lp)==3 or ITALIC == get_attr_icflag(lp)) do + set_attr(lp, attr_icflag, IC_PROCESSED); + lx, lp = lp, node_next(lp) end + Np.last = lx; return lp end local function calc_np_pbox(lp, last) @@ -564,16 +569,17 @@ do local attr_jchar_code = luatexbase.attributes['ltj@charcode'] local attr_autospc = luatexbase.attributes['ltj@autospc'] local attr_autoxspc = luatexbase.attributes['ltj@autoxspc'] + local getcomponents = node.direct.getcomponents --local ltjf_get_vert_glyph = ltjf.get_vert_glyph function set_np_xspc_jachar(Nx, x) local m = ltjf_font_metric_table[getfont(x)] - local c, c_glyph = ltjs_orig_char_table[x], getchar(x) + local c, c_glyph = (not getcomponents(x) and ltjs_orig_char_table[x]), getchar(x) + if c and c~=c_glyph then set_attr(x, attr_jchar_code, c) end c = c or c_glyph local cls = slow_find_char_class(c, m, c_glyph) Nx.met, Nx.class, Nx.char = m, cls, c; local mc = m.char_type; Nx.char_type = mc if cls~=0 then set_attr(x, attr_jchar_class, cls) end - if c~=c_glyph then set_attr(x, attr_jchar_code, c) 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 @@ -598,9 +604,9 @@ do function set_np_xspc_alchar(Nx, c,x, lig) if c~=-1 then local f = (lig ==1) and nullfunc or node_tail - local xc, xs = getfield(x, 'components'), getsubtype(x) + local xc, xs = getcomponents(x), getsubtype(x) while xc and xs and xs%4>=2 do - x = f(xc); xc, xs = getfield(x, 'components'), getsubtype(x) + x = f(xc); xc, xs = getcomponents(x), getsubtype(x) end c = getchar(x) Nx.pre = table_current_stack[PRE + c] or 0