From a0fb1a4d69667793af3cff54f71b5c01ad5434c1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 4 Sep 2012 23:02:12 +0000 Subject: luatexja (4sep12) git-svn-id: svn://tug.org/texlive/trunk@27593 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/luatex/luatexja/ltj-charrange.lua | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua') diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua index 6d7f5c32023..d976cb3debd 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua +++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua @@ -13,7 +13,15 @@ local err, warn, info, log = luatexbase.errwarinf(_NAME) luatexja.load_module('base'); local ltjb = luatexja.base local floor = math.floor +local pow = math.pow local has_attr = node.has_attribute +local kcat_attr_table = {} +local pow_table = {} +for i = 0, 216 do + kcat_attr_table[i] = luatexbase.attributes['ltj@kcat'..floor(i/31)] + pow_table[i] = pow(2, i%31) +end +pow_table[217] = pow(2, 31) -- jcr_table_main[chr_code] = index -- index : internal 0, 1, 2, ..., 216 0: 'other' @@ -54,27 +62,22 @@ function char_to_range(c) -- return the (external) range number 'So I changed this one to zero.'}) c=0 elseif c<0x80 then return -1 - else - local i = jcr_table_main[c] or 0 - if i==0 then return 217 else return i end - end + else return jcr_table_main[c] or 0 end end function get_range_setting(i) -- i: internal range number - return floor(tex.getattribute( - luatexbase.attributes['ltj@kcat'..floor(i/31)]) - /math.pow(2, i%31))%2 + return floor(tex.getattribute(kcat_attr_table[i])/pow_table[i])%2 end -- glyph_node p は和文文字か? function is_ucs_in_japanese_char(p) local c = p.char - if c<0x80 then return false + if c<0x80 then + return false else local i=jcr_table_main[c] return (floor( - has_attr(p, luatexbase.attributes['ltj@kcat'..floor(i/31)]) - /math.pow(2, i%31))%2 ~= jcr_noncjk) + has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk) end end @@ -89,10 +92,9 @@ function toggle_char_range(g, i) -- i: external range number local kc if i>0 then kc=0 else kc=1; i=-i end if i>216 then i=0 end - local attr = luatexbase.attributes['ltj@kcat'..floor(i/31)] + local attr = kcat_attr_table[i] local a = tex.getattribute(attr) - local k = math.pow(2, i%31) - tex.setattribute(g,attr,(floor(a/k/2)*2+kc)*k+a%k) + tex.setattribute(g,attr,(floor(a/pow_table[i+1])*2+kc)*pow_table[i]+a%pow_table[i]) end end -- cgit v1.2.3