summaryrefslogtreecommitdiff
path: root/src/fontloader/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/fontloader/misc')
-rw-r--r--src/fontloader/misc/fontloader-font-map.lua4
-rw-r--r--src/fontloader/misc/fontloader-l-lpeg.lua198
2 files changed, 178 insertions, 24 deletions
diff --git a/src/fontloader/misc/fontloader-font-map.lua b/src/fontloader/misc/fontloader-font-map.lua
index e26f28e..449a00f 100644
--- a/src/fontloader/misc/fontloader-font-map.lua
+++ b/src/fontloader/misc/fontloader-font-map.lua
@@ -23,6 +23,8 @@ local fonts = fonts or { }
local mappings = fonts.mappings or { }
fonts.mappings = mappings
+local allocate = utilities.storage.allocate
+
--[[ldx--
<p>Eventually this code will disappear because map files are kind
of obsolete. Some code may move to runtime or auxiliary modules.</p>
@@ -194,7 +196,7 @@ local namesplitter = Ct(C((1 - ligseparator - varseparator)^1) * (ligseparator *
-- to be completed .. for fonts that use unicodes for ligatures which
-- is a actually a bad thing and should be avoided in the first place
-local overloads = {
+local overloads = allocate {
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 },
diff --git a/src/fontloader/misc/fontloader-l-lpeg.lua b/src/fontloader/misc/fontloader-l-lpeg.lua
index 192e32f..0c89706 100644
--- a/src/fontloader/misc/fontloader-l-lpeg.lua
+++ b/src/fontloader/misc/fontloader-l-lpeg.lua
@@ -888,24 +888,155 @@ end
-- return make(tree)
-- end
+local p_false = P(false)
+local p_true = P(true)
+
+-- local function make(t,hash)
+-- local p = p_false
+-- local keys = sortedkeys(t)
+-- for i=1,#keys do
+-- local k = keys[i]
+-- local v = t[k]
+-- local h = hash[v]
+-- if h then
+-- if next(v) then
+-- p = p + P(k) * (make(v,hash) + p_true)
+-- else
+-- p = p + P(k) * p_true
+-- end
+-- else
+-- if next(v) then
+-- p = p + P(k) * make(v,hash)
+-- else
+-- p = p + P(k)
+-- end
+-- end
+-- end
+-- return p
+-- end
+
+-- local function make(t,hash)
+-- local p = p_false
+-- local keys = sortedkeys(t)
+-- local function making(t,w)
+-- local p = p_false
+-- local keys = sortedkeys(t)
+-- for i=1,#keys do
+-- local k = keys[i]
+-- local v = t[k]
+-- if w then
+-- if next(v) then
+-- p = p + P(k) * (making(v,w) + p_true)
+-- else
+-- p = p + P(k) * p_true
+-- end
+-- else
+-- if next(v) then
+-- p = p + P(k) * making(v,w)
+-- else
+-- p = p + P(k)
+-- end
+-- end
+-- end
+-- return p
+-- end
+-- for i=1,#keys do
+-- local k = keys[i]
+-- local v = t[k]
+-- local h = hash[v]
+-- if h then
+-- if next(v) then
+-- p = p + P(k) * (making(v,true) + p_true)
+-- else
+-- p = p + P(k) * p_true
+-- end
+-- else
+-- if next(v) then
+-- p = p + P(k) * making(v,false)
+-- else
+-- p = p + P(k)
+-- end
+-- end
+-- end
+-- return p
+-- end
+--
+-- function lpeg.utfchartabletopattern(list) -- goes to util-lpg
+-- local tree = { }
+-- local hash = { }
+-- local n = #list
+-- if n == 0 then
+-- for s in next, list do
+-- local t = tree
+-- for c in gmatch(s,".") do
+-- local tc = t[c]
+-- if not tc then
+-- tc = { }
+-- t[c] = tc
+-- end
+-- t = tc
+-- end
+-- hash[t] = s
+-- end
+-- else
+-- for i=1,n do
+-- local t = tree
+-- local s = list[i]
+-- for c in gmatch(s,".") do
+-- local tc = t[c]
+-- if not tc then
+-- tc = { }
+-- t[c] = tc
+-- end
+-- t = tc
+-- end
+-- hash[t] = s
+-- end
+-- end
+-- return make(tree,hash)
+-- end
+
+
local function make(t,hash)
- local p = P(false)
+ local p = p_false
local keys = sortedkeys(t)
+ local function making(t,w)
+ local p = p_false
+ local keys = sortedkeys(t)
+ for i=1,#keys do
+ local k = keys[i]
+ local v = t[k]
+ if w then
+ if v == true then
+ p = p + P(k) * p_true
+ else
+ p = p + P(k) * (making(v,w) + p_true)
+ end
+ else
+ if v == true then
+ p = p + P(k)
+ else
+ p = p + P(k) * making(v,w)
+ end
+ end
+ end
+ return p
+ end
for i=1,#keys do
local k = keys[i]
local v = t[k]
local h = hash[v]
if h then
- if next(v) then
- p = p + P(k) * (make(v,hash) + P(true))
+ if v == true then
+ p = p + P(k) * p_true
else
- p = p + P(k) * P(true)
+ p = p + P(k) * (making(v,true) + p_true)
end
else
- if next(v) then
- p = p + P(k) * make(v,hash)
- else
+ if v == true then
p = p + P(k)
+ else
+ p = p + P(k) * making(v,false)
end
end
end
@@ -914,41 +1045,62 @@ end
function lpeg.utfchartabletopattern(list) -- goes to util-lpg
local tree = { }
- local hash = { }
+-- local hash = { }
+ local hash
local n = #list
if n == 0 then
- -- we could always use this branch
+ hash = list
for s in next, list do
local t = tree
+ local p, pk
for c in gmatch(s,".") do
- local tc = t[c]
- if not tc then
- tc = { }
- t[c] = tc
+ if t == true then
+ t = { [c] = true }
+ p[pk] = t
+ p = t
+ t = true
+ else
+ local tc = t[c]
+ if not tc then
+ tc = true
+ t[c] = tc
+ end
+ p = t
+ t = tc
end
- t = tc
+ pk = c
end
- hash[t] = s
end
else
+ hash = { }
for i=1,n do
local t = tree
local s = list[i]
+ local p, pk
for c in gmatch(s,".") do
- local tc = t[c]
- if not tc then
- tc = { }
- t[c] = tc
+ if t == true then
+ t = { [c] = true }
+ p[pk] = t
+ p = t
+ t = true
+ else
+ local tc = t[c]
+ if not tc then
+ tc = true
+ t[c] = true
+ end
+ p = t
+ t = tc
end
- t = tc
+ pk = c
end
- hash[t] = s
+ hash[s] = true
end
end
return make(tree,hash)
end
--- inspect ( lpeg.utfchartabletopattern {
+-- lpeg.utfchartabletopattern {
-- utfchar(0x00A0), -- nbsp
-- utfchar(0x2000), -- enquad
-- utfchar(0x2001), -- emquad
@@ -964,7 +1116,7 @@ end
-- utfchar(0x200B), -- zerowidthspace
-- utfchar(0x202F), -- narrownobreakspace
-- utfchar(0x205F), -- math thinspace
--- } )
+-- }
-- a few handy ones:
--