From: Hironori Kitagawa Date: Tue, 10 Jun 2014 23:06:17 +0000 (+0900) Subject: Optimized ltj-pretreat.lua and updated test12-ltjtarticle.tex. X-Git-Tag: 20150420.0~190 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=babfe8c4da4c40b72ce650c2a920046ba200ac29;p=luatex-ja%2Fluatexja.git Optimized ltj-pretreat.lua and updated test12-ltjtarticle.tex. --- diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 9e585f1..f16df90 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -799,6 +799,22 @@ function luatexja.direction.check_adjust_direction() stop_time_measure('box_primitive_hook') end +-- setbox +local id_adjust = node.id('adjust') +function luatexja.direction.hook_empty_box() + start_time_measure('box_primitive_hook') + local reg_num = tex_getcount('ltj@tempcnta') + local list_dir = get_dir_count() + local h = tex.getbox(reg_num) + if h then + if not h.head then + h.head = to_node(create_dir_whatsit(nil, nil, get_dir_count())) + luatexja.ext_show_node(h, '> ', print) + end + end + stop_time_measure('box_primitive_hook') +end + -- vsplit do local split_dir_whatsit diff --git a/src/ltj-pretreat.lua b/src/ltj-pretreat.lua index 080cf89..5182cb8 100644 --- a/src/ltj-pretreat.lua +++ b/src/ltj-pretreat.lua @@ -26,6 +26,7 @@ local floor = math.floor local has_attr = Dnode.has_attribute local set_attr = Dnode.set_attribute local node_traverse = Dnode.traverse +local node_traverse_id = Dnode.traverse_id local node_remove =luatexja.Dnode_remove -- Dnode.remove local node_next = (Dnode ~= node) and Dnode.getnext or node.next local node_prev = (Dnode ~= node) and Dnode.getprev or node.prev @@ -56,50 +57,51 @@ local dir_tate = luatexja.dir_table.dir_tate ------------------------------------------------------------------------ -- MAIN PROCESS STEP 1: replace fonts ------------------------------------------------------------------------ -local wt, wtd +local wt, wtd = {}, {} do local start_time_measure, stop_time_measure = ltjb.start_time_measure, ltjb.stop_time_measure local head local is_dir_tate - local suppress_hyphenate_ja_aux = {} - suppress_hyphenate_ja_aux[id_glyph] = function(p) + local suppress_hyphenate_ja_aux_glyph = function(p) if (has_attr(p, attr_icflag) or 0)<=0 and is_ucs_in_japanese_char(p) then local pc = getchar(p) - local pf = ltjf_replace_altfont(has_attr(p, attr_curjfnt) or getfont(p), pc) - setfield(p, 'font', pf); set_attr(p, attr_curjfnt, pf) + local pof, pcj = getfont(p), has_attr(p, attr_curjfnt) + local pf = ltjf_replace_altfont(pcj or pof, pc) + if pof~=pf then setfield(p, 'font', pf) end + if pcj~=pf then set_attr(p, attr_curjfnt, pf) end setfield(p, 'subtype', floor(getsubtype(p)*0.5)*2) set_attr(p, attr_orig_char, pc) end - return p end - suppress_hyphenate_ja_aux[id_math] = function(p) - return node_end_of_math(node_next(p)) end - suppress_hyphenate_ja_aux[50] = function(p) return p end - suppress_hyphenate_ja_aux[id_whatsit] = function(p) + local suppress_hyphenate_ja_aux_whatsit = function(p) if getsubtype(p)==sid_user then local uid = getfield(p, 'user_id') if uid==STCK then - wt[#wt+1] = p; head = node_remove(head, p) + wt[#wt+1] = p elseif uid==DIR then if has_attr(p, attr_icflag)