summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3backend
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-03-31 03:01:28 +0000
committerNorbert Preining <norbert@preining.info>2023-03-31 03:01:28 +0000
commitff15e9aea45682289b6f31fa687c1b51f543d09e (patch)
tree6d69087aaae1e3fbd3ac00a7922eb41b940c1fa6 /macros/latex/contrib/l3backend
parent0a426619b66178dd2257f1ece60ff80f86f40e88 (diff)
CTAN sync 202303310301
Diffstat (limited to 'macros/latex/contrib/l3backend')
-rw-r--r--macros/latex/contrib/l3backend/CHANGELOG.md11
-rw-r--r--macros/latex/contrib/l3backend/README.md2
-rw-r--r--macros/latex/contrib/l3backend/l3backend-basics.dtx16
-rw-r--r--macros/latex/contrib/l3backend/l3backend-box.dtx4
-rw-r--r--macros/latex/contrib/l3backend/l3backend-code.pdfbin933659 -> 933580 bytes
-rw-r--r--macros/latex/contrib/l3backend/l3backend-color.dtx164
-rw-r--r--macros/latex/contrib/l3backend/l3backend-draw.dtx4
-rw-r--r--macros/latex/contrib/l3backend/l3backend-graphics.dtx4
-rw-r--r--macros/latex/contrib/l3backend/l3backend-header.dtx4
-rw-r--r--macros/latex/contrib/l3backend/l3backend-opacity.dtx67
-rw-r--r--macros/latex/contrib/l3backend/l3backend-pdf.dtx4
-rw-r--r--macros/latex/contrib/l3backend/l3backend.ins28
12 files changed, 204 insertions, 104 deletions
diff --git a/macros/latex/contrib/l3backend/CHANGELOG.md b/macros/latex/contrib/l3backend/CHANGELOG.md
index 9a588abdaa..82228400e2 100644
--- a/macros/latex/contrib/l3backend/CHANGELOG.md
+++ b/macros/latex/contrib/l3backend/CHANGELOG.md
@@ -6,6 +6,12 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+## [2023-03-30]
+
+### Changed
+- Integrate l3color and l3opacity with luaotfload to ensure that
+ opacity specifications don't conflict.
+
## [2023-01-16]
### Changed
@@ -14,7 +20,7 @@ this project uses date-based 'snapshot' version identifiers.
## [2022-10-26]
### Changed
-- Avoid setting media box is `\mag` is non-standard
+- Avoid setting media box if `\mag` is non-standard
## [2022-09-28]
@@ -282,7 +288,8 @@ this project uses date-based 'snapshot' version identifiers.
- Include `l3backend` in file names
- Moved backend code to internal for each 'parent' module
-[Unreleased]: https://github.com/latex3/latex3/compare/2023-01-16...HEAD
+[Unreleased]: https://github.com/latex3/latex3/compare/2023-03-30...HEAD
+[2023-03-30]: https://github.com/latex3/latex3/compare/2023-01-16...2023-03-30
[2023-01-16]: https://github.com/latex3/latex3/compare/2022-10-26...2023-01-16
[2022-10-26]: https://github.com/latex3/latex3/compare/2022-09-28...2022-10-26
[2022-09-28]: https://github.com/latex3/latex3/compare/2022-08-30...2022-09-28
diff --git a/macros/latex/contrib/l3backend/README.md b/macros/latex/contrib/l3backend/README.md
index dba3d7b409..02fab16f9f 100644
--- a/macros/latex/contrib/l3backend/README.md
+++ b/macros/latex/contrib/l3backend/README.md
@@ -1,7 +1,7 @@
LaTeX3 Backend Drivers
======================
-Release 2023-01-16
+Release 2023-03-30
This package forms parts of `expl3`, and contains the code used to interface
with backends (drivers) across the `expl3` codebase. The functions here are
diff --git a/macros/latex/contrib/l3backend/l3backend-basics.dtx b/macros/latex/contrib/l3backend/l3backend-basics.dtx
index 918ddaa06d..1f821aff25 100644
--- a/macros/latex/contrib/l3backend/l3backend-basics.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-basics.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-basics} Implementation}
+% \section{\pkg{l3backend-basics} implementation}
%
% \begin{macrocode}
%<*package>
@@ -70,27 +70,27 @@
% \begin{macrocode}
\ProvidesExplFile
%<*dvipdfmx>
- {l3backend-dvipdfmx.def}{2023-01-16}{}
+ {l3backend-dvipdfmx.def}{2023-03-30}{}
{L3 backend support: dvipdfmx}
%</dvipdfmx>
%<*dvips>
- {l3backend-dvips.def}{2023-01-16}{}
+ {l3backend-dvips.def}{2023-03-30}{}
{L3 backend support: dvips}
%</dvips>
%<*dvisvgm>
- {l3backend-dvisvgm.def}{2023-01-16}{}
+ {l3backend-dvisvgm.def}{2023-03-30}{}
{L3 backend support: dvisvgm}
%</dvisvgm>
%<*luatex>
- {l3backend-luatex.def}{2023-01-16}{}
+ {l3backend-luatex.def}{2023-03-30}{}
{L3 backend support: PDF output (LuaTeX)}
%</luatex>
%<*pdftex>
- {l3backend-pdftex.def}{2023-01-16}{}
+ {l3backend-pdftex.def}{2023-03-30}{}
{L3 backend support: PDF output (pdfTeX)}
%</pdftex>
%<*xetex>
- {l3backend-xetex.def}{2023-01-16}{}
+ {l3backend-xetex.def}{2023-03-30}{}
{L3 backend support: XeTeX}
%</xetex>
% \end{macrocode}
diff --git a/macros/latex/contrib/l3backend/l3backend-box.dtx b/macros/latex/contrib/l3backend/l3backend-box.dtx
index f7e1c7d37a..ae7e2281fc 100644
--- a/macros/latex/contrib/l3backend/l3backend-box.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-box.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-box} Implementation}
+% \section{\pkg{l3backend-box} implementation}
%
% \begin{macrocode}
%<*package>
diff --git a/macros/latex/contrib/l3backend/l3backend-code.pdf b/macros/latex/contrib/l3backend/l3backend-code.pdf
index 8a33bad815..1ce7f2d3a8 100644
--- a/macros/latex/contrib/l3backend/l3backend-code.pdf
+++ b/macros/latex/contrib/l3backend/l3backend-code.pdf
Binary files differ
diff --git a/macros/latex/contrib/l3backend/l3backend-color.dtx b/macros/latex/contrib/l3backend/l3backend-color.dtx
index 1aff7262eb..786282333e 100644
--- a/macros/latex/contrib/l3backend/l3backend-color.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-color.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-color} Implementation}
+% \section{\pkg{l3backend-color} implementation}
%
% \begin{macrocode}
%<*package>
@@ -68,85 +68,6 @@
% \texttt{dvipdfmx}/\XeTeX{} is PDF-based means it (largely) sticks closer to
% direct PDF output.
%
-% \subsection{Collecting information from \LaTeXe{}}
-%
-% \subsubsection{\texttt{dvips}-style}
-%
-% \begin{macrocode}
-%<*dvisvgm|dvipdfmx|dvips|xetex>
-% \end{macrocode}
-%
-% \begin{macro}{\@@_backend_pickup:N}
-% \begin{macro}{\@@_backend_pickup:w}
-% Allow for \LaTeXe{} color. Here, the possible input values are limited:
-% \texttt{dvips}-style colors can be taken as-is. The \texttt{x}-type expansion
-% is there to cover the case where \pkg{xcolor} is in use.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_backend_pickup:N #1
- {
- \exp_args:NV \tl_if_head_is_space:nTF \current@color
- {
- \tl_set:Nn #1 { { gray } { 0 } }
- \msg_warning:nnx { color } { unhandled }
- { \current@color }
- }
- {
- \exp_last_unbraced:Nx \@@_backend_pickup:w
- { \current@color } \s_@@_stop #1
- }
- }
-\cs_new_protected:Npn \@@_backend_pickup:w #1 ~ #2 \s_@@_stop #3
- { \tl_set:Nn #3 { {#1} {#2} } }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macrocode}
-%</dvisvgm|dvipdfmx|dvips|xetex>
-% \end{macrocode}
-%
-% \subsubsection{\LuaTeX{} and \pdfTeX{}}
-%
-% \begin{macrocode}
-%<*luatex|pdftex>
-% \end{macrocode}
-%
-% \begin{macro}{\@@_backend_pickup:N}
-% \begin{macro}{\@@_backend_pickup:w}
-% Same ideas, but with a different backend-dependent format.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_backend_pickup:N #1
- {
- \exp_last_unbraced:Nx \@@_backend_pickup:w
- { \current@color } ~ 0 ~ 0 ~ 0 \s_@@_stop #1
- }
-\cs_new_protected:Npn \@@_backend_pickup:w
- #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \s_@@_stop #7
- {
- \str_if_eq:nnTF {#2} { g }
- { \tl_set:Nn #7 { { gray } {#1} } }
- {
- \str_if_eq:nnTF {#4} { rg }
- { \tl_set:Nn #7 { { rgb } { #1 ~ #2 ~ #3 } } }
- {
- \str_if_eq:nnTF {#5} { k }
- { \tl_set:Nn #7 { { cmyk } { #1 ~ #2 ~ #3 ~ #4 } } }
- {
- \tl_set:Nn #1 { { gray } { 0 } }
- \msg_warning:nnx { color } { unhandled }
- { \current@color }
- }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macrocode}
-%</luatex|pdftex>
-% \end{macrocode}
-%
% \subsection{The color stack}
%
% For PDF-based engines, we have a color stack available inside the specials.
@@ -289,6 +210,8 @@
% \begin{macrocode}
\tl_new:N \l_@@_backend_fill_tl
\tl_new:N \l_@@_backend_stroke_tl
+\tl_set:Nn \l_@@_backend_fill_tl { 0 ~ g }
+\tl_set:Nn \l_@@_backend_stroke_tl { 0 ~ G }
% \end{macrocode}
% \end{variable}
%
@@ -1341,6 +1264,85 @@
%</package>
% \end{macrocode}
%
+% \subsection{Font handling integration}
+%
+% In \LuaTeX{} these colors should also be usable to color fonts, so
+% \texttt{luaotfload} color handling is extended to include these.
+%
+% \begin{macrocode}
+%<*lua>
+% \end{macrocode}
+%
+% \begin{macrocode}
+local l = lpeg
+local spaces = l.P' '^0
+local digit16 = l.R('09', 'af', 'AF')
+
+local octet = digit16 * digit16 / function(s)
+ return string.format('%.3g ', tonumber(s, 16) / 255)
+end
+
+if luaotfload and luaotfload.set_transparent_colorstack then
+ local htmlcolor = l.Cs(octet * octet * octet * -1 * l.Cc'rg')
+ local color_export = {
+ token.create'tex_endlocalcontrol:D',
+ token.create'tex_hpack:D',
+ token.new(0, 1),
+ token.create'color_export:nnN',
+ token.new(0, 1),
+ '',
+ token.new(0, 2),
+ token.new(0, 1),
+ 'backend',
+ token.new(0, 2),
+ token.create'l_tmpa_tl',
+ token.create'exp_after:wN',
+ token.create'__color_select:nn',
+ token.create'l_tmpa_tl',
+ token.new(0, 2),
+ }
+ local group_end = token.create'group_end:'
+ local value = (1 - l.P'}')^0
+ luatexbase.add_to_callback('luaotfload.parse_color', function (value)
+% Also allow HTML colors to preserve compatibility
+ local html = htmlcolor:match(value)
+ if html then return html end
+
+ tex.runtoks(function()
+ token.get_next()
+ color_export[6] = value
+ tex.sprint(-2, color_export)
+ end)
+ local list = token.scan_list()
+ if not list.head or list.head.next
+ or list.head.subtype ~= node.subtype'pdf_colorstack' then
+ error'Unexpected backend behavior'
+ end
+ local cmd = list.head.data
+ node.free(list)
+ return cmd
+ end, 'l3color')
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</lua>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*luatex>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*package>
+\lua_load_module:n {l3backend-luatex}
+%</package>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</luatex>
+% \end{macrocode}
+%
% \end{implementation}
%
% \PrintIndex
diff --git a/macros/latex/contrib/l3backend/l3backend-draw.dtx b/macros/latex/contrib/l3backend/l3backend-draw.dtx
index d9f4f53cff..6577bc3008 100644
--- a/macros/latex/contrib/l3backend/l3backend-draw.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-draw.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-draw} Implementation}
+% \section{\pkg{l3backend-draw} implementation}
%
% \begin{macrocode}
%<*package>
diff --git a/macros/latex/contrib/l3backend/l3backend-graphics.dtx b/macros/latex/contrib/l3backend/l3backend-graphics.dtx
index a347bddccf..b042bd04e5 100644
--- a/macros/latex/contrib/l3backend/l3backend-graphics.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-graphics.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-graphics} Implementation}
+% \section{\pkg{l3backend-graphics} implementation}
%
% \begin{macrocode}
%<*package>
diff --git a/macros/latex/contrib/l3backend/l3backend-header.dtx b/macros/latex/contrib/l3backend/l3backend-header.dtx
index 69062bf241..595e6a2924 100644
--- a/macros/latex/contrib/l3backend/l3backend-header.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-header.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-header} Implementation}
+% \section{\pkg{l3backend-header} implementation}
%
% \begin{macrocode}
%<*dvips&header>
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
diff --git a/macros/latex/contrib/l3backend/l3backend-pdf.dtx b/macros/latex/contrib/l3backend/l3backend-pdf.dtx
index 321a4baa0e..bb80237d4d 100644
--- a/macros/latex/contrib/l3backend/l3backend-pdf.dtx
+++ b/macros/latex/contrib/l3backend/l3backend-pdf.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-pdf} Implementation}
+% \section{\pkg{l3backend-pdf} implementation}
%
% \begin{macrocode}
%<*package>
diff --git a/macros/latex/contrib/l3backend/l3backend.ins b/macros/latex/contrib/l3backend/l3backend.ins
index cfa8ece984..5b8945f012 100644
--- a/macros/latex/contrib/l3backend/l3backend.ins
+++ b/macros/latex/contrib/l3backend/l3backend.ins
@@ -137,4 +137,32 @@ and all files in that bundle must be distributed together.
}
}
+% Lua code
+
+\def\MetaPrefix{--}
+\preamble
+
+Copyright (C) 2023 The LaTeX Project
+
+It may be distributed and/or modified under the conditions of
+the LaTeX Project Public License (LPPL), either version 1.3c of
+this license or (at your option) any later version. The latest
+version of this license is in the file:
+
+ https://www.latex-project.org/lppl.txt
+
+This file is part of the "l3backend bundle" (The Work in LPPL)
+and all files in that bundle must be distributed together.
+
+\endpreamble
+\nopostamble
+\generate
+ {
+ \file{l3backend-luatex.lua}
+ {
+ \from{l3backend-color.dtx} {lua}
+ \from{l3backend-opacity.dtx} {lua}
+ }
+ }
+
\endbatchfile