diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-08-04 09:53:17 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-08-04 09:53:17 +0200 |
commit | 817e18d3f6969b1b50b4883ec4d5bb05c985db88 (patch) | |
tree | 3569da776df0f8bcf449efd99b11380544d44ec5 /tex | |
parent | ab253433729006addd4336870face2facce5f894 (diff) | |
download | context-817e18d3f6969b1b50b4883ec4d5bb05c985db88.tar.gz |
2017-08-04 09:46:00
Diffstat (limited to 'tex')
24 files changed, 380 insertions, 341 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 422431de5..92f84faee 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.08.03 11:02} +\newcontextversion{2017.08.04 09:40} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index d17fff45a..1b97ea1b6 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2017.08.03 11:02} +\edef\contextversion{2017.08.04 09:40} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-cs.mkii b/tex/context/base/mkii/mult-cs.mkii index 837a397fb..423d47e26 100644 --- a/tex/context/base/mkii/mult-cs.mkii +++ b/tex/context/base/mkii/mult-cs.mkii @@ -687,6 +687,7 @@ \setinterfaceconstant{bottomoffset}{offsetspodku} \setinterfaceconstant{bottomspace}{bottomspace} \setinterfaceconstant{bottomstate}{statusspodku} +\setinterfaceconstant{break}{break} \setinterfaceconstant{buffer}{buffer} \setinterfaceconstant{cache}{cache} \setinterfaceconstant{calculate}{pocitat} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index ea19bb659..9af4f2fd3 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.08.03 11:02} +\newcontextversion{2017.08.04 09:40} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index a1cc5c7b0..0a6301ff1 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -41,7 +41,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2017.08.03 11:02} +\edef\contextversion{2017.08.04 09:40} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index 6741add90..dc1b95e14 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -2072,7 +2072,7 @@ do local nofsubtables = #subtables local order = lookup.order local flags = lookup.flags - -- this is expected in th efont handler (faster checking) + -- this is expected in the font handler (faster checking) if flags[1] then flags[1] = "mark" end if flags[2] then flags[2] = "ligature" end if flags[3] then flags[3] = "base" end diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi index 4dd15812f..0dfdf0842 100644 --- a/tex/context/base/mkiv/font-lib.mkvi +++ b/tex/context/base/mkiv/font-lib.mkvi @@ -43,9 +43,21 @@ \registerctxluafile{font-otl}{1.001} \registerctxluafile{font-oto}{1.001} \registerctxluafile{font-otj}{1.001} -\registerctxluafile{font-oup}{1.001} + +\doifelsefile{font-oup-new.lua} { + \registerctxluafile{font-oup-new}{1.001} +} { + \registerctxluafile{font-oup}{1.001} +} + \registerctxluafile{font-ota}{1.001} -\registerctxluafile{font-ots}{1.001} + +\doifelsefile{font-ots-new.lua} { + \registerctxluafile{font-ots-new}{1.001} +} { + \registerctxluafile{font-ots}{1.001} +} + \registerctxluafile{font-otd}{1.001} \registerctxluafile{font-otc}{1.001} \registerctxluafile{font-oth}{1.001} diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index f0afb35de..1d6ef1f31 100644 --- a/tex/context/base/mkiv/font-mis.lua +++ b/tex/context/base/mkiv/font-mis.lua @@ -21,7 +21,7 @@ local readers = otf.readers if readers then - otf.version = otf.version or 3.101 + otf.version = otf.version or 3.102 otf.cache = otf.cache or containers.define("fonts", "otl", otf.version, true) function fonts.helpers.getfeatures(name,save) diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua index a4dec4f74..2670a924b 100644 --- a/tex/context/base/mkiv/font-nod.lua +++ b/tex/context/base/mkiv/font-nod.lua @@ -18,7 +18,10 @@ local match, rep = string.match, string.rep fonts = fonts or { } nodes = nodes or { } -local fonts, nodes, node, context = fonts, nodes, node, context + +local fonts = fonts +local nodes = nodes +local context = context local tracers = nodes.tracers or { } nodes.tracers = tracers @@ -296,24 +299,41 @@ function step_tracers.features() local f = collection[1] while f do if getid(f) == glyph_code then - local tfmdata, t = fontidentifiers[getfont(f)], { } + local tfmdata = fontidentifiers[getfont(f)] + local features = tfmdata.resources.features + local result_1 = { } + local result_2 = { } + local gpos = features and features.gpos or { } + local gsub = features and features.gsub or { } for feature, value in table.sortedhash(tfmdata.shared.features) do if feature == "number" or feature == "features" then - -- private + value = false elseif type(value) == "boolean" then if value then - t[#t+1] = formatters["%s=yes"](feature) + value = "yes" else - -- skip + value = false end else - t[#t+1] = formatters["%s=%s"](feature,value) + -- use value + end + if value then + if gpos[feature] or gsub[feature] or feature == "language" or feature == "script" then + result_1[#result_1+1] = formatters["%s=%s"](feature,value) + else + result_2[#result_2+1] = formatters["%s=%s"](feature,value) + end end end - if #t > 0 then - context(concat(t,", ")) + if #result_1 > 0 then + context("{\\bf[basic:} %, t{\\bf]} ",result_1) + else + context("{\\bf[}no basic features{\\bf]} ") + end + if #result_2 > 0 then + context("{\\bf[extra:} %, t{\\bf]}",result_2) else - context("no features") + context("{\\bf[}no extra features{\\bf]}") end return end diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua index 9adc8bff2..04fbf88f5 100644 --- a/tex/context/base/mkiv/font-osd.lua +++ b/tex/context/base/mkiv/font-osd.lua @@ -461,7 +461,6 @@ local sequence_reorder_matras = { nofsteps = 1, steps = { { - osdstep = true, coverage = pre_mark, } } @@ -476,7 +475,6 @@ local sequence_reorder_reph = { nofsteps = 1, steps = { { - osdstep = true, coverage = { }, } } @@ -491,7 +489,6 @@ local sequence_reorder_pre_base_reordering_consonants = { nofsteps = 1, steps = { { - osdstep = true, coverage = { }, } } @@ -505,7 +502,7 @@ local sequence_remove_joiners = { type = "devanagari_remove_joiners", nofsteps = 1, steps = { - { osdstep = true, + { coverage = both_joiners_true, }, } @@ -633,35 +630,22 @@ local function initializedevanagi(tfmdata) if coverage then local reph = false if kind == "rphf" then - -- - -- KE: I don't understand the rationale behind osdstep. The original if - -- statement checked whether coverage is contextual chaining. - -- - -- HH: The osdstep signals that we deal with our own feature here, not - -- one in the font itself so it was just a safeguard against us overloading - -- something driven by the font. - -- - -- if step.osdstep then -- selective - if true then -- always - -- rphf acts on consonant + halant - for k, v in next, ra do - local r = coverage[k] - if r then - local h = false - for k, v in next, halant do - local h = r[k] - if h then - reph = h.ligature or false - break - end - end - if reph then + -- rphf acts on consonant + halant + for k, v in next, ra do + local r = coverage[k] + if r then + local h = false + for k, v in next, halant do + local h = r[k] + if h then + reph = h.ligature or false break end end + if reph then + break + end end - else - -- rphf might be result of other handler/chainproc end end seqsubset[#seqsubset+1] = { kind, coverage, reph } @@ -1289,7 +1273,11 @@ end -- 2 Try to find a target position the same way as for pre-base matra. If it is found, reorder pre-base consonant glyph. -- 3 If position is not found, reorder immediately before main consonant. --- UNTESTED: NOT CALLED IN EXAMPLE +-- Here we implement a few handlers: +-- +-- function(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) +-- return head, start, done +-- end function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) local current = start @@ -1349,32 +1337,6 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) return head, start, true end --- function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement) --- local stop = getnext(start) --- local font = getfont(start) --- while stop do --- local char = ischar(stop) --- if char and (char == c_zwnj or char == c_zwj) then --- stop = getnext(stop) --- else --- break --- end --- end --- if stop then --- setnext(getprev(stop)) --- setprev(stop,getprev(start)) --- end --- local prev = getprev(start) --- if prev then --- setnext(prev,stop) --- end --- if head == start then --- head = stop --- end --- flush_list(start) --- return head, stop, true --- end - function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement) local stop = getnext(start) local font = getfont(start) diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua index 0d470c690..7014761f1 100644 --- a/tex/context/base/mkiv/font-otc.lua +++ b/tex/context/base/mkiv/font-otc.lua @@ -21,8 +21,9 @@ local otf = fonts.handlers.otf local registerotffeature = otf.features.register local setmetatableindex = table.setmetatableindex -local mergesteps = fonts.helpers.mergesteps +local checkmerge = fonts.helpers.checkmerge local checkflags = fonts.helpers.checkflags +local checksteps = fonts.helpers.checksteps local normalized = { substitution = "substitution", @@ -647,7 +648,8 @@ local function addfeature(data,feature,specifications) end end -- - setmetatableindex(steps,mergesteps) -- speedup + checkmerge(specification) + checksteps(specification) -- s[i] = { [stepkey] = steps, @@ -709,8 +711,6 @@ local function addfeature(data,feature,specifications) end end -- - setmetatableindex(steps,mergesteps) -- speedup - -- if featureflags[1] then featureflags[1] = "mark" end if featureflags[2] then featureflags[2] = "ligature" end if featureflags[3] then featureflags[3] = "base" end @@ -725,8 +725,10 @@ local function addfeature(data,feature,specifications) nofsteps = nofsteps, type = steptype, } - -- new + -- checkflags(sequence,resources) + checkmerge(sequence) + checksteps(sequence) -- position | prepend | append local first, last = getrange(sequences,category) inject(specification,sequences,sequence,first,last,category,feature) diff --git a/tex/context/base/mkiv/font-otj.lua b/tex/context/base/mkiv/font-otj.lua index 657f1a2a6..580a65dde 100644 --- a/tex/context/base/mkiv/font-otj.lua +++ b/tex/context/base/mkiv/font-otj.lua @@ -1042,6 +1042,9 @@ local function inject_everything(head,where) -- kern(w-x) glyph(p) kern(x) mark(n) ox = px - pn.markx - rightkern -- report_injections("r2l case 1: %p",ox) +if not pn.markmark then -- check or not (no longer needed) + ox = ox + (pn.leftkern or 0) +end else -- kern(x) glyph(p) kern(w-x) mark(n) -- ox = px - getwidth(p) + pn.markx - pp.leftkern diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index f6d99dbe0..4625c5aaf 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -52,7 +52,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.101 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.102 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otl", otf.version, true) otf.svgcache = containers.define("fonts", "svg", otf.version, true) otf.sbixcache = containers.define("fonts", "sbix", otf.version, true) diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index 6af5aa405..7194109a1 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -693,7 +693,7 @@ function handlers.gsub_single(head,start,dataset,sequence,replacement) return head, start, true end -function handlers.gsub_alternate(head,start,dataset,sequence,alternative) +function handlers.gsub_alternate(head,start,dataset,sequence,alternative,rlmode,skiphash) local kind = dataset[4] local what = dataset[1] local value = what == true and tfmdata.shared.features[kind] or what @@ -712,14 +712,17 @@ function handlers.gsub_alternate(head,start,dataset,sequence,alternative) return head, start, true end -function handlers.gsub_multiple(head,start,dataset,sequence,multiple) +function handlers.gsub_multiple(head,start,dataset,sequence,multiple,rlmode,skiphash) if trace_multiples then logprocess("%s: replacing %s by multiple %s",pref(dataset,sequence),gref(getchar(start)),gref(multiple)) end return multiple_glyphs(head,start,multiple,sequence.flags[1],dataset[1]) end -function handlers.gsub_ligature(head,start,dataset,sequence,ligature) +-- Don't we deal with disc otherwise now? I need to check if the next one can be +-- simplified. + +function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skiphash) local current = getnext(start) if not current then return head, start, false, nil @@ -838,7 +841,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) return head, start, false, discfound end -function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,injection) +function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) local startchar = getchar(start) local format = step.format if format == "single" or type(kerns) == "table" then -- the table check can go @@ -855,14 +858,7 @@ function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,in return head, start, false end --- elseif krn and step.format == "pair" --- and (not krn[1] or type(krn[1]) == "boolean") --- and (not krn[2] or type(krn[2]) == "boolean") --- and marks[nextchar] then --KE --- prev = snext --KE --- snext = getnext(snext) --KE - -function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,injection) +function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) local snext = getnext(start) if not snext then return head, start, false @@ -871,17 +867,10 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,inje while snext do local nextchar = ischar(snext,currentfont) if nextchar then - -- local krn = kerns[nextchar] - -- if not krn and marks[nextchar] then - -- prev = snext - -- snext = getnext(snext) - -- elseif not krn then - -- break - -- else if marks[nextchar] and sequence.flags[1] then prev = snext snext = getnext(snext) --- if sequence.skipsome and sequence.skipsome[nextchar] then +-- if skiphash and skiphash[nextchar] then -- includes marks too when flag -- prev = snext -- snext = getnext(snext) else @@ -938,7 +927,7 @@ end we need to explicitly test for basechar, baselig and basemark entries.</p> --ldx]]-- -function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) +function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode,skiphash) local markchar = getchar(start) if marks[markchar] then local base = getprev(start) -- [glyph] [start=mark] @@ -993,7 +982,7 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) return head, start, false end -function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode) +function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode,skiphash) local markchar = getchar(start) if marks[markchar] then local base = getprev(start) -- [glyph] [optional marks] [start=mark] @@ -1058,7 +1047,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm return head, start, false end -function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode) +function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode,skiphash) local markchar = getchar(start) if marks[markchar] then local base = getprev(start) -- [glyph] [basemark] [start=mark] @@ -1094,7 +1083,7 @@ function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode) return head, start, false end -function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,step,i) -- to be checked +function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,skiphash,step) -- to be checked local startchar = getchar(start) if marks[startchar] then if trace_cursive then @@ -1162,7 +1151,7 @@ local logwarning = report_chain -- in a bit weird way. There is no lookup and the replacement comes from the lookup -- itself. It is meant mostly for dealing with Urdu. -local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode) +local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode,skiphash) local char = getchar(start) local replacement = replacements[char] if replacement then @@ -1216,7 +1205,7 @@ end -- logwarning("%s: bad step, no proper return values",cref(dataset,sequence)) -- end -function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,chainindex) +function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1433,7 +1422,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup return head, start, false, 0, false end -function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,chainindex) +function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1465,7 +1454,7 @@ function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,r return head, start, false end -function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,chainindex) -- todo: injections ? +function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) -- todo: injections ? local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1486,17 +1475,10 @@ function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlm if not nextchar then break end - -- local krn = kerns[nextchar] - -- if not krn and marks[nextchar] then - -- prev = snext - -- snext = getnext(snext) - -- elseif not krn then - -- break - -- else if marks[nextchar] and sequence.flags[1] then prev = snext snext = getnext(snext) --- elseif sequence.markclass and sequence.markclass[nextchar] then - skipsome +-- if skiphash and skiphash[nextchar] then -- prev = snext -- snext = getnext(snext) else @@ -1547,7 +1529,7 @@ function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlm return head, start, false end -function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1615,7 +1597,7 @@ function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlooku return head, start, false end -function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1687,7 +1669,7 @@ function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentl return head, start, false end -function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1743,7 +1725,7 @@ function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlooku return head, start, false end -function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then @@ -1880,7 +1862,7 @@ end local noflags = { false, false, false, false } -local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- skipped) +local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck) local size = ck[5] - ck[4] + 1 local chainlookups = ck[6] @@ -1904,7 +1886,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- local chainproc = chainprocs[chainkind] if chainproc then local ok - head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,1) + head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash) if ok then done = true end @@ -1929,19 +1911,15 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- -- It's very unlikely that we will have skip classes here but still ... we seldom -- enter this branch anyway. - if skipsome then - skipsome = sequence.skipsome - end - local i = 1 local laststart = start local nofchainlookups = #chainlookups -- useful? while start do - if skipsome then -- hm, so we know we skip some + if skiphash then -- hm, so we know we skip some while start do local char = ischar(start,currentfont) if char then - if skipsome[char] then + if skiphash and skiphash[char] then start = getnext(start) else break @@ -1959,7 +1937,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- local chainproc = chainprocs[chainkind] if chainproc then local ok, n - head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,i) + head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash) -- messy since last can be changed ! if ok then done = true @@ -1992,7 +1970,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- -- todo: needs checking for holes in the replacements local replacements = ck[7] if replacements then - head, start, done = reversesub(head,start,last,dataset,sequence,replacements,rlmode) + head, start, done = reversesub(head,start,last,dataset,sequence,replacements,rlmode,skiphash) else done = true if trace_contexts then @@ -2003,7 +1981,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- return head, start, done end -local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) +local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) if not start then return head, start, false @@ -2233,14 +2211,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) end if not notmatchpre[lookaheaddisc] then local ok = false - cf, start, ok = chainrun(cf,start,cl,dataset,sequence,rlmode,ck,skipped) + cf, start, ok = chainrun(cf,start,cl,dataset,sequence,rlmode,skiphash,ck) if ok then done = true end end if not notmatchreplace[lookaheaddisc] then local ok = false - new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,ck,skipped) + new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck) if ok then done = true end @@ -2289,14 +2267,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) end if not notmatchpost[backtrackdisc] then local ok = false - cf, start, ok = chainrun(cf,start,last,dataset,sequence,rlmode,ck,skipped) + cf, start, ok = chainrun(cf,start,last,dataset,sequence,rlmode,skiphash,ck) if ok then done = true end end if not notmatchreplace[backtrackdisc] then local ok = false - new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,ck,skipped) + new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck) if ok then done = true end @@ -2323,7 +2301,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) else local ok = false - head, start, ok = chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped) + head, start, ok = chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck) if ok then done = true end @@ -2333,7 +2311,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) return head, start, done end -local function chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match) +local function chaintrac(head,start,dataset,sequence,rlmode,skiphash,ck,match) local rule = ck[1] local lookuptype = ck[8] or ck[2] local nofseq = #ck[3] @@ -2348,7 +2326,7 @@ end -- tests because they have many steps with one context (having multiple contexts makes more sense) -- also because we (can) reduce them. --- local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) +-- local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash) -- local sweepnode = sweepnode -- local sweeptype = sweeptype -- local currentfont = currentfont @@ -2356,7 +2334,6 @@ end -- local checkdisc = sweeptype and getprev(head) -- local flags = sequence.flags or noflags -- local done = false --- local skipsome = sequence.skipsome -- local skipped = false -- local startprev, -- startnext = getboth(start) @@ -2395,7 +2372,7 @@ end -- if last then -- local char, id = ischar(last,currentfont) -- if char then --- if skipsome and skipsome[char] then +-- if skiphash and skiphash[char] then -- skipped = true -- if trace_skips then -- show_skip(dataset,sequence,char,ck,classes[char]) @@ -2504,7 +2481,7 @@ end -- if prev then -- local char, id = ischar(prev,currentfont) -- if char then --- if skipsome and skipsome[char] then +-- if skiphash and skiphash[char] then -- skipped = true -- if trace_skips then -- show_skip(dataset,sequence,char,ck,classes[char]) @@ -2644,7 +2621,7 @@ end -- if current then -- local char, id = ischar(current,currentfont) -- if char then --- if skipsome and skipsome[char] then +-- if skiphash and skiphash[char] then -- skipped = true -- if trace_skips then -- show_skip(dataset,sequence,char,ck,classes[char]) @@ -2761,12 +2738,12 @@ end -- end -- if match then -- if trace_contexts then --- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,true) +-- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true) -- end -- if diskseen or sweepnode then --- head, start, done = chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) +-- head, start, done = chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck) -- else --- head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped) +-- head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck) -- end -- if done then -- break @@ -2774,7 +2751,7 @@ end -- -- next context -- end -- -- elseif trace_chains then --- -- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match) +-- -- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,match) -- end -- end -- if diskseen then @@ -2789,7 +2766,7 @@ end -- "labels" instead. This is one of the cases where it makes th ecode more readable and we might -- even gain a bit performance. -local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) +local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash) -- optimizing for rlmode gains nothing local sweepnode = sweepnode local sweeptype = sweeptype @@ -2810,7 +2787,6 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local currentfont = currentfont local skipped -- = false - local skipsome = sequence.skipsome local startprev, startnext = getboth(start) @@ -2849,7 +2825,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if last then local char, id = ischar(last,currentfont) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then skipped = true if trace_skips then show_skip(dataset,sequence,char,ck,classes[char]) @@ -2956,7 +2932,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if prev then local char, id = ischar(prev,currentfont) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then skipped = true if trace_skips then show_skip(dataset,sequence,char,ck,classes[char]) @@ -3082,7 +3058,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if current then local char, id = ischar(current,currentfont) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then skipped = true if trace_skips then show_skip(dataset,sequence,char,ck,classes[char]) @@ -3195,12 +3171,12 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end end if trace_contexts then - chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,true) + chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true) end if diskseen or sweepnode then - head, start, done = chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) + head, start, done = chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck) else - head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped) + head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck) end if done then break @@ -3209,7 +3185,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end ::next:: -- if trace_chains then - -- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match) + -- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,false) -- end end if diskseen then @@ -3228,13 +3204,13 @@ handlers.gpos_context = handle_contextchain -- this needs testing -local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode) +local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps = currentlookup.steps local nofsteps = currentlookup.nofsteps if nofsteps > 1 then reportmoresteps(dataset,sequence) end - return handle_contextchain(head,start,dataset,sequence,currentlookup,rlmode) + return handle_contextchain(head,start,dataset,sequence,currentlookup,rlmode,skiphash) end chainprocs.gsub_context = chained_contextchain @@ -3249,12 +3225,12 @@ chainprocs.gpos_context = chained_contextchain -- -- function otf.registerchainproc(name,f) -- -- chainprocs[name] = f --- chainprocs[name] = function(head,start,stop,dataset,sequence,currentlookup,rlmode) +-- chainprocs[name] = function(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) -- local done = currentlookup.nofsteps > 0 -- if not done then -- reportzerosteps(dataset,sequence) -- else --- head, start, done = f(head,start,stop,dataset,sequence,currentlookup,rlmode) +-- head, start, done = f(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) -- if not head or not start then -- reportbadsteps(dataset,sequence) -- end @@ -3665,7 +3641,7 @@ end local nesting = 0 -local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) +local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) local done = false local sweep = sweephead[head] if sweep then @@ -3686,7 +3662,7 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm local lookupmatch = lookupcache[char] if lookupmatch then local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done = true end @@ -3787,7 +3763,7 @@ local function t_run_single(start,stop,font,attr,lookupcache) return 0 end -local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) +local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) local a -- happens often so no assignment is faster if attr then a = getattr(sub,0) @@ -3801,7 +3777,7 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase if char then local lookupmatch = lookupcache[char] if lookupmatch then - local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,1,injection) + local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) if ok then return true end @@ -3811,7 +3787,7 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase end end -local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) +local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) local done = false local sweep = sweephead[head] if sweep then @@ -3836,7 +3812,7 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm if lookupmatch then -- we could move all code inline but that makes things even more unreadable local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done = true break @@ -3947,7 +3923,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps) return 0 end -local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) +local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) local a -- happens often so no assignment is faster if attr then a = getattr(sub,0) @@ -3964,7 +3940,7 @@ local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,datase local lookupcache = step.coverage local lookupmatch = lookupcache[char] if lookupmatch then - local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,i,injection) -- sub was head + local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) -- sub was head if ok then return true end @@ -4148,16 +4124,18 @@ do local handler = handlers[typ] -- store in dataset local steps = sequence.steps local nofsteps = sequence.nofsteps - local skipsome = sequence.skipsome + local skiphash = sequence.skiphash if not steps then - -- this permits injection, watch the different arguments - local h, d, ok = handler(head,head,dataset,sequence,nil,nil,nil,0,font,attr) + -- This permits injection, watch the different arguments. Watch out, the arguments passed + -- are not frozen as we might extend or change this. Is this used at all apart from some + -- experiments? + local h, ok = handler(head,dataset,sequence,initialrl,font,attr) -- less arguments now if ok then done = true - if h then - head = h - end + end + if h and h ~= head then + head = h end elseif typ == "gsub_reversecontextchain" then -- @@ -4185,9 +4163,8 @@ do local lookupcache = step.coverage local lookupmatch = lookupcache[char] if lookupmatch then - -- todo: disc? local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done = true break @@ -4216,7 +4193,7 @@ do while start do local char, id = ischar(start,font) if char then - if skipsome and skipsome[char] then -- we never needed it here but let's try + if skiphash and skiphash[char] then -- we never needed it here but let's try start = getnext(start) else local lookupmatch = lookupcache[char] @@ -4231,7 +4208,7 @@ do end if a then local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done = true end @@ -4252,11 +4229,11 @@ do if not discs or discs[start] == true then local ok if gpossing then - start, ok = kernrun(start,k_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + start, ok = kernrun(start,k_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) elseif typ == "gsub_ligature" then - start, ok = testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + start, ok = testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) else - start, ok = comprun(start,c_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + start, ok = comprun(start,c_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) end if ok then done = true @@ -4281,7 +4258,7 @@ do if char then local m = merged[char] if m then - if skipsome and skipsome[char] then -- we never needed it here but let's try + if skiphash and skiphash[char] then -- we never needed it here but let's try start = getnext(start) else local a -- happens often so no assignment is faster @@ -4302,7 +4279,7 @@ do if lookupmatch then -- we could move all code inline but that makes things even more unreadable local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done = true break @@ -4329,11 +4306,11 @@ do if not discs or discs[start] == true then local ok if gpossing then - start, ok = kernrun(start,k_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + start, ok = kernrun(start,k_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) elseif typ == "gsub_ligature" then - start, ok = testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + start, ok = testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) else - start, ok = comprun(start,c_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + start, ok = comprun(start,c_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) end if ok then done = true @@ -4419,7 +4396,7 @@ do position = position + 1 local m = merged[char] if m then - if skipsome and skipsome[char] then -- we never needed it here but let's try + if skiphash and skiphash[char] then -- we never needed it here but let's try start = getnext(start) else for i=m[1],m[2] do @@ -4428,7 +4405,7 @@ do local lookupmatch = lookupcache[char] if lookupmatch then local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then -- if matches then -- matches[position] = i @@ -4526,27 +4503,35 @@ otf.handlers = handlers -- used in devanagari local setspacekerns = nodes.injections.setspacekerns if not setspacekerns then os.exit() end +-- This pseudo feature has no steps, so it gets called as: +-- +-- function(head,dataset,sequence,initialrl,font,attr) +-- return head, done +-- end +-- +-- Also see (!!). + if fontfeatures then - function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr) + function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) local features = fontfeatures[font] local enabled = features and features.spacekern and features.kern if enabled then setspacekerns(font,sequence) end - return head, start, enabled + return head, enabled end else -- generic (no hashes) - function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr) + function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) local shared = fontdata[font].shared local features = shared and shared.features local enabled = features and features.spacekern and features.kern if enabled then setspacekerns(font,sequence) end - return head, start, enabled + return head, enabled end end @@ -4676,6 +4661,7 @@ local function spaceinitializer(tfmdata,value) -- attr } if last > 0 then local triggersequence = { + -- no steps, see (!!) features = { kern = feat or { dflt = { dflt = true, } } }, flags = noflags, name = "trigger_space_kerns", diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua index dab746125..c67662844 100644 --- a/tex/context/base/mkiv/font-oup.lua +++ b/tex/context/base/mkiv/font-oup.lua @@ -2534,8 +2534,15 @@ local function mergesteps(t,k) end end +local function checkmerge(sequence) + local steps = sequence.steps + if steps then + setmetatableindex(steps,mergesteps) + end +end + local function checkflags(sequence,resources) - if not sequence.skipsome then + if not sequence.skiphash then local flags = sequence.flags if flags then local skipmark = flags[1] @@ -2544,24 +2551,38 @@ local function checkflags(sequence,resources) local markclass = sequence.markclass local skipsome = skipmark or skipligature or skipbase or markclass or false if skipsome then - sequence.skipsome = setmetatableindex(function(t,k) + sequence.skiphash = setmetatableindex(function(t,k) local c = resources.classes[k] -- delayed table local v = c == skipmark or (markclass and c == "mark" and not markclass[k]) or c == skipligature or c == skipbase +-- local v = (skipmark and c == "mark") +-- or (markclass and c == "mark" and not markclass[k]) +-- or (skipligature and c == "ligature") +-- or (skipbase and c == "base") t[k] = v or false return v end) else - sequence.skipsome = false + sequence.skiphash = false end else - sequence.skipsome = false + sequence.skiphash = false + end + end +end + +local function checksteps(sequence) + local steps = sequence.steps + if steps then + for i=1,#steps do + steps[i].index = i end end end if fonts.helpers then - fonts.helpers.mergesteps = mergesteps + fonts.helpers.checkmerge = checkmerge fonts.helpers.checkflags = checkflags + fonts.helpers.checksteps = checksteps -- has to happen last end function readers.expand(data) @@ -2619,8 +2640,6 @@ function readers.expand(data) if steps then local nofsteps = sequence.nofsteps - setmetatableindex(steps,mergesteps) - local kind = sequence.type local markclass = sequence.markclass if markclass then @@ -2632,7 +2651,9 @@ function readers.expand(data) end end + checkmerge(sequence) checkflags(sequence,resources) + checksteps(sequence) for i=1,nofsteps do local step = steps[i] diff --git a/tex/context/base/mkiv/font-tra.mkiv b/tex/context/base/mkiv/font-tra.mkiv index 8ca4bf3e4..07a28b7ab 100644 --- a/tex/context/base/mkiv/font-tra.mkiv +++ b/tex/context/base/mkiv/font-tra.mkiv @@ -198,6 +198,41 @@ % \blank}% % \endgroup} +\newconstant\showotfstepsmode \showotfstepsmode\plusfour + +\unexpanded\def\showotfsteps_n + {\blank + \begingroup + \advance\leftskip6\emwidth + \showotfstepmessages\recurselevel + \par + \endgroup + \blank + \dontleavehmode + \hbox to \hsize \bgroup + \hbox to 6\emwidth \bgroup + \bf + \ifnum\recurselevel=\scratchcounter result\else step \recurselevel\fi + \hss + \egroup + \vtop \bgroup + \hsize\dimexpr\hsize-6\emwidth\relax + \resetallattributes + \pardir TLT\textdir TLT\relax + \dontleavehmode + \ifnum\recurselevel=\scratchcounter + \ruledhbox{\box\otfcompositionbox}% + \else + \ruledhbox{\showotfstepglyphs\recurselevel}% + \fi + \quad + \showotfstepchars\recurselevel + \hfill + \par + \egroup + \egroup + \blank} + \unexpanded\def\showotfsteps {\begingroup \veryraggedright @@ -226,37 +261,24 @@ \blank \scratchcounter\otfnoffeaturesteps\relax \dorecurse\scratchcounter - {\blank - \begingroup - \advance\leftskip6\emwidth - \showotfstepmessages\recurselevel - \par - \endgroup - \blank - \dontleavehmode - \hbox to \hsize \bgroup - \hbox to 6\emwidth \bgroup - \bf - \ifnum\recurselevel=\scratchcounter result\else step \recurselevel\fi - \hss - \egroup - \vtop \bgroup - \hsize\dimexpr\hsize-6\emwidth\relax - \resetallattributes - \pardir TLT\textdir TLT\relax - \dontleavehmode - \ifnum\recurselevel=\scratchcounter - \ruledhbox{\box\otfcompositionbox}% - \else - \ruledhbox{\showotfstepglyphs\recurselevel}% - \fi - \quad - \showotfstepchars\recurselevel - \hfill - \par - \egroup - \egroup - \blank}% + {\ifcase\showotfstepsmode + \or % 1 = only first + \ifnum\recurselevel=\plusone + \showotfsteps_n + \fi + \or % 2 = only last + \ifnum\recurselevel=\scratchcounter + \showotfsteps_n + \fi + \or % 3 = first and last + \ifnum\recurselevel=\plusone + \showotfsteps_n + \else\ifnum\recurselevel=\scratchcounter + \showotfsteps_n + \fi\fi + \else % everything + \showotfsteps_n + \fi}% \endgroup} \unexpanded\def\startotfsample diff --git a/tex/context/base/mkiv/node-res.lua b/tex/context/base/mkiv/node-res.lua index 85c71a64d..d6f988e0b 100644 --- a/tex/context/base/mkiv/node-res.lua +++ b/tex/context/base/mkiv/node-res.lua @@ -430,11 +430,10 @@ function nutpool.temp() end function nutpool.noad() return copy_nut(noad) end -function nutpool.delimiter() return copy_nut(delimiter) end +function nutpool.delimiter() return copy_nut(delimiter) end nutpool.delim = nutpool.delimiter function nutpool.fence() return copy_nut(fence) end function nutpool.submlist() return copy_nut(submlist) end function nutpool.noad() return copy_nut(noad) end -function nutpool.delimiter() return copy_nut(delim) end nutpool.delim = nutpool.delimiter function nutpool.fence() return copy_nut(fence) end function nutpool.accent() return copy_nut(accent) end function nutpool.radical() return copy_nut(radical) end diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 0e42f2f01..40f20e02d 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 7545fe7af..a0f467fa3 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/interface/mkii/keys-cs.xml b/tex/context/interface/mkii/keys-cs.xml index 9ce2a779a..727f8e9aa 100644 --- a/tex/context/interface/mkii/keys-cs.xml +++ b/tex/context/interface/mkii/keys-cs.xml @@ -693,6 +693,7 @@ <cd:constant name='bottomoffset' value='offsetspodku'/> <cd:constant name='bottomspace' value='bottomspace'/> <cd:constant name='bottomstate' value='statusspodku'/> + <cd:constant name='break' value='break'/> <cd:constant name='buffer' value='buffer'/> <cd:constant name='cache' value='cache'/> <cd:constant name='calculate' value='pocitat'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 10cdcdabd..54eef5bcd 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 5636448f9..16621d972 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/s-fnt-20.mkiv b/tex/context/modules/mkiv/s-fnt-20.mkiv index 99f5eba69..b61caaef6 100644 --- a/tex/context/modules/mkiv/s-fnt-20.mkiv +++ b/tex/context/modules/mkiv/s-fnt-20.mkiv @@ -39,21 +39,15 @@ liga=yes,dlig=yes,rlig=yes,clig=yes, mark=yes,mkmk=yes,kern=yes,curs=yes] -% \definefontfeature -% [otftracker-husayni] -% [analyze=yes,mode=node, -% language=dflt,script=arab,ccmp=yes, -% init=yes,medi=yes,fina=yes,isol=yes, -% calt=yes, -% mark=yes,mkmk=yes,kern=yes,curs=yes] - \definefontfeature - [otftracker-husayni] + [otftracker-husayni-default] [analyze=yes,mode=node, language=dflt,script=arab, init=yes,medi=yes,fina=yes, + calt=yes, rlig=yes, ccmp=yes, + salt=yes, ss01=yes, % full Allah, Muhammad, Allahumma ss05=yes, % full Jiim stacking ss09=yes, % full Haa stacking @@ -78,6 +72,10 @@ mark=yes,mkmk=yes,kern=yes,curs=yes] \definefontfeature + [otftracker-husayni] + [otftracker-husayni-default] + +\definefontfeature [otftracker-simplenaskhi] [analyze=yes,mode=node, language=dflt,script=arab, diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 4e0a15bd3..c1bbcd2d0 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 08/03/17 11:02:54 +-- merge date : 08/04/17 09:40:52 do -- begin closure to overcome local limits and interference @@ -19501,8 +19501,14 @@ local function mergesteps(t,k) return merged end end +local function checkmerge(sequence) + local steps=sequence.steps + if steps then + setmetatableindex(steps,mergesteps) + end +end local function checkflags(sequence,resources) - if not sequence.skipsome then + if not sequence.skiphash then local flags=sequence.flags if flags then local skipmark=flags[1] @@ -19511,23 +19517,32 @@ local function checkflags(sequence,resources) local markclass=sequence.markclass local skipsome=skipmark or skipligature or skipbase or markclass or false if skipsome then - sequence.skipsome=setmetatableindex(function(t,k) + sequence.skiphash=setmetatableindex(function(t,k) local c=resources.classes[k] local v=c==skipmark or (markclass and c=="mark" and not markclass[k]) or c==skipligature or c==skipbase t[k]=v or false return v end) else - sequence.skipsome=false + sequence.skiphash=false end else - sequence.skipsome=false + sequence.skiphash=false + end + end +end +local function checksteps(sequence) + local steps=sequence.steps + if steps then + for i=1,#steps do + steps[i].index=i end end end if fonts.helpers then - fonts.helpers.mergesteps=mergesteps + fonts.helpers.checkmerge=checkmerge fonts.helpers.checkflags=checkflags + fonts.helpers.checksteps=checksteps end function readers.expand(data) if not data or data.expanded then @@ -19574,7 +19589,6 @@ function readers.expand(data) local steps=sequence.steps if steps then local nofsteps=sequence.nofsteps - setmetatableindex(steps,mergesteps) local kind=sequence.type local markclass=sequence.markclass if markclass then @@ -19585,7 +19599,9 @@ function readers.expand(data) sequence.markclass=markclasses[markclass] end end + checkmerge(sequence) checkflags(sequence,resources) + checksteps(sequence) for i=1,nofsteps do local step=steps[i] local baseclasses=step.baseclasses @@ -19715,7 +19731,7 @@ local trace_defining=false registertracker("fonts.defining",function(v) trace_de local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf -otf.version=3.101 +otf.version=3.102 otf.cache=containers.define("fonts","otl",otf.version,true) otf.svgcache=containers.define("fonts","svg",otf.version,true) otf.sbixcache=containers.define("fonts","sbix",otf.version,true) @@ -21676,6 +21692,9 @@ local function inject_everything(head,where) if rightkern then if pn.markdir<0 then ox=px-pn.markx-rightkern +if not pn.markmark then + ox=ox+(pn.leftkern or 0) +end else if false then local leftkern=pp.leftkern @@ -23067,7 +23086,7 @@ function handlers.gsub_single(head,start,dataset,sequence,replacement) setchar(start,replacement) return head,start,true end -function handlers.gsub_alternate(head,start,dataset,sequence,alternative) +function handlers.gsub_alternate(head,start,dataset,sequence,alternative,rlmode,skiphash) local kind=dataset[4] local what=dataset[1] local value=what==true and tfmdata.shared.features[kind] or what @@ -23085,13 +23104,13 @@ function handlers.gsub_alternate(head,start,dataset,sequence,alternative) end return head,start,true end -function handlers.gsub_multiple(head,start,dataset,sequence,multiple) +function handlers.gsub_multiple(head,start,dataset,sequence,multiple,rlmode,skiphash) if trace_multiples then logprocess("%s: replacing %s by multiple %s",pref(dataset,sequence),gref(getchar(start)),gref(multiple)) end return multiple_glyphs(head,start,multiple,sequence.flags[1],dataset[1]) end -function handlers.gsub_ligature(head,start,dataset,sequence,ligature) +function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skiphash) local current=getnext(start) if not current then return head,start,false,nil @@ -23201,7 +23220,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) end return head,start,false,discfound end -function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,injection) +function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) local startchar=getchar(start) local format=step.format if format=="single" or type(kerns)=="table" then @@ -23217,7 +23236,7 @@ function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,in end return head,start,false end -function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,injection) +function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) local snext=getnext(start) if not snext then return head,start,false @@ -23275,7 +23294,7 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,inje return head,start,false end end -function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) +function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode,skiphash) local markchar=getchar(start) if marks[markchar] then local base=getprev(start) @@ -23328,7 +23347,7 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) end return head,start,false end -function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode) +function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode,skiphash) local markchar=getchar(start) if marks[markchar] then local base=getprev(start) @@ -23391,7 +23410,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm end return head,start,false end -function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode) +function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode,skiphash) local markchar=getchar(start) if marks[markchar] then local base=getprev(start) @@ -23426,7 +23445,7 @@ function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode) end return head,start,false end -function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,step,i) +function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,skiphash,step) local startchar=getchar(start) if marks[startchar] then if trace_cursive then @@ -23476,7 +23495,7 @@ local function logprocess(...) report_chain(...) end local logwarning=report_chain -local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode) +local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode,skiphash) local char=getchar(start) local replacement=replacements[char] if replacement then @@ -23497,7 +23516,7 @@ end local function reportmoresteps(dataset,sequence) logwarning("%s: more than 1 step",cref(dataset,sequence)) end -function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,chainindex) +function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -23681,7 +23700,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup end return head,start,false,0,false end -function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,chainindex) +function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -23711,7 +23730,7 @@ function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,r end return head,start,false end -function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,chainindex) +function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -23780,7 +23799,7 @@ function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlm end return head,start,false end -function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -23847,7 +23866,7 @@ function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlooku end return head,start,false end -function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -23918,7 +23937,7 @@ function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentl end return head,start,false end -function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -23973,7 +23992,7 @@ function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlooku end return head,start,false end -function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode) +function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then @@ -24069,7 +24088,7 @@ local function setdiscchecked(d,pre,post,replace) setdisc(d,pre,post,replace) end local noflags={ false,false,false,false } -local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) +local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck) local size=ck[5]-ck[4]+1 local chainlookups=ck[6] local done=false @@ -24082,7 +24101,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) local chainproc=chainprocs[chainkind] if chainproc then local ok - head,start,ok=chainproc(head,start,last,dataset,sequence,chainstep,rlmode,1) + head,start,ok=chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash) if ok then done=true end @@ -24091,18 +24110,15 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) end end else - if skipsome then - skipsome=sequence.skipsome - end local i=1 local laststart=start local nofchainlookups=#chainlookups while start do - if skipsome then + if skiphash then while start do local char=ischar(start,currentfont) if char then - if skipsome[char] then + if skiphash and skiphash[char] then start=getnext(start) else break @@ -24120,7 +24136,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) local chainproc=chainprocs[chainkind] if chainproc then local ok,n - head,start,ok,n=chainproc(head,start,last,dataset,sequence,chainstep,rlmode,i) + head,start,ok,n=chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash) if ok then done=true if n and n>1 and i+n>nofchainlookups then @@ -24148,7 +24164,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) else local replacements=ck[7] if replacements then - head,start,done=reversesub(head,start,last,dataset,sequence,replacements,rlmode) + head,start,done=reversesub(head,start,last,dataset,sequence,replacements,rlmode,skiphash) else done=true if trace_contexts then @@ -24158,7 +24174,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) end return head,start,done end -local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) +local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) if not start then return head,start,false end @@ -24371,14 +24387,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) end if not notmatchpre[lookaheaddisc] then local ok=false - cf,start,ok=chainrun(cf,start,cl,dataset,sequence,rlmode,ck,skipped) + cf,start,ok=chainrun(cf,start,cl,dataset,sequence,rlmode,skiphash,ck) if ok then done=true end end if not notmatchreplace[lookaheaddisc] then local ok=false - new,cnew,ok=chainrun(new,cnew,clast,dataset,sequence,rlmode,ck,skipped) + new,cnew,ok=chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck) if ok then done=true end @@ -24424,14 +24440,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) end if not notmatchpost[backtrackdisc] then local ok=false - cf,start,ok=chainrun(cf,start,last,dataset,sequence,rlmode,ck,skipped) + cf,start,ok=chainrun(cf,start,last,dataset,sequence,rlmode,skiphash,ck) if ok then done=true end end if not notmatchreplace[backtrackdisc] then local ok=false - new,cnew,ok=chainrun(new,cnew,clast,dataset,sequence,rlmode,ck,skipped) + new,cnew,ok=chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck) if ok then done=true end @@ -24456,14 +24472,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) sweephead[replace]=getnext(last) or false else local ok=false - head,start,ok=chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped) + head,start,ok=chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck) if ok then done=true end end return head,start,done end -local function chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match) +local function chaintrac(head,start,dataset,sequence,rlmode,skiphash,ck,match) local rule=ck[1] local lookuptype=ck[8] or ck[2] local nofseq=#ck[3] @@ -24473,7 +24489,7 @@ local function chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match) logwarning("%s: rule %s %s at char %s for (%s,%s,%s) chars, lookuptype %a", cref(dataset,sequence),rule,match and "matches" or "nomatch",gref(char),first-1,last-first+1,nofseq-last,lookuptype) end -local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) +local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash) local sweepnode=sweepnode local sweeptype=sweeptype local postreplace @@ -24492,7 +24508,6 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end local currentfont=currentfont local skipped - local skipsome=sequence.skipsome local startprev, startnext=getboth(start) local done @@ -24522,7 +24537,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if last then local char,id=ischar(last,currentfont) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then skipped=true if trace_skips then show_skip(dataset,sequence,char,ck,classes[char]) @@ -24624,7 +24639,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if prev then local char,id=ischar(prev,currentfont) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then skipped=true if trace_skips then show_skip(dataset,sequence,char,ck,classes[char]) @@ -24742,7 +24757,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if current then local char,id=ischar(current,currentfont) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then skipped=true if trace_skips then show_skip(dataset,sequence,char,ck,classes[char]) @@ -24847,12 +24862,12 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end end if trace_contexts then - chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,true) + chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true) end if diskseen or sweepnode then - head,start,done=chaindisk(head,start,dataset,sequence,rlmode,ck,skipped) + head,start,done=chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck) else - head,start,done=chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped) + head,start,done=chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck) end if done then break @@ -24871,13 +24886,13 @@ handlers.gsub_contextchain=handle_contextchain handlers.gsub_reversecontextchain=handle_contextchain handlers.gpos_contextchain=handle_contextchain handlers.gpos_context=handle_contextchain -local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode) +local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) local steps=currentlookup.steps local nofsteps=currentlookup.nofsteps if nofsteps>1 then reportmoresteps(dataset,sequence) end - return handle_contextchain(head,start,dataset,sequence,currentlookup,rlmode) + return handle_contextchain(head,start,dataset,sequence,currentlookup,rlmode,skiphash) end chainprocs.gsub_context=chained_contextchain chainprocs.gsub_contextchain=chained_contextchain @@ -25197,7 +25212,7 @@ local function testrun(disc,t_run,c_run,...) end end local nesting=0 -local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) +local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) local done=false local sweep=sweephead[head] if sweep then @@ -25217,7 +25232,7 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm local lookupmatch=lookupcache[char] if lookupmatch then local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) + head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done=true end @@ -25311,7 +25326,7 @@ local function t_run_single(start,stop,font,attr,lookupcache) end return 0 end -local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) +local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) local a if attr then a=getattr(sub,0) @@ -25325,7 +25340,7 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase if char then local lookupmatch=lookupcache[char] if lookupmatch then - local h,d,ok=handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,1,injection) + local h,d,ok=handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) if ok then return true end @@ -25334,7 +25349,7 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase end end end -local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) +local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) local done=false local sweep=sweephead[head] if sweep then @@ -25357,7 +25372,7 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm local lookupmatch=lookupcache[char] if lookupmatch then local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done=true break @@ -25459,7 +25474,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps) end return 0 end -local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) +local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) local a if attr then a=getattr(sub,0) @@ -25476,7 +25491,7 @@ local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,datase local lookupcache=step.coverage local lookupmatch=lookupcache[char] if lookupmatch then - local h,d,ok=handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,i,injection) + local h,d,ok=handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) if ok then return true end @@ -25583,14 +25598,14 @@ do local handler=handlers[typ] local steps=sequence.steps local nofsteps=sequence.nofsteps - local skipsome=sequence.skipsome + local skiphash=sequence.skiphash if not steps then - local h,d,ok=handler(head,head,dataset,sequence,nil,nil,nil,0,font,attr) + local h,ok=handler(head,dataset,sequence,initialrl,font,attr) if ok then done=true - if h then - head=h - end + end + if h and h~=head then + head=h end elseif typ=="gsub_reversecontextchain" then local start=find_node_tail(head) @@ -25612,7 +25627,7 @@ do local lookupmatch=lookupcache[char] if lookupmatch then local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done=true break @@ -25641,7 +25656,7 @@ do while start do local char,id=ischar(start,font) if char then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then start=getnext(start) else local lookupmatch=lookupcache[char] @@ -25656,7 +25671,7 @@ do end if a then local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) + head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done=true end @@ -25676,11 +25691,11 @@ do if not discs or discs[start]==true then local ok if gpossing then - start,ok=kernrun(start,k_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + start,ok=kernrun(start,k_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) elseif typ=="gsub_ligature" then - start,ok=testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + start,ok=testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) else - start,ok=comprun(start,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + start,ok=comprun(start,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) end if ok then done=true @@ -25705,7 +25720,7 @@ do if char then local m=merged[char] if m then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then start=getnext(start) else local a @@ -25723,7 +25738,7 @@ do local lookupmatch=lookupcache[char] if lookupmatch then local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then done=true break @@ -25748,11 +25763,11 @@ do if not discs or discs[start]==true then local ok if gpossing then - start,ok=kernrun(start,k_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + start,ok=kernrun(start,k_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) elseif typ=="gsub_ligature" then - start,ok=testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + start,ok=testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) else - start,ok=comprun(start,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + start,ok=comprun(start,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) end if ok then done=true @@ -25815,7 +25830,7 @@ do position=position+1 local m=merged[char] if m then - if skipsome and skipsome[char] then + if skiphash and skiphash[char] then start=getnext(start) else for i=m[1],m[2] do @@ -25824,7 +25839,7 @@ do local lookupmatch=lookupcache[char] if lookupmatch then local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) if ok then break elseif not start then @@ -25897,23 +25912,23 @@ registerotffeature { otf.handlers=handlers local setspacekerns=nodes.injections.setspacekerns if not setspacekerns then os.exit() end if fontfeatures then - function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr) + function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) local features=fontfeatures[font] local enabled=features and features.spacekern and features.kern if enabled then setspacekerns(font,sequence) end - return head,start,enabled + return head,enabled end else - function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr) + function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) local shared=fontdata[font].shared local features=shared and shared.features local enabled=features and features.spacekern and features.kern if enabled then setspacekerns(font,sequence) end - return head,start,enabled + return head,enabled end end local function hasspacekerns(data) @@ -26350,7 +26365,6 @@ local sequence_reorder_matras={ nofsteps=1, steps={ { - osdstep=true, coverage=pre_mark, } } @@ -26364,7 +26378,6 @@ local sequence_reorder_reph={ nofsteps=1, steps={ { - osdstep=true, coverage={}, } } @@ -26378,7 +26391,6 @@ local sequence_reorder_pre_base_reordering_consonants={ nofsteps=1, steps={ { - osdstep=true, coverage={}, } } @@ -26391,7 +26403,7 @@ local sequence_remove_joiners={ type="devanagari_remove_joiners", nofsteps=1, steps={ - { osdstep=true, + { coverage=both_joiners_true, }, } @@ -26500,24 +26512,21 @@ local function initializedevanagi(tfmdata) if coverage then local reph=false if kind=="rphf" then - if true then - for k,v in next,ra do - local r=coverage[k] - if r then - local h=false - for k,v in next,halant do - local h=r[k] - if h then - reph=h.ligature or false - break - end - end - if reph then + for k,v in next,ra do + local r=coverage[k] + if r then + local h=false + for k,v in next,halant do + local h=r[k] + if h then + reph=h.ligature or false break end end + if reph then + break + end end - else end end seqsubset[#seqsubset+1]={ kind,coverage,reph } @@ -28499,8 +28508,9 @@ local fonts=fonts local otf=fonts.handlers.otf local registerotffeature=otf.features.register local setmetatableindex=table.setmetatableindex -local mergesteps=fonts.helpers.mergesteps +local checkmerge=fonts.helpers.checkmerge local checkflags=fonts.helpers.checkflags +local checksteps=fonts.helpers.checksteps local normalized={ substitution="substitution", single="substitution", @@ -29076,7 +29086,8 @@ local function addfeature(data,feature,specifications) steps[nofsteps]=register(coverage,featuretype,format,feature,nofsteps,descriptions,resources) end end - setmetatableindex(steps,mergesteps) + checkmerge(specification) + checksteps(specification) s[i]={ [stepkey]=steps, nofsteps=nofsteps, @@ -29135,7 +29146,6 @@ local function addfeature(data,feature,specifications) askedfeatures[k]=tohash(v) end end - setmetatableindex(steps,mergesteps) if featureflags[1] then featureflags[1]="mark" end if featureflags[2] then featureflags[2]="ligature" end if featureflags[3] then featureflags[3]="base" end @@ -29151,6 +29161,8 @@ local function addfeature(data,feature,specifications) type=steptype, } checkflags(sequence,resources) + checkmerge(sequence) + checksteps(sequence) local first,last=getrange(sequences,category) inject(specification,sequences,sequence,first,last,category,feature) local features=fontfeatures[category] |