summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/back-pdf.lua23
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/grph-swf.lua7
-rw-r--r--tex/context/base/grph-u3d.lua7
-rw-r--r--tex/context/base/lpdf-ano.lua47
-rw-r--r--tex/context/base/lpdf-fld.lua40
-rw-r--r--tex/context/base/lpdf-grp.lua16
-rw-r--r--tex/context/base/lpdf-ini.lua262
-rw-r--r--tex/context/base/lpdf-mis.lua32
-rw-r--r--tex/context/base/lpdf-nod.lua4
-rw-r--r--tex/context/base/lpdf-ren.lua16
-rw-r--r--tex/context/base/lpdf-wid.lua38
-rw-r--r--tex/context/base/lpdf-xmp.lua77
-rw-r--r--tex/context/base/lpdf-xmp.xml43
-rw-r--r--tex/context/base/meta-dum.tex2
-rw-r--r--tex/context/base/mlib-pps.mkiv14
-rw-r--r--tex/context/base/s-fnt-10.tex1
-rw-r--r--tex/context/base/scrn-nav.mkiv12
-rw-r--r--tex/context/base/spac-ver.lua43
-rw-r--r--tex/context/base/spac-ver.mkiv2
-rw-r--r--tex/context/base/supp-fil.lua12
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
23 files changed, 417 insertions, 287 deletions
diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua
index 3b46db0b4..3d21a5961 100644
--- a/tex/context/base/back-pdf.lua
+++ b/tex/context/base/back-pdf.lua
@@ -31,14 +31,17 @@ local registrations = backends.pdf.registrations
local pdfliteral, register = nodes.pdfliteral, nodes.register
-local pdfconstant = lpdf.constant
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfreference = lpdf.reference
-local pdfverbose = lpdf.verbose
-
-local pdfreserveobj = pdf.reserveobj
-local pdfimmediateobj = pdf.immediateobj
+local pdfconstant = lpdf.constant
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfverbose = lpdf.verbose
+local pdfflushobject = lpdf.flushobject
+local pdfreserveobject = lpdf.reserveobject
+local pdfannotation = nodes.pdfannotation
+
+local pdfreserveobj = pdf.reserveobj
+local pdfimmediateobj = pdf.immediateobj
function nodeinjections.rgbcolor(r,g,b)
return register(pdfliteral(format("%s %s %s rg %s %s %s RG",r,g,b,r,g,b)))
@@ -130,7 +133,7 @@ function codeinjections.insertmovie(specification)
Movie = moviedict,
A = controldict,
}
- node.write(nodes.pdfannot(width,height,0,action()))
+ node.write(pdfannotation(width,height,0,action()))
end
function codeinjections.insertsound(specification)
@@ -150,7 +153,7 @@ function codeinjections.insertsound(specification)
Movie = sounddict,
A = controldict,
}
- node.write(nodes.pdfannot(0,0,0,action()))
+ node.write(pdfannotation(0,0,0,action()))
end
end
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 51d5182ec..998d091ca 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2010.02.15 22:16}
+\newcontextversion{2010.02.18 14:48}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index bf1ae6158..b8894df56 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2010.02.15 22:16}
+\edef\contextversion{2010.02.18 14:48}
%D For those who want to use this:
diff --git a/tex/context/base/grph-swf.lua b/tex/context/base/grph-swf.lua
index f9f3c5b2d..e55454b52 100644
--- a/tex/context/base/grph-swf.lua
+++ b/tex/context/base/grph-swf.lua
@@ -8,8 +8,9 @@ if not modules then modules = { } end modules ['grph-swf'] = {
local format = string.format
-local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
+local texsprint = tex.sprint
+local ctxcatcodes = tex.ctxcatcodes
+local pdfannotation = nodes.pdfannotation
function figures.checkers.swf(data)
local dr, du, ds = data.request, data.used, data.status
@@ -28,7 +29,7 @@ function figures.checkers.swf(data)
-- controls = dr.controls,
-- label = dr.label,
}
- -- node.write(nodes.pdfannot(width,-height,0,annot()))
+ -- node.write(pdfannotation(width,-height,0,annot()))
texsprint(ctxcatcodes,format("\\pdfannot width %ssp height %ssp {%s}",width,height,annot())) -- brrrr
--~ if ref then -- wrong ! a direct ref should work
--~ texsprint(ctxcatcodes,format("\\smash{\\pdfrefximage%s\\relax}",ref)) -- brrrr
diff --git a/tex/context/base/grph-u3d.lua b/tex/context/base/grph-u3d.lua
index d69240113..3b1d8365d 100644
--- a/tex/context/base/grph-u3d.lua
+++ b/tex/context/base/grph-u3d.lua
@@ -10,8 +10,9 @@ if not modules then modules = { } end modules ['grph-u3d'] = {
local format = string.format
-local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
+local texsprint = tex.sprint
+local ctxcatcodes = tex.ctxcatcodes
+local pdfannotation = nodes.pdfannotation
function figures.checkers.u3d(data)
local dr, du, ds = data.request, data.used, data.status
@@ -30,7 +31,7 @@ function figures.checkers.u3d(data)
controls = dr.controls,
label = dr.label,
}
- -- node.write(nodes.pdfannot(width,-height,0,annot()))
+ -- node.write(pdfannotation(width,-height,0,annot()))
texsprint(ctxcatcodes,format("\\pdfannot width %ssp height %ssp {%s}",width,height,annot())) -- brrrr
--~ if ref then -- wrong ! a direct ref should work
--~ texsprint(ctxcatcodes,format("\\smash{\\pdfrefximage%s\\relax}",ref)) -- brrrr
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 017a3919a..6e4bdb814 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -31,18 +31,17 @@ local specials = jobreferences.specials
local handlers = jobreferences.handlers
local executers = jobreferences.executers
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfreference = lpdf.reference
-local pdfunicode = lpdf.unicode
-local pdfconstant = lpdf.constant
-
-local pdfreserveobj = pdf.reserveobj
-local pdfimmediateobj = pdf.immediateobj
-local pdfpageref = tex.pdfpageref
-
-local pdfannot = nodes.pdfannot
-local pdfdest = nodes.pdfdest
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfconstant = lpdf.constant
+local pdfflushobject = lpdf.flushobject
+local pdfreserveobject = lpdf.reserveobject
+local pdfannotation = nodes.pdfannotation
+local pdfdestination = nodes.pdfdestination
+
+local pdfpagereference = tex.pdfpageref
local pdf_uri = pdfconstant("URI")
local pdf_gotor = pdfconstant("GoToR")
@@ -60,10 +59,10 @@ local function pagedest(n)
local pd = cache[n]
if not pd then
local a = pdfarray {
- pdfreference(pdfpageref(n)),
+ pdfreference(pdfpagereference(n)),
pdfconstant("Fit")
}
- pd = pdfreference(pdfimmediateobj(tostring(a)))
+ pd = pdfreference(pdfflushobject(a))
cache[n] = pd
end
return pd
@@ -221,7 +220,7 @@ end
-- }
-- local cm = cache[main]
-- if not cm then
--- cm = "/A ".. tostring(pdfreference(pdfimmediateobj(tostring(main))))
+-- cm = "/A ".. tostring(pdfreference(pdfflushobject(main))
-- cache[main] = cm
-- end
-- return cm
@@ -236,7 +235,7 @@ function nodeinjections.reference(width,height,depth,prerolled)
if trace_references then
logs.report("references","w=%s, h=%s, d=%s, a=%s",width,height,depth,prerolled)
end
- return pdfannot(width,height,depth,prerolled)
+ return pdfannotation(width,height,depth,prerolled)
end
end
@@ -247,7 +246,7 @@ function nodeinjections.destination(width,height,depth,name,view)
if trace_destinations then
logs.report("destinations","w=%s, h=%s, d=%s, n=%s, v=%s",width,height,depth,name,view or "no view")
end
- return pdfdest(width,height,depth,name,view)
+ return pdfdestination(width,height,depth,name,view)
end
-- runners and specials
@@ -571,10 +570,10 @@ local function build(levels,start,parent,method)
logs.report("bookmark","%3i %s%s %s",reference.realpage,rep(" ",level-1),(open and "+") or "-",title)
end
local prev = child
- child = pdfreserveobj()
+ child = pdfreserveobject()
if entry then
entry.Next = child and pdfreference(child)
- pdfimmediateobj(prev,tostring(entry))
+ pdfflushobject(prev,entry)
end
entry = pdfdictionary {
Title = pdfunicode(title),
@@ -592,7 +591,7 @@ local function build(levels,start,parent,method)
n = n + 1
i = i + 1
elseif level < startlevel then
- pdfimmediateobj(child,tostring(entry))
+ pdfflushobject(child,entry)
return i, n, first, last
elseif i < #levels and level > startlevel then
i, m, f, l = build(levels,i,pdfreference(child),method)
@@ -607,16 +606,16 @@ local function build(levels,start,parent,method)
if m > 0 then
entry.First, entry.Last = pdfreference(f), pdfreference(l)
end
- pdfimmediateobj(child,tostring(entry))
+ pdfflushobject(child,entry)
return i, n, first, last
end
end
- pdfimmediateobj(child,tostring(entry))
+ pdfflushobject(child,entry)
return nil, n, first, last
end
function codeinjections.addbookmarks(levels,method)
- local parent = pdfreserveobj()
+ local parent = pdfreserveobject()
local _, m, first, last = build(levels,1,pdfreference(parent),method or "internal")
local dict = pdfdictionary {
Type = pdfconstant("Outlines"),
@@ -624,6 +623,6 @@ function codeinjections.addbookmarks(levels,method)
Last = pdfreference(last),
Count = m,
}
- pdfimmediateobj(parent,tostring(dict))
+ pdfflushobject(parent,dict)
lpdf.addtocatalog("Outlines",lpdf.reference(parent))
end
diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua
index 20fbd94f8..76da37beb 100644
--- a/tex/context/base/lpdf-fld.lua
+++ b/tex/context/base/lpdf-fld.lua
@@ -25,17 +25,17 @@ local registrations = backends.pdf.registrations
local registeredsymbol = codeinjections.registeredsymbol
-local pdfstream = lpdf.stream
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfreference = lpdf.reference
-local pdfunicode = lpdf.unicode
-local pdfstring = lpdf.string
-local pdfconstant = lpdf.constant
-local pdftoeight = lpdf.toeight
-
-local pdfimmediateobj = pdf.immediateobj
-local pdfreserveobj = pdf.reserveobj
+local pdfstream = lpdf.stream
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfstring = lpdf.string
+local pdfconstant = lpdf.constant
+local pdftoeight = lpdf.toeight
+local pdfflushobject = lpdf.flushobject
+local pdfreserveobject = lpdf.reserveobject
+local pdfannotation = nodes.pdfannotation
local submitoutputformat = 0 -- 0=unknown 1=HTML 2=FDF 3=XML => not yet used, needs to be checked
@@ -183,7 +183,7 @@ local function registerfonts()
Name = pdfconstant(tag),
BaseFont = pdfconstant(fontnames[tag]),
}
- d[tag] = pdfreference(pdfimmediateobj(tostring(f)))
+ d[tag] = pdfreference(pdfflushobject(f))
end
return d
end
@@ -538,25 +538,25 @@ local function finishfields()
for name, field in next, fields do
local kids = field.kids
if kids then
- pdfimmediateobj(field.kobj,tostring(kids))
+ pdfflushobject(field.kobj,kids)
end
local pobj = field.pobj
end
for name, field in next, radios do
local kids = field.kids
if kids then
- pdfimmediateobj(field.kobj,tostring(kids))
+ pdfflushobject(field.kobj,kids)
end
end
if #collected > 0 then
local acroform = pdfdictionary {
NeedAppearances = true,
- Fields = pdfreference(pdfimmediateobj(tostring(collected))),
+ Fields = pdfreference(pdfflushobject(collected)),
DR = pdfdictionary { Font = registerfonts() },
CO = fieldsetlist(calculationset),
DA = "/tttf 12 Tf 0 g",
}
- lpdf.addtocatalog("AcroForm",pdfreference(pdfimmediateobj(tostring(acroform))))
+ lpdf.addtocatalog("AcroForm",pdfreference(pdfflushobject(acroform)))
end
end
@@ -596,19 +596,19 @@ end
-- can be optional multipass optimization (share objects)
local function save_parent(field,specification,d)
- local kn = pdfreserveobj()
+ local kn = pdfreserveobject()
d.Kids = pdfreference(kn)
field.kobj = kn
field.kids = pdfarray()
- local pn = pdfimmediateobj(tostring(d))
+ local pn = pdfflushobject(d)
field.pobj = pn
collected[#collected+1] = pdfreference(pn)
end
local function save_kid(field,specification,d)
- local kn = pdfreserveobj()
+ local kn = pdfreserveobject()
field.kids[#field.kids+1] = pdfreference(kn)
- node.write(nodes.pdfannot(specification.width,specification.height,0,d(),kn))
+ node.write(pdfannotation(specification.width,specification.height,0,d(),kn))
end
function methods.line(name,specification,variant,extras)
diff --git a/tex/context/base/lpdf-grp.lua b/tex/context/base/lpdf-grp.lua
index 3baff3448..ad01e4d4f 100644
--- a/tex/context/base/lpdf-grp.lua
+++ b/tex/context/base/lpdf-grp.lua
@@ -12,13 +12,11 @@ local nodeinjections = backends.pdf.nodeinjections
local codeinjections = backends.pdf.codeinjections
local registrations = backends.pdf.registrations
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfconstant = lpdf.constant
-local pdfreference = lpdf.reference
-
-local pdfreserveobj = pdf.reserveobj
-local pdfimmediateobj = pdf.immediateobj
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+local pdfflushobject = lpdf.flushobject
local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates)
local f = pdfdictionary {
@@ -31,11 +29,11 @@ local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates)
local s = pdfdictionary {
ShadingType = stype,
ColorSpace = pdfconstant(colorspace),
- Function = pdfreference(pdfimmediateobj(tostring(f))),
+ Function = pdfreference(pdfflushobject(f)),
Coords = pdfarray(coordinates),
Extend = pdfarray { true, true },
}
- lpdf.adddocumentshade(name,pdfreference(pdfimmediateobj(tostring(s))))
+ lpdf.adddocumentshade(name,pdfreference(pdfflushobject(s)))
end
function lpdf.circularshade(name,domain,color_a,color_b,n,colorspace,coordinates)
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index 5b37aca05..3d5a9ba3c 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -11,12 +11,17 @@ if not modules then modules = { } end modules ['lpdf-ini'] = {
local setmetatable, getmetatable, type, next, tostring, tonumber, rawset = setmetatable, getmetatable, type, next, tostring, tonumber, rawset
local char, byte, format, gsub, concat, match, sub = string.char, string.byte, string.format, string.gsub, table.concat, string.match, string.sub
local utfvalues = string.utfvalues
-local texwrite = tex.write
+local texwrite, texset, texsprint, ctxcatcodes = tex.write, tex.set, tex.sprint, tex.ctxcatcodes
local sind, cosd = math.sind, math.cosd
local lpegmatch = lpeg.match
+local pdfreserveobj = pdf and pdf.reserveobj or function() return 1 end -- for testing
+local pdfimmediateobj = pdf and pdf.immediateobj or function() return 2 end -- for testing
+
local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end)
local trace_resources = false trackers.register("backend.resources", function(v) trace_resources = v end)
+local trace_objects = false trackers.register("backend.objects", function(v) trace_objects = v end)
+local trace_detail = false trackers.register("backend.detail", function(v) trace_detail = v end)
lpdf = lpdf or { }
@@ -191,9 +196,8 @@ local function value_c(t) return sub(t[1],2) end -- the call is e
local function value_d(t) return tostring_d(t,true,key) end -- the call is experimental
local function value_a(t) return tostring_a(t,true,key) end -- the call is experimental
local function value_z() return nil end -- the call is experimental
-local function value_t() return true end -- the call is experimental
-local function value_f() return false end -- the call is experimental
-local function value_b() return false end -- the call is experimental
+local function value_t(t) return t.value or true end -- the call is experimental
+local function value_f(t) return t.value or false end -- the call is experimental
local function value_r() return t[1] end -- the call is experimental
local function value_v() return t[1] end -- the call is experimental
@@ -212,7 +216,7 @@ local mt_f = { __lpdftype = "false", __tostring = tostring_f, __call = valu
local mt_r = { __lpdftype = "reference", __tostring = tostring_r, __call = value_r }
local mt_v = { __lpdftype = "verbose", __tostring = tostring_v, __call = value_v }
-function lpdf.stream(t)
+local function pdfstream(t) -- we need to add attrbutes
if t then
for i=1,#t do
t[i] = tostring(t[i])
@@ -221,11 +225,11 @@ function lpdf.stream(t)
return setmetatable(t or { },mt_x)
end
-function lpdf.dictionary(t)
+local function pdfdictionary(t)
return setmetatable(t or { },mt_d)
end
-function lpdf.array(t)
+local function pdfarray(t)
if type(t) == "string" then
return setmetatable({ t },mt_a)
else
@@ -233,17 +237,17 @@ function lpdf.array(t)
end
end
-function lpdf.string(str,default)
+local function pdfstring(str,default)
return setmetatable({ str or default or "" },mt_s)
end
-function lpdf.unicode(str,default)
+local function pdfunicode(str,default)
return setmetatable({ str or default or "" },mt_u)
end
local cache = { } -- can be weak
-function lpdf.number(n,default) -- 0-10
+local function pdfnumber(n,default) -- 0-10
n = n or default
local c = cache[n]
if not c then
@@ -253,11 +257,11 @@ function lpdf.number(n,default) -- 0-10
return c
end
-for i=-1,9 do cache[i] = lpdf.number(i) end
+for i=-1,9 do cache[i] = pdfnumber(i) end
local cache = { } -- can be weak
-function lpdf.constant(str,default)
+local function pdfconstant(str,default)
str = str or default or ""
local c = cache[str]
if not c then
@@ -271,11 +275,11 @@ local p_null = { } setmetatable(p_null, mt_z)
local p_true = { } setmetatable(p_true, mt_t)
local p_false = { } setmetatable(p_false,mt_f)
-function lpdf.null()
+local function pdfnull()
return p_null
end
-function lpdf.boolean(b,default)
+local function pdfboolean(b,default)
if ((type(b) == "boolean") and b) or default then
return p_true
else
@@ -283,14 +287,89 @@ function lpdf.boolean(b,default)
end
end
-function lpdf.reference(r)
+local function pdfreference(r)
return setmetatable({ r or 0 },mt_r)
end
-function lpdf.verbose(t) -- maybe check for type
+local function pdfverbose(t) -- maybe check for type
return setmetatable({ t or "" },mt_v)
end
+lpdf.stream = pdfstream
+lpdf.dictionary = pdfdictionary
+lpdf.array = pdfarray
+lpdf.string = pdfstring
+lpdf.unicode = pdfunicode
+lpdf.number = pdfnumber
+lpdf.constant = pdfconstant
+lpdf.null = pdfnull
+lpdf.boolean = pdfboolean
+lpdf.reference = pdfreference
+lpdf.verbose = pdfverbose
+
+-- n = pdf.obj(n, str)
+-- n = pdf.obj(n, "file", filename)
+-- n = pdf.obj(n, "stream", streamtext, attrtext)
+-- n = pdf.obj(n, "streamfile", filename, attrtext)
+
+-- we only use immediate objects
+
+-- todo: tracing
+
+local names, cache = { }, { }
+
+function lpdf.reserveobject(name)
+ local r = pdfreserveobj()
+ if name then
+ names[name] = r
+ if trace_objects then
+ logs.report("backends", "reserving object number %s under name '%s'",r,name)
+ end
+ elseif trace_objects then
+ logs.report("backends", "reserving object number %s",r)
+ end
+ return r
+end
+
+function lpdf.flushobject(name,data)
+ if data then
+ name = names[name] or name
+ if name then
+ if trace_objects then
+ if trace_detail then
+ logs.report("backends", "flushing object data to reserved object with name '%s' -> %s",name,tostring(data))
+ else
+ logs.report("backends", "flushing object data to reserved object with name '%s'",name)
+ end
+ end
+ return pdfimmediateobj(name,tostring(data))
+ else
+ if trace_objects then
+ if trace_detail then
+ logs.report("backends", "flushing object data to reserved object with number %s -> %s",name,tostring(data))
+ else
+ logs.report("backends", "flushing object data to reserved object with number %s",name)
+ end
+ end
+ return pdfimmediateobj(tostring(data))
+ end
+ else
+ if trace_objects and trace_detail then
+ logs.report("backends", "flushing object data -> %s",tostring(name))
+ end
+ return pdfimmediateobj(tostring(name))
+ end
+end
+
+function lpdf.sharedobj(content)
+ local r = cache[content]
+ if not r then
+ r = pdfreference(pdfimmediateobj(content))
+ cache[content] = r
+ end
+ return r
+end
+
--~ local d = lpdf.dictionary()
--~ local e = lpdf.dictionary { ["e"] = "abc", x = lpdf.dictionary { ["f"] = "ABC" } }
--~ local f = lpdf.dictionary { ["f"] = "ABC" }
@@ -338,94 +417,10 @@ end
--~ print(s()) -- fails somehow
--~ local s = lpdf.boolean(false)
+--~ s.value = true
--~ print(s)
--~ print(s())
-function lpdf.checkedkey(t,key,kind)
- local pn = t[key]
- if pn then
- local tn = type(pn)
- if tn == kind then
- if kind == "string" then
- return pn ~= "" and pn
- elseif kind == "table" then
- return next(pn) and pn
- else
- return pn
- end
- elseif tn == "string" and kind == "number" then
- return tonumber(pn)
- end
- end
-end
-
-function lpdf.checkedvalue(value,kind) -- code not shared
- if value then
- local tv = type(value)
- if tv == kind then
- if kind == "string" then
- return value ~= "" and value
- elseif kind == "table" then
- return next(value) and value
- else
- return value
- end
- elseif tv == "string" and kind == "number" then
- return tonumber(value)
- end
- end
-end
-
-function lpdf.limited(n,min,max,default)
- if not n then
- return default
- else
- n = tonumber(n)
- if not n then
- return default
- elseif n > max then
- return max
- elseif n < min then
- return min
- else
- return n
- end
- end
-end
-
--- there will be more of this
-
-local pdfreference = lpdf.reference
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfverbose = lpdf.verbose
-local pdfreserveobj = pdf.reserveobj
-local pdfimmediateobj = pdf.immediateobj
-
-local texset, texsprint, ctxcatcodes = tex.set, tex.sprint, tex.ctxcatcodes
-
-local pdfobjcache = { }
-
-function lpdf.sharedobj(content)
- local r = pdfobjcache[content]
- if not r then
- r = pdfreference(pdfimmediateobj(content))
- pdfobjcache[content] = r
- end
- return r
-end
-
--- saves definitions later on
-
-backends = backends or { }
-backends.pdf = backends.pdf or {
- comment = "backend for directly generating pdf output",
- nodeinjections = { },
- codeinjections = { },
- registrations = { },
- helpers = { },
-}
-
-- three priority levels, default=2
local pagefinalizers, documentfinalizers = { { }, { }, { } }, { { }, { }, { } }
@@ -510,7 +505,7 @@ local function flushcatalog() if not environment.initex then trace_flush("catalo
local function flushinfo () if not environment.initex then trace_flush("info") pdf.pdfinfo = info () end end
local function flushnames () if not environment.initex then trace_flush("names") pdf.pdfnames = names () end end
-if not pdf.pdfcatalog then
+if pdf and not pdf.pdfcatalog then
local c_template, i_template, n_template = "\\normalpdfcatalog{%s}", "\\normalpdfinfo{%s}", "\\normalpdfnames{%s}"
@@ -595,7 +590,70 @@ function lpdf.id()
return format("%s.%s",tex.jobname,timestamp)
end
+function lpdf.checkedkey(t,key,kind)
+ local pn = t[key]
+ if pn then
+ local tn = type(pn)
+ if tn == kind then
+ if kind == "string" then
+ return pn ~= "" and pn
+ elseif kind == "table" then
+ return next(pn) and pn
+ else
+ return pn
+ end
+ elseif tn == "string" and kind == "number" then
+ return tonumber(pn)
+ end
+ end
+end
+
+function lpdf.checkedvalue(value,kind) -- code not shared
+ if value then
+ local tv = type(value)
+ if tv == kind then
+ if kind == "string" then
+ return value ~= "" and value
+ elseif kind == "table" then
+ return next(value) and value
+ else
+ return value
+ end
+ elseif tv == "string" and kind == "number" then
+ return tonumber(value)
+ end
+ end
+end
+
+function lpdf.limited(n,min,max,default)
+ if not n then
+ return default
+ else
+ n = tonumber(n)
+ if not n then
+ return default
+ elseif n > max then
+ return max
+ elseif n < min then
+ return min
+ else
+ return n
+ end
+ end
+end
+
-- lpdf.addtoinfo("ConTeXt.Version", tex.contextversiontoks)
-- lpdf.addtoinfo("ConTeXt.Time", os.date("%Y.%m.%d %H:%M")) -- :%S
-- lpdf.addtoinfo("ConTeXt.Jobname", tex.jobname)
-- lpdf.addtoinfo("ConTeXt.Url", "www.pragma-ade.com")
+
+-- saves definitions later on
+
+backends = backends or { }
+backends.pdf = backends.pdf or {
+ comment = "backend for directly generating pdf output",
+ nodeinjections = { },
+ codeinjections = { },
+ registrations = { },
+ helpers = { },
+}
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index 429011cc8..a68c7b487 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -28,16 +28,16 @@ local copy_node = node.copy
local pdfliteral, register = nodes.pdfliteral, nodes.register
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfboolean = lpdf.boolean
-local pdfconstant = lpdf.constant
-local pdfreference = lpdf.reference
-local pdfunicode = lpdf.unicode
-local pdfverbose = lpdf.verbose
-local pdfstring = lpdf.string
-
-local pdfreserveobj = pdf.reserveobj
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfboolean = lpdf.boolean
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfverbose = lpdf.verbose
+local pdfstring = lpdf.string
+local pdfflushobject = lpdf.flushobject
+
local pdfimmediateobj = pdf.immediateobj
local tobasepoints = number.tobasepoints
@@ -60,8 +60,8 @@ local function initializenegative()
}
local negative = pdfdictionary { Type = g, TR = pdfreference(pdf.immediateobj("stream","1 exch sub",d())) }
local positive = pdfdictionary { Type = g, TR = pdfconstant("Identity") }
- lpdf.adddocumentextgstate("GSnegative", pdfreference(pdfimmediateobj(tostring(negative))))
- lpdf.adddocumentextgstate("GSPositive", pdfreference(pdfimmediateobj(tostring(positive))))
+ lpdf.adddocumentextgstate("GSnegative", pdfreference(pdfflushobject(negative)))
+ lpdf.adddocumentextgstate("GSPositive", pdfreference(pdfflushobject(positive)))
initializenegative = nil
end
@@ -69,8 +69,8 @@ local function initializeoverprint()
local g = pdfconstant("ExtGState")
local knockout = pdfdictionary { Type = g, OP = false, OPM = 0 }
local overprint = pdfdictionary { Type = g, OP = true, OPM = 1 }
- lpdf.adddocumentextgstate("GSknockout", pdfreference(pdfimmediateobj(tostring(knockout ))))
- lpdf.adddocumentextgstate("GSoverprint", pdfreference(pdfimmediateobj(tostring(overprint))))
+ lpdf.adddocumentextgstate("GSknockout", pdfreference(pdfflushobject(knockout)))
+ lpdf.adddocumentextgstate("GSoverprint", pdfreference(pdfflushobject(overprint)))
initializeoverprint = nil
end
@@ -192,9 +192,9 @@ local function flushjavascripts()
JS = pdfreference(pdfimmediateobj("stream",script)),
}
a[#a+1] = pdfstring(name)
- a[#a+1] = pdfreference(pdfimmediateobj(tostring(j)))
+ a[#a+1] = pdfreference(pdfflushobject(j))
end
- lpdf.addtonames("JavaScript",pdfreference(pdfimmediateobj(tostring(pdfdictionary{ Names = a }))))
+ lpdf.addtonames("JavaScript",pdfreference(pdfflushobject(pdfdictionary{ Names = a })))
end
end
diff --git a/tex/context/base/lpdf-nod.lua b/tex/context/base/lpdf-nod.lua
index eeb22c57c..0ae900123 100644
--- a/tex/context/base/lpdf-nod.lua
+++ b/tex/context/base/lpdf-nod.lua
@@ -31,7 +31,7 @@ function nodes.pdfliteral(str)
return t
end
-function nodes.pdfannot(w,h,d,data,n)
+function nodes.pdfannotation(w,h,d,data,n)
local t = copy_node(pdfannot)
if w and w ~= 0 then t.width = w end
if h and h ~= 0 then t.height = h end
@@ -41,7 +41,7 @@ function nodes.pdfannot(w,h,d,data,n)
return t
end
-function nodes.pdfdest(w,h,d,name,view,n)
+function nodes.pdfdestination(w,h,d,name,view,n)
local t = copy_node(pdfdest)
if w and w ~= 0 then t.width = w end
if h and h ~= 0 then t.height = h end
diff --git a/tex/context/base/lpdf-ren.lua b/tex/context/base/lpdf-ren.lua
index 3b1840e5e..e6bbd67fe 100644
--- a/tex/context/base/lpdf-ren.lua
+++ b/tex/context/base/lpdf-ren.lua
@@ -29,13 +29,11 @@ local executers = jobreferences.executers
local variables = interfaces.variables
-local pdfconstant = lpdf.constant
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfreference = lpdf.reference
-
-local pdfreserveobj = pdf.reserveobj
-local pdfimmediateobj = pdf.immediateobj
+local pdfconstant = lpdf.constant
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfflushobject = lpdf.flushobject
local pdf_ocg = pdfconstant("OCG")
local pdf_ocmd = pdfconstant("OCMD")
@@ -66,13 +64,13 @@ function codeinjections.defineviewerlayer(specification)
Intent = ((specification.kind > 0) and pdf_design) or nil, -- disable layer hiding by user
Usage = ((specification.printable == variables.no) and lpdf_usage) or nil , -- printable or not
}
- local nr = pdfreference(pdfimmediateobj(tostring(n)))
+ local nr = pdfreference(pdfflushobject(n))
pdfln[tag] = nr -- was n
local d = pdfdictionary {
Type = pdf_ocmd,
OCGs = pdfarray { nr },
}
- local dr = pdfreference(pdfimmediateobj(tostring(d)))
+ local dr = pdfreference(pdfflushobject(d))
pdfld[tag] = dr
textlayers[#textlayers+1] = nr
if specification.visible == variables.start then
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index eea2b3548..44d0c5154 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -16,17 +16,21 @@ local registrations = backends.pdf.registrations
local executers = jobreferences.executers
local variables = interfaces.variables
-local pdfconstant = lpdf.constant
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfreference = lpdf.reference
-local pdfunicode = lpdf.unicode
-local pdfstring = lpdf.string
-local pdfcolorspec = lpdf.colorspec
+local pdfconstant = lpdf.constant
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfstring = lpdf.string
+local pdfcolorspec = lpdf.colorspec
+local pdfflushobject = lpdf.flushobject
+local pdfreserveobject = lpdf.reserveobject
local pdfreserveobj = pdf.reserveobj
local pdfimmediateobj = pdf.immediateobj
+local pdfannotation = nodes.pdfannotation
+
-- symbols
local presets = { } -- xforms
@@ -122,17 +126,17 @@ function codeinjections.registercomment(specification)
}
-- watch the nice feed back to tex hack
if usepopupcomments then
- local nd = pdfreserveobj()
- local nc = pdfreserveobj()
+ local nd = pdfreserveobject()
+ local nc = pdfreserveobject()
local c = pdfdictionary {
Subtype = pdfconstant("Popup"),
Parent = pdfreference(nd),
}
d.Popup = pdfreference(nc)
- texbox["commentboxone"] = node.hpack(nodes.pdfannot(0,0,0,d(),nd))
- texbox["commentboxtwo"] = node.hpack(nodes.pdfannot(specification.width,specification.height,0,c(),nc))
+ texbox["commentboxone"] = node.hpack(pdfannotation(0,0,0,d(),nd))
+ texbox["commentboxtwo"] = node.hpack(pdfannotation(specification.width,specification.height,0,c(),nc))
else
- texbox["commentboxone"] = node.hpack(nodes.pdfannot(0,0,0,d()))
+ texbox["commentboxone"] = node.hpack(pdfannotation(0,0,0,d()))
texbox["commentboxtwo"] = nil
end
end
@@ -161,7 +165,7 @@ function codeinjections.embedfile(filename)
UF = pdfstring(newname or basename),
EF = pdfdictionary { F = pdfreference(f) },
}
- local r = pdfreference(pdfimmediateobj(tostring(d)))
+ local r = pdfreference(pdfflushobject(d))
filestreams[filename] = r
return r
end
@@ -205,7 +209,7 @@ function codeinjections.attachfile(specification)
local width = specification.width or 0
local height = specification.height or 0
local depth = specification.depth or 0
- node.write(nodes.pdfannot(width,height,depth,d()))
+ node.write(pdfannotation(width,height,depth,d()))
end
function codeinjections.attachmentid(filename)
@@ -262,7 +266,7 @@ local function insertrenderingwindow(label,width,height,specification)
AA = actions,
}
local r = pdfreserveobj("annot")
- node.write(nodes.pdfannot(width,height,0,d(),r)) -- save ref
+ node.write(pdfannotation(width,height,0,d(),r)) -- save ref
return pdfreference(r)
end
@@ -289,7 +293,7 @@ local function insertrendering(specification)
}
}
}
- mf[label] = pdfreference(pdfimmediateobj(tostring(d)))
+ mf[label] = pdfreference(pdfflushobject(d))
if not ms[label] then
mu[label] = insertrenderingwindow(label,0,0,specification.options)
end
@@ -309,7 +313,7 @@ local function insertrenderingobject(specification)
D = pdfreference(unknown), -- not label but objectname, hm
}
}
- mf[label] = pdfreference(pdfimmediateobj(tostring(d)))
+ mf[label] = pdfreference(pdfflushobject(d))
if ms[label] then
insertrenderingwindow(label,0,0,specification)
end
diff --git a/tex/context/base/lpdf-xmp.lua b/tex/context/base/lpdf-xmp.lua
index 9a936e64d..c8e7b2b57 100644
--- a/tex/context/base/lpdf-xmp.lua
+++ b/tex/context/base/lpdf-xmp.lua
@@ -12,49 +12,8 @@ local xmlfillin = xml.fillin
local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end)
-local xmpmetadata = [[
-<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04">
- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
- <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <dc:format>application/pdf</dc:format>
- <dc:creator>
- <rdf:Seq>
- <rdf:li/>
- </rdf:Seq>
- </dc:creator>
- <dc:description/>
- <dc:title>
- <rdf:Alt>
- <rdf:li xml:lang="x-default"/>
- </rdf:Alt>
- </dc:title>
- </rdf:Description>
- <rdf:Description rdf:about="" xmlns:pdfx="http://ns.adobe.com/pdfx/1.3/">
- <pdfx:ConTeXt.Jobname/>
- <pdfx:ConTeXt.Time/>
- <pdfx:ConTeXt.Url/>
- <pdfx:ConTeXt.Version/>
- <pdfx:ID/>
- <pdfx:PTEX.Fullbanner/>
- </rdf:Description>
- <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
- <xmp:CreateDate/>
- <xmp:CreatorTool/>
- <xmp:ModifyDate/>
- <xmp:MetadataDate/>
- </rdf:Description>
- <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
- <pdf:Keywords/>
- <pdf:Producer/>
- <pdf:Trapped>False</pdf:Trapped>
- </rdf:Description>
- <rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
- <xmpMM:DocumentID/>
- <xmpMM:InstanceID/>
- </rdf:Description>
- </rdf:RDF>
-</x:xmpmeta>
-]]
+local pdfdictionary = lpdf.dictionary
+local pdfconstant = lpdf.constant
-- i wonder why this begin end is empty / w (no time now to look into it)
@@ -110,12 +69,28 @@ local mapping = {
-- maybe some day we will load the xmp file at runtime
-local xmp = xml.convert(xmpmetadata)
+local xmp, xmpfile, xmpname = nil, nil, "lpdf-xmp.xml"
+
+function lpdf.setxmpfile(name)
+ xmpfile = resolvers.findctxfile(name) or ""
+ if xmpfile == "" then
+ xmpfile = nil
+ end
+end
+
+local function valid_xmp()
+ if not xmp then
+ local xmpfile = xmpfile or resolvers.find_file(xmpname) or ""
+ local xmpdata = (xmpfile ~= "" and io.loaddata(xmpfile)) or ""
+ xmp = xml.convert(xmpdata)
+ end
+ return xmp
+end
function lpdf.addxmpinfo(tag,value,check)
local pattern = mapping[tag]
if pattern then
- xmlfillin(xmp,pattern,value,check)
+ xmlfillin(xmp or valid_xmp(),pattern,value,check)
end
end
@@ -132,11 +107,11 @@ end
-- for the do-it-yourselvers
function lpdf.insertxmpinfo(pattern,whatever,prepend)
- xml.insert(xmp,pattern,whatever,prepend)
+ xml.insert(xmp or valid_xmp(),pattern,whatever,prepend)
end
function lpdf.injectxmpinfo(pattern,whatever,prepend)
- xml.inject(xmp,pattern,whatever,prepend)
+ xml.inject(xmp or valid_xmp(),pattern,whatever,prepend)
end
-- flushing
@@ -158,10 +133,10 @@ local function flushxmpinfo()
addxmpinfo("ModifyDate",time)
addxmpinfo("MetadataDate",time)
addxmpinfo("PTEX.Fullbanner", tex.pdftexbanner)
- local blob = xml.tostring(xmp)
- local md = lpdf.dictionary {
- Subtype = lpdf.constant("XML"),
- Type = lpdf.constant("Metadata"),
+ local blob = xml.tostring(xml.first(xmp or valid_xmp(),"/x:xmpmeta"))
+ local md = pdfdictionary {
+ Subtype = pdfconstant("XML"),
+ Type = pdfconstant("Metadata"),
}
if trace_xmp then
commands.writestatus("system","xmp data flushed (see log file)")
diff --git a/tex/context/base/lpdf-xmp.xml b/tex/context/base/lpdf-xmp.xml
new file mode 100644
index 000000000..2947211bd
--- /dev/null
+++ b/tex/context/base/lpdf-xmp.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:format>application/pdf</dc:format>
+ <dc:creator>
+ <rdf:Seq>
+ <rdf:li/>
+ </rdf:Seq>
+ </dc:creator>
+ <dc:description/>
+ <dc:title>
+ <rdf:Alt>
+ <rdf:li xml:lang="x-default"/>
+ </rdf:Alt>
+ </dc:title>
+ </rdf:Description>
+ <rdf:Description rdf:about="" xmlns:pdfx="http://ns.adobe.com/pdfx/1.3/">
+ <pdfx:ConTeXt.Jobname/>
+ <pdfx:ConTeXt.Time/>
+ <pdfx:ConTeXt.Url/>
+ <pdfx:ConTeXt.Version/>
+ <pdfx:ID/>
+ <pdfx:PTEX.Fullbanner/>
+ </rdf:Description>
+ <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
+ <xmp:CreateDate/>
+ <xmp:CreatorTool/>
+ <xmp:ModifyDate/>
+ <xmp:MetadataDate/>
+ </rdf:Description>
+ <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
+ <pdf:Keywords/>
+ <pdf:Producer/>
+ <pdf:Trapped>False</pdf:Trapped>
+ </rdf:Description>
+ <rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
+ <xmpMM:DocumentID/>
+ <xmpMM:InstanceID/>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
diff --git a/tex/context/base/meta-dum.tex b/tex/context/base/meta-dum.tex
index 1d03fb16d..bc19f3c5f 100644
--- a/tex/context/base/meta-dum.tex
+++ b/tex/context/base/meta-dum.tex
@@ -70,6 +70,8 @@
[\c!reduction=0,
\c!text=\v!yes]
+\let\normalexternalfigurereplacement\externalfigurereplacement
+
\def\externalfigurereplacement#1#2#3%
{\getpaletsize[placeholder]%
\ifx\figurereplacementcycle\relax
diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv
index 83880994b..fd9a3c29e 100644
--- a/tex/context/base/mlib-pps.mkiv
+++ b/tex/context/base/mlib-pps.mkiv
@@ -15,6 +15,15 @@
\registerctxluafile{mlib-pps}{1.001}
+%D Todo: catch nested graphics like external figures with dummies.
+
+% \newtoks\everyMPLIBtext % not yet used
+
+% \appendtoks
+% \let\handleuseMPgraphic \thirdofthreearguments
+% \let\handlereusableMPgraphic\thirdofthreearguments
+% \to \everyMPLIBtext
+
% this will move !
\def\MPLIBfigure#1#2#3#4#5#6#7% todo: move Q q to lua
@@ -24,8 +33,9 @@
\vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[sx=\sx,sy=\sy]{\box\scratchbox}\hss}}%
\pdfliteral direct{Q}}
-\def\MPLIBsettext#1% #2%
- {\global\setbox#1\hbox}% {#2}}
+\def\MPLIBsettext#1% #2% we could as well store in hlists at the lua end i.e. just one box
+ {\global\setbox#1\hbox}
+% {\global\setbox#1\hbox\bgroup\the\everyMPLIBtext\let\next}
\def\MPLIBfreetext#1%
{\global\setbox#1\emptybox}
diff --git a/tex/context/base/s-fnt-10.tex b/tex/context/base/s-fnt-10.tex
index 95e9282b8..216d9d232 100644
--- a/tex/context/base/s-fnt-10.tex
+++ b/tex/context/base/s-fnt-10.tex
@@ -45,6 +45,7 @@ function fonts.show_all()
sprint(tex.ctxcatcodes,format("\\stoptabulatehead"))
sprint(tex.ctxcatcodes,format("\\starttabulate[|l|c|l|p|p|p|]"))
for k, unicode in ipairs(table.sortedkeys(chars)) do
+-- for unicode, _ in table.sortedpairs(chars) do
if unicode >= 0 then
local chr, des, dat = chars[unicode], descs[unicode], data[unicode]
local index = chr.index or 0
diff --git a/tex/context/base/scrn-nav.mkiv b/tex/context/base/scrn-nav.mkiv
index cdc862ec0..670b52107 100644
--- a/tex/context/base/scrn-nav.mkiv
+++ b/tex/context/base/scrn-nav.mkiv
@@ -241,4 +241,16 @@
\c!keyword=,
\c!date=\@@iatimestamp]
+%D XMP support:
+
+\setupinteraction
+ [xmpfile=]
+
+\appendtoks
+ % this will move as it is a backend issue
+ \doifsomething\@@iaxmpfile
+ {\ctxlua{if lpdf then lpdf.setxmpfile("\@@iaxmpfile") end}%
+ \globallet\@@iaxmpfile\empty}%
+\to \everysetupinteraction
+
\protect \endinput
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua
index 3bfc84a19..e5d81066c 100644
--- a/tex/context/base/spac-ver.lua
+++ b/tex/context/base/spac-ver.lua
@@ -77,7 +77,7 @@ vspacing.data.snapmethods = vspacing.data.snapmethods or { }
storage.register("vspacing/data/snapmethods", vspacing.data.snapmethods, "vspacing.data.snapmethods")
-local snapmethods = vspacing.data.snapmethods
+local snapmethods = vspacing.data.snapmethods --maybe some older code can go
local default = {
maxheight = true,
@@ -93,28 +93,40 @@ local fractions = {
top = "tlines", bottom = "blines",
}
+local values = {
+ offset = "offset"
+}
+
local colonsplitter = lpeg.splitat(":")
-function interfaces.listtohash(str)
+local function listtohash(str) -- redundant?
local t = { }
for s in gmatch(str,"[^, ]+") do
- local key, fraction = lpegmatch(colonsplitter,s)
+ local key, detail = lpegmatch(colonsplitter,s)
local v = variables[key]
if v then
t[v] = true
- if fraction then
+ if detail then
local k = fractions[key]
if k then
- fraction = tonumber("0" .. fraction)
- if fraction then
+ detail = tonumber("0" .. detail)
+ if detail then
t[k] = fraction
end
+ else
+ k = values[key]
+ if k then
+ detail = string.todimen(detail)
+ if detail then
+ t[k] = detail
+ end
+ end
end
end
else
- fraction = tonumber("0" .. key)
- if fraction then
- t.hfraction, t.dfraction = fraction, fraction
+ detail = tonumber("0" .. key)
+ if detail then
+ t.hfraction, t.dfraction = detail, detail
end
end
end
@@ -129,7 +141,7 @@ end
function vspacing.define_snap_method(name,method)
local n = #snapmethods + 1
- local t = interfaces.listtohash(method)
+ local t = listtohash(method)
snapmethods[n] = t
t.name, t.specification = name, method
tex.write(n)
@@ -212,6 +224,12 @@ local function snap_hlist(current,method,height,depth) -- method.strut is defaul
if method.bottom then
cd = cd + (method.blines or 1) * snaphtdp
end
+ local offset = method.offset
+ if offset then
+ local shifted = vpack_node(current.list)
+ shifted.shift = offset
+ current.list = shifted
+ end
if not height then
current.height = ch
end
@@ -521,7 +539,8 @@ local discard, largest, force, penalty, add, disable, nowhite, goback, together
function vspacing.snap_box(n,how)
local sv = snapmethods[how]
if sv then
- local list = texbox[n].list
+ local box = texbox[n]
+ local list = box.list
--~ if list and (list.id == hlist or list.id == vlist) then
if list then
local s = has_attribute(list,snap_method)
@@ -530,7 +549,7 @@ function vspacing.snap_box(n,how)
logs.report("snapper", "hlist not snapped, already done")
end
else
- local h, d, ch, cd, lines = snap_hlist(list,sv,texht[n],texdp[n])
+ local h, d, ch, cd, lines = snap_hlist(box,sv,texht[n],texdp[n])
texht[n], texdp[n] = ch, cd
if trace_vsnapping then
logs.report("snapper", "hlist snapped from (%s,%s) to (%s,%s) using method '%s' (%s) for '%s' (%s lines)",h,d,ch,cd,sv.name,sv.specification,"direct",lines)
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index afd81717e..7768f80b5 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -1269,6 +1269,8 @@
% maxdepth round depth up
% minheight round height down
% maxheight round height up
+%
+% shift:-3tp vertical shift within box
%D We're not downward compatible with \MKII !
diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua
index 45fba4ae2..1baa9acbe 100644
--- a/tex/context/base/supp-fil.lua
+++ b/tex/context/base/supp-fil.lua
@@ -196,7 +196,8 @@ local function usemodule(name,hassheme)
end
function support.usemodules(prefix,askedname,truename)
- local hashname = prefix .. "-" .. truename
+ local hasprefix = prefix and prefix ~= ""
+ local hashname = ((hasprefix and prefix) or "*") .. "-" .. truename
local status = modstatus[hashname]
if status == 0 then
-- not found
@@ -214,7 +215,7 @@ function support.usemodules(prefix,askedname,truename)
else
status = 0
end
- elseif prefix and prefix ~= "" then
+ elseif hasprefix then
if usemodule(prefix .. "-" .. truename) then
status = 1
else
@@ -223,12 +224,15 @@ function support.usemodules(prefix,askedname,truename)
else
for i=1,#prefixes do
-- todo: reconstruct name i.e. basename
- if usemodule(prefixes[i] .. "-" .. truename) then
+ local thename = prefixes[i] .. "-" .. truename
+ if usemodule(thename) then
status = 1
break
end
end
- if not status and usemodule(truename) then
+ if status then
+ -- ok, don't change
+ elseif usemodule(truename) then
status = 1
else
status = 0
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index c54df5f47..f6d538296 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 02/17/10 14:29:47
+-- merge date : 02/18/10 14:53:55
do -- begin closure to overcome local limits and interference