From 646c7e8fb1513077f47e02c3e03288130de01da9 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Mon, 22 Aug 2022 07:34:00 +0900 Subject: [PATCH] has_attribute -> get_attribute --- src/ltj-adjust.lua | 11 ++++++----- src/ltj-charrange.lua | 12 ++++++------ src/ltj-direction.lua | 26 +++++++++++++------------- src/ltj-jfmglue.lua | 37 +++++++++++++++++++------------------ src/ltj-jfont.lua | 4 ++-- src/ltj-math.lua | 8 ++++---- src/ltj-otf.lua | 6 +++--- src/ltj-pretreat.lua | 11 ++++++----- src/ltj-ruby.lua | 26 +++++++++++++------------- src/ltj-setwidth.lua | 24 ++++++++++++------------ src/luatexja.lua | 12 ++++++------ 11 files changed, 90 insertions(+), 87 deletions(-) diff --git a/src/ltj-adjust.lua b/src/ltj-adjust.lua index bb473de..a46c17c 100644 --- a/src/ltj-adjust.lua +++ b/src/ltj-adjust.lua @@ -34,7 +34,7 @@ local node_next = node.direct.getnext local node_free = node.direct.flush_node or node.direct.free local node_prev = node.direct.getprev local node_tail = node.direct.tail -local has_attr = node.direct.has_attribute +local get_attr = node.direct.get_attribute local set_attr = node.direct.set_attribute local insert_after = node.direct.insert_after @@ -63,7 +63,7 @@ local get_attr_icflag do local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG get_attr_icflag = function(p) - return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG + return (get_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG end end @@ -171,7 +171,7 @@ local function aw_step1(p, total) return total, false-- それ以外は対象外. end local eadt = ltjf_font_metric_table[getfont(xc)] - .char_type[has_attr(xc, attr_jchar_class) or 0].end_adjust + .char_type[get_attr(xc, attr_jchar_class) or 0].end_adjust if not eadt then return total, false end @@ -239,7 +239,7 @@ local function aw_step1_last(p, total) end end local eadt = ltjf_font_metric_table[getfont(xc)] - .char_type[has_attr(xc, attr_jchar_class) or 0].end_adjust + .char_type[get_attr(xc, attr_jchar_class) or 0].end_adjust if not eadt then return total, false end @@ -578,8 +578,9 @@ do local dir_tate = luatexja.dir_table.dir_tate local get_dir_count = ltjd.get_dir_count local ltjf_font_metric_table = ltjf.font_metric_table + local has_attr = node.direct.has_attribute local function get_current_metric(n) - local fn = has_attr(n, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt) + local fn = get_attr(n, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt) return fn and ltjf_font_metric_table[fn] end local function whatsit_callback(Np, lp, Nq) diff --git a/src/ltj-charrange.lua b/src/ltj-charrange.lua index a942012..3ae4f51 100644 --- a/src/ltj-charrange.lua +++ b/src/ltj-charrange.lua @@ -10,8 +10,8 @@ luatexja.charrange = {} luatexja.load_module 'base'; local ltjb = luatexja.base local getchar = node.direct.getchar -local has_attr = node.direct.has_attribute -local has_attr_node = node.has_attribute +local get_attr = node.direct.get_attribute +local get_attr_node = node.get_attribute local tex_getattr = tex.getattribute local UNSET = -0x7FFFFFFF @@ -27,15 +27,15 @@ do local ka = luatexbase.attributes['ltj@kcat0'] for i = 0, 30 do local pw = 2^i; kcat_attr_table[i], pow_table[i] = ka, pw - fn_table[i] = function(p) return has_attr(p, ka)&pw==0 end - nfn_table[i] = function(p) return has_attr_node(p, ka)&pw==0 end + fn_table[i] = function(p) return get_attr(p, ka)&pw==0 end + nfn_table[i] = function(p) return get_attr_node(p, ka)&pw==0 end end end for i = 31, 31*ATTR_RANGE-1 do local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 2^(i%31) kcat_attr_table[i], pow_table[i] = ka, pw - fn_table[i] = function(p) return (has_attr(p, ka) or 0)&pw==0 end - nfn_table[i] = function(p) return (has_attr_node(p, ka) or 0)&pw==0 end + fn_table[i] = function(p) return (get_attr(p, ka) or 0)&pw==0 end + nfn_table[i] = function(p) return (get_attr_node(p, ka) or 0)&pw==0 end end fn_table[-1] = function() return false end -- for char --U+007F nfn_table[-1] = function() return false end -- for char --U+007F diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 41eb677..f0c67f5 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -13,7 +13,7 @@ local dnode = node.direct local cat_lp = luatexbase.catcodetables['latex-package'] local to_node = dnode.tonode local to_direct = dnode.todirect -local has_attr = dnode.has_attribute +local get_attr = dnode.get_attribute local set_attr = dnode.set_attribute local insert_before = dnode.insert_before local insert_after = dnode.insert_after @@ -60,7 +60,7 @@ local dir_math_mod = luatexja.dir_table.dir_math_mod local dir_node_auto = luatexja.dir_table.dir_node_auto local dir_node_manual = luatexja.dir_table.dir_node_manual local function get_attr_icflag(p) - return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG + return (get_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG end local page_direction @@ -96,7 +96,7 @@ end local get_dir_count, get_adjust_dir_count do - local node_attr = node.has_attribute + local node_attr = node.get_attribute local function get_dir_count_inner(h) if h then if h.id==id_whatsit and h.subtype==sid_user and h.user_id==DIR then @@ -333,7 +333,7 @@ do end end if hd==wh[1] then - ltjs.list_dir = has_attr(hd, attr_dir) + ltjs.list_dir = get_attr(hd, attr_dir) local x = node_next(hd) while x and getid(x)==id_glue and getsubtype(x)==3 do node_remove(hd,x); node_free(x); x = node_next(hd) @@ -530,13 +530,13 @@ end -- 2nd ret val はその DIR whatsit function get_box_dir(b, default) start_time_measure 'get_box_dir' - local dir = has_attr(b, attr_dir) or 0 + local dir = get_attr(b, attr_dir) or 0 local bh = getfield(b, 'head') -- We cannot use getlist since b may be an unset_node. local c if bh~=0 then -- bh != nil for bh in traverse_id(id_whatsit, bh) do if getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR then - c = bh; dir = (dir==0) and has_attr(bh, attr_dir) or dir + c = bh; dir = (dir==0) and get_attr(bh, attr_dir) or dir end end end @@ -688,7 +688,7 @@ do local db local dnh = getfield(dn, 'value') for x in traverse(dnh) do - if has_attr(x, attr_dir)%dir_math_mod == new_dir then + if get_attr(x, attr_dir)%dir_math_mod == new_dir then setfield(dn, 'value', to_node(node_remove(dnh, x))) db=x; break end @@ -768,7 +768,7 @@ do if s_dir ~= l_dir then local not_found = true for x in traverse(getfield(wh, 'value')) do - if l_dir == has_attr(x, attr_dir)%dir_node_auto then + if l_dir == get_attr(x, attr_dir)%dir_node_auto then setdimen('ltj@tempdima', getfield(x, key)) not_found = false; break end @@ -818,7 +818,7 @@ do local db local dnh = getfield(wh, 'value') for x in traverse(dnh) do - if has_attr(x, attr_dir)%dir_node_auto==l_dir then + if get_attr(x, attr_dir)%dir_node_auto==l_dir then db = x; break end end @@ -835,7 +835,7 @@ do -- change dimension of dir_nodes which are created "automatically" local bw, bh, bd = getwhd(s) for x in traverse(getfield(wh, 'value')) do - local x_dir = has_attr(x, attr_dir) + local x_dir = get_attr(x, attr_dir) if x_dir0) and (getdepth(lp) + y_adjust) or 0 setfield(lp, 'yoffset', getfield(lp, 'yoffset') - y_adjust); lp = node_next(lp) @@ -360,7 +360,7 @@ function calc_np_aux_glyph_common(lp, acc_flag) if lid==id_glyph and not if_lang_ja(lx) then -- 欧文文字 last_glyph = lx; set_attr(lx, attr_icflag, PROCESSED); Np.last = lx - y_adjust = has_attr(lx,attr_ablshift) or 0 + y_adjust = get_attr(lx,attr_ablshift) or 0 node_depth = max(getdepth(lx) + min(y_adjust, 0), node_depth) adj_depth = (y_adjust>0) and max(getdepth(lx) + y_adjust, adj_depth) or adj_depth setfield(lx, 'yoffset', getfield(lx, 'yoffset') - y_adjust); lx = node_next(lx) @@ -370,9 +370,9 @@ function calc_np_aux_glyph_common(lp, acc_flag) set_attr(lx, attr_icflag, PROCESSED) lx = node_next(lx) -- lx: アクセント本体 if getid(lx)==id_glyph then - setfield(lx, 'yoffset', getfield(lx, 'yoffset') - (has_attr(lx,attr_ablshift) or 0)) + setfield(lx, 'yoffset', getfield(lx, 'yoffset') - (get_attr(lx,attr_ablshift) or 0)) else -- アクセントは上下にシフトされている - setshift(lx, getshift(lx) + (has_attr(lx,attr_ablshift) or 0)) + setshift(lx, getshift(lx) + (get_attr(lx,attr_ablshift) or 0)) end set_attr(lx, attr_icflag, PROCESSED) lx = node_next(lx); set_attr(lx, attr_icflag, PROCESSED) @@ -525,9 +525,9 @@ calc_np_auxtable = { Np.first = Np.first or lp set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp) if getid(lp)==id_glyph then -- アクセント本体 - setfield(lp, 'yoffset', getfield(lp, 'yoffset') - (has_attr(lp,attr_ablshift) or 0)) + setfield(lp, 'yoffset', getfield(lp, 'yoffset') - (get_attr(lp,attr_ablshift) or 0)) else -- アクセントは上下にシフトされている - setshift(lp, getshift(lp) + (has_attr(lp,attr_ablshift) or 0)) + setshift(lp, getshift(lp) + (get_attr(lp,attr_ablshift) or 0)) end set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp) set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp) @@ -571,7 +571,7 @@ function calc_np(last, lp) for k = 1,#Bp do Bp[k] = nil end while lp ~= last do - local lpa = has_attr(lp, attr_icflag) or 0 + local lpa = get_attr(lp, attr_icflag) or 0 -- unbox 由来ノードの検出 if (lpa>=PACKED) and (lpa%PROCESSED_BEGIN_FLAG<=BOXBDD) then if lpa%PROCESSED_BEGIN_FLAG == BOXBDD then @@ -603,6 +603,7 @@ do local dir_tate = luatexja.dir_table.dir_tate -- 和文文字のデータを取得 + local has_attr = node.direct.has_attribute local attr_jchar_class = luatexbase.attributes['ltj@charclass'] local attr_jchar_code = luatexbase.attributes['ltj@charcode'] local attr_autospc = luatexbase.attributes['ltj@autospc'] @@ -628,8 +629,8 @@ do end function set_np_xspc_jachar_hbox(Nx, x) local m = ltjf_font_metric_table[getfont(x)] - local c = has_attr(x, attr_jchar_code) or getchar(x) - Nx.met, Nx.char = m, c; Nx.class = has_attr(x, attr_jchar_class) or 0; + local c = get_attr(x, attr_jchar_code) or getchar(x) + Nx.met, Nx.char = m, c; Nx.class = get_attr(x, attr_jchar_class) or 0; local mc = m.char_type; Nx.char_type = mc Nx.pre = table_current_stack[PRE + c] or 0 Nx.post = table_current_stack[POST + c] or 0 @@ -1438,22 +1439,22 @@ do if w~=1073741823 then setglue(lx, w, st, sh, sto, sho); set_attr(lx, attr_icflag, lxi) else - local m = ltjf_font_metric_table[has_attr(lx, attr_tablshift)] + local m = ltjf_font_metric_table[get_attr(lx, attr_tablshift)] setglue(lx, bk[1], bk[2], bk[3], 0, 0) set_attr(lx, attr_icflag, lxi_jfm) end end local function special_jaglue_after(lx) if get_attr_icflag(lx)==SPECIAL_JAGLUE then - lxi=has_attr(lx, attr_yablshift) + lxi=get_attr(lx, attr_yablshift) if lxi>=PROCESSED_BEGIN_FLAG then lxi = lxi%PROCESSED_BEGIN_FLAG if lxi == KANJI_SKIP then special_jaglue_after_inner(lx, lxi, KANJI_SKIP_JFM, kanji_skip, - ltjf_font_metric_table[has_attr(lx, attr_tablshift)].kanjiskip or null_skip_table) + ltjf_font_metric_table[get_attr(lx, attr_tablshift)].kanjiskip or null_skip_table) else -- lxi == XKANJI_SKIP special_jaglue_after_inner(lx, lxi, XKANJI_SKIP_JFM, xkanji_skip, - ltjf_font_metric_table[has_attr(lx, attr_tablshift)].xkanjiskip or null_skip_table) + ltjf_font_metric_table[get_attr(lx, attr_tablshift)].xkanjiskip or null_skip_table) end else set_attr(lx, attr_icflag, lxi) diff --git a/src/ltj-jfont.lua b/src/ltj-jfont.lua index 6511a48..a4eb427 100644 --- a/src/ltj-jfont.lua +++ b/src/ltj-jfont.lua @@ -19,7 +19,7 @@ local to_direct = node.direct.todirect local node_new = node.direct.new local node_free = node.direct.flush_node or node.direct.free -local has_attr = node.direct.has_attribute +local get_attr = node.direct.get_attribute local set_attr = node.direct.set_attribute local round = tex.round local font_getfont = font.getfont @@ -1025,7 +1025,7 @@ do if p and getid(p)==id_glyph then if is_ucs_in_japanese_char(p) then local j = font_metric_table[ - has_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt) + get_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt) ] local g = new_ic_kern() setkern(g, j.char_type[find_char_class(getchar(p), j)].italic) diff --git a/src/ltj-math.lua b/src/ltj-math.lua index 466596f..0ada03a 100644 --- a/src/ltj-math.lua +++ b/src/ltj-math.lua @@ -32,7 +32,7 @@ local node_new = node.direct.new local node_next = node.direct.getnext local node_remove = node.direct.remove local node_free = node.direct.flush_node or node.direct.free -local has_attr = node.direct.has_attribute +local get_attr = node.direct.get_attribute local set_attr = node.direct.set_attribute local tex_getcount = tex.getcount @@ -77,7 +77,7 @@ local function conv_vcenter(sb) if getid(hd)==id_whatsit and getsubtype(hd)==sid_user and getfield(hd, 'user_id')==DIR then local d = node_next(hd) - if getid(d)==id_vlist and has_attr(d, attr_dir)>=dir_node_auto then + if getid(d)==id_vlist and get_attr(d, attr_dir)>=dir_node_auto then node_free(hd); setlist(h, nil); node_free(h) setlist(sb, d); set_attr(d, attr_icflag, 0) end @@ -143,14 +143,14 @@ cjh_A = function (p, sty) setlist(p, conv_jchar_to_hbox(getlist(p), sty)) end elseif pid == id_mchar then - local pc, fam = getchar (p), has_attr(p, attr_jfam) or -1 + 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, tex_getcount('ltj@@stack')) if f ~= -1 then local q = node_new(id_sub_box) local r = node_new(id_glyph, 256); setnext(r, nil) setchar(r, pc); setfont(r, f) - local k = has_attr(r,attr_ykblshift) or 0; set_attr(r, attr_ykblshift, 0) + local k = get_attr(r,attr_ykblshift) or 0; set_attr(r, attr_ykblshift, 0) -- ltj-setwidth 内で実際の位置補正はおこなうので,補正量を退避 local met = ltjf_font_metric_table[f] r = capsule_glyph_math(r, met, met.char_type[ltjf_find_char_class(pc, met)]); diff --git a/src/ltj-otf.lua b/src/ltj-otf.lua index dcfec33..707dcf5 100644 --- a/src/ltj-otf.lua +++ b/src/ltj-otf.lua @@ -31,7 +31,7 @@ local node_new = node.direct.new local node_remove = node.direct.remove local node_next = node.direct.getnext local node_free = node.direct.flush_node or node.direct.free -local has_attr = node.direct.has_attribute +local get_attr = node.direct.get_attribute local set_attr = node.direct.set_attribute local unset_attr = node.direct.unset_attribute local node_insert_after = node.direct.insert_after @@ -168,9 +168,9 @@ local function extract(head) if puid==OTF then local g = node_new(id_glyph, 0) setchar(g, getfield(p, 'value')) - setfont(g, has_attr(p, attr_curfnt)) + setfont(g, get_attr(p, attr_curfnt)) setlang(g, lang_ja) - set_attr(g, attr_kblshift, has_attr(p, attr_kblshift)) + set_attr(g, attr_kblshift, get_attr(p, attr_kblshift)) head = node_insert_after(head, p, g) head = node_remove(head, p) node_free(p); p = g diff --git a/src/ltj-pretreat.lua b/src/ltj-pretreat.lua index 348378f..9325628 100644 --- a/src/ltj-pretreat.lua +++ b/src/ltj-pretreat.lua @@ -21,6 +21,7 @@ local getlang = node.direct.getlang local pairs = pairs local floor = math.floor +local get_attr = node.direct.get_attribute local has_attr = node.direct.has_attribute local set_attr = node.direct.set_attribute local node_traverse = node.direct.traverse @@ -72,8 +73,8 @@ do if uid==STCK then wt[#wt+1] = p; node_remove(head, p) elseif uid==DIR then - if has_attr(p, attr_icflag)0 and pf) or getfont(p) setfont(p, ltjf_replace_altfont(pf, pc)) setlang(p, lang_ja) @@ -155,7 +156,7 @@ function set_box_stack_level(head, mode) if ltjs.list_dir == dir_tate then for p in traverse_id(id_glyph,to_direct(head)) do if has_attr(p, attr_icflag, 0) and getlang(p)==lang_ja then - local nf = ltjf_replace_altfont( has_attr(p, attr_curtfnt) or getfont(p) , ltjs_orig_char_table[p]) + local nf = ltjf_replace_altfont( get_attr(p, attr_curtfnt) or getfont(p) , ltjs_orig_char_table[p]) setfont(p, nf) if ltjf_font_metric_table[nf].vert_activated then local pc = getchar(p); pc = ltjf_font_metric_table[nf].vform[pc] diff --git a/src/ltj-ruby.lua b/src/ltj-ruby.lua index 5f66166..86117fe 100644 --- a/src/ltj-ruby.lua +++ b/src/ltj-ruby.lua @@ -40,7 +40,7 @@ local node_remove = node.direct.remove local node_next = node.direct.getnext local node_copy, node_tail = node.direct.copy, node.direct.tail local node_free = node.direct.flush_node or node.direct.free -local has_attr, set_attr = node.direct.has_attribute, node.direct.set_attribute +local get_attr, set_attr = node.direct.get_attribute, node.direct.set_attribute local insert_before, insert_after = node.direct.insert_before, node.direct.insert_after local hpack = node.direct.hpack @@ -158,7 +158,7 @@ end -- ルビ組版が行われている段落/hboxでの設定が使われる. -- ルビ文字を格納しているボックスでの設定ではない! local function get_attr_icflag(p) - return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG + return (get_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG end local concat do @@ -220,7 +220,7 @@ do local _, hh, hd = getwhd(box) local hx = h while hx do - local hic = has_attr(hx, attr_icflag) or 0 + local hic = get_attr(hx, attr_icflag) or 0 if (hic == KANJI_SKIP) or (hic == KANJI_SKIP_JFM) or (hic == XKANJI_SKIP) or (hic == XKANJI_SKIP_JFM) or ((hic<=FROM_JFM+63) and (hic>=FROM_JFM)) then @@ -543,7 +543,7 @@ local function pre_high(ahead) local nv = getfield(n, 'value') local rst = getfield(nv, 'value') max_allow_pre = rst.pre or 0 - local atr = has_attr(n, attr_ruby) or 0 + local atr = get_attr(n, attr_ruby) or 0 if max_allow_pre < 0 then -- 直前のルビで intrusion がおこる可能性あり. -- 前 run のデータが残っていればそれを使用, @@ -584,7 +584,7 @@ luatexbase.add_to_callback('hpack_filter', pre_high, 'ltj.ruby.pre', 100) local post_lown do local function write_aux(wv, num, bool) - local id = has_attr(wv, attr_ruby_id) or 0 + local id = get_attr(wv, attr_ruby_id) or 0 if id>0 and cache_handle then cache_handle:write( 'lrob[' .. tostring(id) .. ']=' .. num .. '\nlrob[' .. tostring(-id) .. ']=' .. tostring(bool) .. '\n') @@ -594,8 +594,8 @@ do post_lown = function (rs, rw, cmp, ch) -- ch: the head of `current' hlist if #rs ==0 or not rw then return ch end - local hn = has_attr(rs[1], attr_ruby) - local fn = has_attr(rs[#rs], attr_ruby) + local hn = get_attr(rs[1], attr_ruby) + local fn = get_attr(rs[#rs], attr_ruby) local wv = getfield(rw, 'value') if hn==1 then if fn==2*cmp+2 then @@ -603,7 +603,7 @@ do node_remove(wv, hn) insert_after(ch, rs[1], hn) set_attr(hn, attr_icflag, PROCESSED) - write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk))-- 行中形 + write_aux(wv, get_attr(hn, attr_ruby), get_attr(hn, attr_ruby_post_jfmgk))-- 行中形 else local deg, hn = (fn-1)/2, wv for i = 1, deg do hn = node_next(hn) end; @@ -611,7 +611,7 @@ do setnext(hn, nil) insert_after(ch, rs[1], hn) set_attr(hn, attr_icflag, PROCESSED) - write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk)) + write_aux(wv, get_attr(hn, attr_ruby), get_attr(hn, attr_ruby_post_jfmgk)) end else local deg, hn = max((hn-1)/2,2), wv @@ -622,7 +622,7 @@ do insert_after(ch, rs[1], hn) set_attr(hn, attr_icflag, PROCESSED) if fn == 2*cmp-1 then - write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk)) + write_aux(wv, get_attr(hn, attr_ruby), get_attr(hn, attr_ruby_post_jfmgk)) end end for i = 1,#rs do @@ -648,7 +648,7 @@ local function post_high_break(head) or (hai == id_rule and getsubtype(ha)==0) or (hai == id_whatsit and getsubtype(ha)==sid_user and getfield(ha, 'user_id', RUBY_POST))) - and has_attr(ha, attr_ruby) or 0 + and get_attr(ha, attr_ruby) or 0 if i==0 then ha = node_next(ha) elseif i==1 then @@ -680,7 +680,7 @@ local function post_high_hbox(ahead) or (hai == id_rule and getsubtype(ha)==0) or (hai == id_whatsit and getsubtype(ha)==sid_user and getfield(ha, 'user_id', RUBY_POST))) - and has_attr(ha, attr_ruby) or 0 + and get_attr(ha, attr_ruby) or 0 if i==0 then ha = node_next(ha) elseif i==1 then @@ -800,7 +800,7 @@ do end rst.post = p end - Np.prev_ruby = has_attr(getfield(Nq.nuc, 'value'), attr_ruby_id) + Np.prev_ruby = get_attr(getfield(Nq.nuc, 'value'), attr_ruby_id) -- 前のクラスタがルビであったことのフラグ else -- 直前が文字以外 local nqnv = getfield(Nq.nuc, 'value') diff --git a/src/ltj-setwidth.lua b/src/ltj-setwidth.lua index af474e8..ad01a90 100644 --- a/src/ltj-setwidth.lua +++ b/src/ltj-setwidth.lua @@ -39,7 +39,7 @@ local node_copy = node.direct.copy local node_remove = node.direct.remove local node_tail = node.direct.tail local node_next = node.direct.getnext -local has_attr = node.direct.has_attribute +local get_attr = node.direct.get_attribute local set_attr = node.direct.set_attribute local node_insert_before = node.direct.insert_before local node_insert_after = node.direct.insert_after @@ -73,7 +73,7 @@ do local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG local floor = math.floor get_pr_begin_flag = function (p) - local i = has_attr(p, attr_icflag) or 0 + local i = get_attr(p, attr_icflag) or 0 return i - i%PROCESSED_BEGIN_FLAG end end @@ -99,7 +99,7 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir) if not char_data then return node_next(p), head, p end fshift.down = char_data.down; fshift.left = char_data.left fshift = call_callback("luatexja.set_width", fshift, met, char_data) - local kbl = has_attr(p, attr_ykblshift) or 0 + local kbl = get_attr(p, attr_ykblshift) or 0 -- -- f*: whd specified in JFM local pwidth, pheight,pdepth = getwhd(p) @@ -159,7 +159,7 @@ luatexja.setwidth.capsule_glyph_yoko = capsule_glyph_yoko local function capsule_glyph_tate_rot(p, met, char_data, head, dir, asc) fshift.down = char_data.down; fshift.left = char_data.left fshift = call_callback("luatexja.set_width", fshift, met, char_data) - local kbl = has_attr(p, attr_tkblshift) or 0 + local kbl = get_attr(p, attr_tkblshift) or 0 -- f*: whd specified in JFM local pwidth, pheight,pdepth = getwhd(p) local fwidth = char_data.width or pwidth @@ -192,7 +192,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir) if met.rotation and met.vert_activated then local f = font_getfont(pf) local r, l = met.rotation[pc], f.properties and f.properties.language - if ((r==true) or (type(r)=="table" and not r[l])) and (has_attr(p, attr_vert_ori) or 0)<=0 then + if ((r==true) or (type(r)=="table" and not r[l])) and (get_attr(p, attr_vert_ori) or 0)<=0 then return capsule_glyph_tate_rot(p, met, char_data, head, dir, 0.5*(get_ascender(pf)-get_descender(pf))) end @@ -213,7 +213,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir) fshift = call_callback("luatexja.set_width", fshift, met, char_data) local fheight = char_data.height or 0 local fdepth = char_data.depth or 0 - local y_shift = xo + (has_attr(p,attr_tkblshift) or 0) + local y_shift = xo + (get_attr(p,attr_tkblshift) or 0) local q head, q = node_remove(head, p) local box = node_new(id_hlist, nil, p) @@ -250,7 +250,7 @@ local function capsule_glyph_math(p, met, char_data) 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') + (has_attr(p,attr_ykblshift) or 0) + = - getfield(p, 'yoffset') + (get_attr(p,attr_ykblshift) 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); @@ -268,18 +268,18 @@ function luatexja.setwidth.apply_ashift_math(head, last, attr_ablshift) local pid = getid(p) if p==last then return - elseif (has_attr(p, attr_icflag) or 0) ~= PROCESSED then + elseif (get_attr(p, attr_icflag) or 0) ~= PROCESSED then if pid==id_hlist or pid==id_vlist then - setshift(p, getshift(p) + (has_attr(p,attr_ablshift) or 0)) + setshift(p, getshift(p) + (get_attr(p,attr_ablshift) or 0)) elseif pid==id_rule then - local v = has_attr(p,attr_ablshift) or 0 + local v = get_attr(p,attr_ablshift) or 0 setheight(p, getheight(p)-v); setdepth(p, getdepth(p)+v) set_attr(p, attr_icflag, PROCESSED) elseif pid==id_glyph then -- 欧文文字; 和文文字は pid == id_hlist の場合で処理される -- (see conv_jchar_to_hbox_A in ltj-math.lua) setfield(p, 'yoffset', - getfield(p, 'yoffset') - (has_attr(p,attr_ablshift) or 0)) + getfield(p, 'yoffset') - (get_attr(p,attr_ablshift) or 0)) end set_attr(p, attr_icflag, PROCESSED) end @@ -297,7 +297,7 @@ do if not head then return end local y_adjust, node_depth, adj_depth = 0, 0, 0 for lp in node_traverse_id(id_glyph, head) do - y_adjust = has_attr(lp,attr_ablshift) or 0 + y_adjust = get_attr(lp,attr_ablshift) or 0 local ld = getdepth(lp) node_depth = max(ld + min(y_adjust, 0), node_depth) adj_depth = (y_adjust>0) and max(ld + y_adjust, adj_depth) or adj_depth diff --git a/src/luatexja.lua b/src/luatexja.lua index f6f9622..eb4fdf5 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -417,7 +417,7 @@ do local node_type = node.type local node_next = node.next -local has_attr = node.has_attribute +local get_attr = node.get_attribute local id_penalty = node.id('penalty') local id_glyph = node.id('glyph') @@ -435,7 +435,7 @@ local utfchar = utf.char local function debug_show_node_X(p,print_fn, limit, inner_depth) local k = prefix local s - local pt, pic = node_type(p.id), (has_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG + local pt, pic = node_type(p.id), (get_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG local base = prefix .. string.format('%X', pic) .. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' ' if pt == 'glyph' then s = base .. ' ' @@ -452,11 +452,11 @@ local function debug_show_node_X(p,print_fn, limit, inner_depth) if pt=='ins' then s = base .. '(' .. print_scaled(p.height) .. '+' .. print_scaled(p.depth) .. ')' - .. ', dir=' .. tostring(node.has_attribute(p, attr_dir)) + .. ', dir=' .. tostring(node.get_attribute(p, attr_dir)) else s = base .. '(' .. print_scaled(p.height) .. '+' .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width) - .. ', dir=' .. tostring(node.has_attribute(p, attr_dir)) + .. ', dir=' .. tostring(node.get_attribute(p, attr_dir)) end if (p.shift or 0)~=0 then s = s .. ', shifted ' .. print_scaled(p.shift) @@ -484,7 +484,7 @@ local function debug_show_node_X(p,print_fn, limit, inner_depth) elseif pt=='rule' then s = base .. '(' .. print_scaled(p.height) .. '+' .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width) - .. ', dir=' .. tostring(node.has_attribute(p, attr_dir)) + .. ', dir=' .. tostring(node.get_attribute(p, attr_dir)) print_fn(s) elseif pt=='disc' then print_fn(s) @@ -548,7 +548,7 @@ local function debug_show_node_X(p,print_fn, limit, inner_depth) else s = s .. ' userid:' .. t .. '(node list)' if p.user_id==uid_table.DIR then - s = s .. ' dir: ' .. tostring(node.has_attribute(p, attr_dir)) + s = s .. ' dir: ' .. tostring(node.get_attribute(p, attr_dir)) end print_fn(s) local bid = inner_depth -- 2.11.0