summaryrefslogtreecommitdiff
path: root/src/fontloader/misc
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-04-25 23:21:28 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-04-25 23:21:28 +0200
commitf5ae057cbe8d00ec09269080ee152fd52dfa931f (patch)
tree5943e53385184389c2b7247212392f072bf075e7 /src/fontloader/misc
parent88636ab5075bad0fdd6c635629fc29a9f95d8cbc (diff)
downloadluaotfload-f5ae057cbe8d00ec09269080ee152fd52dfa931f.tar.gz
[fontloader] sync with Context as of 2016-04-25
Diffstat (limited to 'src/fontloader/misc')
-rw-r--r--src/fontloader/misc/fontloader-font-afm.lua4
-rw-r--r--src/fontloader/misc/fontloader-font-otj.lua6
-rw-r--r--src/fontloader/misc/fontloader-font-otr.lua10
-rw-r--r--src/fontloader/misc/fontloader-font-ots.lua20
4 files changed, 29 insertions, 11 deletions
diff --git a/src/fontloader/misc/fontloader-font-afm.lua b/src/fontloader/misc/fontloader-font-afm.lua
index 7003304..99b8577 100644
--- a/src/fontloader/misc/fontloader-font-afm.lua
+++ b/src/fontloader/misc/fontloader-font-afm.lua
@@ -30,7 +30,7 @@ local fonts, logs, trackers, containers, resolvers = fonts, logs, trackers, cont
local next, type, tonumber = next, type, tonumber
local match, gmatch, lower, gsub, strip, find = string.match, string.gmatch, string.lower, string.gsub, string.strip, string.find
local char, byte, sub = string.char, string.byte, string.sub
-local abs, mod = math.abs, math.mod
+local abs = math.abs
local bxor, rshift = bit32.bxor, bit32.rshift
local P, S, R, Cmt, C, Ct, Cs, lpegmatch, patterns = lpeg.P, lpeg.S, lpeg.R, lpeg.Cmt, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.match, lpeg.patterns
local derivetable = table.derive
@@ -317,7 +317,7 @@ do
local function step(c)
local cipher = byte(c)
local plain = bxor(cipher,rshift(r,8))
- r = mod((cipher + r) * c1 + c2,65536)
+ r = ((cipher + r) * c1 + c2) % 65536
return char(plain)
end
diff --git a/src/fontloader/misc/fontloader-font-otj.lua b/src/fontloader/misc/fontloader-font-otj.lua
index aae70d1..ebda723 100644
--- a/src/fontloader/misc/fontloader-font-otj.lua
+++ b/src/fontloader/misc/fontloader-font-otj.lua
@@ -49,8 +49,8 @@ local attributes, nodes, node = attributes, nodes, node
fonts = fonts
local hashes = fonts.hashes
local fontdata = hashes.identifiers
-local parameters = fonts.hashes.parameters
-local resources = fonts.hashes.resources
+----- parameters = fonts.hashes.parameters -- not in generic
+----- resources = fonts.hashes.resources -- not in generic
nodes.injections = nodes.injections or { }
local injections = nodes.injections
@@ -1444,7 +1444,7 @@ local function injectspaces(head)
-- end
leftkerns = trig.left
rightkerns = trig.right
- local par = parameters[font]
+ local par = fontdata[font].parameters -- fallback for generic
factor = par.factor
threshold = par.spacing.width - 1 -- get rid of rounding errors
lastfont = font
diff --git a/src/fontloader/misc/fontloader-font-otr.lua b/src/fontloader/misc/fontloader-font-otr.lua
index a9ad739..24f6854 100644
--- a/src/fontloader/misc/fontloader-font-otr.lua
+++ b/src/fontloader/misc/fontloader-font-otr.lua
@@ -69,7 +69,7 @@ local next, type, unpack = next, type, unpack
local byte, lower, char, strip, gsub = string.byte, string.lower, string.char, string.strip, string.gsub
local bittest = bit32.btest
local concat, remove, unpack, fastcopy = table.concat, table.remov, table.unpack, table.fastcopy
-local floor, mod, abs, sqrt, round = math.floor, math.mod, math.abs, math.sqrt, math.round
+local floor, abs, sqrt, round = math.floor, math.abs, math.sqrt, math.round
local P, R, S, C, Cs, Cc, Ct, Carg, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Ct, lpeg.Carg, lpeg.Cmt
local lpegmatch = lpeg.match
@@ -1270,10 +1270,10 @@ formatreaders[4] = function(f,fontdata,offset)
-- bad encoding
elseif offset == 0 then
if trace_cmap then
- report("format 4.%i segment %2i from %C upto %C at index %H",1,segment,startchar,endchar,mod(startchar + delta,65536))
+ report("format 4.%i segment %2i from %C upto %C at index %H",1,segment,startchar,endchar,(startchar + delta) % 65536)
end
for unicode=startchar,endchar do
- local index = mod(unicode + delta,65536)
+ local index = (unicode + delta) % 65536
if index and index > 0 then
local glyph = glyphs[index]
if glyph then
@@ -1303,13 +1303,13 @@ formatreaders[4] = function(f,fontdata,offset)
else
local shift = (segment-nofsegments+offset/2) - startchar
if trace_cmap then
- report("format 4.%i segment %2i from %C upto %C at index %H",0,segment,startchar,endchar,mod(startchar + delta,65536))
+ report("format 4.%i segment %2i from %C upto %C at index %H",0,segment,startchar,endchar,(startchar + delta) % 65536)
end
for unicode=startchar,endchar do
local slot = shift + unicode
local index = indices[slot]
if index and index > 0 then
- index = mod(index + delta,65536)
+ index = (index + delta) % 65536
local glyph = glyphs[index]
if glyph then
local gu = glyph.unicode
diff --git a/src/fontloader/misc/fontloader-font-ots.lua b/src/fontloader/misc/fontloader-font-ots.lua
index 6911872..ac81989 100644
--- a/src/fontloader/misc/fontloader-font-ots.lua
+++ b/src/fontloader/misc/fontloader-font-ots.lua
@@ -9,6 +9,9 @@ if not modules then modules = { } end modules ['font-ots'] = { -- sequences
-- to be checked: discrun doesn't seem to do something useful now (except run the
-- check again) so if we need it again we'll do a zwnjrun or so
+-- components will go away and be replaced by a property table which simplifies
+-- code (also more efficient)
+
-- beware, on my development machine we test a slightly a more optimized version
-- assumptions:
@@ -566,7 +569,22 @@ local function toligature(head,start,stop,char,dataset,sequence,markflag,discfou
local pre, post, replace, pretail, posttail, replacetail = getdisc(discfound,true)
if not replace then -- todo: signal simple hyphen
local prev = getprev(base)
- local copied = copy_node_list(comp)
+-- local copied = copy_node_list(comp)
+local current = comp
+local previous = nil
+local copied = nil
+while current do
+ if getid(current) == glyph_code then
+ local n = copy_node(current)
+ if copied then
+ setlink(previous,n)
+ else
+ copied = n
+ end
+ previous = n
+ end
+ current = getnext(current)
+end
setprev(discnext,nil) -- also blocks funny assignments
setnext(discprev,nil) -- also blocks funny assignments
if pre then