summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lpdf-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lpdf-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lpdf-ini.lua56
1 files changed, 31 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/context/base/lpdf-ini.lua b/Master/texmf-dist/tex/context/base/lpdf-ini.lua
index 88999358ce1..0b1473d2f93 100644
--- a/Master/texmf-dist/tex/context/base/lpdf-ini.lua
+++ b/Master/texmf-dist/tex/context/base/lpdf-ini.lua
@@ -8,10 +8,10 @@ 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, gmatch = string.char, string.byte, string.format, string.gsub, table.concat, string.match, string.sub, string.gmatch
-local utfvalues = string.utfvalues
-local utfchar = utf.char
+local utfchar, utfvalues = utf.char, utf.values
local sind, cosd = math.sind, math.cosd
local lpegmatch, P, C, R, S, Cc, Cs = lpeg.match, lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc, lpeg.Cs
+local formatters = string.formatters
local pdfreserveobject = pdf.reserveobj
local pdfimmediateobject = pdf.immediateobj
@@ -39,7 +39,7 @@ backends.pdf = backends.pdf or {
lpdf = lpdf or { }
local lpdf = lpdf
-local function tosixteen(str) -- an lpeg might be faster
+local function tosixteen(str) -- an lpeg might be faster (no table)
if not str or str == "" then
return "<feff>" -- not () as we want an indication that it's unicode
else
@@ -105,6 +105,12 @@ local function merge_t(a,b)
return setmetatable(t,getmetatable(a))
end
+local f_key_value = formatters["/%s %s"]
+local f_key_dictionary = formatters["/%s << % t >>"]
+local f_dictionary = formatters["<< % t >>"]
+local f_key_array = formatters["/%s [ % t ]"]
+local f_array = formatters["[ % t ]"]
+
local tostring_a, tostring_d
tostring_d = function(t,contentonly,key)
@@ -120,28 +126,28 @@ tostring_d = function(t,contentonly,key)
rn = rn + 1
local tv = type(v)
if tv == "string" then
- r[rn] = format("/%s %s",k,toeight(v))
+ r[rn] = f_key_value(k,toeight(v))
elseif tv == "unicode" then
- r[rn] = format("/%s %s",k,tosixteen(v))
+ r[rn] = f_key_value(k,tosixteen(v))
elseif tv == "table" then
local mv = getmetatable(v)
if mv and mv.__lpdftype then
- r[rn] = format("/%s %s",k,tostring(v))
+ r[rn] = f_key_value(k,tostring(v))
elseif v[1] then
- r[rn] = format("/%s %s",k,tostring_a(v))
+ r[rn] = f_key_value(k,tostring_a(v))
else
- r[rn] = format("/%s %s",k,tostring_d(v))
+ r[rn] = f_key_value(k,tostring_d(v))
end
else
- r[rn] = format("/%s %s",k,tostring(v))
+ r[rn] = f_key_value(k,tostring(v))
end
end
if contentonly then
- return concat(r, " ")
+ return concat(r," ")
elseif key then
- return format("/%s << %s >>", key, concat(r, " "))
+ return f_key_dictionary(key,r)
else
- return format("<< %s >>", concat(r, " "))
+ return f_dictionary(r)
end
end
end
@@ -180,9 +186,9 @@ tostring_a = function(t,contentonly,key)
if contentonly then
return concat(r, " ")
elseif key then
- return format("/%s [ %s ]", key, concat(r, " "))
+ return f_key_array(key,r)
else
- return format("[ %s ]", concat(r, " "))
+ return f_array(r)
end
end
end
@@ -358,10 +364,10 @@ function lpdf.reserveobject(name)
if name then
names[name] = r
if trace_objects then
- report_objects("reserving number %s under name '%s'",r,name)
+ report_objects("reserving number %a under name %a",r,name)
end
elseif trace_objects then
- report_objects("reserving number %s",r)
+ report_objects("reserving number %a",r)
end
return r
end
@@ -391,15 +397,15 @@ function lpdf.flushobject(name,data)
if named then
if not trace_objects then
elseif trace_detail then
- report_objects("flushing data to reserved object with name '%s' -> %s",name,tostring(data))
+ report_objects("flushing data to reserved object with name %a, data: %S",name,data)
else
- report_objects("flushing data to reserved object with name '%s'",name)
+ report_objects("flushing data to reserved object with name %a",name)
end
return pdfimmediateobject(named,tostring(data))
else
if not trace_objects then
elseif trace_detail then
- report_objects("flushing data to reserved object with number %s -> %s",name,tostring(data))
+ report_objects("flushing data to reserved object with number %s, data: %S",name,data)
else
report_objects("flushing data to reserved object with number %s",name)
end
@@ -407,7 +413,7 @@ function lpdf.flushobject(name,data)
end
else
if trace_objects and trace_detail then
- report_objects("flushing data -> %s",tostring(name))
+ report_objects("flushing data: %S",name)
end
return pdfimmediateobject(tostring(name))
end
@@ -430,7 +436,7 @@ end
function lpdf.flushstreamfileobject(filename,dict,compressed) -- default compressed
if trace_objects then
- report_objects("flushing stream file object '%s'",filename)
+ report_objects("flushing stream file object %a",filename)
end
local dtype = type(dict)
return pdfdeferredobject {
@@ -563,7 +569,7 @@ end
local function run(where,what)
if trace_finalizers then
- report_finalizing("start backend: category=%s, n=%s",what,#where)
+ report_finalizing("start backend, category %a, n %a",what,#where)
end
for i=1,#where do
local w = where[i]
@@ -619,12 +625,12 @@ callbacks.register("finish_pdffile", lpdf.finalizedocument)
local function trace_set(what,key)
if trace_resources then
- report_finalizing("setting key '%s' in '%s'",key,what)
+ report_finalizing("setting key %a in %a",key,what)
end
end
local function trace_flush(what)
if trace_resources then
- report_finalizing("flushing '%s'",what)
+ report_finalizing("flushing %a",what)
end
end
@@ -703,7 +709,7 @@ registerpagefinalizer(checkshades,3,"shades")
function lpdf.rotationcm(a)
local s, c = sind(a), cosd(a)
- return format("%s %s %s %s 0 0 cm",c,s,-s,c)
+ return format("%0.6f %0.6f %0.6f %0.6f 0 0 cm",c,s,-s,c)
end
-- ! -> universaltime