diff options
author | Dohyun Kim <nomosnomos@gmail.com> | 2013-12-29 14:46:00 +0900 |
---|---|---|
committer | Dohyun Kim <nomosnomos@gmail.com> | 2013-12-29 14:46:00 +0900 |
commit | 1de7c5bdfda40e81aa7786ce4856233c1c9a3a52 (patch) | |
tree | 3006c4ebc99b11dd334ac177f53f7e89bd9e9b35 | |
parent | e1946776a33eeea9ac9c2a4460a1a221fccd0817 (diff) | |
download | luaotfload-1de7c5bdfda40e81aa7786ce4856233c1c9a3a52.tar.gz |
reduce the size of res table
-rw-r--r-- | luaotfload-colors.lua | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/luaotfload-colors.lua b/luaotfload-colors.lua index 3b430f3..b8ecb87 100644 --- a/luaotfload-colors.lua +++ b/luaotfload-colors.lua @@ -126,12 +126,12 @@ registerotffeature { --- something is carried around in ``res`` --- for later use by color_handler() --- but what? -local res = {} +local res = nil --- float -> unit local function pageresources(alpha) - res[#res+1] = stringformat("/TransGs%s<</ca %s/CA %s>>", - alpha, alpha, alpha) + res = res or {} + res[alpha] = true end --- we store results of below color handler as tuples of @@ -275,13 +275,13 @@ end local color_handler = function (head) local new_head = node_colorize(head, nil, nil) -- now append our page resources - if res and #res > 0 then + if res then + res["1"] = true local tpr, t = tex.pdfpageresources, "" - res[#res+1] = "/TransGs1<</ca 1/CA 1>>" - for i = 1,#res do - if stringfind(tpr,res[i]) or stringfind(t,res[i]) then - else - t = t .. res[i] + 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 @@ -291,7 +291,7 @@ local color_handler = function (head) tpr = stringgsub(tpr,"/ExtGState<<","%1"..t) tex.pdfpageresources = tpr end - res = {} -- reset res + res = nil -- reset res end return new_head end |