diff options
author | Dohyun Kim <nomosnomos@gmail.com> | 2015-05-04 16:33:31 +0900 |
---|---|---|
committer | Dohyun Kim <nomosnomos@gmail.com> | 2015-05-04 16:33:31 +0900 |
commit | 3b391191018f67233e593a5d5053d9f1ace4a509 (patch) | |
tree | 9f797d01c7cb8b2ab59f4274b565629cea7daaf8 | |
parent | 1f74982cb8e0980d956f97bd9bbb75391eb67d75 (diff) | |
download | luaotfload-3b391191018f67233e593a5d5053d9f1ace4a509.tar.gz |
respect beamer (pgf) transparency
-rw-r--r-- | src/luaotfload-colors.lua | 21 | ||||
-rw-r--r-- | src/luaotfload.sty | 12 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua index 081f0f6..0832083 100644 --- a/src/luaotfload-colors.lua +++ b/src/luaotfload-colors.lua @@ -40,6 +40,8 @@ local setattribute = nodedirect.set_attribute local texset = tex.set local texget = tex.get +local texsettoks = tex.settoks +local texgettoks = tex.gettoks local stringformat = string.format @@ -318,7 +320,12 @@ local color_handler = function (head) -- now append our page resources if res then res["1"] = true - local tpr = texget("pdfpageresources") -- respect other packages. we need a guidance + local tpr = texget("pdfpageresources") + local pgf_loaded = tpr:find("/ExtGState %d+ 0 R") + if pgf_loaded then + tpr = texgettoks("pgf@sys@pgf@resource@list@extgs@toks") -- see luaotfload.sty + end + local t = "" for k in pairs(res) do local str = stringformat("/TransGs%s<</ca %s>>", k, k) -- don't touch stroking elements @@ -327,11 +334,15 @@ local color_handler = function (head) end end if t ~= "" then - if not tpr:find("/ExtGState<<.*>>") then - tpr = tpr .. "/ExtGState<<>>" + if pgf_loaded then + texsettoks("global", "pgf@sys@pgf@resource@list@extgs@toks", tpr..t) + else + if not tpr:find("/ExtGState<<.*>>") then + tpr = tpr .. "/ExtGState<<>>" + end + tpr = tpr:gsub("/ExtGState<<", "%1"..t) + texset("global", "pdfpageresources", tpr) end - tpr = tpr:gsub("/ExtGState<<", "%1"..t) - texset("global", "pdfpageresources", tpr) end res = nil -- reset res end diff --git a/src/luaotfload.sty b/src/luaotfload.sty index 100fb72..63d98ca 100644 --- a/src/luaotfload.sty +++ b/src/luaotfload.sty @@ -33,7 +33,7 @@ \csname ifluaotfloadloaded\endcsname \let\ifluaotfloadloaded\endinput \bgroup\expandafter\expandafter\expandafter\egroup -\expandafter\ifx\csname ProvidesPackage\endcsname\relax +\expandafter\ifx\csname RequirePackage\endcsname\relax \input luatexbase.sty \else \NeedsTeXFormat{LaTeX2e} @@ -45,3 +45,13 @@ \fi \RequireLuaModule{luaotfload-main} +% for compatibility with beamer class, which loads pgf package. +% under non-beamer class, tikz (pgf) should be loaded before luaotfload. +\ifcsname pgf@sys@pgf@resource@list@extgs\endcsname\else\endinput\fi +\count255=\the\catcode`@\relax +\catcode`@=11\relax +\newtoks\pgf@sys@pgf@resource@list@extgs@toks +\def\pgf@sys@pgf@resource@list@extgs{\the\pgf@sys@pgf@resource@list@extgs@toks} +\def\pgf@sys@addpdfresource@extgs@plain#1{\global\pgf@sys@pgf@resource@list@extgs@toks + \expandafter{\the\pgf@sys@pgf@resource@list@extgs@toks #1}} +\catcode`@=\the\count255\relax |