X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-jfmglue.lua;h=330de54fbd355826346ef9cf65dcb6b2e7e59d0d;hb=847312c712d721a0198c00563075948541ced2b7;hp=e37e687ca4c36d2691d68e7beb9f28e7a653ec56;hpb=a6c37dba4272ef5de87886c805f6f902aa5f7175;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index e37e687..330de54 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -9,6 +9,7 @@ luatexbase.provides_module({ module('luatexja.jfmglue', package.seeall) local err, warn, info, log = luatexbase .errwarinf(_NAME) +luatexja.load_module('base'); local ltjb = luatexja.base luatexja.load_module('stack'); local ltjs = luatexja.stack luatexja.load_module('jfont'); local ltjf = luatexja.jfont luatexja.load_module('direction'); local ltjd = luatexja.direction @@ -34,7 +35,7 @@ local insert_before = Dnode.insert_before local insert_after = Dnode.insert_after local node_next = (Dnode ~= node) and Dnode.getnext or node.next local round = tex.round -local ltjd_make_dir_node = ltjd.make_dir_node +local ltjd_make_dir_whatsit = ltjd.make_dir_whatsit local ltjf_font_metric_table = ltjf.font_metric_table local ltjf_find_char_class = ltjf.find_char_class local node_new = Dnode.new @@ -44,9 +45,6 @@ local node_tail = Dnode.tail local node_free = Dnode.free local node_end_of_math = Dnode.end_of_math -local dir_tate = 3 -local dir_yoko = 4 - local id_glyph = node.id('glyph') local id_hlist = node.id('hlist') local id_vlist = node.id('vlist') @@ -106,11 +104,21 @@ local function fast_find_char_class(c,m) end -- 文字クラスの決定 -local function slow_find_char_class(c, m, oc) - local xc = c or oc - local cls = ltjf_find_char_class(oc, m) - if xc ~= oc and cls==0 then cls = ltjf_find_char_class(-xc, m) end - return cls, xc +local slow_find_char_class +do + local start_time_measure = ltjb.start_time_measure + local stop_time_measure = ltjb.stop_time_measure + slow_find_char_class = function (c, m, oc) + start_time_measure('slow_find_chr') + local cls = ltjf_find_char_class(oc, m) + if not c and cls==0 then + stop_time_measure('slow_find_chr') + return ltjf_find_char_class(-c, m), oc + else + stop_time_measure('slow_find_chr') + return cls, oc + end + end end local zero_glue = node_new(id_glue) @@ -170,7 +178,8 @@ local ihb_flag -- JFM グルー挿入抑止用 flag -------------------- hlist 内の文字の検索 local first_char, last_char, find_first_char - +do +local ltjd_glyph_from_packed = ltjd.glyph_from_packed local function check_box(box_ptr, box_end) local p = box_ptr; local found_visible_node = false if not p then @@ -196,7 +205,6 @@ local function check_box(box_ptr, box_end) end if pid==id_kern then local pa = get_attr_icflag(p) - --if pa==IC_PROCESSED or pa == PACKED then if pa==IC_PROCESSED then -- do nothing elseif getsubtype(p)==2 then @@ -208,10 +216,11 @@ local function check_box(box_ptr, box_end) end elseif pid==id_hlist then if PACKED == get_attr_icflag(p) then + local s = ltjd_glyph_from_packed(p) if find_first_char then - first_char = getlist(p); find_first_char = false + first_char = s; find_first_char = false end - last_char = getlist(p); found_visible_node = true + last_char = s; found_visible_node = true else if getfield(p, 'shift')==0 then if check_box(getlist(p), nil) then found_visible_node = true end @@ -254,7 +263,7 @@ function check_box_high(Nx, box_ptr, box_end) end return last_char end - +end -------------------- Np の計算と情報取得 luatexbase.create_callback("luatexja.jfmglue.whatsit_getinfo", "data", @@ -286,11 +295,17 @@ local function check_next_ickern(lp) end local function calc_np_pbox(lp, last) + local first, lpa, nc = (not Np.first), KINSOKU, nil Np.first = Np.first or lp; Np.id = id_pbox - local lpa, nc = KINSOKU, nil set_attr(lp, attr_icflag, get_attr_icflag(lp)); while lp ~=last and (lpa>=PACKED) and (lpa