summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-map.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/font-map.lua')
-rw-r--r--tex/context/base/mkiv/font-map.lua160
1 files changed, 129 insertions, 31 deletions
diff --git a/tex/context/base/mkiv/font-map.lua b/tex/context/base/mkiv/font-map.lua
index 66cf2db39..d931b822e 100644
--- a/tex/context/base/mkiv/font-map.lua
+++ b/tex/context/base/mkiv/font-map.lua
@@ -168,44 +168,73 @@ local function tounicode16sequence(unicodes)
return concat(t)
end
-local function tounicode(unicode)
- if type(unicode) == "table" then
- local t = { }
- for l=1,#unicode do
- local u = unicode[l]
- if u < 0xD7FF or (u > 0xDFFF and u <= 0xFFFF) then
- t[l] = f_single(u)
- else
- u = u - 0x10000
- t[l] = f_double(rshift(u,10)+0xD800,u%1024+0xDC00)
- end
- end
- return concat(t)
- else
- if unicode < 0xD7FF or (unicode > 0xDFFF and unicode <= 0xFFFF) then
- return f_single(unicode)
- else
- unicode = unicode - 0x10000
- return f_double(rshift(unicode,10)+0xD800,unicode%1024+0xDC00)
- end
- end
-end
+-- local function tounicode(unicode)
+-- if type(unicode) == "table" then
+-- local t = { }
+-- for l=1,#unicode do
+-- local u = unicode[l]
+-- if u < 0xD7FF or (u > 0xDFFF and u <= 0xFFFF) then
+-- t[l] = f_single(u)
+-- else
+-- u = u - 0x10000
+-- t[l] = f_double(rshift(u,10)+0xD800,u%1024+0xDC00)
+-- end
+-- end
+-- return concat(t)
+-- else
+-- if unicode < 0xD7FF or (unicode > 0xDFFF and unicode <= 0xFFFF) then
+-- return f_single(unicode)
+-- else
+-- unicode = unicode - 0x10000
+-- return f_double(rshift(unicode,10)+0xD800,unicode%1024+0xDC00)
+-- end
+-- end
+-- end
--- no real gain on runs
+local unknown = f_single(0xFFFD)
--- local hash = table.setmetatableindex(function(t,u)
+-- local function tounicode(unicode)
+-- if type(unicode) == "table" then
+-- local t = { }
+-- for l=1,#unicode do
+-- t[l] = tounicode(unicode[l])
+-- end
+-- return concat(t)
+-- elseif unicode >= 0x00E000 and unicode <= 0x00F8FF then
+-- return unknown
+-- elseif unicode >= 0x0F0000 and unicode <= 0x0FFFFF then
+-- return unknown
+-- elseif unicode >= 0x100000 and unicode <= 0x10FFFF then
+-- return unknown
+-- elseif unicode < 0xD7FF or (unicode > 0xDFFF and unicode <= 0xFFFF) then
+-- return f_single(unicode)
+-- else
+-- unicode = unicode - 0x10000
+-- return f_double(rshift(unicode,10)+0xD800,unicode%1024+0xDC00)
+-- end
+-- end
+
+-- local hash = table.setmetatableindex(function(t,k)
-- local v
--- if u < 0xD7FF or (u > 0xDFFF and u <= 0xFFFF) then
--- v = f_single(u)
+-- if k >= 0x00E000 and k <= 0x00F8FF then
+-- v = unknown
+-- elseif k >= 0x0F0000 and k <= 0x0FFFFF then
+-- v = unknown
+-- elseif k >= 0x100000 and k <= 0x10FFFF then
+-- v = unknown
+-- elseif k < 0xD7FF or (k > 0xDFFF and k <= 0xFFFF) then
+-- v = f_single(k)
-- else
--- u = u - 0x10000
--- v = f_double(rshift(u,10)+0xD800,u%1024+0xDC00)
+-- local k = k - 0x10000
+-- v = f_double(rshift(k,10)+0xD800,k%1024+0xDC00)
-- end
--- t[u] = v
+-- t[k] = v
-- return v
-- end)
--
--- local function tounicode(unicode,name)
+-- table.makeweak(hash)
+--
+-- local function tounicode(unicode)
-- if type(unicode) == "table" then
-- local t = { }
-- for l=1,#unicode do
@@ -217,6 +246,69 @@ end
-- end
-- end
+local hash = { }
+local conc = { }
+
+-- table.makeweak(hash)
+
+-- table.setmetatableindex(hash,function(t,k)
+-- if type(k) == "table" then
+-- local n = #k
+-- for l=1,n do
+-- conc[l] = hash[k[l]]
+-- end
+-- return concat(conc,"",1,n)
+-- end
+-- local v
+-- if k >= 0x00E000 and k <= 0x00F8FF then
+-- v = unknown
+-- elseif k >= 0x0F0000 and k <= 0x0FFFFF then
+-- v = unknown
+-- elseif k >= 0x100000 and k <= 0x10FFFF then
+-- v = unknown
+-- elseif k < 0xD7FF or (k > 0xDFFF and k <= 0xFFFF) then
+-- v = f_single(k)
+-- else
+-- local k = k - 0x10000
+-- v = f_double(rshift(k,10)+0xD800,k%1024+0xDC00)
+-- end
+-- t[k] = v
+-- return v
+-- end)
+--
+-- local function tounicode(unicode)
+-- return hash[unicode]
+-- end
+
+table.setmetatableindex(hash,function(t,k)
+ if k < 0xD7FF or (k > 0xDFFF and k <= 0xFFFF) then
+ v = f_single(k)
+ else
+ local k = k - 0x10000
+ v = f_double(rshift(k,10)+0xD800,k%1024+0xDC00)
+ end
+ t[k] = v
+ return v
+end)
+
+local function tounicode(k)
+ if type(k) == "table" then
+ local n = #k
+ for l=1,n do
+ conc[l] = hash[k[l]]
+ end
+ return concat(conc,"",1,n)
+ elseif k >= 0x00E000 and k <= 0x00F8FF then
+ return unknown
+ elseif k >= 0x0F0000 and k <= 0x0FFFFF then
+ return unknown
+ elseif k >= 0x100000 and k <= 0x10FFFF then
+ return unknown
+ else
+ return hash[k]
+ end
+end
+
local function fromunicode16(str)
if #str == 4 then
return tonumber(str,16)
@@ -431,7 +523,8 @@ function mappings.addtounicode(data,filename,checklookups,forceligatures)
glyph.unicode = unicode
end
else
- local t, n = { }, 0
+ local t = { }
+ local n = 0
for l=1,nsplit do
local base = split[l]
local u = unicodes[base] or unicodevector[base] or contextvector[name]
@@ -487,12 +580,17 @@ function mappings.addtounicode(data,filename,checklookups,forceligatures)
missing[du] = true
nofmissing = nofmissing + 1
end
+ else
+ -- maybe a message or so
end
end
else
local overload = overloads[du]
if overload then
glyph.unicode = overload.unicode
+ elseif not glyph.unicode then
+ missing[du] = true
+ nofmissing = nofmissing + 1
end
end
end