summaryrefslogtreecommitdiff
path: root/src/fontloader/misc/fontloader-font-ots.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-06-15 00:02:42 +0200
committerGitHub <noreply@github.com>2016-06-15 00:02:42 +0200
commit36cc5c9c567e24916f254203fc362bf124e26d02 (patch)
tree56cdd0a401ffbb99e8702f47a7865677b0971a8e /src/fontloader/misc/fontloader-font-ots.lua
parent17fbf1d1c26047f1e0e80fc6e5f3331f6183a795 (diff)
parentba744a4bce3ed03eefbf2b4746fa24e6d388d9ff (diff)
downloadluaotfload-36cc5c9c567e24916f254203fc362bf124e26d02.tar.gz
Merge pull request #364 from phi-gamma/master
fixes, 3rd edition
Diffstat (limited to 'src/fontloader/misc/fontloader-font-ots.lua')
-rw-r--r--src/fontloader/misc/fontloader-font-ots.lua47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/fontloader/misc/fontloader-font-ots.lua b/src/fontloader/misc/fontloader-font-ots.lua
index 21225c2..51704bf 100644
--- a/src/fontloader/misc/fontloader-font-ots.lua
+++ b/src/fontloader/misc/fontloader-font-ots.lua
@@ -124,7 +124,7 @@ local trace_cursive = false registertracker("otf.cursive", function(v
local trace_preparing = false registertracker("otf.preparing", function(v) trace_preparing = v end)
local trace_bugs = false registertracker("otf.bugs", function(v) trace_bugs = v end)
local trace_details = false registertracker("otf.details", function(v) trace_details = v end)
-local trace_applied = false registertracker("otf.applied", function(v) trace_applied = v end)
+----- trace_applied = false registertracker("otf.applied", function(v) trace_applied = v end)
local trace_steps = false registertracker("otf.steps", function(v) trace_steps = v end)
local trace_skips = false registertracker("otf.skips", function(v) trace_skips = v end)
local trace_directions = false registertracker("otf.directions", function(v) trace_directions = v end)
@@ -145,10 +145,8 @@ local report_direct = logs.reporter("fonts","otf direct")
local report_subchain = logs.reporter("fonts","otf subchain")
local report_chain = logs.reporter("fonts","otf chain")
local report_process = logs.reporter("fonts","otf process")
------ report_prepare = logs.reporter("fonts","otf prepare")
local report_warning = logs.reporter("fonts","otf warning")
local report_run = logs.reporter("fonts","otf run")
-local report_check = logs.reporter("fonts","otf check")
registertracker("otf.replacements", "otf.singles,otf.multiples,otf.alternatives,otf.ligatures")
registertracker("otf.positions","otf.marks,otf.kerns,otf.cursive")
@@ -185,10 +183,7 @@ local setlink = nuts.setlink
local ischar = nuts.is_char
-local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
-local delete_node = nuts.delete
-local remove_node = nuts.remove
local copy_node = nuts.copy
local copy_node_list = nuts.copy_list
local find_node_tail = nuts.tail
@@ -244,7 +239,7 @@ local cursonce = true
local fonthashes = fonts.hashes
local fontdata = fonthashes.identifiers
-local otffeatures = fonts.constructors.newfeatures("otf")
+local otffeatures = fonts.constructors.features.otf
local registerotffeature = otffeatures.register
local onetimemessage = fonts.loggers.onetimemessage or function() end
@@ -3064,7 +3059,7 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm
while start do
local char = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if not a or (a == attr) then
local lookupmatch = lookupcache[char]
if lookupmatch then
@@ -3097,7 +3092,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
while start ~= stop do
local char = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if not a or (a == attr) then
local lookupmatch = lookupcache[char]
if lookupmatch then -- hm, hyphens can match (tlig) so we need to really check
@@ -3132,7 +3127,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
end
-- local function d_run_single(prev,font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
--- local a = getattr(prev,0)
+-- local a = attr and getattr(prev,0)
-- if not a or (a == attr) then
-- local char = ischar(prev) -- can be disc
-- if char then
@@ -3149,7 +3144,7 @@ end
-- end
local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
- local a = getattr(sub,0)
+ local a = attr and getattr(sub,0)
if not a or (a == attr) then
for n in traverse_nodes(sub) do -- only gpos
if n == last then
@@ -3181,7 +3176,7 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm
while start do
local char = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if not a or (a == attr) then
for i=1,nofsteps do
local step = steps[i]
@@ -3228,7 +3223,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
while start ~= stop do
local char = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if not a or (a == attr) then
for i=1,nofsteps do
local step = steps[i]
@@ -3271,7 +3266,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
end
-- local function d_run_multiple(prev,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
--- local a = getattr(prev,0)
+-- local a = attr and getattr(prev,0)
-- if not a or (a == attr) then
-- local char = ischar(prev) -- can be disc
-- if char then
@@ -3297,7 +3292,7 @@ end
-- end
local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
- local a = getattr(sub,0)
+ local a = attr and getattr(sub,0)
if not a or (a == attr) then
for n in traverse_nodes(sub) do -- only gpos
if n == last then
@@ -3394,6 +3389,14 @@ local function featuresprocessor(head,font,attr)
end
+ -- some 10% faster when no dynamics but hardly measureable on real runs .. but: it only
+ -- works when we have no other dynamics as otherwise the zero run will be applied to the
+ -- whole stream for which we then need to pass another variable which we won't
+
+ -- if attr == 0 then
+ -- attr = false
+ -- end
+
head = tonut(head)
if trace_steps then
@@ -3405,7 +3408,7 @@ local function featuresprocessor(head,font,attr)
local done = false
local datasets = otf.dataset(tfmdata,font,attr)
- local dirstack = { } -- could move outside function btu we can have local runss
+ local dirstack = { } -- could move outside function but we can have local runs
sweephead = { }
@@ -3451,7 +3454,7 @@ local function featuresprocessor(head,font,attr)
while start do
local char = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if not a or (a == attr) then
for i=1,nofsteps do
local step = steps[i]
@@ -3485,18 +3488,15 @@ local function featuresprocessor(head,font,attr)
local start = head -- local ?
rlmode = 0 -- to be checked ?
if nofsteps == 1 then -- happens often
-
local step = steps[1]
local lookupcache = step.coverage
if not lookupcache then
- -- can't happen, no check in loop either
report_missing_coverage(dataset,sequence)
else
-
while start do
local char, id = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if a then
a = (a == attr) and (not attribute or getprop(start,a_state) == attribute)
else
@@ -3553,7 +3553,7 @@ local function featuresprocessor(head,font,attr)
while start do
local char, id = ischar(start,font)
if char then
- local a = getattr(start,0)
+ local a = attr and getattr(start,0)
if a then
a = (a == attr) and (not attribute or getprop(start,a_state) == attribute)
else
@@ -3652,6 +3652,9 @@ registerotffeature {
}
}
+otf.nodemodeinitializer = featuresinitializer
+otf.featuresprocessor = featuresprocessor
+
-- This can be used for extra handlers, but should be used with care!
otf.handlers = handlers -- used in devanagari