summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/luatex/luatexja/tool/function_uax50.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/luatex/luatexja/tool/function_uax50.lua')
-rw-r--r--Master/texmf-dist/source/luatex/luatexja/tool/function_uax50.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/luatex/luatexja/tool/function_uax50.lua b/Master/texmf-dist/source/luatex/luatexja/tool/function_uax50.lua
new file mode 100644
index 00000000000..90d16f8ccc6
--- /dev/null
+++ b/Master/texmf-dist/source/luatex/luatexja/tool/function_uax50.lua
@@ -0,0 +1,50 @@
+kpse.set_program_name('luatex')
+dofile(kpse.find_file('lualibs.lua'))
+
+local function toX(a) return string.format('0x%X',a) end
+
+local uax_revision = '10.0.0'
+print(' -- UAX#50 for Unicode ' .. uax_revision)
+local fh = io.open('VerticalOrientation-' .. uax_revision .. '.txt')
+local t = {}
+
+for c in fh:lines() do
+ if c:match('(%x+)%.%.(%x+)%s+;%sT-[rR]') then
+ local b, e = c:match('(%x+)%.%.(%x+)%s+;')
+ b, e = tonumber(b,16), tonumber(e,16)
+ for i=b,e do t[i]=true end
+ elseif c:match('(%x+)%s+;%sT-[rR]') then
+ local b = c:match('(%x+)%s+;')
+ t[tonumber(b,16)]=true
+ end
+end
+
+fh:close()
+local t2={}
+local b, v = 0, t[0]
+for i=0,0x10ffff do
+ if t[i]~=v then
+ table.insert(t2,b); b, v=i, t[i]
+ end
+end
+table.insert(t2,b)
+
+print(' -- t[0] = ' .. tostring(t[0]))
+print(table.serialize(t2,' local t'))
+
+--[[
+for i,v in ipairs(t2) do
+ print(i, toX(v[1]) .. ' ≦x< ' .. toX(v[2]), v[3])
+end
+]]
+
+print([[ local function rotate_in_uax50(i)
+ local lo, hi = 1, #t
+ while lo < hi do
+ local mi = math.ceil((lo+hi)/2)
+ if t[mi]<=i then lo=mi else hi=mi-1 end
+ end
+ return lo%2==1
+ end
+]])
+