From 778f381ba6a448ab00d67994a412dd4226d43238 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 8 Oct 2021 20:46:55 +0200 Subject: 2021-10-08 20:07:00 --- scripts/context/lua/mtx-context.lua | 12 ++++++++++-- scripts/context/lua/mtx-fonts.lua | 4 ++-- scripts/context/lua/mtx-pdf.lua | 25 +++++++++++++++++++++---- 3 files changed, 33 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index d2e63640a..5a67f4f2a 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -111,8 +111,10 @@ local engine_new = filenameonly(getargument("engine") or directives.value("syste local engine_old = filenameonly(environment.ownmain) or filenameonly(environment.ownbin) local function restart(engine_old,engine_new) - local ownname = filejoinname(filepathpart(environment.ownname),"mtxrun.lua") - local command = format("%s --luaonly %q %s --redirected",engine_new,ownname,environment.reconstructcommandline()) + local generate = environment.arguments.generate and (engine_new == "luatex" or engine_new == "luajittex") + local arguments = generate and "--generate" or environment.reconstructcommandline() + local ownname = filejoinname(filepathpart(environment.ownname),"mtxrun.lua") + local command = format("%s --luaonly %q %s --redirected",engine_new,ownname,arguments) report(format("redirect %s -> %s: %s",engine_old,engine_new,command)) local result = os.execute(command) os.exit(result == 0 and 0 or 1) @@ -1720,6 +1722,12 @@ end -- getting it done +if getargument("pdftex") then + setargument("engine","pdftex") +elseif getargument("xetex") then + setargument("engine","xetex") +end + if getargument("timedlog") then logs.settimedlog() end diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua index feefdeada..bf37b069a 100644 --- a/scripts/context/lua/mtx-fonts.lua +++ b/scripts/context/lua/mtx-fonts.lua @@ -295,7 +295,7 @@ local function showfeatures(tag,specification) else done = true end - report(" % -8s % -8s % -8s",f,s,concat(table.sortedkeys(ss), " ")) -- todo: padd 4 + report(" %-8s %-8s %-8s",f,s,concat(table.sortedkeys(ss), " ")) -- todo: padd 4 end end end @@ -317,7 +317,7 @@ local function showfeatures(tag,specification) report(" method feature formats") report() for k, v in table.sortedhash(methods) do - report(" % -8s % -14s %s",k,v.feature,v.format) + report(" %-8s %-14s %s",k,v.feature,v.format) end end end diff --git a/scripts/context/lua/mtx-pdf.lua b/scripts/context/lua/mtx-pdf.lua index fbb1a3995..201d73623 100644 --- a/scripts/context/lua/mtx-pdf.lua +++ b/scripts/context/lua/mtx-pdf.lua @@ -7,7 +7,7 @@ if not modules then modules = { } end modules ['mtx-pdf'] = { } local tonumber = tonumber -local format, gmatch, gsub = string.format, string.gmatch, string.gsub +local format, gmatch, gsub, match, find = string.format, string.gmatch, string.gsub, string.match, string.find local utfchar = utf.char local concat = table.concat local setmetatableindex, sortedhash, sortedkeys = table.setmetatableindex, table.sortedhash, table.sortedkeys @@ -27,11 +27,13 @@ local helpinfo = [[ show metadata xml blob replace newlines in metadata show used fonts ( + show object"/> mtxrun --script pdf --info foo.pdf mtxrun --script pdf --metadata foo.pdf mtxrun --script pdf --metadata --pretty foo.pdf + mtxrun --script pdf --stream=4 foo.pdf @@ -46,10 +48,14 @@ local application = logs.application { local report = application.report -if pdfe then - dofile(resolvers.findfile("lpdf-pde.lua","tex")) -else +if not pdfe then dofile(resolvers.findfile("lpdf-epd.lua","tex")) +elseif CONTEXTLMTXMODE then + dofile(resolvers.findfile("util-dim.lua","tex")) + dofile(resolvers.findfile("lpdf-ini.lmt","tex")) + dofile(resolvers.findfile("lpdf-pde.lmt","tex")) +else + dofile(resolvers.findfile("lpdf-pde.lua","tex")) end scripts = scripts or { } @@ -349,6 +355,15 @@ function scripts.pdf.fonts(filename) end end +function scripts.pdf.object(filename,n) + if n then + local pdffile = loadpdffile(filename) + if pdffile then + print(lpdf.epdf.verboseobject(pdffile,n) or "no object with number " .. n) + end + end +end + -- scripts.pdf.info("e:/tmp/oeps.pdf") -- scripts.pdf.metadata("e:/tmp/oeps.pdf") -- scripts.pdf.fonts("e:/tmp/oeps.pdf") @@ -364,6 +379,8 @@ elseif environment.argument("metadata") then scripts.pdf.metadata(filename,environment.argument("pretty")) elseif environment.argument("fonts") then scripts.pdf.fonts(filename) +elseif environment.argument("object") then + scripts.pdf.object(filename,tonumber(environment.argument("object"))) elseif environment.argument("exporthelp") then application.export(environment.argument("exporthelp"),filename) else -- cgit v1.2.3