[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Allow customizing color stack for transparancy (402341d)

Marcel Fabian Krüger tex at 2krueger.de
Tue Jun 7 08:32:26 CEST 2022


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/402341d81384bb44b547426c5bab912c459bee4e

>---------------------------------------------------------------

commit 402341d81384bb44b547426c5bab912c459bee4e
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Jun 7 08:24:13 2022 +0200

    Allow customizing color stack for transparancy


>---------------------------------------------------------------

402341d81384bb44b547426c5bab912c459bee4e
 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 71e7c0e..8aad8e4 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 bd27574..13468e2 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





More information about the latex3-commits mailing list.