-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make luaotfload transparency work with its hooks #101
Conversation
Since we added new PDF resource management, transparent font settings through luaotfload were broken. It was now possible to fix this thanks to new hooks in luaotfload. See latex3/luaotfload#212
I hope gucci-on-fleek/lua-widow-control#39 can be resolved here as well, while at it. I have "draft" in vlasakm@1b2070e. |
Alright, 1b2070e is good for gucci-on-fleek/lua-widow-control#39, so I pushed it and hope this PR is ready to go. What do you think @olsak? |
cited from gucci-on-fleek/lua-widow-control#39: "OpTeX: Cannot colour the first line of the page since OpTeX resets the colour there." I don't understand this. I am unable to create a minimal example which shows the problem. |
A messy example: \fontfam[LM]
\directlua{
callback.add_to_callback("pre_output_filter", function (head)
for hlist in node.traverse_id(node.id("hlist"), head) do
local colour = string.format(
"\%.2f \%.2f \%.2f rg",
1,
math.random(),
math.random()
)
local start_colour = node.new("whatsit", "pdf_colorstack")
start_colour.stack = 0
start_colour.command = 1
start_colour.data = colour
local end_colour = node.new("whatsit", "pdf_colorstack")
end_colour.stack = 0
end_colour.command = 2
start_colour.next = hlist.list
hlist.list = start_colour
node.slide(hlist.list).next = end_colour
end
return head
end, "test")
}
Hello!
Hello!
Hello!
\vfill\eject
Hello!
Hello!
Hello!
\bye If we disassemble the PDF with
|
Well, in this case the fix can maybe be as simple as this: diff --git a/optex/base/optex.lua b/optex/base/optex.lua
index bb67d7e..9e9c83a 100644
--- a/optex/base/optex.lua
+++ b/optex/base/optex.lua
@@ -652,10 +652,10 @@ end
-- for this. See the definition of `pre_shipout_filter` for details on
-- limitations.
callback.add_to_callback("pre_shipout_filter", function(list)
- -- By setting initial color to -1 we force initial setting of color on
- -- every page. This is useful for transparently supporting other default
- -- colors than black (although it has a price for each normal document).
- local list = colorize(todirect(list), -1, -1, 0)
+ -- Each page has implicitly preset black color and no transparency, we tell
+ -- this to the colorize function so that it can take advantage of it and
+ -- not set it.
+ local list = colorize(todirect(list), 0, 0, 0)
return tonode(list)
end, "_colors")
-- This setting of But this doesn't save the general case, where the nodes could have color attributes set. Making |
Hm, maybe the interface should change, so that |
In the last commit I wrapped the hooks into luaotfload in |
Since we added new PDF resource management, transparent font settings through luaotfload were broken.
It was now possible to fix this thanks to new hooks in luaotfload. See latex3/luaotfload#212.
I tested with https://github.com/vlasakm/optex-minim/blob/master/examples/optex-minim-pgf-test.tex, since that file mixes a lot of things (luaotfload transparency, optex transparency, minim metapost resources, pgf resources, optex macro resources, ...), but didn't do a lot of thorough testing.