diff --git a/outputters/base.lua b/outputters/base.lua index 0b7db5a1f..d45a7fe55 100644 --- a/outputters/base.lua +++ b/outputters/base.lua @@ -62,6 +62,8 @@ function outputter.setMetadata (_, _, _) end function outputter.setBookmark (_, _, _) end +function outputter.drawRaw (_) end + function outputter:getOutputFilename () local fname if SILE.outputFilename then diff --git a/outputters/cairo.lua b/outputters/cairo.lua index fdde05712..c217bcb4c 100644 --- a/outputters/cairo.lua +++ b/outputters/cairo.lua @@ -120,4 +120,9 @@ function outputter:debugHbox (hbox, scaledWidth) cr:move_to(x, y) end +-- untested +function outputter:drawRaw (literal) + cr:show_text(literal) +end + return outputter diff --git a/outputters/debug.lua b/outputters/debug.lua index df72f1dbe..b1c21825a 100644 --- a/outputters/debug.lua +++ b/outputters/debug.lua @@ -183,4 +183,8 @@ function outputter:setMetadata (key, value) self:_writeline("Set metadata", key, value) end +function outputter:drawRaw (literal) + self:_writeline("Draw raw", literal) +end + return outputter diff --git a/outputters/libtexpdf.lua b/outputters/libtexpdf.lua index f9b4915eb..b18949744 100644 --- a/outputters/libtexpdf.lua +++ b/outputters/libtexpdf.lua @@ -386,4 +386,10 @@ function outputter:setBookmark (dest, title, level) pdf.bookmark(d, level) end +-- Assumes the caller known what they want to stuff in raw PDF format +function outputter:drawRaw (literal) + self:_ensureInit() + pdf.add_content(literal) +end + return outputter diff --git a/outputters/podofo.lua b/outputters/podofo.lua index 593c1afb4..7891248b8 100644 --- a/outputters/podofo.lua +++ b/outputters/podofo.lua @@ -106,4 +106,10 @@ function outputter:debugHbox (hbox, scaledWidth) --cr:move_to(x, y) end +-- untested +function outputter:drawRaw (literal) + local x, y = self:getCursor() + painter:DrawText(x, y, literal, string.len(literal) +end + return outputter diff --git a/outputters/text.lua b/outputters/text.lua index b9580c81a..73d56ec9e 100644 --- a/outputters/text.lua +++ b/outputters/text.lua @@ -82,4 +82,9 @@ function outputter:drawHbox (value, width) end end +function outputter.drawRaw (literal) + self:_ensureInit + outfile:write(literal) +end + return outputter diff --git a/packages/pdfstructure/init.lua b/packages/pdfstructure/init.lua index 9deeba3d0..4749993b5 100644 --- a/packages/pdfstructure/init.lua +++ b/packages/pdfstructure/init.lua @@ -126,16 +126,13 @@ function package:registerCommands () if SILE.outputter._name ~= "libtexpdf" then SU.error("pdf package requires libtexpdf backend") end - if type(SILE.outputter._ensureInit) == "function" then - SILE.outputter:_ensureInit() - end SILE.typesetter:pushHbox({ value = nil, height = SILE.measurement(0), width = SILE.measurement(0), depth = SILE.measurement(0), outputYourself = function (_, _, _) - pdf.add_content(content[1]) + SILE.outputter:drawRaw (content[1]) end }) end)