-- 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
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)
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
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
return (Np[name] or Nq[name]) and ((Np[name]~=0) and (Nq[name]~=0))
end
--- OAX, OBX: alchar or math
-local function get_OAX_skip()
+-- NA, NB: alchar or math
+local function get_NA_skip()
local pm = Np.met
local g, _, kn, kp, kh = new_jfm_glue(
pm.char_type,
and get_xkanjiskip_low(false, pm, kn, kp, kh)
return g, k
end
-local function get_OBX_skip()
+local function get_NB_skip()
local qm = Nq.met
local g, _, kn, kp, kh = new_jfm_glue(
qm.char_type, Nq.class,
handle_penalty_normal(0, Np.pre, g); real_insert(g); real_insert(k)
elseif Nq.pre then
local g, k
- if non_ihb_flag then g, k = get_OAX_skip() end -- O_A->X
+ if non_ihb_flag then g, k = get_NA_skip() end -- N_A->X
if not g then g = get_xkanjiskip(Np) end
handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g);
real_insert(g); real_insert(k)
-- jachar .. (anything)
local function handle_nq_jachar()
if Np.pre then
- local g = non_ihb_flag and get_OBX_skip() or get_xkanjiskip(Nq) -- O_B->X
+ local g = non_ihb_flag and get_NB_skip() or get_xkanjiskip(Nq) -- N_B->X
handle_penalty_normal(Nq.post, (Np.id==id_hlist and 0 or Np.pre), g); real_insert(g)
else
local g =non_ihb_flag and (get_OB_skip()) -- O_B