summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-08-18 14:36:00 +0200
committerHans Hagen <pragma@wxs.nl>2009-08-18 14:36:00 +0200
commitb4b3a706fa151ca1769854921a4424f52d9f7421 (patch)
treea43c508034a66e3c8a49806cd57baf9411adfaf8 /tex
parent9e7781a95addbf3c500abf5a49cfe2f68fe506c0 (diff)
downloadcontext-b4b3a706fa151ca1769854921a4424f52d9f7421.tar.gz
beta 2009.08.18 14:36
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/attr-ini.lua16
-rw-r--r--tex/context/base/back-pdf.lua12
-rw-r--r--tex/context/base/char-def.lua2
-rw-r--r--tex/context/base/lpdf-col.lua6
-rw-r--r--tex/context/base/lpdf-ini.lua23
-rw-r--r--tex/context/base/lpdf-mis.lua35
-rw-r--r--tex/context/base/mlib-pps.lua6
-rw-r--r--tex/context/base/strc-lst.lua3
-rw-r--r--tex/context/base/strc-ref.lua3
-rw-r--r--tex/context/base/strc-ref.mkiv2
10 files changed, 73 insertions, 35 deletions
diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua
index 61bbb5f79..535488c35 100644
--- a/tex/context/base/attr-ini.lua
+++ b/tex/context/base/attr-ini.lua
@@ -263,7 +263,7 @@ transparencies.attribute = attributes.private('transparency')
storage.register("transparencies/registered", transparencies.registered, "transparencies.registered")
storage.register("transparencies/values", transparencies.values, "transparencies.values")
-local registered = transparencies.registered
+local registered = transparencies.registered -- we could use a 2 dimensional table instead
local data = transparencies.data
local values = transparencies.values
local template = "%s:%s"
@@ -278,14 +278,22 @@ local function register_transparency(...)
return register_transparency(...)
end
-function transparencies.register(name,a,t)
+function transparencies.register(name,a,t,force) -- name is irrelevant here (can even be nil)
+ -- Force needed here for metapost converter. We could always force
+ -- but then we'd end up with transparencies resources even if we
+ -- would not use transparencies (but define them only). This is
+ -- somewhat messy.
local stamp = format(template,a,t)
local n = registered[stamp]
if not n then
n = #values + 1
values[n] = { a, t }
registered[stamp] = n
- register_transparency(n,a,t) -- needed here for metapost converter
+ if force then
+ register_transparency(n,a,t)
+ end
+ elseif force and not data[n] then
+ register_transparency(n,a,t)
end
return registered[stamp]
end
@@ -312,7 +320,7 @@ local function reviver(data,n)
end
setmetatable(transparencies, { __index = extender })
-setmetatable(transparencies.data, { __index = reviver })
+setmetatable(transparencies.data, { __index = reviver }) -- register if used
-- check if there is an identity
diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua
index 0b6a41c71..908801d8a 100644
--- a/tex/context/base/back-pdf.lua
+++ b/tex/context/base/back-pdf.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['back-pdf'] = {
license = "see context related readme files"
}
+-- we will move code to lpdf-* files (second cleanup stage)
+
--[[ldx--
<p>This module implements a couple of cleanup methods. We need these
in order to meet the <l n='pdf'/> specification. Watch the double
@@ -62,16 +64,6 @@ function nodeinjections.transparency(n)
return register(pdfliteral(format("/Tr%s gs",n)))
end
-local positive = register(pdfliteral("/GSpositive gs"))
-local negative = register(pdfliteral("/GSnegative gs"))
-local overprint = register(pdfliteral("/GSoverprint gs"))
-local knockout = register(pdfliteral("/GSknockout gs"))
-
-function nodeinjections.positive () return copy_node(positive) end
-function nodeinjections.negative () return copy_node(negative) end
-function nodeinjections.overprint() return copy_node(overprint) end
-function nodeinjections.knockout () return copy_node(knockout) end
-
local effects = {
normal = 0,
inner = 0,
diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua
index 76bdcabfb..665572ee8 100644
--- a/tex/context/base/char-def.lua
+++ b/tex/context/base/char-def.lua
@@ -50320,7 +50320,7 @@ characters.data={
direction="l",
linebreak="al",
mathclass="variable",
- mathname="hbar",
+ mathname="hslash",
specials={ "font", 0x0127 },
unicodeslot=0x210F,
},
diff --git a/tex/context/base/lpdf-col.lua b/tex/context/base/lpdf-col.lua
index 2973f7e76..0e4f6e495 100644
--- a/tex/context/base/lpdf-col.lua
+++ b/tex/context/base/lpdf-col.lua
@@ -50,13 +50,13 @@ function lpdf.color(model,ca,default) -- todo: use gray when no color
end
end
-function lpdf.transparency(ct,default)
+function lpdf.transparency(ct,default) -- kind of overlaps with transparencycode
-- beware, we need this hack because normally transparencies are not
-- yet registered and therefore the number is not not known ... we
-- might use the attribute number itself in the future
local ct = transparenciesvalue(ct)
if ct then
- return format("/Tr%s gs",registertransparancy(nil,ct[1],ct[2]))
+ return format("/Tr%s gs",registertransparancy(nil,ct[1],ct[2],true))
else
return "/Tr0 gs"
end
@@ -138,7 +138,7 @@ function lpdf.spotcode(model,n,f,d,p)
end
function lpdf.transparencycode(a,t)
intransparency = true
- return format("/Tr%s gs",registertransparancy(nil,a,t))
+ return format("/Tr%s gs",registertransparancy(nil,a,t,true)) -- true forces resource
end
function lpdf.finishtransparencycode()
if intransparency then
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index 49f722c6a..3335c6237 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -14,6 +14,8 @@ local utfvalues = string.utfvalues
local texwrite = tex.write
local sind, cosd = math.sind, math.cosd
+local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end)
+
lpdf = lpdf or { }
local function tosixteen(str)
@@ -416,39 +418,46 @@ function lpdf.addtopageresources (k,v) pageresources [k] = v end
function lpdf.addtopageattributes (k,v) pageattributes [k] = v end
function lpdf.addtopagesattributes(k,v) pagesattributes[k] = v end
-local function set(where,f,when)
- local w = where[when or 2]
+local function set(where,f,when,what)
+ when = when or 2
+ local w = where[when]
w[#w+1] = f
+ if trace_finalizers then
+ logs.report("backend","%s set: [%s,%s]",what,when,#w)
+ end
end
-local function run(where)
+local function run(where,what)
for i=1,#where do
local w = where[i]
for j=1,#w do
+ if trace_finalizers then
+ logs.report("backend","%s finalizer: [%s,%s]",what,i,j)
+ end
w[j]()
end
end
end
function lpdf.registerpagefinalizer(f,when)
- set(pagefinalizers,f,when)
+ set(pagefinalizers,f,when,"page")
end
function lpdf.registerdocumentfinalizer(f,when)
- set(documentfinalizers,f,when)
+ set(documentfinalizers,f,when,"document")
end
function lpdf.finalizepage()
if not environment.initex then
resetpageproperties()
- run(pagefinalizers)
+ run(pagefinalizers,"page")
setpageproperties()
end
end
function lpdf.finalizedocument()
if not environment.initex then
- run(documentfinalizers)
+ run(documentfinalizers,"document")
end
end
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index 1bc1e99c6..142b32574 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -24,6 +24,10 @@ local nodeinjections = backends.pdf.nodeinjections
local codeinjections = backends.pdf.codeinjections
local registrations = backends.pdf.registrations
+local copy_node = node.copy
+
+local pdfliteral, register = nodes.pdfliteral, nodes.register
+
local pdfdictionary = lpdf.dictionary
local pdfarray = lpdf.array
local pdfboolean = lpdf.boolean
@@ -42,7 +46,12 @@ local variables = interfaces.variables
lpdf.addtoinfo ("Trapped", pdfboolean(false))
lpdf.addtocatalog("Version", pdfconstant(format("1.%s",tex.pdfminorversion)))
--- we could do this selectively
+--
+
+local positive = register(pdfliteral("/GSpositive gs"))
+local negative = register(pdfliteral("/GSnegative gs"))
+local overprint = register(pdfliteral("/GSoverprint gs"))
+local knockout = register(pdfliteral("/GSknockout gs"))
local function initializenegative()
local a = pdfarray { 0, 1 }
@@ -56,19 +65,37 @@ local function initializenegative()
local positive = pdfdictionary { Type = g, TR = pdfconstant("Identity") }
lpdf.adddocumentextgstate("GSnegative", pdfreference(pdfimmediateobj(tostring(negative))))
lpdf.adddocumentextgstate("GSPositive", pdfreference(pdfimmediateobj(tostring(positive))))
+ initializenegative = nil
end
-
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))))
+ initializeoverprint = nil
+end
+
+function nodeinjections.overprint()
+ if initializeoverprint then initializeoverprint() end
+ return copy_node(overprint)
+end
+function nodeinjections.knockout ()
+ if initializeoverprint then initializeoverprint() end
+ return copy_node(knockout)
+end
+
+function nodeinjections.positive()
+ if initializenegative then initializenegative() end
+ return copy_node(positive)
+end
+function nodeinjections.negative()
+ if initializenegative then initializenegative() end
+ return copy_node(negative)
end
-lpdf.registerdocumentfinalizer(initializenegative)
-lpdf.registerdocumentfinalizer(initializeoverprint)
+--
function codeinjections.addtransparencygroup()
-- png: /CS /DeviceRGB /I true
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 79c3dd34f..cf4fe69be 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -52,7 +52,7 @@ local innertransparency = nooutertransparency
local pdfcolor, pdftransparency = lpdf.color, lpdf.transparency
local registercolor, registerspotcolor = colors.register, colors.registerspotcolor
-local registertransparencies = transparencies.register
+local registertransparency = transparencies.register
function metapost.set_outer_color(mode,colormodel,colorattribute,transparencyattribute)
-- has always to be called before conversion
@@ -178,11 +178,11 @@ end
function metapost.specials.tr(specification,object,result)
local a, t = match(specification,"^(.+),(.+)$")
local before = a and t and function()
- result[#result+1] = format("/Tr%s gs",registertransparencies('mp',a,t))
+ result[#result+1] = format("/Tr%s gs",registertransparency(nil,a,t,true)) -- maybe nil instead of 'mp'
return object, result
end
local after = before and function()
- result[#result+1] = outertransparency -- here we could revert to teh outer color
+ result[#result+1] = outertransparency -- here we could revert to the outer color
return object, result
end
return object, before, nil, after
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index 47855e3dd..dd45e7f68 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -123,7 +123,8 @@ local nesting = { }
function lists.pushnesting(i)
local r = lists.result[i]
local name = r.metadata.name
- local n = (r and r.numberdata.numbers[sections.getlevel(name)]) or 0
+ local numberdata = r and r.numberdata
+ local n = (numberdata and numberdata.numbers[sections.getlevel(name)]) or 0
insert(nesting, { number = n, name = name, result = lists.result })
end
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index d4896f47f..b1b77f45f 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -361,7 +361,8 @@ local function resolve(prefix,reference,args,set) -- we start with prefix,refere
local r = settings_to_array(reference)
for i=1,#r do
local ri = r[i]
- local d = defined[prefix][ri] or defined[""][ri]
+ local dp = defined[prefix] or defined[""]
+ local d = dp[ri]
if d then
resolve(prefix,d[2],nil,set)
else
diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv
index 10ae4c84f..8bf724b99 100644
--- a/tex/context/base/strc-ref.mkiv
+++ b/tex/context/base/strc-ref.mkiv
@@ -1221,7 +1221,7 @@
{\dosingleempty\dodospecialfrom}
\def\dodospecialfrom[#1]%
- {\dontleavehmode\goto{\ctxlua{jobreferences.from("#1")}}[#1]}
+ {\dontleavehmode\goto{\ctxlua{jobreferences.from("#1")}}[url(#1)]}
%D We also support:
%D