diff options
author | Norbert Preining <norbert@preining.info> | 2023-03-31 03:01:28 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-03-31 03:01:28 +0000 |
commit | ff15e9aea45682289b6f31fa687c1b51f543d09e (patch) | |
tree | 6d69087aaae1e3fbd3ac00a7922eb41b940c1fa6 /macros/latex/contrib/l3backend/l3backend-opacity.dtx | |
parent | 0a426619b66178dd2257f1ece60ff80f86f40e88 (diff) |
CTAN sync 202303310301
Diffstat (limited to 'macros/latex/contrib/l3backend/l3backend-opacity.dtx')
-rw-r--r-- | macros/latex/contrib/l3backend/l3backend-opacity.dtx | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/macros/latex/contrib/l3backend/l3backend-opacity.dtx b/macros/latex/contrib/l3backend/l3backend-opacity.dtx index 465e51804a..3f3dd1c84a 100644 --- a/macros/latex/contrib/l3backend/l3backend-opacity.dtx +++ b/macros/latex/contrib/l3backend/l3backend-opacity.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2023-01-16} +% \date{Released 2023-03-30} % % \maketitle % @@ -53,7 +53,7 @@ % % \begin{implementation} % -% \section{\pkg{l3backend-opacity} Implementation} +% \section{\pkg{l3backend-opacity} implementation} % % \begin{macrocode} %<*package> @@ -287,6 +287,69 @@ %</package> % \end{macrocode} % +% \subsection{Font handling integration} +% +% In \LuaTeX{} we want to use these functions also for transparent fonts +% to avoid interference between both uses of transparency. +% +% \begin{macrocode} +%<*lua> +% \end{macrocode} +% +% First we need to check if pdfmanagement is active from Lua. +% \begin{macrocode} +local pdfmanagement_active do + local pdfmanagement_if_active_p = token.create'pdfmanagement_if_active_p:' + local cmd = pdfmanagement_if_active_p.cmdname + if cmd == 'undefined_cs' then + pdfmanagement_active = false + else + token.put_next(pdfmanagement_if_active_p) + pdfmanagement_active = token.scan_int() ~= 0 + end +end + +if pdfmanagement_active and luaotfload and luaotfload.set_transparent_colorstack then + luaotfload.set_transparent_colorstack(token.create'c__opacity_backend_stack_int'.index) + + local transparent_register = { + token.create'pdfmanagement_add:nnn', + token.new(0, 1), + 'Page/Resources/ExtGState', + token.new(0, 2), + token.new(0, 1), + '', + token.new(0, 2), + token.new(0, 1), + '<</ca ', + '', + '/CA ', + '', + '>>', + token.new(0, 2), + } + luatexbase.add_to_callback('luaotfload.parse_transparent', function(value) + value = (octet * -1):match(value) + if not value then + tex.error'Invalid transparency value' + return + end + value = value:sub(1, -2) + local result = 'opacity' .. value + tex.runtoks(function() + transparent_register[6], transparent_register[10], transparent_register[12] = result, value, value + tex.sprint(-2, transparent_register) + end) + return '/' .. result .. ' gs' + end, 'l3opacity') +end +% \end{macrocode} +% +% \begin{macrocode} +%</lua> +% \end{macrocode} +% +% % \end{implementation} % % \PrintIndex |