[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev, transparent-layer: Don't add invisible layers for color glyphs (9aa9916)

Marcel Fabian Krüger tex at 2krueger.de
Sun Jul 19 03:55:44 CEST 2020


Repository : https://github.com/latex3/luaotfload
On branches: dev,transparent-layer
Link       : https://github.com/latex3/luaotfload/commit/9aa9916a594ee7ddd5a9ede950789012861f61e6

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

commit 9aa9916a594ee7ddd5a9ede950789012861f61e6
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Fri Jul 17 16:14:43 2020 +0200

    Don't add invisible layers for color glyphs


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

9aa9916a594ee7ddd5a9ede950789012861f61e6
 src/luaotfload-harf-plug.lua | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index e5ede81..4d154d7 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -705,6 +705,7 @@ local function tonodes(head, node, run, glyphs)
             if layers then
               local cmds = {} -- Every layer will add 5 cmds
               local prev_color = nil
+              local k = 1 -- k == j except that k does only get increased if the layer isn't dropped
               for j = 1, #layers do
                 local layer = layers[j]
                 local layerchar = characters[gid_offset + layer.glyph]
@@ -718,13 +719,16 @@ local function tonodes(head, node, run, glyphs)
                 -- color, we don’t check for it here explicitly since we will
                 -- get nil anyway.
                 local color = palette[layer.color_index]
-                cmds[5*j - 4] = (color and not prev_color) and save_cmd or nop_cmd
-                cmds[5*j - 3] = prev_color == color and nop_cmd or (color and {"pdf", "page", color_to_rgba(color)} or restore_cmd)
-                cmds[5*j - 2] = push_cmd
-                cmds[5*j - 1] = {"char", layer.glyph + gid_offset}
-                cmds[5*j] = pop_cmd
-                fontglyphs[layer.glyph].used = true
-                prev_color = color
+                if not color or color.alpha ~= 0 then
+                  cmds[5*k - 4] = (color and not prev_color) and save_cmd or nop_cmd
+                  cmds[5*k - 3] = prev_color == color and nop_cmd or (color and {"pdf", "page", color_to_rgba(color)} or restore_cmd)
+                  cmds[5*k - 2] = push_cmd
+                  cmds[5*k - 1] = {"char", layer.glyph + gid_offset}
+                  cmds[5*k] = pop_cmd
+                  fontglyphs[layer.glyph].used = true
+                  prev_color = color
+                  k = k+1
+                end
               end
               cmds[#cmds + 1] = prev_color and restore_cmd
               if not character.colored then





More information about the latex3-commits mailing list.