summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-01-01 22:57:02 +0000
committerKarl Berry <karl@freefriends.org>2014-01-01 22:57:02 +0000
commit0479a789f43c32b8fbc9d74bb82c615932a3c5b1 (patch)
treeb1c9d139f32df9676c239bdad84408cf55124729 /Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua
parent999dd6fa37bd291385b20ccf85f980eccfd2e683 (diff)
luaotfload (1jan14)
git-svn-id: svn://tug.org/texlive/trunk@32538 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua41
1 files changed, 21 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua
index ac9291dae7b..b8ecb875c7d 100644
--- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua
+++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua
@@ -1,5 +1,5 @@
if not modules then modules = { } end modules ['luaotfload-colors'] = {
- version = "2.3a",
+ version = "2.4",
comment = "companion to luaotfload.lua (font color)",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
@@ -126,19 +126,12 @@ registerotffeature {
--- something is carried around in ``res``
--- for later use by color_handler() --- but what?
-local res --- <- state of what?
+local res = nil
--- float -> unit
local function pageresources(alpha)
- local res2
- if not res then
- res = "/TransGs1<</ca 1/CA 1>>"
- end
- res2 = stringformat("/TransGs%s<</ca %s/CA %s>>",
- alpha, alpha, alpha)
- res = stringformat("%s%s",
- res,
- stringfind(res, res2) and "" or res2)
+ res = res or {}
+ res[alpha] = true
end
--- we store results of below color handler as tuples of
@@ -280,17 +273,25 @@ end
--- node -> node
local color_handler = function (head)
- -- check if our page resources existed in the previous run
- -- and remove it to avoid duplicating it later
- if res then
- local r = "/ExtGState<<" .. res .. ">>"
- tex.pdfpageresources = stringgsub(tex.pdfpageresources, r, "")
- end
local new_head = node_colorize(head, nil, nil)
-- now append our page resources
- if res and stringfind(res, "%S") then -- test for non-empty string
- local r = "/ExtGState<<" .. res .. ">>"
- tex.pdfpageresources = tex.pdfpageresources..r
+ if res then
+ res["1"] = true
+ local tpr, t = tex.pdfpageresources, ""
+ for k in pairs(res) do
+ local str = stringformat("/TransGs%s<</ca %s/CA %s>>", k, k, k)
+ if not stringfind(tpr,str) then
+ t = t .. str
+ end
+ end
+ if t ~= "" then
+ if not stringfind(tpr,"/ExtGState<<.*>>") then
+ tpr = tpr.."/ExtGState<<>>"
+ end
+ tpr = stringgsub(tpr,"/ExtGState<<","%1"..t)
+ tex.pdfpageresources = tpr
+ end
+ res = nil -- reset res
end
return new_head
end