summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-15 21:30:30 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-15 21:30:30 +0200
commit3d9fb7a20b16edd5babed9a56ca70662c0fcb011 (patch)
tree7fa932570d89b22a639c3062d07c6adb1841f5ae /tex/context/base/mkiv
parent9db0c39e07509226287ef0075dfda8d2386416ed (diff)
downloadcontext-3d9fb7a20b16edd5babed9a56ca70662c0fcb011.tar.gz
2016-06-15 20:23:00
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r--tex/context/base/mkiv/cldf-ini.lua2
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context-todo.tex3
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/font-dsp.lua125
-rw-r--r--tex/context/base/mkiv/font-mis.lua2
-rw-r--r--tex/context/base/mkiv/font-ocl.lua84
-rw-r--r--tex/context/base/mkiv/font-otc.lua20
-rw-r--r--tex/context/base/mkiv/font-otl.lua4
-rw-r--r--tex/context/base/mkiv/font-ots.lua271
-rw-r--r--tex/context/base/mkiv/font-oup.lua13
-rw-r--r--tex/context/base/mkiv/font-pre.mkiv5
-rw-r--r--tex/context/base/mkiv/font-sel.lua24
-rw-r--r--tex/context/base/mkiv/lpdf-mis.lua173
-rw-r--r--tex/context/base/mkiv/math-ini.mkiv12
-rw-r--r--tex/context/base/mkiv/mult-def.lua4
-rw-r--r--tex/context/base/mkiv/publ-ini.mkiv2
-rw-r--r--tex/context/base/mkiv/scrn-pag.lua1
-rw-r--r--tex/context/base/mkiv/scrn-pag.mkvi2
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin9231 -> 9200 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin269053 -> 269053 bytes
21 files changed, 441 insertions, 310 deletions
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
index f2ccf0e16..465f7243d 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 6dcc8bb8b..4cca7e3be 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ