-box_stack_level = 0
--- This is used in jfmglue.lua.
-
-local function suppress_hyphenate_ja(head)
- local non_math = true
- for p in node_traverse(head) do
- if p.id == id_glyph and non_math then
- if (has_attr(p, attr_icflag) or 0)<=0 and ltjc_is_ucs_in_japanese_char(p) then
- p.font = has_attr(p, attr_curjfnt) or p.font
- set_attr(p, attr_orig_char, p.char)
- set_attr(p, attr_yablshift, has_attr(p, attr_ykblshift) or 0)
- p.subtype = floor(p.subtype/2)*2
+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)<PROCESSED_BEGIN_FLAG then
+ ltjs.list_dir = has_attr(p, attr_dir)
+ else -- こっちのケースは通常使用では起こらない
+ wtd[#wtd+1] = p; node_remove(head, p)
+ end
+ end
+ end
+ return node_next(p)
+ end,
+ }
+ setmetatable(suppress_hyphenate_ja_aux,
+ {
+ __index = function() return node_next end,
+ })
+ local function suppress_hyphenate_ja (h)
+ start_time_measure('ltj_hyphenate')
+ head = to_direct(h)
+ for i = 1,#wt do wt[i]=nil end
+ for i = 1,#wtd do wtd[i]=nil end
+ for i,_ in pairs(ltjs_orig_char_table) do
+ ltjs_orig_char_table[i] = nil
+ end
+ ltjs.list_dir=ltjd_get_dir_count()
+ do
+ local p = head
+ while p do
+ local pid = getid(p)
+ while pid==id_glyph do
+ local pc = getchar(p)
+ if has_attr(p, attr_icflag, 0) and is_ucs_in_japanese_char(p, pc) then
+ setfont(p, ltjf_replace_altfont(has_attr(p, attr_curjfnt) or getfont(p), pc))
+ setlang(p, lang_ja)
+ ltjs_orig_char_table[p] = pc
+ end
+ p = node_next(p); pid = getid(p)
+ end
+ p = (suppress_hyphenate_ja_aux[pid])(p)