From f58a2cb5d22c5931581274db1f0ec85ac903b747 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 28 Oct 2019 20:03:50 +0100 Subject: 2019-10-28 18:22:00 --- tex/context/base/mkiv/grph-inc.lua | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'tex/context/base/mkiv/grph-inc.lua') diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index bfe67094e..1d59972ab 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -298,6 +298,7 @@ local figures_resources = allocate() figures.resources = figures_resources local existers = allocate() figures.existers = existers local checkers = allocate() figures.checkers = checkers local includers = allocate() figures.includers = includers +local remappers = allocate() figures.remappers = remappers local converters = allocate() figures.converters = converters local identifiers = allocate() figures.identifiers = identifiers local programs = allocate() figures.programs = programs @@ -324,7 +325,7 @@ local figures_order = allocate { local figures_formats = allocate { -- magic and order will move here ["pdf"] = { list = { "pdf" } }, - ["mps"] = { patterns = { "mps", "%d+" } }, + ["mps"] = { patterns = { "^mps$", "^%d+$" } }, -- we need to anchor ["jpg"] = { list = { "jpg", "jpeg" } }, ["png"] = { list = { "png" } }, ["jp2"] = { list = { "jp2" } }, @@ -779,24 +780,32 @@ local function register(askedname,specification) arguments or "" ) end - -- quick hack - local converter = (newformat ~= format or resolution or arguments) and converters[format] + -- begin of quick hack + local remapper = remappers[format] + if remapper then + remapper = remapper[conversion] + if remapper then + specification = remapper(specification) or specification + format = specification.format + newformat = format + conversion = nil + end + end + -- end of quick hack + local converter = (not remapper) and (newformat ~= format or resolution or arguments) and converters[format] if converter then - if converter[newformat] then - converter = converter[newformat] + local okay = converter[newformat] + if okay then + converter = okay else newformat = defaultformat - if converter[newformat] then - converter = converter[newformat] - else - converter = nil - newformat = defaultformat - end + converter = converter[newformat] end elseif trace_conversion then report_inclusion("no converter for %a to %a",format,newformat) end if converter then + -- todo: make this a function -- -- todo: outline as helper function -- @@ -891,7 +900,7 @@ local function register(askedname,specification) format = suffix end end -specification.format = format + specification.format = format elseif io.exists(oldname) then report_inclusion("file %a is bugged",oldname) if format and imagetypes[format] then @@ -1425,6 +1434,7 @@ local transforms = setmetatableindex ( local function checktransform(figure,forced) if auto_transform then + local orientation = (forced ~= "" and forced ~= v_auto and forced) or figure.orientation or 0 local transform = transforms["orientation-"..orientation] figure.transform = transform -- cgit v1.2.3