diff options
Diffstat (limited to 'src/fontloader/misc')
-rw-r--r-- | src/fontloader/misc/fontloader-font-con.lua | 22 | ||||
-rw-r--r-- | src/fontloader/misc/fontloader-font-otf.lua | 33 | ||||
-rw-r--r-- | src/fontloader/misc/fontloader-l-lpeg.lua | 26 |
3 files changed, 63 insertions, 18 deletions
diff --git a/src/fontloader/misc/fontloader-font-con.lua b/src/fontloader/misc/fontloader-font-con.lua index bb96912..72fbb5c 100644 --- a/src/fontloader/misc/fontloader-font-con.lua +++ b/src/fontloader/misc/fontloader-font-con.lua @@ -507,6 +507,7 @@ function constructors.scale(tfmdata,specification) local nonames = properties.noglyphnames local haskerns = properties.haskerns or properties.mode == "base" -- we can have afm in node mode local hasligatures = properties.hasligatures or properties.mode == "base" -- we can have afm in node mode + local realdimensions = properties.realdimensions -- if changed and not next(changed) then changed = false @@ -618,6 +619,27 @@ function constructors.scale(tfmdata,specification) local width = description.width local height = description.height local depth = description.depth + if realdimensions then + -- this is mostly for checking issues + if not height or height == 0 then + local bb = description.boundingbox + local ht = bb[4] + if ht ~= 0 then + height = ht + end + if not depth or depth == 0 then + local dp = -bb[2] + if dp ~= 0 then + depth = dp + end + end + elseif not depth or depth == 0 then + local dp = -description.boundingbox[2] + if dp ~= 0 then + depth = dp + end + end + end if width then width = hdelta*width else width = scaledwidth end if height then height = vdelta*height else height = scaledheight end -- if depth then depth = vdelta*depth else depth = scaleddepth end diff --git a/src/fontloader/misc/fontloader-font-otf.lua b/src/fontloader/misc/fontloader-font-otf.lua index c7e83a4..85eebaa 100644 --- a/src/fontloader/misc/fontloader-font-otf.lua +++ b/src/fontloader/misc/fontloader-font-otf.lua @@ -107,6 +107,7 @@ registerdirective("fonts.otf.loader.pack", function(v) packdata = registerdirective("fonts.otf.loader.syncspace", function(v) syncspace = v end) registerdirective("fonts.otf.loader.forcenotdef", function(v) forcenotdef = v end) registerdirective("fonts.otf.loader.overloadkerns", function(v) overloadkerns = v end) +-----------------("fonts.otf.loader.alldimensions", function(v) alldimensions = v end) function otf.fileformat(filename) local leader = lower(io.loadchunk(filename,4)) @@ -637,17 +638,27 @@ actions["add dimensions"] = function(data,filename) -- d.name = ".notdef" -- end if bb then - local ht, dp = bb[4], -bb[2] - if ht == 0 or ht < 0 then - -- not set - else - d.height = ht - end - if dp == 0 or dp < 0 then - -- not set - else - d.depth = dp - end + local ht = bb[4] + local dp = -bb[2] + -- if alldimensions then + -- if ht ~= 0 then + -- d.height = ht + -- end + -- if dp ~= 0 then + -- d.depth = dp + -- end + -- else + if ht == 0 or ht < 0 then + -- not set + else + d.height = ht + end + if dp == 0 or dp < 0 then + -- not set + else + d.depth = dp + end + -- end end end end diff --git a/src/fontloader/misc/fontloader-l-lpeg.lua b/src/fontloader/misc/fontloader-l-lpeg.lua index 9225b57..4aadadb 100644 --- a/src/fontloader/misc/fontloader-l-lpeg.lua +++ b/src/fontloader/misc/fontloader-l-lpeg.lua @@ -841,7 +841,7 @@ local function make(t) local function making(t) local p = p_false local keys = sortedkeys(t) - local okay = t[""] +-- local okay = t[""] for i=1,#keys do local k = keys[i] if k ~= "" then @@ -850,13 +850,16 @@ local function make(t) p = p + P(k) * p_true elseif v == false then -- can't happen - elseif okay then - p = p + P(k) * (making(v) + p_true) +-- elseif okay then +-- p = p + P(k) * (making(v) + p_true) else p = p + P(k) * making(v) end end end + if t[""] then + p = p + p_true + end return p end local p = p_false @@ -869,8 +872,8 @@ local function make(t) p = p + P(k) * p_true elseif v == false then -- can't happen - elseif v[""] then - p = p + P(k) * (making(v) + p_true) +-- elseif v[""] then +-- p = p + P(k) * (making(v) + p_true) else p = p + P(k) * making(v) end @@ -956,10 +959,11 @@ function lpeg.utfchartabletopattern(list) -- goes to util-lpg return make(tree) end --- local t = { "a", "abc", "ac", "abe", "abxyz", "xy", "bef" } +-- local t = { "a", "abc", "ac", "abe", "abxyz", "xy", "bef","aa" } -- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/string.upper + 1)^1) --- + -- inspect(lpegmatch(p,"a")) +-- inspect(lpegmatch(p,"aa")) -- inspect(lpegmatch(p,"aaaa")) -- inspect(lpegmatch(p,"ac")) -- inspect(lpegmatch(p,"bc")) @@ -974,6 +978,14 @@ end -- inspect(lpegmatch(p,"abxyz")) -- inspect(lpegmatch(p,"foobarbefcrap")) +-- local t = { ["^"] = 1, ["^^"] = 2, ["^^^"] = 3, ["^^^^"] = 4 } +-- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/t + 1)^1) +-- inspect(lpegmatch(p," ^ ^^ ^^^ ^^^^ ^^^^^ ^^^^^^ ^^^^^^^ ")) + +-- local t = { ["^^"] = 2, ["^^^"] = 3, ["^^^^"] = 4 } +-- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/t + 1)^1) +-- inspect(lpegmatch(p," ^ ^^ ^^^ ^^^^ ^^^^^ ^^^^^^ ^^^^^^^ ")) + -- lpeg.utfchartabletopattern { -- utfchar(0x00A0), -- nbsp -- utfchar(0x2000), -- enquad |