summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-map.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/font-map.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-map.lua b/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
index 706c5b70923..d4a1b4594fb 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
@@ -10,9 +10,9 @@ local tonumber, next, type = tonumber, next, type
local match, format, find, concat, gsub, lower = string.match, string.format, string.find, table.concat, string.gsub, string.lower
local P, R, S, C, Ct, Cc, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.match
-local floor = math.floor
local formatters = string.formatters
local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys
+local rshift = bit32.rshift
local trace_loading = false trackers.register("fonts.loading", function(v) trace_loading = v end)
local trace_mapping = false trackers.register("fonts.mapping", function(v) trace_mapping = v end)
@@ -78,6 +78,9 @@ end
local f_single = formatters["%04X"]
local f_double = formatters["%04X%04X"]
+-- floor(x/256) => rshift(x, 8)
+-- floor(x/1024) => rshift(x,10)
+
-- 0.684 0.661 0,672 0.650 : cache at lua end (more mem)
-- 0.682 0,672 0.698 0.657 : no cache (moderate mem i.e. lua strings)
-- 0.644 0.647 0.655 0.645 : convert in c (less mem in theory)
@@ -88,7 +91,7 @@ local f_double = formatters["%04X%04X"]
-- s = f_single(unicode)
-- else
-- unicode = unicode - 0x10000
--- s = f_double(floor(unicode/1024)+0xD800,unicode%1024+0xDC00)
+-- s = f_double(rshift(unicode,10)+0xD800,unicode%1024+0xDC00)
-- end
-- t[unicode] = s
-- return s
@@ -147,7 +150,7 @@ local function tounicode16(unicode)
return f_single(unicode)
else
unicode = unicode - 0x10000
- return f_double(floor(unicode/1024)+0xD800,unicode%1024+0xDC00)
+ return f_double(rshift(unicode,10)+0xD800,unicode%1024+0xDC00)
end
end
@@ -159,13 +162,13 @@ local function tounicode16sequence(unicodes)
t[l] = f_single(u)
else
u = u - 0x10000
- t[l] = f_double(floor(u/1024)+0xD800,u%1024+0xDC00)
+ t[l] = f_double(rshift(u,10)+0xD800,u%1024+0xDC00)
end
end
return concat(t)
end
-local function tounicode(unicode,name)
+local function tounicode(unicode)
if type(unicode) == "table" then
local t = { }
for l=1,#unicode do
@@ -174,7 +177,7 @@ local function tounicode(unicode,name)
t[l] = f_single(u)
else
u = u - 0x10000
- t[l] = f_double(floor(u/1024)+0xD800,u%1024+0xDC00)
+ t[l] = f_double(rshift(u,10)+0xD800,u%1024+0xDC00)
end
end
return concat(t)
@@ -183,7 +186,7 @@ local function tounicode(unicode,name)
return f_single(unicode)
else
unicode = unicode - 0x10000
- return f_double(floor(unicode/1024)+0xD800,unicode%1024+0xDC00)
+ return f_double(rshift(unicode,10)+0xD800,unicode%1024+0xDC00)
end
end
end
@@ -196,7 +199,7 @@ end
-- v = f_single(u)
-- else
-- u = u - 0x10000
--- v = f_double(floor(u/1024)+0xD800,u%1024+0xDC00)
+-- v = f_double(rshift(u,10)+0xD800,u%1024+0xDC00)
-- end
-- t[u] = v
-- return v
@@ -269,7 +272,7 @@ local namesplitter = Ct(C((1 - ligseparator - varseparator)^1) * (ligseparator *
do
- local overloads = allocate {
+ local overloads = {
IJ = { name = "I_J", unicode = { 0x49, 0x4A }, mess = 0x0132 },
ij = { name = "i_j", unicode = { 0x69, 0x6A }, mess = 0x0133 },
ff = { name = "f_f", unicode = { 0x66, 0x66 }, mess = 0xFB00 },
@@ -284,7 +287,7 @@ do
-- emdash = { name = "emdash", unicode = 0x2014, mess = 0x2014 },
}
- local o = { }
+ local o = allocate { }
for k, v in next, overloads do
local name = v.name