summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-12-10 01:31:19 +0000
committerKarl Berry <karl@freefriends.org>2012-12-10 01:31:19 +0000
commiteb3f5f9a64a4553a16273f9ff5cfe99d10f27dd8 (patch)
tree5e47c27e88cdb655ee7fefcf919ab531e8a4b757 /Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua
parent64b7e39503022a8c0ce58857cea7f25d57369757 (diff)
luatexja (9dec12)
git-svn-id: svn://tug.org/texlive/trunk@28482 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.lua36
1 files changed, 19 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua
index d976cb3debd..6d13c916349 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-charrange.lua
@@ -12,22 +12,23 @@ local err, warn, info, log = luatexbase.errwarinf(_NAME)
luatexja.load_module('base'); local ltjb = luatexja.base
+ATTR_RANGE = 7
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
+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)
end
-pow_table[217] = pow(2, 31)
+pow_table[31*ATTR_RANGE] = pow(2, 31)
-- jcr_table_main[chr_code] = index
-- index : internal 0, 1, 2, ..., 216 0: 'other'
-- external 1 2 216, (out of range): 'other'
--- initialize
+-- initialize
local jcr_table_main = {}
local jcr_cjk = 0; local jcr_noncjk = 1; local ucs_out = 0x110000
@@ -36,11 +37,12 @@ for i=0x100,ucs_out-1 do jcr_table_main[i]=0 end
-- EXT: add characters to a range
function add_char_range(b,e,ind) -- ind: external range number
- if not ind or ind<0 or ind>216 then -- 0 は error にしない(隠し)
+ if not ind or ind<0 or ind>=7*ATTR_RANGE then -- 0 は error にしない(隠し)
ltjb.package_error('luatexja',
"invalid character range number (" .. ind .. ")",
- {"A character range number should be in the range 1..216,",
- "ignored."})
+ "A character range number should be in the range 1.."
+ .. 7+ATTR_RANGE-1 .. ",\n" ..
+ "ignored.")
return
elseif b<0x80 or e>=ucs_out then
ltjb.package_warning('luatexja',
@@ -48,7 +50,7 @@ function add_char_range(b,e,ind) -- ind: external range number
'I take the intersection with [0x80, 0x10ffff].')
elseif b>e then
local j=b; e=b; b=j
- end
+ end
for i=math.max(0x80,b),math.min(ucs_out-1,e) do
jcr_table_main[i]=ind
end
@@ -58,8 +60,8 @@ function char_to_range(c) -- return the (external) range number
if not c or c<0 or c>0x10FFFF then
ltjb.package_error('luatexja',
'bad character code (' .. tostring(c) .. ')',
- {'A character number must be between 0 and 0x10ffff.',
- 'So I changed this one to zero.'})
+ 'A character number must be between 0 and 0x10ffff.\n' ..
+ 'So I changed this one to zero.')
c=0
elseif c<0x80 then return -1
else return jcr_table_main[c] or 0 end
@@ -72,12 +74,12 @@ end
-- glyph_node p は和文文字か?
function is_ucs_in_japanese_char(p)
local c = p.char
- if c<0x80 then
- return false
- else
- local i=jcr_table_main[c]
+ if c<0x80 then
+ return false
+ else
+ local i=jcr_table_main[c]
return (floor(
- has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk)
+ has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk)
end
end
@@ -87,15 +89,15 @@ function toggle_char_range(g, i) -- i: external range number
ltjb.package_error('luatexja',
"invalid character range number (" .. tostring(i).. ")",
"A character range number must be a number, ignored.")
- elseif i==0 then return
+ elseif i==0 then return
else
local kc
if i>0 then kc=0 else kc=1; i=-i end
- if i>216 then i=0 end
+ if i>=7*ATTR_RANGE then i=0 end
local attr = kcat_attr_table[i]
local a = tex.getattribute(attr)
tex.setattribute(g,attr,(floor(a/pow_table[i+1])*2+kc)*pow_table[i]+a%pow_table[i])
end
end
--- EOF \ No newline at end of file
+-- EOF