From 402341d81384bb44b547426c5bab912c459bee4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Tue, 7 Jun 2022 08:24:13 +0200 Subject: [PATCH] Allow customizing color stack for transparancy --- src/luaotfload-colors.lua | 19 +++++++++++++++++++ src/luaotfload-l3color.lua | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua index 71e7c0e4..8aad8e4b 100644 --- a/src/luaotfload-colors.lua +++ b/src/luaotfload-colors.lua @@ -453,6 +453,25 @@ end function luaotfload.set_transparentparser(cb) custom_parsetransparent = cb end +function luaotfload.set_transparentstack(stack) + if type(transparent_stack) == 'number' then + tex.error"luaotfload's transparency stack can't be changed after it has been used" + else + local t = type(stack) + if t == 'function' or t == 'number' then + function transparent_stack() + if t == 'function' then + transparent_stack = stack() + else + transparent_stack = stack + end + return transparent_stack + end + else + tex.error("Invalid argument in luaotfload.set_transparentstack") + end + end +end setmetatable(fonts.handlers.otf.statistics.usedfeatures.color, { __index = function(t, k) diff --git a/src/luaotfload-l3color.lua b/src/luaotfload-l3color.lua index bd27574a..13468e2c 100644 --- a/src/luaotfload-l3color.lua +++ b/src/luaotfload-l3color.lua @@ -47,7 +47,7 @@ luaotfload.set_colorparser(function (value) tex.runtoks(function() token.get_next() color_export[6] = value - tex.sprint(-1, color_export) + tex.sprint(-2, color_export) end) local list = token.scan_list() if not list.head or list.head.next or list.head.subtype ~= node.subtype'pdf_colorstack' then