diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-21 23:46:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-21 23:46:31 +0000 |
commit | dbf06c3ecc6528bd2410630d2a251940ec0c9b23 (patch) | |
tree | c875bdd9f4e6a021f50e1e36e2779c07b828347c /Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua | |
parent | 142d903dcd96ad083d58f5518aa138a676eb68c0 (diff) |
luatexja (21apr15)
git-svn-id: svn://tug.org/texlive/trunk@36992 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua index e2d97de7134..020cec9a3c3 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua +++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua @@ -3,7 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.charrange', - date = '2014/01/19', + date = '2014/05/08', description = 'Handling the range of Japanese characters', }) module('luatexja.charrange', package.seeall) @@ -24,13 +24,16 @@ local pow = math.pow local kcat_attr_table = {} local pow_table = {} local fn_table = {} -- used in is_ucs_in_japanese_char_direct +local nfn_table = {} -- used in is_ucs_in_japanese_char_node for i = 0, 31*ATTR_RANGE-1 do - kcat_attr_table[i] = luatexbase.attributes['ltj@kcat'..floor(i/31)] - pow_table[i] = pow(2, i%31) - fn_table[i] = function(p) - return floor(has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk - end + local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 1/pow(2, i%31) + local jcr_noncjk = jcr_noncjk + kcat_attr_table[i], pow_table[i] = ka, pow(2, i%31) + fn_table[i] = function(p) return floor(has_attr(p, ka)*pw)%2 ~= jcr_noncjk end + nfn_table[i] = function(p) return floor(has_attr_node(p, ka)*pw)%2 ~= jcr_noncjk end end +fn_table[-1] = function() return false end -- for char --U+007F +nfn_table[-1] = function() return false end -- for char --U+007F pow_table[31*ATTR_RANGE] = pow(2, 31) -- jcr_table_main[chr_code] = index @@ -42,6 +45,7 @@ jcr_table_main = {} local jcr_table_main = jcr_table_main local ucs_out = 0x110000 +for i=0x0 ,0x7F do jcr_table_main[i]=-1 end for i=0x80 ,0xFF do jcr_table_main[i]=1 end for i=0x100,ucs_out-1 do jcr_table_main[i]=0 end @@ -68,12 +72,8 @@ function add_char_range(b,e,ind) -- ind: external range number end function char_to_range(c) -- return the external range number - c=ltjb.in_unicode(c, false) - if c<0x80 then return -1 - else - local r = jcr_table_main[c] or 217 - return (r and r~=0) and r or 217 - end + local r = jcr_table_main[ltjb.in_unicode(c, false)] or 217 + return (r~=0) and r or 217 end function get_range_setting(i) -- i: internal range number @@ -82,29 +82,17 @@ end -- glyph_node p は和文文字か? function is_ucs_in_japanese_char_node(p) - local c = p.char - if c<0x80 then - return false - else - local i=jcr_table_main[c] - return (floor( - has_attr_node(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk) - end + return nfn_table[jcr_table_main[c or p.char]](p) end is_ucs_in_japanese_char = is_ucs_in_japanese_char_node +-- only ltj-otf.lua uses this version -function is_ucs_in_japanese_char_direct(p) - local c = getchar(p) - if c<0x80 then - return false - else - return fn_table[jcr_table_main[c]](p) - end +function is_ucs_in_japanese_char_direct(p ,c) + return fn_table[jcr_table_main[c or getchar(p)]](p) end function is_japanese_char_curlist(c) -- assume that c>=0x80 - local i=jcr_table_main[c] - return get_range_setting(i)~= jcr_noncjk + return get_range_setting(jcr_table_main[c])~= jcr_noncjk end -- EXT @@ -120,7 +108,8 @@ function toggle_char_range(g, i) -- i: external range number if i>=7*ATTR_RANGE then i=0 end local attr = kcat_attr_table[i] local a = tex_getattr(attr) - tex.setattribute(g,attr,(floor(a/pow_table[i+1])*2+kc)*pow_table[i]+a%pow_table[i]) + tex.setattribute(g, attr, + (floor(a/pow_table[i+1])*2+kc)*pow_table[i]+a%pow_table[i]) end end |