Closed gucci-on-fleek closed 1 year ago
Instead of start_colour.stack = 0
etc. you need node.setwhatsitfield(start_colour, 'stack', 0)
and similar in LuaMetaLaTeX. That's needed for all whatsit fields.
(Untested, I'll write a proper answer when I have more time)
Instead of start_colour.stack = 0 etc. you need node.setwhatsitfield(start_colour, 'stack', 0) and similar in LuaMetaLaTeX. That's needed for all whatsit fields.
Unfortunately, that doesn't seem to solve the problem. It does at least give a different error message. I was able to fix that error message by using 28
instead of "pdf_colorstack"
as the subtype, then I got a different error that I was able to fix by setting the colorstack` field to a specific table.
Running this code:
\input ltluatex
\directlua{
luatexbase.add_to_callback("post_linebreak_filter", function(head)
local start_colour = node.new("whatsit", 28)
node.setwhatsitfield(start_colour, "colorstack", {
page_stack = {},
mode = "page",
action = "push",
data = "1 0 0 rg"
})
local end_colour = node.new("whatsit", 28)
node.setwhatsitfield(end_colour, "colorstack", {
page_stack = {},
mode = "page",
action = "pop"
})
local last_line = node.tail(head).list
start_colour.next = last_line
node.tail(last_line).next = end_colour
node.tail(head).list = start_colour
return true
end, "test")
}
\input knuth
\bye
works without any errors, but it doesn't actually put any colour on the page. I'm pretty sure that page_stack
shouldn't just be an empty table, but I'm not exactly sure what it should be.
Yes, the interface for pdf_colorstack
was not all that compatible with LuaTeX from the Lua side. I made them a bit more similar, so now you can do
\input ltluatex
\directlua{
local start_colour = node.new("whatsit", node.subtype'pdf_colorstack')
node.setwhatsitfield(start_colour, 'stack', 0)
node.setwhatsitfield(start_colour, 'command', 1)
node.setwhatsitfield(start_colour, 'data', "1 0 0 rg")
node.write(start_colour)
}
\input knuth
\directlua{
local end_colour = node.new("whatsit", node.subtype'pdf_colorstack')
node.setwhatsitfield(end_colour, 'stack', 0)
node.setwhatsitfield(end_colour, 'command', 2)
node.write(end_colour)
}
\bye
Works perfectly, thanks!
Inserting
pdf_colorstack
whatsit nodes from Lua causes a compilation failure when the page is shipped out. Both of these examples:work with LuaTeX, but fail in
luametaplain
with the following error:I'm also open to using a different method to colour a node list if this method is unsupported in LuaMetaLaTeX/LuaMetaPlain.