-- -- luatexja/ltj-pretreat.lua -- luatexja.load_module('base'); local ltjb = luatexja.base luatexja.load_module('charrange'); local ltjc = luatexja.charrange luatexja.load_module('stack'); local ltjs = luatexja.stack luatexja.load_module('jfont'); local ltjf = luatexja.jfont luatexja.load_module('direction'); local ltjd = luatexja.direction local to_node = node.direct.tonode local to_direct = node.direct.todirect local setfield = node.direct.setfield local getid = node.direct.getid local getfont = node.direct.getfont local getchar = node.direct.getchar local getfield = node.direct.getfield local getsubtype = node.direct.getsubtype local getlang = node.direct.getlang or function (n) return getfield(n,'lang') end local pairs = pairs local floor = math.floor local has_attr = node.direct.has_attribute local set_attr = node.direct.set_attribute local node_traverse = node.direct.traverse local node_remove = node.direct.remove local node_next = node.direct.getnext local node_free = node.direct.free local node_end_of_math = node.direct.end_of_math local tex_getcount = tex.getcount local id_glyph = node.id('glyph') local id_math = node.id('math') local id_whatsit = node.id('whatsit') local sid_user = node.subtype('user_defined') local attr_dir = luatexbase.attributes['ltj@dir'] local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] local attr_curtfnt = luatexbase.attributes['ltj@curtfnt'] local attr_icflag = luatexbase.attributes['ltj@icflag'] local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct local ltjs_orig_char_table = ltjs.orig_char_table local ltjf_replace_altfont = ltjf.replace_altfont --local ltjf_font_extra_info = ltjf.font_extra_info local attr_orig_char = luatexbase.attributes['ltj@origchar'] local STCK = luatexja.userid_table.STCK local DIR = luatexja.userid_table.DIR local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG local dir_tate = luatexja.dir_table.dir_tate local lang_ja = luatexja.lang_ja local setlang = node.direct.setlang or function(n,l) setfield(n,'lang',l) end local setfont = node.direct.setfont or function(n,l) setfield(n,'font',l) end local setchar = node.direct.setchar or function(n,l) setfield(n,'char',l) end ------------------------------------------------------------------------ -- MAIN PROCESS STEP 1: replace fonts ------------------------------------------------------------------------ local wt, wtd = {}, {} do local ltjd_get_dir_count = ltjd.get_dir_count local start_time_measure, stop_time_measure = ltjb.start_time_measure, ltjb.stop_time_measure local head local suppress_hyphenate_ja_aux = { [id_math] = function(p) return node_next(node_end_of_math(node_next(p))) end, [id_whatsit] = function(p) if getsubtype(p)==sid_user then local uid = getfield(p, 'user_id') if uid==STCK then wt[#wt+1] = p; node_remove(head, p) elseif uid==DIR then if has_attr(p, attr_icflag)