diff options
49 files changed, 772 insertions, 527 deletions
diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua index 6eb7eabbf..c086d4b58 100644 --- a/scripts/context/lua/mtx-fonts.lua +++ b/scripts/context/lua/mtx-fonts.lua @@ -15,7 +15,7 @@ local nameonly, basename, joinpath, collapsepath = file.nameonly, file.basename, local lower = string.lower local otfversion = 2.826 -local otlversion = 3.022 +local otlversion = 3.023 local helpinfo = [[ <?xml version="1.0"?> diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 2f0286ca8..5e336dfc7 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index 62df21b85..249e18523 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{controls} \setinterfaceconstant{conversion}{konversion} \setinterfaceconstant{convertfile}{konvertieredatei} +\setinterfaceconstant{copies}{copies} \setinterfaceconstant{corner}{winkel} \setinterfaceconstant{coupling}{verknuepfung} \setinterfaceconstant{couplingway}{verkopplungsart} diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index d0bad9459..3ea8f87c5 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{controls} \setinterfaceconstant{conversion}{conversion} \setinterfaceconstant{convertfile}{convertfile} +\setinterfaceconstant{copies}{copies} \setinterfaceconstant{corner}{corner} \setinterfaceconstant{coupling}{coupling} \setinterfaceconstant{couplingway}{couplingway} diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii index 8f938bed7..9a1f53a52 100644 --- a/tex/context/base/mkii/mult-fr.mkii +++ b/tex/context/base/mkii/mult-fr.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{controles} \setinterfaceconstant{conversion}{conversion} \setinterfaceconstant{convertfile}{conversionfichier} +\setinterfaceconstant{copies}{copies} \setinterfaceconstant{corner}{coin} \setinterfaceconstant{coupling}{couplage} \setinterfaceconstant{couplingway}{modecouplage} diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 42388d718..4d68bc4df 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{controlli} \setinterfaceconstant{conversion}{conversione} \setinterfaceconstant{convertfile}{convertifile} +\setinterfaceconstant{copies}{copies} \setinterfaceconstant{corner}{angolo} \setinterfaceconstant{coupling}{accoppiamento} \setinterfaceconstant{couplingway}{modoaccoppiamento} diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii index 01870066e..0711108d1 100644 --- a/tex/context/base/mkii/mult-nl.mkii +++ b/tex/context/base/mkii/mult-nl.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{sturing} \setinterfaceconstant{conversion}{conversie} \setinterfaceconstant{convertfile}{converteerfile} +\setinterfaceconstant{copies}{kopieen} \setinterfaceconstant{corner}{hoek} \setinterfaceconstant{coupling}{koppeling} \setinterfaceconstant{couplingway}{koppelwijze} diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index b3df69def..de5030276 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{کنترلها} \setinterfaceconstant{conversion}{تبدیل} \setinterfaceconstant{convertfile}{پروندهتبدیل} +\setinterfaceconstant{copies}{copies} \setinterfaceconstant{corner}{گوشه} \setinterfaceconstant{coupling}{تزویج} \setinterfaceconstant{couplingway}{روشتزویج} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index c232d6b13..44e01db6a 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -722,6 +722,7 @@ \setinterfaceconstant{controls}{controale} \setinterfaceconstant{conversion}{conversie} \setinterfaceconstant{convertfile}{convertestefisier} +\setinterfaceconstant{copies}{copies} \setinterfaceconstant{corner}{colt} \setinterfaceconstant{coupling}{cuplare} \setinterfaceconstant{couplingway}{modcuplare} diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua index 353b02273..f868975e5 100644 --- a/tex/context/base/mkiv/cldf-ini.lua +++ b/tex/context/base/mkiv/cldf-ini.lua @@ -1836,7 +1836,7 @@ end local p_texescape = patterns.texescape function context.escaped(s) - return lpegmatch(p_texescape,s) or s + return context(lpegmatch(p_texescape,s) or s) end -- templates diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 18eaa405b..0e2566f1b 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{2016.06.13 17:00} +\newcontextversion{2016.06.15 20:18} %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-todo.tex b/tex/context/base/mkiv/context-todo.tex index 4df9dc816..81ef2bff1 100644 --- a/tex/context/base/mkiv/context-todo.tex +++ b/tex/context/base/mkiv/context-todo.tex @@ -44,6 +44,9 @@ play with par callback and properties \stopitem \startitem + optimize positions for columnareas and parpos (sequential) + \stopitem + \startitem add flag to font for math engine \stopitem \startitem diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 7abb268ff..febdef216 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.06.13 17:00} +\edef\contextversion{2016.06.15 20:18} \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 a1ae17f9b..1e8b3bd0c 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -365,6 +365,26 @@ end -- We generalize the chained lookups so that we can do with only one handler -- when processing them. +local function readlookuparray(f,noflookups) + local lookups = { } + if noflookups > 0 then + local length = 0 + for i=1,noflookups do + local index = readushort(f) + 1 + if index > length then + length = index + end + lookups[index] = readushort(f) + 1 + end + for index=1,length do + if not lookups[index] then + lookups[index] = false + end + end + end + return lookups +end + local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,what) local tableoffset = lookupoffset + offset setposition(f,tableoffset) @@ -389,10 +409,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n for i=2,nofcurrent do current[i] = { readushort(f) } end - local lookups = { } - for i=1,noflookups do - lookups[readushort(f)+1] = readushort(f) + 1 - end + local lookups = readlookuparray(f,noflookups) rules[#rules+1] = { current = current, lookups = lookups @@ -435,10 +452,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n for i=2,nofcurrent do current[i] = currentclasses[readushort(f) + 1] end - local lookups = { } - for i=1,noflookups do - lookups[readushort(f)+1] = readushort(f) + 1 - end + local lookups = readlookuparray(f,noflookups) rules[#rules+1] = { current = current, lookups = lookups @@ -462,10 +476,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n elseif subtype == 3 then local current = readarray(f) local noflookups = readushort(f) - local lookups = { } - for i=1,noflookups do - lookups[readushort(f)+1] = readushort(f) + 1 - end + local lookups = readlookuparray(f,noflookups) current = readcoveragearray(f,tableoffset,current,true) return { format = "coverage", @@ -525,10 +536,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof end end local noflookups = readushort(f) - local lookups = { } - for i=1,noflookups do - lookups[readushort(f)+1] = readushort(f) + 1 - end + local lookups = readlookuparray(f,noflookups) rules[#rules+1] = { before = before, current = current, @@ -596,10 +604,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof end -- no sequence index here (so why in context as it saves nothing) local noflookups = readushort(f) - local lookups = { } - for i=1,noflookups do - lookups[readushort(f)+1] = readushort(f) + 1 - end + local lookups = readlookuparray(f,noflookups) rules[#rules+1] = { before = before, current = current, @@ -627,10 +632,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof local current = readarray(f) local after = readarray(f) local noflookups = readushort(f) - local lookups = { } - for i=1,noflookups do - lookups[readushort(f)+1] = readushort(f) + 1 - end + local lookups = readlookuparray(f,noflookups) before = readcoveragearray(f,tableoffset,before,true) current = readcoveragearray(f,tableoffset,current,true) after = readcoveragearray(f,tableoffset,after,true) @@ -1626,45 +1628,58 @@ do report_issue(i,what,sequence,"empty") rule.lookups = nil else - for index, lookupid in sortedhash(rlookups) do -- nicer - local h = sublookuphash[lookupid] - if not h then - -- here we have a lookup that is used independent as well - -- as in another one - local lookup = lookups[lookupid] - if lookup then - local d = lookup.done - if d then - nofsublookups = nofsublookups + 1 - -- report("registering %i as sublookup %i",lookupid,nofsublookups) - h = { - index = nofsublookups, -- handy for tracing - name = f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), - derived = true, -- handy for tracing - steps = d.steps, - nofsteps = d.nofsteps, - type = d.lookuptype, - markclass = d.markclass or nil, - flags = d.flags, - -- chain = d.chain, - } - sublookuplist[nofsublookups] = h - sublookuphash[lookupid] = nofsublookups - sublookupcheck[lookupid] = 1 + -- we can have holes in rlookups + -- for index, lookupid in sortedhash(rlookups) do + local length = #rlookups +-- for index in next, rlookups do +-- if index > length then +-- length = index +-- end +-- end + for index=1,length do + local lookupid = rlookups[index] + if lookupid then + local h = sublookuphash[lookupid] + if not h then + -- here we have a lookup that is used independent as well + -- as in another one + local lookup = lookups[lookupid] + if lookup then + local d = lookup.done + if d then + nofsublookups = nofsublookups + 1 + -- report("registering %i as sublookup %i",lookupid,nofsublookups) + h = { + index = nofsublookups, -- handy for tracing + name = f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), + derived = true, -- handy for tracing + steps = d.steps, + nofsteps = d.nofsteps, + type = d.lookuptype, + markclass = d.markclass or nil, + flags = d.flags, + -- chain = d.chain, + } + sublookuplist[nofsublookups] = h + sublookuphash[lookupid] = nofsublookups + sublookupcheck[lookupid] = 1 + else + report_issue(i,what,sequence,"missing") + rule.lookups = nil + break + end else - report_issue(i,what,sequence,"missing") + report_issue(i,what,sequence,"bad") rule.lookups = nil break end else - report_issue(i,what,sequence,"bad") - rule.lookups = nil - break + sublookupcheck[lookupid] = sublookupcheck[lookupid] + 1 end + rlookups[index] = h or false else - sublookupcheck[lookupid] = sublookupcheck[lookupid] + 1 + rlookups[index] = false end - rlookups[index] = h end end end diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index 6cf305309..9426c3148 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.022 + otf.version = otf.version or 3.023 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-ocl.lua b/tex/context/base/mkiv/font-ocl.lua index 9661083bf..b2aba7ac7 100644 --- a/tex/context/base/mkiv/font-ocl.lua +++ b/tex/context/base/mkiv/font-ocl.lua @@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['font-ocl'] = { -- todo : user list of colors +local tostring, next = tostring, next + local formatters = string.formatters local otf = fonts.handlers.otf @@ -168,31 +170,81 @@ if context and xml.convert then local report_svg = logs.reporter("fonts","svg conversion") + local xmlconvert = xml.convert + local xmlfirst = xml.first + local loaddata = io.loaddata + local savedata = io.savedata + local remove = os.remove + + -- function otfsvg.topdf(svgshapes) + -- local svgfile = "temp-otf-svg-shape.svg" + -- local pdffile = "temp-otf-svg-shape.pdf" + -- local command = "inkscape " .. svgfile .. " --export-pdf=" .. pdffile + -- local testrun = false + -- local pdfshapes = { } + -- local nofshapes = #svgshapes + -- report_svg("processing %i svg containers",nofshapes) + -- statistics.starttiming() + -- for i=1,nofshapes do + -- local entry = svgshapes[i] + -- for j=entry.first,entry.last do + -- local svg = xmlconvert(entry.data) + -- local data = xmlfirst(svg,"/svg[@id='glyph"..j.."']") + -- savedata(svgfile,tostring(data)) + -- report_svg("processing svg shape of glyph %i in container %i",j,i) + -- os.execute(command) + -- pdfshapes[j] = loaddata(pdffile) + -- end + -- if testrun and i > testrun then + -- report_svg("quiting test run") + -- break + -- end + -- end + -- remove(svgfile) + -- statistics.stoptiming() + -- report_svg("conversion time: %0.3f",statistics.elapsedtime()) + -- return pdfshapes + -- end + function otfsvg.topdf(svgshapes) - local svgfile = "temp-otf-svg-shape.svg" - local pdffile = "temp-otf-svg-shape.pdf" - local command = "inkscape " .. svgfile .. " --export-pdf=" .. pdffile - -- local command = [[python "c:\Users\Hans Hagen\AppData\Roaming\Python\Scripts\cairosvg" -f pdf ]] .. svgfile .. " -o " .. pdffile - local testrun = false + local inkscape = io.popen("inkscape --shell 2>&1","w") local pdfshapes = { } local nofshapes = #svgshapes + local f_svgfile = formatters["temp-otf-svg-shape-%i.svg"] + local f_pdffile = formatters["temp-otf-svg-shape-%i.pdf"] + local f_convert = formatters["%s --export-pdf=%s\n"] report_svg("processing %i svg containers",nofshapes) + statistics.starttiming() for i=1,nofshapes do local entry = svgshapes[i] for j=entry.first,entry.last do - local svg = xml.convert(entry.data) - local data = xml.first(svg,"/svg[@id='glyph"..j.."']") - io.savedata(svgfile,tostring(data)) - report_svg("processing svg shape of glyph %i in container %i",j,i) - os.execute(command) - pdfshapes[j] = io.loaddata(pdffile) - end - if testrun and i > testrun then - report_svg("quiting test run") - break + local svg = xmlconvert(entry.data) + local root = svg and xmlfirst(svg,"/svg[@id='glyph"..j.."']") + local data = root and tostring(root) + if data and data ~= "" then + local svgfile = f_svgfile(j) + local pdffile = f_pdffile(j) + savedata(svgfile,data) + inkscape:write(f_convert(svgfile,pdffile)) + pdfshapes[j] = true + end end end - os.remove(svgfile) + inkscape:write("quit\n") + -- while inkscape:read("*a") do + -- os.sleep(0.1) + -- end + inkscape:close() + report_svg("processing %i pdf results",nofshapes) + for i in next, pdfshapes do + local svgfile = f_svgfile(i) + local pdffile = f_pdffile(i) + pdfshapes[i] = loaddata(pdffile) + remove(svgfile) + remove(pdffile) + end + statistics.stoptiming() + report_svg("conversion time: %0.3f",statistics.elapsedtime()) return pdfshapes end diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua index d50b1ec14..30a58ad72 100644 --- a/tex/context/base/mkiv/font-otc.lua +++ b/tex/context/base/mkiv/font-otc.lua @@ -100,16 +100,16 @@ local function addfeature(data,feature,specifications) return end -local alreadydone = resources.alreadydone -if not alreadydone then - alreadydone = { } - resources.alreadydone = alreadydone -end -if alreadydone[specifications] then - return -else - alreadydone[specifications] = true -end + local alreadydone = resources.alreadydone + if not alreadydone then + alreadydone = { } + resources.alreadydone = alreadydone + end + if alreadydone[specifications] then + return + else + alreadydone[specifications] = true + end -- feature has to be unique but the name entry wins eventually diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index c7c278a71..59d868bee 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -53,7 +53,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.022 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.023 -- 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.pdfcache = containers.define("fonts", "pdf", otf.version, true) @@ -747,7 +747,7 @@ end otf.getgsub = getgsub -- returns value, gsub_kind function otf.getsubstitution(tfmdata,k,kind,value) - local found, kind = getgsub(tfmdata,k,kind) + local found, kind = getgsub(tfmdata,k,kind,value) if not found then -- elseif kind == "gsub_single" then diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index 51704bf0e..d63d524cc 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -192,6 +192,7 @@ local free_node = nuts.free local end_of_math = nuts.end_of_math local traverse_nodes = nuts.traverse local traverse_id = nuts.traverse_id +local remove_node = nuts.remove local setmetatableindex = table.setmetatableindex @@ -1236,7 +1237,7 @@ function chainprocs.gsub_multiple(head,start,stop,dataset,sequence,currentlookup if trace_multiples then logprocess("%s: replacing %s by multiple characters %s",cref(dataset,sequence),gref(startchar),gref(replacement)) end - return multiple_glyphs(head,start,replacement,currentlookup.flags[1]) -- not sequence.flags? + return multiple_glyphs(head,start,replacement,sequence.flags[1]) end return head, start, false end @@ -2033,67 +2034,6 @@ local function chaindisk(head,start,last,dataset,sequence,chainlookup,rlmode,k,c return head, start, ok end --- helpers from elsewhere - --- local function currentmatch(current,n,l) --- while current do --- if getid(current) ~= glyph_code then --- return false --- elseif seq[n][getchar(current)] then --- n = n + 1 --- current = getnext(current) --- if not current then --- return true, n, current --- elseif n > l then --- -- match = false --- return true, n, current --- end --- else --- return false --- end --- end --- end --- --- local function aftermatch(current,n,l) --- while current do --- if getid(current) ~= glyph_code then --- return false --- elseif seq[n][getchar(current)] then --- n = n + 1 --- current = getnext(current) --- if not current then --- return true, n, current --- elseif n > l then --- -- match = false --- return true, n, current --- end --- else --- return false --- end --- end --- end --- --- local function beforematch(current,n) --- local finish = getprev(current) --- local current = find_node_tail(current) --- while current do --- if getid(current) ~= glyph_code then --- return false --- elseif seq[n][getchar(current)] then --- n = n - 1 --- current = getprev(current) --- if not current or current == finish then --- return true, n, current --- elseif n < 1 then --- -- match = false --- return true, n, current --- end --- else --- return false --- end --- end --- end - local noflags = { false, false, false, false } local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) @@ -2116,9 +2056,10 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local ck = contexts[k] local seq = ck[3] local s = #seq + local size = 1 -- f..l = mid string if s == 1 then - -- never happens + -- this seldom happens as it makes no sense (bril, ebgaramond, husayni, minion) local char = ischar(current,currentfont) if char then match = seq[1][char] @@ -2129,48 +2070,34 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local f = ck[4] local l = ck[5] -- current match - if f == 1 and f == l then -- current only - -- already a hit - -- match = true - else -- before/current/after | before/current | current/after - -- no need to test first hit (to be optimized) - if f == l then -- new, else last out of sync (f is > 1) - -- match = true - else - local discfound = nil - local n = f + 1 - last = getnext(last) -- the second in current (first already matched) - while n <= l do - if not last and (sweeptype == "post" or sweeptype == "replace") then - last = getnext(sweepnode) - sweeptype = nil - end - if last then - local char, id = ischar(last,currentfont) - if char then - local ccd = descriptions[char] - if ccd then - local class = ccd.class or "base" - if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then - skipped = true - if trace_skips then - show_skip(dataset,sequence,char,ck,class) - end + size = l - f + 1 + if size > 1 then + -- before/current/after | before/current | current/after + local discfound = nil + local n = f + 1 + last = getnext(last) -- the second in current (first already matched) + while n <= l do + if not last and (sweeptype == "post" or sweeptype == "replace") then + last = getnext(sweepnode) + sweeptype = nil + end + if last then + local char, id = ischar(last,currentfont) + if char then + local ccd = descriptions[char] + if ccd then + local class = ccd.class or "base" + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + skipped = true + if trace_skips then + show_skip(dataset,sequence,char,ck,class) + end + last = getnext(last) + elseif seq[n][char] then + if n < l then last = getnext(last) - elseif seq[n][char] then - if n < l then - last = getnext(last) - end - n = n + 1 - else - if discfound then - notmatchreplace[discfound] = true - match = not notmatchpre[discfound] - else - match = false - end - break end + n = n + 1 else if discfound then notmatchreplace[discfound] = true @@ -2180,7 +2107,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end - elseif char == false then + else if discfound then notmatchreplace[discfound] = true match = not notmatchpre[discfound] @@ -2188,60 +2115,68 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) match = false end break - elseif id == disc_code then - diskseen = true - discfound = last - notmatchpre[last] = nil - notmatchpost[last] = true - notmatchreplace[last] = nil - local pre, post, replace = getdisc(last) - if pre then - local n = n - while pre do - if seq[n][getchar(pre)] then - n = n + 1 - pre = getnext(pre) - if n > l then - break - end - else - notmatchpre[last] = true + end + elseif char == false then + if discfound then + notmatchreplace[discfound] = true + match = not notmatchpre[discfound] + else + match = false + end + break + elseif id == disc_code then + diskseen = true + discfound = last + notmatchpre[last] = nil + notmatchpost[last] = true + notmatchreplace[last] = nil + local pre, post, replace = getdisc(last) + if pre then + local n = n + while pre do + if seq[n][getchar(pre)] then + n = n + 1 + pre = getnext(pre) + if n > l then break end - end - if n <= l then + else notmatchpre[last] = true + break end - else + end + if n <= l then notmatchpre[last] = true end - if replace then - -- so far we never entered this branch - while replace do - if seq[n][getchar(replace)] then - n = n + 1 - replace = getnext(replace) - if n > l then - break - end - else - notmatchreplace[last] = true - match = not notmatchpre[last] + else + notmatchpre[last] = true + end + if replace then + -- so far we never entered this branch + while replace do + if seq[n][getchar(replace)] then + n = n + 1 + replace = getnext(replace) + if n > l then break end + else + notmatchreplace[last] = true + match = not notmatchpre[last] + break end - match = not notmatchpre[last] end - -- maybe only if match - last = getnext(last) - else - match = false - break + match = not notmatchpre[last] end + -- maybe only if match + last = getnext(last) else match = false break end + else + match = false + break end end end @@ -2509,7 +2444,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end end if match then - -- can lookups be of a different type ? + -- Can lookups be of a different type? local diskchain = diskseen or sweepnode if trace_contexts then local rule = ck[1] @@ -2523,8 +2458,12 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local chainlookups = ck[6] if chainlookups then local nofchainlookups = #chainlookups - -- we can speed this up if needed - if nofchainlookups == 1 then + -- Lookups can be like { 1, false, 3 } or { false, 2 } or basically anything and + -- #lookups can be less than #current + if size == 1 then + -- if nofchainlookups > size then + -- -- bad rules + -- end local chainlookup = chainlookups[1] local chainkind = chainlookup.type local chainproc = chainprocs[chainkind] @@ -2542,8 +2481,16 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) logprocess("%s: %s is not yet supported (1)",cref(dataset,sequence),chainkind) end else + -- See LookupType 5: Contextual Substitution Subtable. Now it becomes messy. The + -- easiest case is where #current maps on #lookups i.e. one-to-one. But what if + -- we have a ligature. Cf the spec we then need to advance one character but we + -- really need to test it as there are fonts out there that are fuzzy and have + -- too many lookups: + -- + -- U+1105 U+119E U+1105 U+119E : sourcehansansklight: script=hang ccmp=yes + -- local i = 1 - while start and true do + while start do if skipped then while start do -- todo: use properties local char = getchar(start) @@ -2560,12 +2507,8 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end end end - -- see remark in ms standard under : LookupType 5: Contextual Substitution Subtable - local chainlookup = chainlookups[1] -- should be i when they can be different - if not chainlookup then - -- we just advance - i = i + 1 -- shouldn't that be #current - else + local chainlookup = chainlookups[i] + if chainlookup then local chainkind = chainlookup.type local chainproc = chainprocs[chainkind] if chainproc then @@ -2578,29 +2521,18 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) -- messy since last can be changed ! if ok then done = true - if n and n > 1 then - -- we have a ligature (cf the spec we advance one but we really need to test it - -- as there are fonts out there that are fuzzy and have too many lookups: - -- - -- U+1105 U+119E U+1105 U+119E : sourcehansansklight: script=hang ccmp=yes - -- - if i + n > nofchainlookups then - -- if trace_contexts then - -- logprocess("%s: quitting lookups",cref(dataset,sequence)) - -- end - break - else - -- we need to carry one - end + if n and n > 1 and i + n > nofchainlookups then + -- this is a safeguard, we just ignore the rest of the lookups + break end end else -- actually an error logprocess("%s: %s is not yet supported (2)",cref(dataset,sequence),chainkind) end - i = i + 1 end - if i > nofchainlookups or not start then + i = i + 1 + if i > size or not start then break elseif start then start = getnext(start) @@ -2608,6 +2540,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end end else + -- 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) diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua index e2d209a76..571c69f13 100644 --- a/tex/context/base/mkiv/font-oup.lua +++ b/tex/context/base/mkiv/font-oup.lua @@ -1302,7 +1302,8 @@ function readers.pack(data) local r = rule.before if r then for i=1,#r do r[i] = pack_boolean(r[i]) end end local r = rule.after if r then for i=1,#r do r[i] = pack_boolean(r[i]) end end local r = rule.current if r then for i=1,#r do r[i] = pack_boolean(r[i]) end end - local r = rule.replacements if r then rule.replacements = pack_flat (r) end -- can have holes + local r = rule.lookups if r then rule.lookups = pack_mixed (r) end + local r = rule.replacements if r then rule.replacements = pack_flat (r) end end end end @@ -1703,9 +1704,16 @@ function readers.unpack(data) end end end + local lookups = rule.lookups + if lookups then + local tv = tables[lookups] + if tv then + rule.lookups = tv + end + end local replacements = rule.replacements if replacements then - local tv = tables[replace] + local tv = tables[replacements] if tv then rule.replacements = tv end @@ -2171,6 +2179,7 @@ function readers.expand(data) local lookups = rule.lookups or false local subtype = nil if lookups then + -- is now indexed for k, v in next, lookups do local lookup = sublookups[v] if lookup then diff --git a/tex/context/base/mkiv/font-pre.mkiv b/tex/context/base/mkiv/font-pre.mkiv index 3b3a76d9c..801702e15 100644 --- a/tex/context/base/mkiv/font-pre.mkiv +++ b/tex/context/base/mkiv/font-pre.mkiv @@ -127,6 +127,11 @@ [script=arab] \definefontfeature + [syriac] + [arabic] + [fin2=yes,fin3=yes,med2=yes] + +\definefontfeature [hebrew] [semitic-complete] [script=hebr] diff --git a/tex/context/base/mkiv/font-sel.lua b/tex/context/base/mkiv/font-sel.lua index 4faf7d9bb..d5bb754f7 100644 --- a/tex/context/base/mkiv/font-sel.lua +++ b/tex/context/base/mkiv/font-sel.lua @@ -17,39 +17,39 @@ local splitat, lpegmatch = lpeg.splitat, lpeg.match local formatters = string.formatters local settings_to_array = utilities.parsers.settings_to_array local settings_to_hash = utilities.parsers.settings_to_hash - + local v_default = interfaces.variables.default - + local implement = interfaces.implement - + local selectfont = fonts.select or { } fonts.select = selectfont - + local data = selectfont.data or { } selectfont.data = data - + local fallbacks = selectfont.fallbacks or { } selectfont.fallbacks = fallbacks - + local methods = selectfont.methods or { } selectfont.methods = methods - + local extras = selectfont.extras or { } selectfont.extras = extras - + local alternatives = selectfont.alternatives or { } selectfont.alternatives = alternatives - + local presets = selectfont.presets or { } selectfont.presets = presets - + local defaults = selectfont.defaults or { } selectfont.defaults = defaults local getlookups = fonts.names.getlookups local registerdesignsizes = fonts.goodies.designsizes.register local bodyfontsizes = storage.shared.bodyfontsizes - + local ctx_definefontsynonym = context.definefontsynonym local ctx_resetfontfallback = context.resetfontfallback local ctx_startfontclass = context.startfontclass @@ -923,4 +923,4 @@ implement { name = "definefontfamilypreset", actions = selectfont.definefontfamilypreset, arguments = { "string", "string" } -}
\ No newline at end of file +} diff --git a/tex/context/base/mkiv/lpdf-mis.lua b/tex/context/base/mkiv/lpdf-mis.lua index 64c061e18..5bd0aa29d 100644 --- a/tex/context/base/mkiv/lpdf-mis.lua +++ b/tex/context/base/mkiv/lpdf-mis.lua @@ -50,7 +50,21 @@ local addtopageattributes = lpdf.addtopageattributes local addtonames = lpdf.addtonames local variables = interfaces.variables + local v_stop = variables.stop +local v_none = variables.none +local v_max = variables.max +local v_bookmark = variables.bookmark +local v_fit = variables.fit +local v_doublesided = variables.doublesided +local v_singlesided = variables.singlesided +local v_default = variables.default +local v_auto = variables.auto +local v_fixed = variables.fixed +local v_landscape = variables.landscape +local v_portrait = variables.portrait +local v_page = variables.page +local v_paper = variables.paper local positive = register(pdfliteral("/GSpositive gs")) local negative = register(pdfliteral("/GSnegative gs")) @@ -247,23 +261,99 @@ lpdf.registerdocumentfinalizer(flushjavascripts,"javascripts") -- -- -- local pagespecs = { - [variables.max] = { mode = "FullScreen", layout = false, fit = false, fixed = false, duplex = false }, - [variables.bookmark] = { mode = "UseOutlines", layout = false, fit = false, fixed = false, duplex = false }, - [variables.fit] = { mode = "UseNone", layout = false, fit = true, fixed = false, duplex = false }, - [variables.doublesided] = { mode = "UseNone", layout = "TwoColumnRight", fit = true, fixed = false, duplex = false }, - [variables.singlesided] = { mode = "UseNone", layout = false, fit = false, fixed = false, duplex = false }, - [variables.default] = { mode = "UseNone", layout = "auto", fit = false, fixed = false, duplex = false }, - [variables.auto] = { mode = "UseNone", layout = "auto", fit = false, fixed = false, duplex = false }, - [variables.none] = { mode = false, layout = false, fit = false, fixed = false, duplex = false }, - -- new - [variables.fixed] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = false }, -- noscale - [variables.landscape] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = "DuplexFlipShortEdge" }, - [variables.portrait] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = "DuplexFlipLongEdge" }, - [variables.page] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = "Simplex" }, + [v_none] = { + }, + [v_max] = { + mode = "FullScreen", + }, + [v_bookmark] = { + mode = "UseOutlines", + }, + [v_fit] = { + mode = "UseNone", + fit = true, + }, + [v_doublesided] = { + mode = "UseNone", + layout = "TwoColumnRight", + fit = true, + }, + [v_singlesided] = { + mode = "UseNone" + }, + [v_default] = { + mode = "UseNone", + layout = "auto", + }, + [v_auto] = { + mode = "UseNone", + layout = "auto", + }, + [v_fixed] = { + mode = "UseNone", + layout = "auto", + fixed = true, -- noscale + }, + [v_landscape] = { + mode = "UseNone", + layout = "auto", + fixed = true, + duplex = "DuplexFlipShortEdge", + }, + [v_portrait] = { + mode = "UseNone", + layout = "auto", + fixed = true, + duplex = "DuplexFlipLongEdge", + }, + [v_page] = { + mode = "UseNone", + layout = "auto", + fixed = true, + duplex = "Simplex", + }, + [v_paper] = { + mode = "UseNone", + layout = "auto", + fixed = true, + duplex = "Simplex", + paper = true, + }, +} + +local plusspecs = { + [v_max] = { + mode = "FullScreen", + }, + [v_bookmark] = { + mode = "UseOutlines", + }, + [v_fit] = { + fit = true, + }, + [v_doublesided] = { + layout = "TwoColumnRight", + }, + [v_fixed] = { + fixed = true, + }, + [v_landscape] = { + duplex = "DuplexFlipShortEdge", + }, + [v_portrait] = { + duplex = "DuplexFlipLongEdge", + }, + [v_page] = { + duplex = "Simplex" , + }, + [v_paper] = { + paper = true, + }, } local pagespec, topoffset, leftoffset, height, width, doublesided = "default", 0, 0, 0, 0, false local cropoffset, bleedoffset, trimoffset, artoffset = 0, 0, 0, 0 +local copies = false function codeinjections.setupcanvas(specification) local paperheight = specification.paperheight @@ -275,11 +365,16 @@ function codeinjections.setupcanvas(specification) if paperwidth then texset('global','pagewidth',paperwidth) end - pagespec = specification.mode or pagespec - topoffset = specification.topoffset or 0 - leftoffset = specification.leftoffset or 0 - height = specification.height or texget("pageheight") - width = specification.width or texget("pagewidth") + pagespec = specification.mode or pagespec + topoffset = specification.topoffset or 0 + leftoffset = specification.leftoffset or 0 + height = specification.height or texget("pageheight") + width = specification.width or texget("pagewidth") + -- + copies = specification.copies + if copies and copies < 2 then + copies = false + end -- cropoffset = specification.cropoffset or 0 trimoffset = cropoffset - (specification.trimoffset or 0) @@ -293,22 +388,17 @@ end local function documentspecification() if not pagespec or pagespec == "" then - pagespec = variables.default + pagespec = v_default end - -- local settings = utilities.parsers.settings_to_array(pagespec) - -- local spec = pagespecs[variables.default] - -- for i=1,#settings do - -- local s = pagespecs[settings[i]] - -- if s then - -- for k, v in next, s do - -- spec[k] = v - -- end - -- end - -- end - local spec = pagespecs[pagespec] or pagespecs[variables.default] + local settings = utilities.parsers.settings_to_array(pagespec) + -- so the first one detemines the defaults + local first = settings[1] + local defaults = pagespecs[first] + local spec = defaults or pagespecs[v_default] + -- successive keys can modify this if spec.layout == "auto" then if doublesided then - local s = pagespecs[variables.doublesided] -- to be checked voor interfaces + local s = pagespecs[v_doublesided] -- to be checked voor interfaces for k, v in next, s do spec[k] = v end @@ -316,22 +406,35 @@ local function documentspecification() spec.layout = false end end + -- we start at 2 when we have a valid first default set + for i=defaults and 2 or 1,#settings do + local s = plusspecs[settings[i]] + if s then + for k, v in next, s do + spec[k] = v + end + end + end + -- local layout = spec.layout local mode = spec.mode local fit = spec.fit local fixed = spec.fixed local duplex = spec.duplex + local paper = spec.paper if layout then addtocatalog("PageLayout",pdfconstant(layout)) end if mode then addtocatalog("PageMode",pdfconstant(mode)) end - if fit or fixed or duplex then + if fit or fixed or duplex or copies or paper then addtocatalog("ViewerPreferences",pdfdictionary { - FitWindow = fit and true or nil, - PrintScaling = fixed and pdfconstant("None") or nil, - Duplex = duplex and pdfconstant(duplex) or nil, + FitWindow = fit and true or nil, + PrintScaling = fixed and pdfconstant("None") or nil, + Duplex = duplex and pdfconstant(duplex) or nil, + NumCopies = copies and copies or nil, + PickTrayByPDFSize = paper and true or nil, }) end addtoinfo ("Trapped", pdfconstant("False")) -- '/Trapped' in /Info, 'Trapped' in XMP diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv index 777af412f..20d4a42a0 100644 --- a/tex/context/base/mkiv/math-ini.mkiv +++ b/tex/context/base/mkiv/math-ini.mkiv @@ -361,11 +361,13 @@ % if there were many features we could have a feature pass over math nodes but it makes no % sense now so we have commands to deal with it -\unexpanded\def\mathaltcal {\math_set_font_alternate{cal}\cal} % set via goody file -%unexpanded\def\mathslashedzero {\math_set_font_alternate{zero}0} % set via goody file or automatic -\unexpanded\def\mathdotless {\math_set_font_alternate{dotless}} % set via goody file or automatic -\unexpanded\def\mathdotlessi {{\mathdotless i}} -\unexpanded\def\mathdotlessj {{\mathdotless j}} +\unexpanded\def\mathaltcalligraphic{\math_set_font_alternate{calligraphic}\cal} % set via goody file +%unexpanded\def\mathslashedzero {\math_set_font_alternate{zero}0} % set via goody file or automatic +\unexpanded\def\mathdotless {\math_set_font_alternate{dotless}} % set via goody file or automatic +\unexpanded\def\mathdotlessi {{\mathdotless i}} +\unexpanded\def\mathdotlessj {{\mathdotless j}} + +\let\mathaltcal\mathaltcalligraphic %let\textslashedzero\slashedzero \unexpanded\def\autoslashedzero{\mathortext\mathslashedzero\textslashedzero} \let\textdotlessi \dotlessi \unexpanded\def\autodotlessi {\mathortext\mathdotlessi \textdotlessi} diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 645cf3523..f59851f49 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -7322,6 +7322,10 @@ return { ["pe"]="پروندهتبدیل", ["ro"]="convertestefisier", }, + ["copies"]={ + ["en"]="copies", + ["nl"]="kopieen", + }, ["corner"]={ ["cs"]="roh", ["de"]="winkel", diff --git a/tex/context/base/mkiv/publ-ini.mkiv b/tex/context/base/mkiv/publ-ini.mkiv index 29ba543cd..3e39dc770 100644 --- a/tex/context/base/mkiv/publ-ini.mkiv +++ b/tex/context/base/mkiv/publ-ini.mkiv @@ -14,6 +14,8 @@ % TODO: s! vs v! for default and neutral key/values % todo: too many refs in list +% TODO A.-B. Foo (dash as connector, see JMH) + % todo: no need for all these %'s % todo: tagging diff --git a/tex/context/base/mkiv/scrn-pag.lua b/tex/context/base/mkiv/scrn-pag.lua index dba5b4786..bd65e53d9 100644 --- a/tex/context/base/mkiv/scrn-pag.lua +++ b/tex/context/base/mkiv/scrn-pag.lua @@ -40,6 +40,7 @@ implement { { "bleedoffset", "dimen" }, { "artoffset", "dimen" }, { "trimoffset", "dimen" }, + { "copies", "integer" }, } } } diff --git a/tex/context/base/mkiv/scrn-pag.mkvi b/tex/context/base/mkiv/scrn-pag.mkvi index 7a7effdc4..b7e056e2b 100644 --- a/tex/context/base/mkiv/scrn-pag.mkvi +++ b/tex/context/base/mkiv/scrn-pag.mkvi @@ -227,6 +227,7 @@ trimoffset \canvastrimoffset bleedoffset \canvasbleedoffset artoffset \canvasartoffset + copies \numexpr\interactionscreenparameter\c!copies\relax \relax %\global\let\scrn_canvas_synchronize_simple \relax \global\let\scrn_canvas_synchronize_complex\relax} @@ -251,6 +252,7 @@ \c!veroffset=\zeropoint, \c!backspace=\backspace, \c!topspace=\topspace, + \c!copies=\plusone, % not the best place but backend anyway \c!option=\v!auto] \appendtoks diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex f2ccf0e16..465f7243d 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 6dcc8bb8b..4cca7e3be 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/fonts/mkiv/minion-math.lfg b/tex/context/fonts/mkiv/minion-math.lfg new file mode 100644 index 000000000..a867a00e3 --- /dev/null +++ b/tex/context/fonts/mkiv/minion-math.lfg @@ -0,0 +1,24 @@ +local kern_100 = { bottomright = { { kern = -100 } } } +local kern_150 = { bottomright = { { kern = -150 } } } +local kern_200 = { bottomright = { { kern = -200 } } } + +return { + name = "minion-math", + version = "1.00", + comment = "Goodies that complement minion math.", + author = "Hans Hagen", + copyright = "ConTeXt development team", + designsizes = { + ["Minion-Math"] = { + ["8.4pt"] = "file:MinionMath-Tiny.otf", + ["9.8pt"] = "file:MinionMath-Capt.otf", + default = "file:MinionMath-Regular.otf", + }, + }, + mathematics = { + kerns = { + [0x1D449] = kern_200, -- 𝑉 + [0x1D44A] = kern_150, -- 𝑊 + }, + }, +} diff --git a/tex/context/fonts/mkiv/type-imp-minion.mkiv b/tex/context/fonts/mkiv/type-imp-minion.mkiv new file mode 100644 index 000000000..a09bc6264 --- /dev/null +++ b/tex/context/fonts/mkiv/type-imp-minion.mkiv @@ -0,0 +1,38 @@ +%D \module +%D [ file=type-imp-minion, +%D version=2016.06.14, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Minion, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + + +\definefontfallback[MinionMathFallback][file:latinmodern-math.otf][uppercasescript] + +\starttypescriptcollection[minion] + + \starttypescript [\s!serif][minion][\s!all] + \definefontsynonym[\s!Serif] [\s!file:MinionPro-Regular.otf][\s!features=\s!default] + \definefontsynonym[\s!SerifBold] [\s!file:MinionPro-Bold.otf] [\s!features=\s!default] + \definefontsynonym[\s!SerifItalic] [\s!file:MinionPro-It.otf] [\s!features=\s!default] + \definefontsynonym[\s!SerifBoldItalic][\s!file:MinionPro-BoldIt.otf] [\s!features=\s!default] + \stoptypescript + + \starttypescript [\s!math][minion][\s!all] + \loadfontgoodies[minion-math] + \definefontsynonym[\s!MathRoman][Minion-Math][\s!features=\s!math\mathsizesuffix,\s!designsize=\s!auto,\s!goodies=minion-math,\s!fallbacks=MinionMathFallback] + \stoptypescript + + \starttypescript [minion] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [minion] [\s!default] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] [\s!rscale=0.8] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.8] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [minion] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/fonts/mkiv/type-imp-texgyre.mkiv b/tex/context/fonts/mkiv/type-imp-texgyre.mkiv index e617a2505..64861a6ef 100644 --- a/tex/context/fonts/mkiv/type-imp-texgyre.mkiv +++ b/tex/context/fonts/mkiv/type-imp-texgyre.mkiv @@ -215,6 +215,22 @@ \stoptypescriptcollection +% tricky: we cannot mix now as the file is loaded only once + +\startmode[txmath] + + \starttypescriptcollection[texgyre-math-times] + + \starttypescript [\s!math][times,termes][\s!all] + \loadfontgoodies[tx-math] + \definefontsynonym[\s!MathRoman][txmath@tx-math] + % \definefontsynonym[\s!MathRomanBold][MathRoman] + \stoptypescript + + \stoptypescriptcollection + +\stopmode + \startnotmode[txmath] \starttypescriptcollection[texgyre-math-times] @@ -229,6 +245,20 @@ \stopnotmode +\startmode[pxmath] + + \starttypescriptcollection[texgyre-math-pagella] + + \starttypescript [\s!math][palatino,pagella][\s!all] + \loadfontgoodies[px-math] + \definefontsynonym[\s!MathRoman][pxmath@px-math] + % \definefontsynonym[\s!MathRomanBold][MathRoman] + \stoptypescript + + \stoptypescriptcollection + +\stopmode + \startnotmode[pxmath] \starttypescriptcollection[texgyre-math-pagella] @@ -263,31 +293,4 @@ \stoptypescriptcollection -\startmode[txmath] - - \starttypescriptcollection[texgyre-math-times] - - \starttypescript [\s!math][times,termes][\s!all] - \loadfontgoodies[tx-math] - \definefontsynonym[\s!MathRoman][txmath@tx-math] - % \definefontsynonym[\s!MathRomanBold][MathRoman] - \stoptypescript - - \stoptypescriptcollection - -\stopmode - -\startmode[pxmath] - - \starttypescriptcollection[texgyre-math-pagella] - - \starttypescript [\s!math][palatino,pagella][\s!all] - \loadfontgoodies[px-math] - \definefontsynonym[\s!MathRoman][pxmath@px-math] - % \definefontsynonym[\s!MathRomanBold][MathRoman] - \stoptypescript - - \stoptypescriptcollection - -\stopmode diff --git a/tex/context/fonts/mkiv/xits-math.lfg b/tex/context/fonts/mkiv/xits-math.lfg index 8e1274365..dd09dd0f1 100644 --- a/tex/context/fonts/mkiv/xits-math.lfg +++ b/tex/context/fonts/mkiv/xits-math.lfg @@ -28,15 +28,15 @@ return { -- ["xits-math"] = italics, -- }, alternates = { - cal = { feature = 'ss01', value = 1, comment = "Mathematical Calligraphic Alphabet" }, - greekssup = { feature = 'ss02', value = 1, comment = "Mathematical Greek Sans Serif Alphabet" }, - greekssit = { feature = 'ss03', value = 1, comment = "Mathematical Italic Sans Serif Digits" }, - monobfnum = { feature = 'ss04', value = 1, comment = "Mathematical Bold Monospace Digits" }, - mathbbbf = { feature = 'ss05', value = 1, comment = "Mathematical Bold Double-Struck Alphabet" }, - mathbbit = { feature = 'ss06', value = 1, comment = "Mathematical Italic Double-Struck Alphabet" }, - mathbbbi = { feature = 'ss07', value = 1, comment = "Mathematical Bold Italic Double-Struck Alphabet" }, - upint = { feature = 'ss08', value = 1, comment = "Upright Integrals" }, - vertnot = { feature = 'ss09', value = 1, comment = "Negated Symbols With Vertical Stroke" }, + calligraphic = { feature = 'ss01', value = 1, comment = "Mathematical Calligraphic Alphabet" }, + greekssup = { feature = 'ss02', value = 1, comment = "Mathematical Greek Sans Serif Alphabet" }, + greekssit = { feature = 'ss03', value = 1, comment = "Mathematical Italic Sans Serif Digits" }, + monobfnum = { feature = 'ss04', value = 1, comment = "Mathematical Bold Monospace Digits" }, + mathbbbf = { feature = 'ss05', value = 1, comment = "Mathematical Bold Double-Struck Alphabet" }, + mathbbit = { feature = 'ss06', value = 1, comment = "Mathematical Italic Double-Struck Alphabet" }, + mathbbbi = { feature = 'ss07', value = 1, comment = "Mathematical Bold Italic Double-Struck Alphabet" }, + upint = { feature = 'ss08', value = 1, comment = "Upright Integrals" }, + vertnot = { feature = 'ss09', value = 1, comment = "Negated Symbols With Vertical Stroke" }, }, } } diff --git a/tex/context/interface/mkii/keys-cs.xml b/tex/context/interface/mkii/keys-cs.xml index c368ca014..8d3f17a4e 100644 --- a/tex/context/interface/mkii/keys-cs.xml +++ b/tex/context/interface/mkii/keys-cs.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='controls'/> <cd:constant name='conversion' value='konverze'/> <cd:constant name='convertfile' value='konverzesouboru'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='roh'/> <cd:constant name='coupling' value='propojeni'/> <cd:constant name='couplingway' value='zpusobpropojeni'/> diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml index 45abd7dce..2f6fc9bcc 100644 --- a/tex/context/interface/mkii/keys-de.xml +++ b/tex/context/interface/mkii/keys-de.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='controls'/> <cd:constant name='conversion' value='konversion'/> <cd:constant name='convertfile' value='konvertieredatei'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='winkel'/> <cd:constant name='coupling' value='verknuepfung'/> <cd:constant name='couplingway' value='verkopplungsart'/> diff --git a/tex/context/interface/mkii/keys-en.xml b/tex/context/interface/mkii/keys-en.xml index 3a71b17bd..ab91bf43e 100644 --- a/tex/context/interface/mkii/keys-en.xml +++ b/tex/context/interface/mkii/keys-en.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='controls'/> <cd:constant name='conversion' value='conversion'/> <cd:constant name='convertfile' value='convertfile'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='corner'/> <cd:constant name='coupling' value='coupling'/> <cd:constant name='couplingway' value='couplingway'/> diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml index f107c84b8..03e20c347 100644 --- a/tex/context/interface/mkii/keys-fr.xml +++ b/tex/context/interface/mkii/keys-fr.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='controles'/> <cd:constant name='conversion' value='conversion'/> <cd:constant name='convertfile' value='conversionfichier'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='coin'/> <cd:constant name='coupling' value='couplage'/> <cd:constant name='couplingway' value='modecouplage'/> diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml index 2e3bb5b5d..616d491fe 100644 --- a/tex/context/interface/mkii/keys-it.xml +++ b/tex/context/interface/mkii/keys-it.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='controlli'/> <cd:constant name='conversion' value='conversione'/> <cd:constant name='convertfile' value='convertifile'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='angolo'/> <cd:constant name='coupling' value='accoppiamento'/> <cd:constant name='couplingway' value='modoaccoppiamento'/> diff --git a/tex/context/interface/mkii/keys-nl.xml b/tex/context/interface/mkii/keys-nl.xml index 704a815f0..da812cb7b 100644 --- a/tex/context/interface/mkii/keys-nl.xml +++ b/tex/context/interface/mkii/keys-nl.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='sturing'/> <cd:constant name='conversion' value='conversie'/> <cd:constant name='convertfile' value='converteerfile'/> + <cd:constant name='copies' value='kopieen'/> <cd:constant name='corner' value='hoek'/> <cd:constant name='coupling' value='koppeling'/> <cd:constant name='couplingway' value='koppelwijze'/> diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml index 87ad3dbe1..a6c908796 100644 --- a/tex/context/interface/mkii/keys-pe.xml +++ b/tex/context/interface/mkii/keys-pe.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='کنترلها'/> <cd:constant name='conversion' value='تبدیل'/> <cd:constant name='convertfile' value='پروندهتبدیل'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='گوشه'/> <cd:constant name='coupling' value='تزویج'/> <cd:constant name='couplingway' value='روشتزویج'/> diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index bc6227e90..7a5da9946 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -728,6 +728,7 @@ <cd:constant name='controls' value='controale'/> <cd:constant name='conversion' value='conversie'/> <cd:constant name='convertfile' value='convertestefisier'/> + <cd:constant name='copies' value='copies'/> <cd:constant name='corner' value='colt'/> <cd:constant name='coupling' value='cuplare'/> <cd:constant name='couplingway' value='modcuplare'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 98c62a2bf..8783f845e 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-interactionscreen.xml b/tex/context/interface/mkiv/i-interactionscreen.xml index 69edbcdb9..6e337f6d6 100644 --- a/tex/context/interface/mkiv/i-interactionscreen.xml +++ b/tex/context/interface/mkiv/i-interactionscreen.xml @@ -31,7 +31,7 @@ <cd:parameter name="topspace"> <cd:constant type="cd:dimension"/> </cd:parameter> - <cd:parameter name="option"> + <cd:parameter name="option" list="yes"> <cd:constant type="fit"/> <cd:constant type="max"/> <cd:constant type="singlesided"/> @@ -44,6 +44,10 @@ <cd:constant type="landscape"/> <cd:constant type="portrait"/> <cd:constant type="page"/> + <cd:constant type="paper"/> + </cd:parameter> + <cd:parameter name="copies"> + <cd:constant type="cd:number"/> </cd:parameter> <cd:parameter name="delay"> <cd:constant type="none" default="yes"/> @@ -61,4 +65,4 @@ </cd:arguments> </cd:command> -</cd:interface>
\ No newline at end of file +</cd:interface> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 624380cec..e464b7c63 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-fonts-features.lua b/tex/context/modules/mkiv/s-fonts-features.lua index 0a7cf8b13..7300cb768 100644 --- a/tex/context/modules/mkiv/s-fonts-features.lua +++ b/tex/context/modules/mkiv/s-fonts-features.lua @@ -49,12 +49,12 @@ function moduledata.fonts.features.showused(specification) elseif rawget(descriptions,feature) then NC() context(feature) NC() context("+") -- extra - NC() context(descriptions[feature]) + NC() context.escaped(descriptions[feature]) done = true elseif rawget(features,feature) then NC() context(feature) NC() -- otf - NC() context(features[feature]) + NC() context.escaped(features[feature]) done = true else NC() context(feature) diff --git a/tex/context/modules/mkiv/s-fonts-shapes.lua b/tex/context/modules/mkiv/s-fonts-shapes.lua index 8f872e4bc..c07fad285 100644 --- a/tex/context/modules/mkiv/s-fonts-shapes.lua +++ b/tex/context/modules/mkiv/s-fonts-shapes.lua @@ -115,9 +115,6 @@ local function showglyphshape(specification) if not charnum then charnum = fonts.helpers.nametoslot(n) end - context.start() - context.dontleavehmode() - context.obeyMPboxdepth() local characters = tfmdata.characters local descriptions = tfmdata.descriptions local parameters = tfmdata.parameters @@ -130,6 +127,9 @@ local function showglyphshape(specification) local width, italic = (d.width or 0)*factor, (d.italic or 0)*factor local top_accent, bot_accent = (d.top_accent or 0)*factor, (d.bot_accent or 0)*factor local anchors, math = d.anchors, d.math + context.start() + context.dontleavehmode() + context.obeyMPboxdepth() context.startMPcode() context("numeric lw ; lw := .125bp ;") context("pickup pencircle scaled lw ;") @@ -143,7 +143,7 @@ local function showglyphshape(specification) if #v > 0 then local l = { } for kk, vv in ipairs(v) do - local h, k = vv.height, vv.kern + local h, k = vv.height or 0, vv.kern or 0 if h and k then l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) end @@ -160,7 +160,7 @@ local function showglyphshape(specification) if #v > 0 then local l = { } for kk, vv in ipairs(v) do - local h, k = vv.height, vv.kern + local h, k = vv.height or 0, vv.kern or 0 if h and k then l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) end @@ -171,7 +171,7 @@ local function showglyphshape(specification) context('label.%s("\\type{%s}",%s shifted (0,2bp)) ;',loc,txt,l[1]) end for kk, vv in ipairs(v) do - local h, k = vv.height, vv.kern + local h, k = vv.height or 0, vv.kern or 0 if h and k then context('label.top("(%s,%s)",%s shifted (0,-2bp));',k,h,l[kk]) end @@ -183,13 +183,13 @@ local function showglyphshape(specification) if kerns then for _, slant in ipairs { slant_1, slant_2 } do for k,v in pairs(kerns) do - if k == "top_right" then + if k == "topright" then slant(v,width+italic,0,k,1,1,"top","ulft") - elseif k == "bottom_right" then + elseif k == "bottomright" then slant(v,width,0,k,1,1,"bot","lrt") - elseif k == "top_left" then + elseif k == "topleft" then slant(v,0,0,k,-1,1,"top","ulft") - elseif k == "bottom_left" then + elseif k == "bottomleft" then slant(v,0,0,k,-1,1,"bot","lrt") end end @@ -257,6 +257,7 @@ local function showglyphshape(specification) context("setbounds currentpicture to boundingbox currentpicture enlarged 1bp ;") context("currentpicture := currentpicture scaled 8 ;") context.stopMPcode() + context.stop() -- elseif c then -- lastdata, lastunicode = nil, nil -- local factor = (7200/7227)/65536 @@ -290,10 +291,9 @@ local function showglyphshape(specification) -- context("currentpicture := currentpicture scaled 8 ;") -- context.stopMPcode() else - lastdata, lastunicode = nil, nil - context("no such shape: 0x%05X",charnum) + -- lastdata, lastunicode = nil, nil + -- context("no such shape: 0x%05X",charnum) end - context.stop() end moduledata.fonts.shapes.showglyphshape = showglyphshape diff --git a/tex/context/modules/mkiv/s-fonts-shapes.mkiv b/tex/context/modules/mkiv/s-fonts-shapes.mkiv index c1e9d61d2..3e2bc26f6 100644 --- a/tex/context/modules/mkiv/s-fonts-shapes.mkiv +++ b/tex/context/modules/mkiv/s-fonts-shapes.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +%D I will redo this module (using outlines). + \startmodule[fonts-shapes] \registerctxluafile{s-fonts-shapes}{} @@ -107,9 +109,10 @@ % \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D45D}\stopTEXpage % \page - % \showallglyphshapes[name=name:cambria-math,size=100bp] +\showallglyphshapes[name=name:cambria-math,size=100bp] % \showallglyphshapes[name=name:dejavuserif,size=100bp] -\showallglyphshapes[name=file:brill.otf,size=100bp] +% \showallglyphshapes[name=file:brill.otf,size=100bp] +% \showallglyphshapes[name=file:minionmath-regular.otf,size=100bp] \stoptext diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 6f96d9740..978598881 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 : 06/13/16 17:00:29 +-- merge date : 06/15/16 20:18:05 do -- begin closure to overcome local limits and interference @@ -11479,6 +11479,25 @@ local function covered(subset,all) end return used end +local function readlookuparray(f,noflookups) + local lookups={} + if noflookups>0 then + local length=0 + for i=1,noflookups do + local index=readushort(f)+1 + if index>length then + length=index + end + lookups[index]=readushort(f)+1 + end + for index=1,length do + if not lookups[index] then + lookups[index]=false + end + end + end + return lookups +end local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,what) local tableoffset=lookupoffset+offset setposition(f,tableoffset) @@ -11503,10 +11522,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n for i=2,nofcurrent do current[i]={ readushort(f) } end - local lookups={} - for i=1,noflookups do - lookups[readushort(f)+1]=readushort(f)+1 - end + local lookups=readlookuparray(f,noflookups) rules[#rules+1]={ current=current, lookups=lookups @@ -11547,10 +11563,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n for i=2,nofcurrent do current[i]=currentclasses[readushort(f)+1] end - local lookups={} - for i=1,noflookups do - lookups[readushort(f)+1]=readushort(f)+1 - end + local lookups=readlookuparray(f,noflookups) rules[#rules+1]={ current=current, lookups=lookups @@ -11574,10 +11587,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n elseif subtype==3 then local current=readarray(f) local noflookups=readushort(f) - local lookups={} - for i=1,noflookups do - lookups[readushort(f)+1]=readushort(f)+1 - end + local lookups=readlookuparray(f,noflookups) current=readcoveragearray(f,tableoffset,current,true) return { format="coverage", @@ -11632,10 +11642,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof end end local noflookups=readushort(f) - local lookups={} - for i=1,noflookups do - lookups[readushort(f)+1]=readushort(f)+1 - end + local lookups=readlookuparray(f,noflookups) rules[#rules+1]={ before=before, current=current, @@ -11700,10 +11707,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof end end local noflookups=readushort(f) - local lookups={} - for i=1,noflookups do - lookups[readushort(f)+1]=readushort(f)+1 - end + local lookups=readlookuparray(f,noflookups) rules[#rules+1]={ before=before, current=current, @@ -11731,10 +11735,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof local current=readarray(f) local after=readarray(f) local noflookups=readushort(f) - local lookups={} - for i=1,noflookups do - lookups[readushort(f)+1]=readushort(f)+1 - end + local lookups=readlookuparray(f,noflookups) before=readcoveragearray(f,tableoffset,before,true) current=readcoveragearray(f,tableoffset,current,true) after=readcoveragearray(f,tableoffset,after,true) @@ -12629,41 +12630,47 @@ do report_issue(i,what,sequence,"empty") rule.lookups=nil else - for index,lookupid in sortedhash(rlookups) do - local h=sublookuphash[lookupid] - if not h then - local lookup=lookups[lookupid] - if lookup then - local d=lookup.done - if d then - nofsublookups=nofsublookups+1 - h={ - index=nofsublookups, - name=f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), - derived=true, - steps=d.steps, - nofsteps=d.nofsteps, - type=d.lookuptype, - markclass=d.markclass or nil, - flags=d.flags, - } - sublookuplist[nofsublookups]=h - sublookuphash[lookupid]=nofsublookups - sublookupcheck[lookupid]=1 + local length=#rlookups + for index=1,length do + local lookupid=rlookups[index] + if lookupid then + local h=sublookuphash[lookupid] + if not h then + local lookup=lookups[lookupid] + if lookup then + local d=lookup.done + if d then + nofsublookups=nofsublookups+1 + h={ + index=nofsublookups, + name=f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), + derived=true, + steps=d.steps, + nofsteps=d.nofsteps, + type=d.lookuptype, + markclass=d.markclass or nil, + flags=d.flags, + } + sublookuplist[nofsublookups]=h + sublookuphash[lookupid]=nofsublookups + sublookupcheck[lookupid]=1 + else + report_issue(i,what,sequence,"missing") + rule.lookups=nil + break + end else - report_issue(i,what,sequence,"missing") + report_issue(i,what,sequence,"bad") rule.lookups=nil break end else - report_issue(i,what,sequence,"bad") - rule.lookups=nil - break + sublookupcheck[lookupid]=sublookupcheck[lookupid]+1 end + rlookups[index]=h or false else - sublookupcheck[lookupid]=sublookupcheck[lookupid]+1 + rlookups[index]=false end - rlookups[index]=h end end end @@ -14486,7 +14493,8 @@ function readers.pack(data) local r=rule.before if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end local r=rule.after if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end local r=rule.current if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end - local r=rule.replacements if r then rule.replacements=pack_flat (r) end + local r=rule.lookups if r then rule.lookups=pack_mixed (r) end + local r=rule.replacements if r then rule.replacements=pack_flat (r) end end end end @@ -14830,9 +14838,16 @@ function readers.unpack(data) end end end + local lookups=rule.lookups + if lookups then + local tv=tables[lookups] + if tv then + rule.lookups=tv + end + end local replacements=rule.replacements if replacements then - local tv=tables[replace] + local tv=tables[replacements] if tv then rule.replacements=tv end @@ -15348,7 +15363,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.022 +otf.version=3.023 otf.cache=containers.define("fonts","otl",otf.version,true) otf.svgcache=containers.define("fonts","svg",otf.version,true) otf.pdfcache=containers.define("fonts","pdf",otf.version,true) @@ -15901,7 +15916,7 @@ local function getgsub(tfmdata,k,kind,value) end otf.getgsub=getgsub function otf.getsubstitution(tfmdata,k,kind,value) - local found,kind=getgsub(tfmdata,k,kind) + local found,kind=getgsub(tfmdata,k,kind,value) if not found then elseif kind=="gsub_single" then return found @@ -18149,6 +18164,7 @@ local free_node=nuts.free local end_of_math=nuts.end_of_math local traverse_nodes=nuts.traverse local traverse_id=nuts.traverse_id +local remove_node=nuts.remove local setmetatableindex=table.setmetatableindex local zwnj=0x200C local zwj=0x200D @@ -19022,7 +19038,7 @@ function chainprocs.gsub_multiple(head,start,stop,dataset,sequence,currentlookup if trace_multiples then logprocess("%s: replacing %s by multiple characters %s",cref(dataset,sequence),gref(startchar),gref(replacement)) end - return multiple_glyphs(head,start,replacement,currentlookup.flags[1]) + return multiple_glyphs(head,start,replacement,sequence.flags[1]) end return head,start,false end @@ -19750,6 +19766,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local ck=contexts[k] local seq=ck[3] local s=#seq + local size=1 if s==1 then local char=ischar(current,currentfont) if char then @@ -19758,44 +19775,33 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) else local f=ck[4] local l=ck[5] - if f==1 and f==l then - else - if f==l then - else - local discfound=nil - local n=f+1 - last=getnext(last) - while n<=l do - if not last and (sweeptype=="post" or sweeptype=="replace") then - last=getnext(sweepnode) - sweeptype=nil - end - if last then - local char,id=ischar(last,currentfont) - if char then - local ccd=descriptions[char] - if ccd then - local class=ccd.class or "base" - if class==skipmark or class==skipligature or class==skipbase or (markclass and class=="mark" and not markclass[char]) then - skipped=true - if trace_skips then - show_skip(dataset,sequence,char,ck,class) - end + size=l-f+1 + if size>1 then + local discfound=nil + local n=f+1 + last=getnext(last) + while n<=l do + if not last and (sweeptype=="post" or sweeptype=="replace") then + last=getnext(sweepnode) + sweeptype=nil + end + if last then + local char,id=ischar(last,currentfont) + if char then + local ccd=descriptions[char] + if ccd then + local class=ccd.class or "base" + if class==skipmark or class==skipligature or class==skipbase or (markclass and class=="mark" and not markclass[char]) then + skipped=true + if trace_skips then + show_skip(dataset,sequence,char,ck,class) + end + last=getnext(last) + elseif seq[n][char] then + if n<l then last=getnext(last) - elseif seq[n][char] then - if n<l then - last=getnext(last) - end - n=n+1 - else - if discfound then - notmatchreplace[discfound]=true - match=not notmatchpre[discfound] - else - match=false - end - break end + n=n+1 else if discfound then notmatchreplace[discfound]=true @@ -19805,7 +19811,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end - elseif char==false then + else if discfound then notmatchreplace[discfound]=true match=not notmatchpre[discfound] @@ -19813,58 +19819,66 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) match=false end break - elseif id==disc_code then - diskseen=true - discfound=last - notmatchpre[last]=nil - notmatchpost[last]=true - notmatchreplace[last]=nil - local pre,post,replace=getdisc(last) - if pre then - local n=n - while pre do - if seq[n][getchar(pre)] then - n=n+1 - pre=getnext(pre) - if n>l then - break - end - else - notmatchpre[last]=true + end + elseif char==false then + if discfound then + notmatchreplace[discfound]=true + match=not notmatchpre[discfound] + else + match=false + end + break + elseif id==disc_code then + diskseen=true + discfound=last + notmatchpre[last]=nil + notmatchpost[last]=true + notmatchreplace[last]=nil + local pre,post,replace=getdisc(last) + if pre then + local n=n + while pre do + if seq[n][getchar(pre)] then + n=n+1 + pre=getnext(pre) + if n>l then break end - end - if n<=l then + else notmatchpre[last]=true + break end - else + end + if n<=l then notmatchpre[last]=true end - if replace then - while replace do - if seq[n][getchar(replace)] then - n=n+1 - replace=getnext(replace) - if n>l then - break - end - else - notmatchreplace[last]=true - match=not notmatchpre[last] + else + notmatchpre[last]=true + end + if replace then + while replace do + if seq[n][getchar(replace)] then + n=n+1 + replace=getnext(replace) + if n>l then break end + else + notmatchreplace[last]=true + match=not notmatchpre[last] + break end - match=not notmatchpre[last] end - last=getnext(last) - else - match=false - break + match=not notmatchpre[last] end + last=getnext(last) else match=false break end + else + match=false + break end end end @@ -20133,7 +20147,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local chainlookups=ck[6] if chainlookups then local nofchainlookups=#chainlookups - if nofchainlookups==1 then + if size==1 then local chainlookup=chainlookups[1] local chainkind=chainlookup.type local chainproc=chainprocs[chainkind] @@ -20152,7 +20166,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end else local i=1 - while start and true do + while start do if skipped then while start do local char=getchar(start) @@ -20169,10 +20183,8 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end end end - local chainlookup=chainlookups[1] - if not chainlookup then - i=i+1 - else + local chainlookup=chainlookups[i] + if chainlookup then local chainkind=chainlookup.type local chainproc=chainprocs[chainkind] if chainproc then @@ -20184,19 +20196,16 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end if ok then done=true - if n and n>1 then - if i+n>nofchainlookups then - break - else - end + if n and n>1 and i+n>nofchainlookups then + break end end else logprocess("%s: %s is not yet supported (2)",cref(dataset,sequence),chainkind) end - i=i+1 end - if i>nofchainlookups or not start then + i=i+1 + if i>size or not start then break elseif start then start=getnext(start) @@ -23108,6 +23117,7 @@ if not modules then modules={} end modules ['font-ocl']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } +local tostring,next=tostring,next local formatters=string.formatters local otf=fonts.handlers.otf local f_color_start=formatters["pdf:direct: %f %f %f rg"] @@ -23226,30 +23236,47 @@ do end if context and xml.convert then local report_svg=logs.reporter("fonts","svg conversion") + local xmlconvert=xml.convert + local xmlfirst=xml.first + local loaddata=io.loaddata + local savedata=io.savedata + local remove=os.remove function otfsvg.topdf(svgshapes) - local svgfile="temp-otf-svg-shape.svg" - local pdffile="temp-otf-svg-shape.pdf" - local command="inkscape "..svgfile.." --export-pdf="..pdffile - local testrun=false + local inkscape=io.popen("inkscape --shell 2>&1","w") local pdfshapes={} local nofshapes=#svgshapes + local f_svgfile=formatters["temp-otf-svg-shape-%i.svg"] + local f_pdffile=formatters["temp-otf-svg-shape-%i.pdf"] + local f_convert=formatters["%s --export-pdf=%s\n"] report_svg("processing %i svg containers",nofshapes) + statistics.starttiming() for i=1,nofshapes do local entry=svgshapes[i] for j=entry.first,entry.last do - local svg=xml.convert(entry.data) - local data=xml.first(svg,"/svg[@id='glyph"..j.."']") - io.savedata(svgfile,tostring(data)) - report_svg("processing svg shape of glyph %i in container %i",j,i) - os.execute(command) - pdfshapes[j]=io.loaddata(pdffile) - end - if testrun and i>testrun then - report_svg("quiting test run") - break - end - end - os.remove(svgfile) + local svg=xmlconvert(entry.data) + local root=svg and xmlfirst(svg,"/svg[@id='glyph"..j.."']") + local data=root and tostring(root) + if data and data~="" then + local svgfile=f_svgfile(j) + local pdffile=f_pdffile(j) + savedata(svgfile,data) + inkscape:write(f_convert(svgfile,pdffile)) + pdfshapes[j]=true + end + end + end + inkscape:write("quit\n") + inkscape:close() + report_svg("processing %i pdf results",nofshapes) + for i in next,pdfshapes do + local svgfile=f_svgfile(i) + local pdffile=f_pdffile(i) + pdfshapes[i]=loaddata(pdffile) + remove(svgfile) + remove(pdffile) + end + statistics.stoptiming() + report_svg("conversion time: %0.3f",statistics.elapsedtime()) return pdfshapes end else |