[latex3-commits] [git/LaTeX3-latex3-luaotfload] transparent-layer: Counting is hard (fba4788)
Marcel Fabian Krüger
tex at 2krueger.de
Fri Jul 17 19:57:23 CEST 2020
Repository : https://github.com/latex3/luaotfload
On branch : transparent-layer
Link : https://github.com/latex3/luaotfload/commit/fba4788ba8fa6c5cada037fc59b30ad103f8a7d4
>---------------------------------------------------------------
commit fba4788ba8fa6c5cada037fc59b30ad103f8a7d4
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Fri Jul 17 19:57:23 2020 +0200
Counting is hard
>---------------------------------------------------------------
fba4788ba8fa6c5cada037fc59b30ad103f8a7d4
src/luaotfload-harf-plug.lua | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index d9a1738..0c45d74 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -717,6 +717,7 @@ local function tonodes(head, node, run, glyphs)
local cmds = {} -- Every layer will add 5 cmds
local prev_color = nil
local set_alpha_255 = { "nop" } -- By default alpha 255 is ignored
+ local k = 1 -- k == j except that k does only get inccreased if the layer isn't dropped
for j = 1, #layers do
local layer = layers[j]
local layerchar = characters[gid_offset + layer.glyph]
@@ -731,8 +732,8 @@ local function tonodes(head, node, run, glyphs)
-- get nil anyway.
local color = palette[layer.color_index]
if not color or color.alpha ~= 0 then
- cmds[6*j - 5] = (color and not prev_color) and save_cmd or nop_cmd
- cmds[6*j - 4] = prev_color == color and nop_cmd or (color and {"pdf", "page", color_to_rgba(color)} or restore_cmd)
+ cmds[6*k - 5] = (color and not prev_color) and save_cmd or nop_cmd
+ cmds[6*k - 4] = prev_color == color and nop_cmd or (color and {"pdf", "page", color_to_rgba(color)} or restore_cmd)
local trans_cmd
if not color or (prev_color and prev_color.alpha == color.alpha) then
trans_cmd = nop_cmd
@@ -744,12 +745,13 @@ local function tonodes(head, node, run, glyphs)
table.move(set_alpha_cmd[255], 1, 2, 1, set_alpha_255)
end
end
- cmds[6*j - 3] = trans_cmd
- cmds[6*j - 2] = push_cmd
- cmds[6*j - 1] = {"char", layer.glyph + gid_offset}
- cmds[6*j] = pop_cmd
+ cmds[6*k - 3] = trans_cmd
+ cmds[6*k - 2] = push_cmd
+ cmds[6*k - 1] = {"char", layer.glyph + gid_offset}
+ cmds[6*k] = pop_cmd
fontglyphs[layer.glyph].used = true
prev_color = color
+ k = k+1
end
end
cmds[#cmds + 1] = prev_color and restore_cmd
More information about the latex3-commits
mailing list.