diff options
author | Karl Berry <karl@freefriends.org> | 2019-05-02 22:51:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-05-02 22:51:31 +0000 |
commit | 4de7376b42147ed2246d7320e079bdebd84d9503 (patch) | |
tree | c84b6bf2943a50ce3651f54a5fd83a3918e8905e | |
parent | fc9aebc5bf923b3e26bd4157f786523ff49d2cbe (diff) |
l3kernel (22apr19)
git-svn-id: svn://tug.org/texlive/trunk@50950 c570f23f-e606-0410-a88d-b1316a301751
83 files changed, 6399 insertions, 3524 deletions
diff --git a/Master/texmf-dist/doc/latex/l3kernel/CHANGELOG.md b/Master/texmf-dist/doc/latex/l3kernel/CHANGELOG.md index a232782f2b7..5efd87df0dc 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/CHANGELOG.md +++ b/Master/texmf-dist/doc/latex/l3kernel/CHANGELOG.md @@ -7,6 +7,13 @@ this project uses date-based 'snapshot' version identifiers. ## [Unreleased] +## [2019-04-21] + +### Added + +- Experimental support for a range of PDF concepts at the lowest + (driver abstraction) level + ## [2019-04-06] ### Changed @@ -350,7 +357,8 @@ this project uses date-based 'snapshot' version identifiers. - Step functions have been added for dim variables, e.g. `\dim_step_inline:nnnn` -[Unreleased]: https://github.com/latex3/latex3/compare/2019-04-06...HEAD +[Unreleased]: https://github.com/latex3/latex3/compare/2019-04-21...HEAD +[2019-04-21]: https://github.com/latex3/latex3/compare/2019-04-06...2019-04-21 [2019-04-06]: https://github.com/latex3/latex3/compare/2019-03-26...2019-04-06 [2019-03-26]: https://github.com/latex3/latex3/compare/2019-03-05...2019-03-26 [2019-03-05]: https://github.com/latex3/latex3/compare/2019-02-15...2019-03-05 diff --git a/Master/texmf-dist/doc/latex/l3kernel/README.md b/Master/texmf-dist/doc/latex/l3kernel/README.md index 21e8c406069..d0ea5bd3ceb 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/README.md +++ b/Master/texmf-dist/doc/latex/l3kernel/README.md @@ -1,7 +1,7 @@ LaTeX3 Programming Conventions ============================== -Release 2019-04-06 +Release 2019-04-21 Overview -------- diff --git a/Master/texmf-dist/doc/latex/l3kernel/expl3.pdf b/Master/texmf-dist/doc/latex/l3kernel/expl3.pdf Binary files differindex f8298c22eb7..4b9b2f1c853 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/expl3.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/expl3.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/interface3.pdf b/Master/texmf-dist/doc/latex/l3kernel/interface3.pdf Binary files differindex fc9efe72f61..ac810baa529 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/interface3.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/interface3.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/interface3.tex b/Master/texmf-dist/doc/latex/l3kernel/interface3.tex index 90e3870655e..fa126268a06 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/interface3.tex +++ b/Master/texmf-dist/doc/latex/l3kernel/interface3.tex @@ -54,7 +54,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2019-04-06} +\date{Released 2019-04-21} \pagenumbering{roman} \maketitle diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3docstrip.pdf b/Master/texmf-dist/doc/latex/l3kernel/l3docstrip.pdf Binary files differindex 813e2f15181..131e29d9bb0 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3docstrip.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/l3docstrip.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.pdf b/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.pdf Binary files differindex 796ad86a84d..b0392fc1bf6 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.tex b/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.tex index 4e0b4778bb7..630bcb65881 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.tex +++ b/Master/texmf-dist/doc/latex/l3kernel/l3styleguide.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2019-04-06} +\date{Released 2019-04-21} \begin{document} diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.pdf b/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.pdf Binary files differindex 48f111356e0..c7a285f7c62 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.tex b/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.tex index a02353f1a4e..805f81a188a 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.tex +++ b/Master/texmf-dist/doc/latex/l3kernel/l3syntax-changes.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2019-04-06} +\date{Released 2019-04-21} \newcommand{\TF}{\textit{(TF)}} diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.pdf b/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.pdf Binary files differindex 8ca1b0fee55..89cfd7eb967 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.tex b/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.tex index 84fe26c9db2..5d7a80eb95d 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.tex +++ b/Master/texmf-dist/doc/latex/l3kernel/l3term-glossary.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2019-04-06} +\date{Released 2019-04-21} \newcommand{\TF}{\textit{(TF)}} diff --git a/Master/texmf-dist/doc/latex/l3kernel/source3.pdf b/Master/texmf-dist/doc/latex/l3kernel/source3.pdf Binary files differindex 733075f7d33..9bed9bc6374 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/source3.pdf +++ b/Master/texmf-dist/doc/latex/l3kernel/source3.pdf diff --git a/Master/texmf-dist/doc/latex/l3kernel/source3.tex b/Master/texmf-dist/doc/latex/l3kernel/source3.tex index c415c61b375..0d1e8db2d90 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/source3.tex +++ b/Master/texmf-dist/doc/latex/l3kernel/source3.tex @@ -53,7 +53,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2019-04-06} +\date{Released 2019-04-21} \pagenumbering{roman} \maketitle diff --git a/Master/texmf-dist/doc/latex/l3kernel/source3body.tex b/Master/texmf-dist/doc/latex/l3kernel/source3body.tex index aa014771634..1efbed70800 100644 --- a/Master/texmf-dist/doc/latex/l3kernel/source3body.tex +++ b/Master/texmf-dist/doc/latex/l3kernel/source3body.tex @@ -2,7 +2,7 @@ File: source3body.tex -Copyright (C) 1990-2012,2014-2018 The LaTeX3 Project +Copyright (C) 1990-2012,2014-2019 The LaTeX3 Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -483,6 +483,17 @@ used on top of \LaTeXe{} if \cs{outer} tokens are used in the arguments. \DocInput{l3unicode.dtx} \DocInput{l3candidates.dtx} \DocInput{l3drivers.dtx} +\ExplSyntaxOn +\clist_gput_right:Nn \g_docinput_clist + { + l3drivers-basics.dtx , + l3drivers-color.dtx , + l3drivers-box.dtx , + l3drivers-draw.dtx , + l3drivers-image.dtx , + l3drivers-pdf.dtx + } +\ExplSyntaxOff \ExplSyntaxOn \clist_gput_right:Nn \g_docinput_clist { l3deprecation.dtx } diff --git a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx index 8d6c820b85a..09996096f79 100644 --- a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx @@ -23,7 +23,7 @@ % for those people who are interested. % %<*driver|generic|package> -\def\ExplFileDate{2019-04-06}% +\def\ExplFileDate{2019-04-21}% %</driver|generic|package> %<*driver> \documentclass[full]{l3doc} @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3.ins b/Master/texmf-dist/source/latex/l3kernel/l3.ins index 73132b1e222..2451257ac01 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3.ins +++ b/Master/texmf-dist/source/latex/l3kernel/l3.ins @@ -2,7 +2,7 @@ File l3.ins -Copyright (C) 2011,2012,2014-2018 The LaTeX3 Project +Copyright (C) 2011,2012,2014-2019 The LaTeX3 Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -115,11 +115,71 @@ and all files in that bundle must be distributed together. % not distributed: %\generate{\file{l3doc.ist} {\from{l3doc.dtx} {docist}}} -\generate{\file{l3dvipdfmx.def} {\from{l3drivers.dtx} {package,dvipdfmx} }} -\generate{\file{l3dvips.def} {\from{l3drivers.dtx} {package,dvips} }} -\generate{\file{l3dvisvgm.def} {\from{l3drivers.dtx} {package,dvisvgm} }} -\generate{\file{l3pdfmode.def} {\from{l3drivers.dtx} {package,pdfmode} }} -\generate{\file{l3xdvipdfmx.def} {\from{l3drivers.dtx} {package,xdvipdfmx}}} +\generate + { + \file{l3dvipdfmx.def} + { + \from{l3drivers.dtx} {package,dvipdfmx} + \from{l3drivers-basics.dtx}{package,dvipdfmx} + \from{l3drivers-color.dtx} {package,dvipdfmx} + \from{l3drivers-box.dtx} {package,dvipdfmx} + \from{l3drivers-draw.dtx} {package,dvipdfmx} + \from{l3drivers-image.dtx} {package,dvipdfmx} + \from{l3drivers-pdf.dtx} {package,dvipdfmx} + } + } +\generate + { + \file{l3dvips.def} + { + \from{l3drivers.dtx} {package,dvips} + \from{l3drivers-basics.dtx}{package,dvips} + \from{l3drivers-color.dtx} {package,dvips} + \from{l3drivers-box.dtx} {package,dvips} + \from{l3drivers-draw.dtx} {package,dvips} + \from{l3drivers-image.dtx} {package,dvips} + \from{l3drivers-pdf.dtx} {package,dvips} + } + } +\generate + { + \file{l3dvisvgm.def} + { + \from{l3drivers.dtx} {package,dvisvgm} + \from{l3drivers-basics.dtx}{package,dvisvgm} + \from{l3drivers-color.dtx} {package,dvisvgm} + \from{l3drivers-box.dtx} {package,dvisvgm} + \from{l3drivers-draw.dtx} {package,dvisvgm} + \from{l3drivers-image.dtx} {package,dvisvgm} + \from{l3drivers-pdf.dtx} {package,dvisvgm} + } + } +\generate + { + \file{l3pdfmode.def} + { + \from{l3drivers.dtx} {package,pdfmode} + \from{l3drivers-basics.dtx}{package,pdfmode} + \from{l3drivers-color.dtx} {package,pdfmode} + \from{l3drivers-box.dtx} {package,pdfmode} + \from{l3drivers-draw.dtx} {package,pdfmode} + \from{l3drivers-image.dtx} {package,pdfmode} + \from{l3drivers-pdf.dtx} {package,pdfmode} + } + } +\generate + { + \file{l3xdvipdfmx.def} + { + \from{l3drivers.dtx} {package,xdvipdfmx} + \from{l3drivers-basics.dtx}{package,xdvipdfmx} + \from{l3drivers-color.dtx} {package,xdvipdfmx} + \from{l3drivers-box.dtx} {package,xdvipdfmx} + \from{l3drivers-draw.dtx} {package,xdvipdfmx} + \from{l3drivers-image.dtx} {package,xdvipdfmx} + \from{l3drivers-pdf.dtx} {package,xdvipdfmx} + } + } \generate{\file{l3docstrip.tex} {\from{l3docstrip.dtx} {program}}} @@ -130,7 +190,7 @@ and all files in that bundle must be distributed together. \def\MetaPrefix{--} \preamble -Copyright (C) 1990-2017 The LaTeX3 Project +Copyright (C) 1990-2019 The LaTeX3 Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx b/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx index 483ad7d41ca..f47082f4cf9 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx index 788b00f36fa..b78dbe8c6fd 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3bootstrap.dtx b/Master/texmf-dist/source/latex/l3kernel/l3bootstrap.dtx index 9c9efc05026..09d82e7623a 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3bootstrap.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3bootstrap.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx index f65f9e45443..e8263234e22 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index 1ce35fdd7fd..f39ec112729 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx b/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx index 172fabac50f..d791282d867 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx b/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx index 7f6d327421f..f17be5ff627 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3color-base.dtx b/Master/texmf-dist/source/latex/l3kernel/l3color-base.dtx index 0c0f462765a..c958a571e2f 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3color-base.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3color-base.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx b/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx index 4039dc67336..08b49ce5eb0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx b/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx index 7a0cf4c9c1a..65080b66f0a 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx @@ -79,7 +79,7 @@ and all files in that bundle must be distributed together. % % \title{The \cls{l3doc} class} % \author{\Team} -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % \maketitle % \tableofcontents % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3docstrip.dtx b/Master/texmf-dist/source/latex/l3kernel/l3docstrip.dtx index ab16591782e..a16a7db57c7 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3docstrip.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3docstrip.dtx @@ -63,7 +63,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers-basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers-basics.dtx new file mode 100644 index 00000000000..382e2d735f9 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers-basics.dtx @@ -0,0 +1,354 @@ +% \iffalse meta-comment +% +%% File: l3drivers-basics.dtx +% +% Copyright (C) 2011-2019 The LaTeX3 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 "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full,kernel]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3drivers-basics} package\\ Driver basics^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-04-21} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3drivers-basics} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=driver> +% \end{macrocode} +% +% Whilst there is a reasonable amount of code overlap between drivers, +% it is much clearer to have the blocks more-or-less separated than run +% in together and DocStripped out in parts. As such, most of the following +% is set up on a per-driver basis, though there is some common code (again +% given in blocks not interspersed with other material). +% +% All the file identifiers are up-front so that they come out in the right +% place in the files. +% \begin{macrocode} +%<*package> +\ProvidesExplFile +%<*dvipdfmx> + {l3dvipdfmx.def}{2019-04-06}{} + {L3 Experimental driver: dvipdfmx} +%</dvipdfmx> +%<*dvips> + {l3dvips.def}{2019-04-06}{} + {L3 Experimental driver: dvips} +%</dvips> +%<*dvisvgm> + {l3dvisvgm.def}{2019-04-06}{} + {L3 Experimental driver: dvisvgm} +%</dvisvgm> +%<*pdfmode> + {l3pdfmode.def}{2019-04-06}{} + {L3 Experimental driver: PDF mode} +%</pdfmode> +%<*xdvipdfmx> + {l3xdvipdfmx.def}{2019-04-06}{} + {L3 Experimental driver: xdvipdfmx} +%</xdvipdfmx> +%</package> +% \end{macrocode} +% +% The order of the driver code here is such that we get somewhat logical +% outcomes in terms of code sharing whilst keeping things readable. (Trying to +% mix all of the code by concept is almost unmanageable.) The key parts which +% are shared are +% \begin{itemize} +% \item Color support is either \texttt{dvips}-like or \texttt{pdfmode}-like. +% \item \texttt{pdfmode} and \texttt{(x)dvipdfmx} share drawing routines. +% \item \texttt{xdvipdfmx} is largely the same as \texttt{dvipdfmx} so +% takes most of the same code. +% \end{itemize} +% +% \begin{macro}{\@@_literal:e, \@@_literal:n, \@@_literal:x} +% The one shared function for all drivers is access to the basic +% \tn{special} primitive: it has slightly odd expansion behaviour +% so a wrapper is provided. +% \begin{macrocode} +\cs_new_eq:NN \@@_literal:e \tex_special:D +\cs_new_protected:Npn \@@_literal:n #1 + { \@@_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \@@_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \subsection{\texttt{dvips} driver} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_literal_postscript:n, \@@_literal_postscript:x} +% Literal PostScript can be included using a few low-level formats. Here, +% we use the form with no positioning: this is overall more convenient as +% a wrapper. Note that this does require that where position is important, +% an appropriate wrapper is included. +% \begin{macrocode} +\cs_new_protected:Npn \@@_literal_postscript:n #1 + { \@@_literal:n { ps:: #1 } } +\cs_generate_variant:Nn \@@_literal_postscript:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_postscript:n, \@@_postscript:x} +% PostScript data that does have positioning, and also applying +% a shift to |SDict| (which is not done automatically by +% |ps:| or |ps::|, in contrast to |!| or |"|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_postscript:n #1 + { \@@_literal:n { ps: SDict ~ begin ~ #1 ~ end } } +\cs_generate_variant:Nn \@@_postscript:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_postscript_header:n} +% PostScript for the header: a small saving but makes the code clearer. +% \begin{macrocode} +\cs_new_protected:Npn \@@_postscript_header:n #1 + { \@@_literal:n { ! #1 } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_align_currentpoint_begin:, \@@_align_currentpoint_end:} +% In \texttt{dvips} there is no build-in saving of the current +% position, and so some additional PostScript is required to set up the +% transformation matrix and also to restore it afterwards. Notice the use +% of the stack to save the current position \enquote{up front} and to +% move back to it at the end of the process. Notice that the |[begin]|/^^A +% |[end]| pair here mean that we can use a run of PostScript statements +% in separate lines: not \emph{required} but does make the code and +% output more clear. +% \begin{macrocode} +\cs_new_protected:Npn \@@_align_currentpoint_begin: + { + \@@_literal:n { ps::[begin] } + \@@_literal_postscript:n { currentpoint } + \@@_literal_postscript:n { currentpoint~translate } + } +\cs_new_protected:Npn \@@_align_currentpoint_end: + { + \@@_literal_postscript:n { neg~exch~neg~exch~translate } + \@@_literal:n { ps::[end] } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} +% Saving/restoring scope for general operations needs to be done with +% \texttt{dvips} positioning (try without to see this!). Thus we need the +% |ps:| version of the special here. As only the graphics state is ever +% altered within this pairing, we use the lower-cost |g|-versions. +% \begin{macrocode} +\cs_new_protected:Npn \@@_scope_begin: + { \@@_literal:n { ps:gsave } } +\cs_new_protected:Npn \@@_scope_end: + { \@@_literal:n { ps:grestore } } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} driver} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% The direct PDF driver covers both \pdfTeX{} and \LuaTeX{}. The latter +% renames and restructures the driver primitives but this can be handled +% at one level of abstraction. As such, we avoid using two separate drivers +% for this material at the cost of some \texttt{x}-type definitions to get +% everything expanded up-front. +% +% \begin{macro}{\@@_literal_pdf:n, \@@_literal_pdf:x} +% This is equivalent to \verb|\special{pdf:}| but the engine can +% track it. Without the \texttt{direct} keyword everything is kept in +% sync: the transformation matrix is set to the current point automatically. +% Note that this is still inside the text (\texttt{BT} \dots \texttt{ET} +% block). +% \begin{macrocode} +\cs_new_protected:Npx \@@_literal_pdf:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D literal } + { \tex_pdfliteral:D } + { \exp_not:N \exp_not:n {#1} } + } +\cs_generate_variant:Nn \@@_literal_pdf:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} +% Higher-level interfaces for saving and restoring the graphic state. +% \begin{macrocode} +\cs_new_protected:Npx \@@_scope_begin: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D save \scan_stop: } + { \tex_pdfsave:D } + } +\cs_new_protected:Npx \@@_scope_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D restore \scan_stop: } + { \tex_pdfrestore:D } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_matrix:n, \@@_matrix:x} +% Here the appropriate function is set up to insert an affine matrix +% into the PDF. With \pdfTeX{} and \LuaTeX{} in direct PDF output mode there +% is a primitive for this, which only needs the rotation/scaling/skew part. +% \begin{macrocode} +\cs_new_protected:Npx \@@_matrix:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D setmatrix } + { \tex_pdfsetmatrix:D } + { \exp_not:N \exp_not:n {#1} } + } +\cs_generate_variant:Nn \@@_matrix:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} driver} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% The \texttt{dvipdfmx} shares code with the PDF mode one (using the common +% section to this file) but also with \texttt{xdvipdfmx}. The latter is close +% to identical to \texttt{dvipdfmx} and so all of the code here is extracted +% for both drivers, with some \texttt{clean up} for \texttt{xdvipdfmx} as +% required. +% +% \begin{macro}{\@@_literal_pdf:n, \@@_literal_pdf:x} +% Equivalent to \texttt{pdf:content} but favored as the link to +% the \pdfTeX{} primitive approach is clearer. +% \begin{macrocode} +\cs_new_protected:Npn \@@_literal_pdf:n #1 + { \@@_literal:n { pdf:literal~ #1 } } +\cs_generate_variant:Nn \@@_literal_pdf:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} +% Scoping is done using the driver-specific specials. +% \begin{macrocode} +\cs_new_protected:Npn \@@_scope_begin: + { \@@_literal:n { x:gsave } } +\cs_new_protected:Npn \@@_scope_end: + { \@@_literal:n { x:grestore } } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} driver} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\@@_literal_svg:n, \@@_literal_svg:x} +% Unlike the other drivers, the requirements for making SVG files mean +% that we can't conveniently transform all operations to the current point. +% That makes life a bit more tricky later as that needs to be accounted for. +% A new line is added after each call to help to keep the output readable +% for debugging. +% \begin{macrocode} +\cs_new_protected:Npn \@@_literal_svg:n #1 + { \@@_literal:n { dvisvgm:raw~ #1 { ?nl } } } +\cs_generate_variant:Nn \@@_literal_svg:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} +% A scope in SVG terms is slightly different to the other drivers as +% operations have to be \enquote{tied} to these not simply inside them. +% \begin{macrocode} +\cs_new_protected:Npn \@@_scope_begin: + { \@@_literal_svg:n { <g> } } +\cs_new_protected:Npn \@@_scope_end: + { \@@_literal_svg:n { </g> } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_scope_begin:n, \@@_scope_begin:x} +% In SVG transformations, clips and so on are attached directly to scopes so +% we need a way or allowing for that. This is rather more useful than +% \cs{@@_scope_begin:} as a result. No assumptions are made about the nature +% of the scoped operation(s). +% \begin{macrocode} +\cs_new_protected:Npn \@@_scope_begin:n #1 + { \@@_literal_svg:n { <g~ #1 > } } +\cs_generate_variant:Nn \@@_scope_begin:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvisvgm> +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers-box.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers-box.dtx new file mode 100644 index 00000000000..f9bd0afad7c --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers-box.dtx @@ -0,0 +1,473 @@ +% \iffalse meta-comment +% +%% File: l3drivers-box.dtx +% +% Copyright (C) 2011-2019 The LaTeX3 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 "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full,kernel]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3drivers-box} package\\ Driver box support^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-04-21} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3drivers-box} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=driver> +% \end{macrocode} +% +% \subsection{\texttt{dvips} driver} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\driver_box_use_clip:N} +% The \texttt{dvips} driver scales all absolute dimensions based on the +% output resolution selected and any \TeX{} magnification. Thus for any +% operation involving absolute lengths there is a correction to make. See +% \texttt{normalscale} from \texttt{special.pro} for the variables, noting +% that here everything is saved on the stack rather than as a separate +% variable. Once all of that is done, the actual clipping is trivial. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_clip:N #1 + { + \@@_scope_begin: + \@@_align_currentpoint_begin: + \@@_literal_postscript:n { matrix~currentmatrix } + \@@_literal_postscript:n + { Resolution~72~div~VResolution~72~div~scale } + \@@_literal_postscript:n { DVImag~dup~scale } + \@@_literal_postscript:x + { + 0 ~ + \dim_to_decimal_in_bp:n { \box_dp:N #1 } ~ + \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ + \dim_to_decimal_in_bp:n { -\box_ht:N #1 - \box_dp:N #1 } ~ + rectclip + } + \@@_literal_postscript:n { setmatrix } + \@@_align_currentpoint_end: + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_box_use_rotate:Nn} +% \begin{macro}{\@@_box_use_rotate:Nn} +% Rotating using \texttt{dvips} does not require that the box dimensions +% are altered and has a very convenient built-in operation. Zero rotation +% must be written as |0| not |-0| so there is a quick test. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 + { \exp_args:NNf \@@_box_use_rotate:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 + { + \@@_scope_begin: + \@@_align_currentpoint_begin: + \@@_literal_postscript:x + { + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -(#2) , 5 ) } } ~ + rotate + } + \@@_align_currentpoint_end: + \box_use:N #1 + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_box_use_scale:Nnn} +% The \texttt{dvips} driver once again has a dedicated operation we can +% use here. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 + { + \@@_scope_begin: + \@@_align_currentpoint_begin: + \@@_literal_postscript:x + { + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } ~ + scale + } + \@@_align_currentpoint_end: + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} driver} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \begin{macro}{\driver_box_use_clip:N} +% The general method is to save the current location, define a clipping path +% equivalent to the bounding box, then insert the content at the current +% position and in a zero width box. The \enquote{real} width is then made up +% using a horizontal skip before tidying up. There are other approaches that +% can be taken (for example using XForm objects), but the logic here shares +% as much code as possible and uses the same conversions (and so same +% rounding errors) in all cases. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_clip:N #1 + { + \@@_scope_begin: + \@@_literal_pdf:x + { + 0~ + \dim_to_decimal_in_bp:n { -\box_dp:N #1 } ~ + \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ + \dim_to_decimal_in_bp:n { \box_ht:N #1 + \box_dp:N #1 } ~ + re~W~n + } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_box_use_rotate:Nn} +% \begin{macro}{\@@_box_use_rotate:Nn} +% \begin{variable}{\l_@@_cos_fp, \l_@@_sin_fp} +% Rotations are set using an affine transformation matrix which therefore +% requires sine/cosine values not the angle itself. We store the rounded +% values to avoid rounding twice. There are also a couple of comparisons to +% ensure that |-0| is not written to the output, as this avoids any issues +% with problematic display programs. Note that numbers are compared to~$0$ +% after rounding. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 + { \exp_args:NNf \@@_box_use_rotate:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 + { + \@@_scope_begin: + \box_set_wd:Nn #1 { 0pt } + \fp_set:Nn \l_@@_cos_fp { round ( cosd ( #2 ) , 5 ) } + \fp_compare:nNnT \l_@@_cos_fp = \c_zero_fp + { \fp_zero:N \l_@@_cos_fp } + \fp_set:Nn \l_@@_sin_fp { round ( sind ( #2 ) , 5 ) } + \@@_matrix:x + { + \fp_use:N \l_@@_cos_fp \c_space_tl + \fp_compare:nNnTF \l_@@_sin_fp = \c_zero_fp + { 0~0 } + { + \fp_use:N \l_@@_sin_fp + \c_space_tl + \fp_eval:n { -\l_@@_sin_fp } + } + \c_space_tl + \fp_use:N \l_@@_cos_fp + } + \box_use:N #1 + \@@_scope_end: + } +\fp_new:N \l_@@_cos_fp +\fp_new:N \l_@@_sin_fp +% \end{macrocode} +% \end{variable} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_box_use_scale:Nnn} +% The same idea as for rotation but without the complexity of signs and +% cosines. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 + { + \@@_scope_begin: + \@@_matrix:x + { + \fp_eval:n { round ( #2 , 5 ) } ~ + 0~0~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} driver} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro}{\driver_box_use_clip:N} +% The code here is identical to that for \texttt{pdfmode}: unlike rotation and +% scaling, there is no higher-level support in the driver for clipping. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_clip:N #1 + { + \@@_scope_begin: + \@@_literal_pdf:x + { + 0~ + \dim_to_decimal_in_bp:n { -\box_dp:N #1 } ~ + \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ + \dim_to_decimal_in_bp:n { \box_ht:N #1 + \box_dp:N #1 } ~ + re~W~n + } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_box_use_rotate:Nn} +% \begin{macro}{\@@_box_use_rotate:Nn} +% Rotating in \texttt{(x)}dvipdmfx can be implemented using either PDF or +% driver-specific code. The former approach however is not \enquote{aware} +% of the content of boxes: this means that any embedded links would not be +% adjusted by the rotation. As such, the driver-native approach is preferred: +% the code therefore is similar (though not identical) to the \texttt{dvips} +% version (notice the rotation angle here is positive). As for +% \texttt{dvips}, zero rotation is written as |0| not |-0|. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 + { \exp_args:NNf \@@_box_use_rotate:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 + { + \@@_scope_begin: + \@@_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( #2 , 5 ) } } + } + \box_use:N #1 + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_box_use_scale:Nnn} +% Much the same idea for scaling: use the higher-level driver operation to allow +% for box content. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 + { + \@@_scope_begin: + \@@_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} driver} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\driver_box_use_clip:N} +% \begin{variable}{\g_@@_clip_path_int} +% Clipping in SVG is more involved than with other drivers. The first issue +% is that the clipping path must be defined separately from where it is used, +% so we need to track how many paths have applied. The naming here uses +% \texttt{l3cp} as the namespace with a number following. Rather than use +% a rectangular operation, we define the path manually as this allows it to +% have a depth: easier than the alternative approach of shifting content +% up and down using scopes to allow for the depth of the \TeX{} box and +% keep the reference point the same! +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_clip:N #1 + { + \int_gincr:N \g_@@_clip_path_int + \@@_literal_svg:x + { < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > } + \@@_literal_svg:x + { + < + path ~ d = + " + M ~ 0 ~ + \dim_to_decimal:n { -\box_dp:N #1 } ~ + L ~ \dim_to_decimal:n { \box_wd:N #1 } ~ + \dim_to_decimal:n { -\box_dp:N #1 } ~ + L ~ \dim_to_decimal:n { \box_wd:N #1 } ~ + \dim_to_decimal:n { \box_ht:N #1 + \box_dp:N #1 } ~ + L ~ 0 ~ + \dim_to_decimal:n { \box_ht:N #1 + \box_dp:N #1 } ~ + Z + " + /> + } + \@@_literal_svg:n + { < /clipPath > } +% \end{macrocode} +% In general the SVG set up does not try to transform coordinates to the +% current point. For clipping we need to do that, so have a transformation +% here to get us to the right place, and a matching one just before the +% \TeX{} box is inserted to get things back on track. The clip path needs to +% come between those two such that if lines up with the current point, as +% does the \TeX{} box. +% \begin{macrocode} + \@@_scope_begin:n + { + transform = + " + translate ( { ?x } , { ?y } ) ~ + scale ( 1 , -1 ) + " + } + \@@_scope_begin:x + { + clip-path = + "url ( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int ) " + } + \@@_scope_begin:n + { + transform = + " + scale ( -1 , 1 ) ~ + translate ( { ?x } , { ?y } ) ~ + scale ( -1 , -1 ) + " + } + \box_use:N #1 + \@@_scope_end: + \@@_scope_end: + \@@_scope_end: +% \skip_horizontal:n { \box_wd:N #1 } + } +\int_new:N \g_@@_clip_path_int +% \end{macrocode} +% \end{variable} +% \end{macro} +% +% \begin{macro}{\driver_box_use_rotate:Nn} +% Rotation has a dedicated operation which includes a centre-of-rotation +% optional pair. That can be picked up from the driver syntax, so there is +% no need to worry about the transformation matrix. +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 + { + \@@_scope_begin:x + { + transform = + " + rotate + ( \fp_eval:n { round ( -(#2) , 5 ) } , ~ { ?x } , ~ { ?y } ) + " + } + \box_use:N #1 + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_box_use_scale:Nnn} +% In contrast to rotation, we have to account for the current position in this +% case. That is done using a couple of translations in addition to the scaling +% (which is therefore done backward with a flip). +% \begin{macrocode} +\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 + { + \@@_scope_begin:x + { + transform = + " + translate ( { ?x } , { ?y } ) ~ + scale + ( + \fp_eval:n { round ( -#2 , 5 ) } , + \fp_eval:n { round ( -#3 , 5 ) } + ) ~ + translate ( { ?x } , { ?y } ) ~ + scale ( -1 ) + " + } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvisvgm> +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers-color.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers-color.dtx new file mode 100644 index 00000000000..0f17e011368 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers-color.dtx @@ -0,0 +1,307 @@ +% \iffalse meta-comment +% +%% File: l3drivers-color.dtx +% +% Copyright (C) 2011-2019 The LaTeX3 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 "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full,kernel]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3drivers-color} package\\ Driver color support^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-04-21} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3drivers-color} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=driver> +% \end{macrocode} +% +% Color support is split into two parts: a \enquote{general} concept and +% one directly linked to drawings (or rather the split between filling +% and stroking). General color is relatively easy to handle: we have a color +% stack available with all modern drivers, and can use that.% +% Whilst \texttt{(x)dvipdfmx} does have its own approach to color specials, +% it is easier to use \texttt{dvips}-like ones for all cases except direct +% PDF output. +% +% \subsection{\texttt{dvips}-style} +% +% \begin{macrocode} +%<*dvisvgm|dvipdfmx|dvips|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro}{\driver_color_pickup:N} +% \begin{macro}{\@@_color_pickup:w} +% Allow for \LaTeXe{} color. Here, the possible input values are limited: +% \texttt{dvips}-style colors can mainly be taken as-is with the exception +% spot ones (here we need a model and a tint). +% \begin{macrocode} +%<*package> +\cs_new_protected:Npn \driver_color_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \driver_color_pickup:N #1 + { + \exp_args:NV \tl_if_head_is_space:nTF \current@color + { + \tl_set:Nx #1 + { + spot ~ + \exp_after:wN \use:n \current@color \c_space_tl 1 + } + } + { + \exp_last_unbraced:Nx \@@_color_pickup:w + { \current@color } \q_stop #1 + } + } + \cs_new_protected:Npn \@@_color_pickup:w #1 ~ #2 \q_stop #3 + { \tl_set:Nn #3 { #1 ~ #2 } } + } + { } + } +%</package> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_color_cmyk:nnnn} +% \begin{macro}{\driver_color_gray:n} +% \begin{macro}{\driver_color_rgb:nnn} +% \begin{macro}{\driver_color_spot:nn} +% \begin{macro}{\@@_color_select:n, \@@_color_select:x} +% \begin{macro}{\@@_color_reset:} +% \begin{macro}{driver.fc} +% Push the data to the stack. In the case of \texttt{dvips} also reset the +% drawing fill color in raw PostScript. +% \begin{macrocode} +\cs_new_protected:Npn \driver_color_cmyk:nnnn #1#2#3#4 + { + \@@_color_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \driver_color_gray:n #1 + { \@@_color_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \driver_color_rgb:nnn #1#2#3 + { + \@@_color_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \driver_color_spot:nn #1#2 + { \@@_color_select:n { #1 } } +\cs_new_protected:Npn \@@_color_select:n #1 + { + \@@_literal:n { color~push~ #1 } +%<*dvips> + \@@_postscript:n { /driver.fc~{ }~def } +%</dvips> + \group_insert_after:N \@@_color_reset: + } +\cs_generate_variant:Nn \@@_color_select:n { x } +\cs_new_protected:Npn \@@_color_reset: + { \@@_literal:n { color~pop } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</dvisvgm|dvipdfmx|dvips|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode}} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \begin{macro}{\driver_color_pickup:N} +% \begin{macro}{\@@_color_pickup:w} +% The current color in driver-dependent format: pick up the package-mode +% data if available. We end up converting back and forward in this route as +% we store our color data in \texttt{dvips} format. +% The \tn{current@color} needs to be \texttt{x}-expanded before +% \cs{@@_color_pickup:w} breaks it apart, because for instance +% \pkg{xcolor} sets it to be instructions to generate a colour +% \begin{macrocode} +%<*package> +\cs_new_protected:Npn \driver_color_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \driver_color_pickup:N #1 + { + \exp_last_unbraced:Nx \@@_color_pickup:w + { \current@color } ~ 0 ~ 0 ~ 0 \q_stop #1 + } + \cs_new_protected:Npn \@@_color_pickup:w + #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \q_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 } } + { + \str_if_eq:nnTF {#2} { cs } + { + \tl_set:Nx #7 { spot ~ \use_none:n #1 ~ #5 } + } + { + \tl_set:Nn #7 { gray ~ 0 } + } + } + } + } + } + } + { } + } +%</package> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{variable}{\l_@@_color_stack_int} +% \pdfTeX{} and \LuaTeX{} have multiple stacks available, and to track +% which one is in use a variable is required. +% \begin{macrocode} +\int_new:N \l_@@_color_stack_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_color_cmyk:nnnn, \@@_color_cmyk:nnnn} +% \begin{macro}{\driver_color_gray:n, \@@_color_gray:n} +% \begin{macro}{\driver_color_rgb:nnn, \@@_color_rgb:nnn} +% \begin{macro}{\driver_color_spot:nn} +% \begin{macro}{\@@_color_select:n, \@@_color_select:x} +% \begin{macro}{\@@_color_reset:} +% Simply dump the data, but allowing for \LuaTeX{}. +% \begin{macrocode} +\cs_new_protected:Npn \driver_color_cmyk:nnnn #1#2#3#4 + { + \use:x + { + \@@_color_cmyk:nnnn + { \fp_eval:n {#1} } + { \fp_eval:n {#2} } + { \fp_eval:n {#3} } + { \fp_eval:n {#4} } + } + } +\cs_new_protected:Npn \@@_color_cmyk:nnnn #1#2#3#4 + { + \@@_color_select:n + { #1 ~ #2 ~ #3 ~ #4 ~ k ~ #1 ~ #2 ~ #3 ~ #4 ~ K } + } +\cs_new_protected:Npn \driver_color_gray:n #1 + { \exp_args:Nx \@@_color_gray:n { \fp_eval:n {#1} } } +\cs_new_protected:Npn \@@_color_gray:n #1 + { \@@_color_select:n { #1 ~ g ~ #1 ~ G } } +\cs_new_protected:Npn \driver_color_rgb:nnn #1#2#3 + { + \use:x + { + \@@_color_rgb:nnn + { \fp_eval:n {#1} } + { \fp_eval:n {#2} } + { \fp_eval:n {#3} } + } + } +\cs_new_protected:Npn \@@_color_rgb:nnn #1#2#3 + { \@@_color_select:n { #1 ~ #2 ~ #3 ~ rg ~ #1 ~ #2 ~ #3 ~ RG } } +\cs_new_protected:Npn \driver_color_spot:nn #1#2 + { \@@_color_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ sc ~ #2 ~ SC } } +\cs_new_protected:Npx \@@_color_select:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l_@@_color_stack_int push {#1} + \group_insert_after:N \exp_not:N \@@_color_reset: + } +\cs_generate_variant:Nn \@@_color_select:n { x } +\cs_new_protected:Npx \@@_color_reset: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l_@@_color_stack_int pop \scan_stop: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers-draw.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers-draw.dtx new file mode 100644 index 00000000000..6e6be61890b --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers-draw.dtx @@ -0,0 +1,1338 @@ +% \iffalse meta-comment +% +%% File: l3drivers-draw.dtx +% +% Copyright (C) 2011-2019 The LaTeX3 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 "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full,kernel]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3drivers-draw} package\\ Driver drawing support^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-04-21} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3drivers-draw} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=driver> +% \end{macrocode} +% +% \subsection{\texttt{dvips} driver} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_draw_literal:n, \@@_draw_literal:x} +% The same as literal PostScript: same arguments about positioning apply +% her. +% \begin{macrocode} +\cs_new_eq:NN \@@_draw_literal:n \@@_literal_postscript:n +\cs_generate_variant:Nn \@@_draw_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_begin:, \driver_draw_end:} +% \begin{macro}{driver.fc} +% The |ps::[begin]| special here deals with positioning but allows us to +% continue on to a matching |ps::[end]|: contrast with |ps:|, which positions +% but where we can't split material between separate calls. The +% |@beginspecial|/|@endspecial| pair are from |special.pro| and correct the +% scale and $y$-axis direction. The definition of |/driver.fc| deals with fill +% color in paths. In contrast to \pkg{pgf}, we don't save the current point: +% discussion with Tom Rokici suggested a better way to handle the necessary +% translations (see \cs{driver_draw_box_use:Nnnnn}). (Note that +% |@beginspecial|/|@endspecial| forms a driver scope.) The |[begin]|/^^A +% |[end]| lines are handled differently from the rest as they are +% conceptually different: not really drawing literals but instructions to +% \texttt{dvips} itself. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_begin: + { + \@@_literal:n { ps::[begin] } + \@@_draw_literal:n { @beginspecial } + \@@_darw_literal:n { SDict ~ begin ~ /driver.fc ~ { } ~ def ~ end } + } +\cs_new_protected:Npn \driver_draw_end: + { + \@@_draw_literal:n { @endspecial } + \@@_literal:n { ps::[end] } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_scope_begin:, \driver_draw_scope_end:} +% Scope here may need to contain saved definitions, so the entire memory +% rather than just the graphic state has to be sent to the stack. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_scope_begin: + { \@@_draw_literal:n { save } } +\cs_new_protected:Npn \driver_draw_scope_end: + { \@@_draw_literal:n { restore } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_moveto:nn, \driver_draw_lineto:nn} +% \begin{macro}{\driver_draw_rectangle:nnnn} +% \begin{macro}{\driver_draw_curveto:nnnnnn} +% Path creation operations mainly resolve directly to PostScript primitive +% steps, with only the need to convert to \texttt{bp}. Notice that +% \texttt{x}-type expansion is included here to ensure that any variable +% values are forced to literals before any possible caching. There is +% no native rectangular path command (without also clipping, filling or +% stroking), so that task is done using a small amount of PostScript. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 + { + \@@_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ + \dim_to_decimal_in_bp:n {#2} ~ moveto + } + } +\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 + { + \@@_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ + \dim_to_decimal_in_bp:n {#2} ~ lineto + } + } +\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 + { + \@@_draw_literal:x + { + \dim_to_decimal_in_bp:n {#4} ~ \dim_to_decimal_in_bp:n {#3} ~ + \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ + moveto~dup~0~rlineto~exch~0~exch~rlineto~neg~0~rlineto~closepath + } + } +\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 + { + \@@_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ + \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ + \dim_to_decimal_in_bp:n {#5} ~ \dim_to_decimal_in_bp:n {#6} ~ + curveto + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_evenodd_rule:, \driver_draw_nonzero_rule:} +% \begin{variable}{\g_@@_draw_eor_bool} +% The even-odd rule here can be implemented as a simply switch. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_evenodd_rule: + { \bool_gset_true:N \g_@@_draw_eor_bool } +\cs_new_protected:Npn \driver_draw_nonzero_rule: + { \bool_gset_false:N \g_@@_draw_eor_bool } +\bool_new:N \g_@@_draw_eor_bool +% \end{macrocode} +% \end{variable} +% \end{macro} +% +% \begin{macro} +% { +% \driver_draw_closepath: , +% \driver_draw_stroke: , +% \driver_draw_closestroke: , +% \driver_draw_fill: , +% \driver_draw_fillstroke: , +% \driver_draw_clip: , +% \driver_draw_discardpath: +% } +% \begin{variable}{\g_@@_draw_clip_bool} +% Unlike PDF, PostScript doesn't track separate colors for strokes and other +% elements. It is also desirable to have the |clip| keyword after a stroke or +% fill. To achieve those outcomes, there is some work to do. For color, the +% stoke color is simple but the fill one has to be inserted by hand. For +% clipping, the required ordering is achieved using a \TeX{} switch. All of +% the operations end with a new path instruction as they do not terminate +% (again in contrast to PDF). +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_closepath: + { \@@_draw_literal:n { closepath } } +\cs_new_protected:Npn \driver_draw_stroke: + { + \@@_draw_literal:n { stroke } + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_draw_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_draw_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +\cs_new_protected:Npn \driver_draw_closestroke: + { + \driver_draw_closepath: + \driver_draw_stroke: + } +\cs_new_protected:Npn \driver_draw_fill: + { + \@@_draw_literal:n { gsave } + \@@_draw_literal:n { driver.fc } + \@@_draw_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + fill + } + \@@_draw_literal:n { grestore } + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_draw_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_draw_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +\cs_new_protected:Npn \driver_draw_fillstroke: + { + \@@_draw_literal:n { gsave } + \@@_draw_literal:n { driver.fc } + \@@_draw_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + fill + } + \@@_draw_literal:n { grestore } + \@@_draw_literal:n { stroke } + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_draw_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_draw_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +\cs_new_protected:Npn \driver_draw_clip: + { \bool_gset_true:N \g_@@_draw_clip_bool } +\bool_new:N \g_@@_draw_clip_bool +\cs_new_protected:Npn \driver_draw_discardpath: + { + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_draw_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_draw_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +% \end{macrocode} +% \end{variable} +% \end{macro} +% +% \begin{macro}{\driver_draw_dash_pattern:nn} +% \begin{macro}{\@@_draw_dash:n} +% \begin{macro}{\driver_draw_linewidth:n} +% \begin{macro}{\driver_draw_miterlimit:n} +% \begin{macro} +% { +% \driver_draw_cap_butt:, \driver_draw_cap_round:, \driver_draw_cap_rectangle:, +% \driver_draw_join_miter:, \driver_draw_join_round:, \driver_draw_join_bevel: +% } +% Converting paths to output is again a case of mapping directly to +% PostScript operations. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 + { + \@@_draw_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \@@_draw_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ setdash + } + } +\cs_new:Npn \@@_draw_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \driver_draw_linewidth:n #1 + { + \@@_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ setlinewidth } + } +\cs_new_protected:Npn \driver_draw_miterlimit:n #1 + { \@@_draw_literal:x { \fp_eval:n {#1} ~ setmiterlimit } } +\cs_new_protected:Npn \driver_draw_cap_butt: + { \@@_draw_literal:n { 0 ~ setlinecap } } +\cs_new_protected:Npn \driver_draw_cap_round: + { \@@_draw_literal:n { 1 ~ setlinecap } } +\cs_new_protected:Npn \driver_draw_cap_rectangle: + { \@@_draw_literal:n { 2 ~ setlinecap } } +\cs_new_protected:Npn \driver_draw_join_miter: + { \@@_draw_literal:n { 0 ~ setlinejoin } } +\cs_new_protected:Npn \driver_draw_join_round: + { \@@_draw_literal:n { 1 ~ setlinejoin } } +\cs_new_protected:Npn \driver_draw_join_bevel: + { \@@_draw_literal:n { 2 ~ setlinejoin } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \driver_draw_color_fill_cmyk:nnnn , +% \driver_draw_color_stroke_cmyk:nnnn +% } +% \begin{macro} +% { +% \driver_draw_color_fill_gray:n , +% \driver_draw_color_stroke_gray:n +% } +% \begin{macro} +% { +% \driver_draw_color_fill_rgb:nnn , +% \driver_draw_color_stroke_rgb:nnn +% } +% \begin{macro} +% { +% \@@_draw_color_fill:n, \@@_draw_color_fill:x, +% \@@_draw_color_stroke:n, \@@_draw_color_stroke:x +% } +% For \texttt{dvips}, we can use the standard color stack to deal with +% stroke color, but for fills have to switch to raw PostScript. This is +% thus not handled by the stack, but the context is very restricted. See +% also how fills are implemented. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_color_fill_cmyk:nnnn #1#2#3#4 + { + \@@_draw_color_fill:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + setcmykcolor + } + } +\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 + { + \@@_draw_color_stroke:x + { + cmyk ~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \driver_draw_color_fill_gray:n #1 + { \@@_draw_color_fill:x { \fp_eval:n {#1} ~ setgray } } +\cs_new_protected:Npn \driver_draw_color_stroke_gray:n #1 + { \@@_draw_color_stroke:x { gray ~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \driver_draw_color_fill_rgb:nnn #1#2#3 + { + \@@_draw_color_fill:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ setrgbcolor } + } +\cs_new_protected:Npn \driver_draw_color_stroke_rgb:nnn #1#2#3 + { + \@@_draw_color_stroke:x + { rgb ~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \@@_draw_color_fill:n #1 + { \@@_postscript:n { SDict ~ begin ~ /driver.fc ~ { #1 } ~ def ~ end } } +\cs_generate_variant:Nn \@@_draw_color_fill:n { x } +\cs_new_protected:Npn \@@_draw_color_stroke:n #1 + { + \@@_literal:n { color~push~#1 } + \group_insert_after:N \@@_color_reset: + } +\cs_generate_variant:Nn \@@_draw_color_stroke:n { x } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_cm:nnnn} +% In \texttt{dvips}, keeping the transformations in line with the engine +% is unfortunately not possible for scaling and rotations: even if we +% decompose the matrix into those operations, there is still no driver +% tracking (\emph{cf.}~\texttt{(x)dvipdfmx}). Thus we take the shortest +% path available and simply dump the matrix as given. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 + { + \@@_draw_literal:n + { + [ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + 0 ~ 0 + ] ~ + concat + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_box_use:Nnnnn} +% Inside a picture |@beginspecial|/|@endspecial| are active, which is +% normally a good thing but means that the position and scaling would be off +% if the box was inserted directly. To deal with that, there are a number of +% possible approaches. The implementation here was suggested by Tom Rokici +% (author of \texttt{dvips}). We end the current special placement, then +% set the current point with a literal |[begin]|. As for general +% literals, we then use the stack to store the current point and move to +% it. To insert the required transformation, we have to flip the $y$-axis, +% once before and once after it. Then we get back to the \TeX{} reference +% point to insert our content. The clean up has to happen in the right +% places, hence the |[begin]|/|[end]| pair around |restore|. Finally, +% we can return to \enquote{normal} drawing mode. Notice that the set up +% here is very similar to that in \cs{@@_align_currentpoint_\ldots}, but +% the ordering of saving and restoring is different (intermixed). +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5 + { + \@@_draw_literal:n { @endspecial } + \@@_draw_literal:n { [end] } + \@@_draw_literal:n { [begin] } + \@@_draw_literal:n { save } + \@@_draw_literal:n { currentpoint } + \@@_draw_literal:n { currentpoint~translate } + \driver_draw_cm:nnnn { 1 } { 0 } { 0 } { -1 } + \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} + \driver_draw_cm:nnnn { 1 } { 0 } { 0 } { -1 } + \@@_draw_literal:n { neg~exch~neg~exch~translate } + \@@_draw_literal:n { [end] } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_draw_literal:n { [begin] } + \@@_draw_literal:n { restore } + \@@_draw_literal:n { [end] } + \@@_draw_literal:n { [begin] } + \@@_draw_literal:n { @beginspecial } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} and \texttt{(x)dvipdfmx}} +% +% Both \texttt{pdfmode} and \texttt{(x)dvipdfmx} directly produce PDF output +% and understand a shared set of specials for drawing commands. +% +% \begin{macrocode} +%<*dvipdfmx|pdfmode|xdvipdfmx> +% \end{macrocode} +% +% \subsubsection{Drawing} +% +% \begin{macro}{\@@_draw_literal:n, \@@_draw_literal:x} +% Pass data through using a dedicated interface. +% \begin{macrocode} +\cs_new_eq:NN \@@_draw_literal:n \@@_literal_pdf:n +\cs_generate_variant:Nn \@@_draw_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_begin:, \driver_draw_end:} +% No special requirements here, so simply set up a drawing scope. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_begin: + { \driver_draw_scope_begin: } +\cs_new_protected:Npn \driver_draw_end: + { \driver_draw_scope_end: } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_scope_begin:, \driver_draw_scope_end:} +% Use the driver-level scope mechanisms. +% \begin{macrocode} +\cs_new_eq:NN \driver_draw_scope_begin: \@@_scope_begin: +\cs_new_eq:NN \driver_draw_scope_end: \@@_scope_end: +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_moveto:nn, \driver_draw_lineto:nn} +% \begin{macro}{\driver_draw_curveto:nnnnnn} +% \begin{macro}{\driver_draw_rectangle:nnnn} +% Path creation operations all resolve directly to PDF primitive steps, with +% only the need to convert to \texttt{bp}. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 + { + \@@_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } + } +\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 + { + \@@_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } + } +\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 + { + \@@_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ + \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ + \dim_to_decimal_in_bp:n {#5} ~ \dim_to_decimal_in_bp:n {#6} ~ + c + } + } +\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 + { + \@@_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ + \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ + re + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_evenodd_rule:, \driver_draw_nonzero_rule:} +% \begin{variable}{\g_@@_draw_eor_bool} +% The even-odd rule here can be implemented as a simply switch. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_evenodd_rule: + { \bool_gset_true:N \g_@@_draw_eor_bool } +\cs_new_protected:Npn \driver_draw_nonzero_rule: + { \bool_gset_false:N \g_@@_draw_eor_bool } +\bool_new:N \g_@@_draw_eor_bool +% \end{macrocode} +% \end{variable} +% \end{macro} +% +% \begin{macro} +% { +% \driver_draw_closepath: , +% \driver_draw_stroke: , +% \driver_draw_closestroke: , +% \driver_draw_fill: , +% \driver_draw_fillstroke: , +% \driver_draw_clip: , +% \driver_draw_discardpath: +% } +% Converting paths to output is again a case of mapping directly to +% PDF operations. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_closepath: + { \@@_draw_literal:n { h } } +\cs_new_protected:Npn \driver_draw_stroke: + { \@@_draw_literal:n { S } } +\cs_new_protected:Npn \driver_draw_closestroke: + { \@@_draw_literal:n { s } } +\cs_new_protected:Npn \driver_draw_fill: + { + \@@_draw_literal:x + { f \bool_if:NT \g_@@_draw_eor_bool * } + } +\cs_new_protected:Npn \driver_draw_fillstroke: + { + \@@_draw_literal:x + { B \bool_if:NT \g_@@_draw_eor_bool * } + } +\cs_new_protected:Npn \driver_draw_clip: + { + \@@_draw_literal:x + { W \bool_if:NT \g_@@_draw_eor_bool * } + } +\cs_new_protected:Npn \driver_draw_discardpath: + { \@@_draw_literal:n { n } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_dash_pattern:nn} +% \begin{macro}{\@@_draw_dash:n} +% \begin{macro}{\driver_draw_linewidth:n} +% \begin{macro}{\driver_draw_miterlimit:n} +% \begin{macro} +% { +% \driver_draw_cap_butt:, \driver_draw_cap_round:, \driver_draw_cap_rectangle:, +% \driver_draw_join_miter:, \driver_draw_join_round:, \driver_draw_join_bevel: +% } +% Converting paths to output is again a case of mapping directly to +% PDF operations. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 + { + \@@_draw_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \@@_draw_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ d + } + } +\cs_new:Npn \@@_draw_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \driver_draw_linewidth:n #1 + { + \@@_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ w } + } +\cs_new_protected:Npn \driver_draw_miterlimit:n #1 + { \@@_draw_literal:x { \fp_eval:n {#1} ~ M } } +\cs_new_protected:Npn \driver_draw_cap_butt: + { \@@_draw_literal:n { 0 ~ J } } +\cs_new_protected:Npn \driver_draw_cap_round: + { \@@_draw_literal:n { 1 ~ J } } +\cs_new_protected:Npn \driver_draw_cap_rectangle: + { \@@_draw_literal:n { 2 ~ J } } +\cs_new_protected:Npn \driver_draw_join_miter: + { \@@_draw_literal:n { 0 ~ j } } +\cs_new_protected:Npn \driver_draw_join_round: + { \@@_draw_literal:n { 1 ~ j } } +\cs_new_protected:Npn \driver_draw_join_bevel: + { \@@_draw_literal:n { 2 ~ j } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \driver_draw_color_fill_cmyk:nnnn , +% \driver_draw_color_stroke_cmyk:nnnn +% } +% \begin{macro} +% { +% \driver_draw_color_fill_gray:n , +% \driver_draw_color_stroke_gray:n +% } +% \begin{macro} +% { +% \driver_draw_color_fill_rgb:nnn , +% \driver_draw_color_stroke_rgb:nnn +% } +% \begin{macro}{\@@_color_fill_select:n, \@@_color_fill_select:x} +% For the stroke color, all engines here can use the color stack to handle +% the setting. However, that is not the case for fill color: the stack in +% \texttt{(x)dvipdfmx} only covers one type of color. So we have to use +% different approaches for the two sets of engines. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_color_fill_cmyk:nnnn #1#2#3#4 + { + \@@_color_fill_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 + { + \@@_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \driver_draw_color_fill_gray:n #1 + { \@@_color_fill_select:x { \fp_eval:n {#1} ~ g } } +\cs_new_protected:Npn \driver_draw_color_stroke_gray:n #1 + { \@@_color_select:x { \fp_eval:n {#1} ~ G } } +\cs_new_protected:Npn \driver_draw_color_fill_rgb:nnn #1#2#3 + { + \@@_color_fill_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } + } +\cs_new_protected:Npn \driver_draw_color_stroke_rgb:nnn #1#2#3 + { + \@@_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } + } +%<*pdfmode> +\cs_new_eq:NN \@@_color_fill_select:n \@@_color_select:n +%</pdfmode> +%<*dvipdfmx|xdvipdfmx> +\cs_new_eq:NN \@@_color_fill_select:n \@@_draw_literal:n +%</dvipdfmx|xdvipdfmx> +\cs_generate_variant:Nn \@@_color_fill_select:n { x } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_cm:nnnn} +% \begin{macro}{\@@_draw_cm:nnnn} +% Another split here between \texttt{pdfmode} and \texttt{(x)dvipdfmx}. +% In the former, we have a direct method to maintain alignment: the driver +% can use a matrix itself. For \texttt{(x)dvipdfmx}, we can to decompose the +% matrix into rotations and a scaling, then use those operations as they +% are handled by the driver. (There is driver support for matrix operations in +% \texttt{(x)dvipdfmx}, but as a matched pair so not suitable for the +% \enquote{stand alone} transformation set up here.) +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 + { +%<*pdfmode> + \@@_matrix:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } +%</pdfmode> +%<*dvipdfmx|xdvipdfmx> + \@@_draw_cm_decompose:nnnnN {#1} {#2} {#3} {#4} + \@@_draw_cm:nnnn +%</dvipdfmx|xdvipdfmx> + } +%<*dvipdfmx|xdvipdfmx> +\cs_new_protected:Npn \@@_draw_cm:nnnn #1#2#3#4 + { + \@@_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#1} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#1 , 5 ) } } + } + \@@_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \@@_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#4} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#4 , 5 ) } } + } + } +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_draw_cm_decompose:nnnnN} +% \begin{macro} +% { +% \@@_draw_cm_decompose_auxi:nnnnN, +% \@@_draw_cm_decompose_auxii:nnnnN, +% \@@_draw_cm_decompose_auxiii:nnnnN, +% } +% Internally, transformations for drawing are tracked as a matrix. Not all +% engines provide a way of dealing with this: if we use a raw matrix, the +% engine looses track of positions (for example for hyperlinks), and this is +% not desirable. They do, however, allow us to track rotations and scalings. +% Luckily, we can decompose any (two-dimensional) matrix into two rotations +% and a single scaling: +% \[ +% \begin{bmatrix} +% A & B \\ C & D +% \end{bmatrix} +% = +% \begin{bmatrix} +% \cos\beta & \sin\beta \\ -\sin\beta & \cos\beta +% \end{bmatrix} +% \begin{bmatrix} +% w_{1} & 0 \\ 0 & w_{2} +% \end{bmatrix} +% \begin{bmatrix} +% \cos\gamma & \sin\gamma \\ -\sin\gamma & \cos\gamma +% \end{bmatrix} +% \] +% The parent matrix can be converted to +% \[ +% \begin{bmatrix} +% A & B \\ C & D +% \end{bmatrix} +% = +% \begin{bmatrix} +% E & H \\-H & E +% \end{bmatrix} +% + +% \begin{bmatrix} +% F & G \\ G & -F +% \end{bmatrix} +% \] +% From these, we can find that +% \begin{align*} +% \frac{w_{1} + w_{2}}{2} &= \sqrt{E^{2} + H^{2}} \\ +% \frac{w_{1} - w_{2}}{2} &= \sqrt{F^{2} + G^{2}} \\ +% \gamma - \beta &= \tan^{-1}(G/F) \\ +% \gamma + \beta &= \tan^{-1}(H/E) +% \end{align*} +% at which point we just have to do various pieces of re-arrangement to +% get all of the values. (See J.~Blinn, \emph{IEEE Comput.\ Graph.\ Appl.}, +% 1996, \textbf{16}, 82--88.) There is one wrinkle: the PostScript (and PDF) +% way of specifying a transformation matrix exchanges where one would +% normally expect $B$ and $C$ to be. +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +\cs_new_protected:Npn \@@_draw_cm_decompose:nnnnN #1#2#3#4#5 + { + \use:x + { + \@@_draw_cm_decompose_auxi:nnnnN + { \fp_eval:n { (#1 + #4) / 2 } } + { \fp_eval:n { (#1 - #4) / 2 } } + { \fp_eval:n { (#3 + #2) / 2 } } + { \fp_eval:n { (#3 - #2) / 2 } } + } + #5 + } +\cs_new_protected:Npn \@@_draw_cm_decompose_auxi:nnnnN #1#2#3#4#5 + { + \use:x + { + \@@_draw_cm_decompose_auxii:nnnnN + { \fp_eval:n { 2 * sqrt ( #1 * #1 + #4 * #4 ) } } + { \fp_eval:n { 2 * sqrt ( #2 * #2 + #3 * #3 ) } } + { \fp_eval:n { atand ( #3 , #2 ) } } + { \fp_eval:n { atand ( #4 , #1 ) } } + } + #5 + } +\cs_new_protected:Npn \@@_draw_cm_decompose_auxii:nnnnN #1#2#3#4#5 + { + \use:x + { + \@@_draw_cm_decompose_auxiii:nnnnN + { \fp_eval:n { ( #4 - #3 ) / 2 } } + { \fp_eval:n { ( #1 + #2 ) / 2 } } + { \fp_eval:n { ( #1 - #2 ) / 2 } } + { \fp_eval:n { ( #4 + #3 ) / 2 } } + } + #5 + } +\cs_new_protected:Npn \@@_draw_cm_decompose_auxiii:nnnnN #1#2#3#4#5 + { + \fp_compare:nNnTF { abs( #2 ) } > { abs ( #3 ) } + { #5 {#1} {#2} {#3} {#4} } + { #5 {#1} {#3} {#2} {#4} } + } +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_box_use:Nnnnn} +% Inserting a \TeX{} box transformed to the requested position and using +% the current matrix is done using a mixture of \TeX{} and low-level +% manipulation. The offset can be handled by \TeX{}, so only any rotation/^^A +% skew/scaling component needs to be done using the matrix operation. As this +% operation can never be cached, the scope is set directly not using the +% \texttt{draw} version. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5 + { + \@@_scope_begin: +%<*pdfmode> + \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} +%</pdfmode> +%<*dvipdfmx|xdvipdfmx> + \@@_literal:x + { + pdf:btrans~matrix~ + \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ + \fp_eval:n {#4} ~ \fp_eval:n {#5} ~ + 0 ~ 0 + } +%</dvipdfmx|xdvipdfmx> + \hbox_overlap_right:n { \box_use:N #1 } +%<*dvipdfmx|xdvipdfmx> + \@@_literal:n { pdf:etrans } +%</dvipdfmx|xdvipdfmx> + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|pdfmode|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} driver} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\@@_draw_literal:n, \@@_draw_literal:x} +% The same as the more general literal call. +% \begin{macrocode} +\cs_new_eq:NN \@@_draw_literal:n \@@_literal_svg:n +\cs_generate_variant:Nn \@@_draw_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_begin:, \driver_draw_end:} +% A drawing needs to be set up such that the co-ordinate system is +% translated. That is done inside a scope, which as described below +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_begin: + { + \driver_draw_scope_begin: + \@@_draw_scope:n { transform="translate({?x},{?y})~scale(1,-1)" } + } +\cs_new_protected:Npn \driver_draw_end: + { \driver_draw_scope_end: } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_scope_begin:, \driver_draw_scope_end:} +% \begin{macro}{\@@_draw_scope:n, \@@_draw_scope:x} +% \begin{variable}{\g_@@_draw_scope_int, \l_@@_draw_scope_int} +% Several settings that with other drivers are \enquote{stand alone} have +% to be given as part of a scope in SVG. As a result, there is a need to +% provide a mechanism to automatically close these extra scopes. That is +% done using a dedicated function and a pair of tracking variables. Within +% each graphics scope we use a global variable to do the work, with a group +% used to save the value between scopes. The result is that no direct action +% is needed when creating a scope. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_scope_begin: + { + \int_set_eq:NN + \l_@@_draw_scope_int + \g_@@_draw_scope_int + \group_begin: + \int_gzero:N \g_@@_draw_scope_int + } +\cs_new_protected:Npn \driver_draw_scope_end: + { + \prg_replicate:nn + { \g_@@_draw_scope_int } + { \@@_draw_literal:n { </g> } } + \group_end: + \int_gset_eq:NN + \g_@@_draw_scope_int + \l_@@_draw_scope_int + } +\cs_new_protected:Npn \@@_draw_scope:n #1 + { + \@@_draw_literal:n { <g~ #1 > } + \int_gincr:N \g_@@_draw_scope_int + } +\cs_generate_variant:Nn \@@_draw_scope:n { x } +\int_new:N \g_@@_draw_scope_int +\int_new:N \l_@@_draw_scope_int +% \end{macrocode} +% \end{variable} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_moveto:nn, \driver_draw_lineto:nn} +% \begin{macro}{\driver_draw_rectangle:nnnn} +% \begin{macro}{\driver_draw_curveto:nnnnnn} +% \begin{macro}{\@@_draw_add_to_path:n} +% \begin{variable}{\g_@@_draw_path_tl} +% Once again, some work is needed to get path constructs correct. Rather +% then write the values as they are given, the entire path needs to be +% collected up before being output in one go. For that we use a dedicated +% storage routine, which adds spaces as required. Since paths should +% be fully expanded there is no need to worry about the internal +% \texttt{x}-type expansion. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 + { + \@@_draw_add_to_path:n + { M ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } + } +\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 + { + \@@_draw_add_to_path:n + { L ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } + } +\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 + { + \@@_draw_add_to_path:n + { + M ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} + h ~ \dim_to_decimal:n {#3} ~ + v ~ \dim_to_decimal:n {#4} ~ + h ~ \dim_to_decimal:n { -#3 } ~ + Z + } + } +\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 + { + \@@_draw_add_to_path:n + { + C ~ + \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} ~ + \dim_to_decimal:n {#3} ~ \dim_to_decimal:n {#4} ~ + \dim_to_decimal:n {#5} ~ \dim_to_decimal:n {#6} + } + } +\cs_new_protected:Npn \@@_draw_add_to_path:n #1 + { + \tl_gset:Nx \g_@@_draw_path_tl + { + \g_@@_draw_path_tl + \tl_if_empty:NF \g_@@_draw_path_tl { \c_space_tl } + #1 + } + } +\tl_new:N \g_@@_draw_path_tl +% \end{macrocode} +% \end{variable} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_evenodd_rule:, \driver_draw_nonzero_rule:} +% The fill rules here have to be handled as scopes. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_evenodd_rule: + { \@@_draw_scope:n { fill-rule="evenodd" } } +\cs_new_protected:Npn \driver_draw_nonzero_rule: + { \@@_draw_scope:n { fill-rule="nonzero" } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_draw_path:n} +% \begin{macro} +% { +% \driver_draw_closepath: , +% \driver_draw_stroke: , +% \driver_draw_closestroke: , +% \driver_draw_fill: , +% \driver_draw_fillstroke: , +% \driver_draw_clip: , +% \driver_draw_discardpath: +% } +% \begin{variable}{\g_@@_draw_clip_bool} +% \begin{variable}{\g_@@_draw_path_int} +% Setting fill and stroke effects and doing clipping all has to be done using +% scopes. This means setting up the various requirements in a shared +% auxiliary which deals with the bits and pieces. Clipping paths are reused +% for path drawing: not essential but avoids constructing them twice. +% Discarding a path needs a separate function as it's not quite the same. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_closepath: + { \@@_draw_add_to_path:n { Z } } +\cs_new_protected:Npn \@@_draw_path:n #1 + { + \bool_if:NTF \g_@@_draw_clip_bool + { + \int_gincr:N \g_@@_clip_path_int + \@@_draw_literal:x + { + < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > + { ?nl } + <path~d=" \g_@@_draw_path_tl "/> { ?nl } + < /clipPath > { ? nl } + < + use~xlink:href = + "\c_hash_str l3path \int_use:N \g_@@_path_int " ~ + #1 + /> + } + \@@_draw_scope:x + { + clip-path = + "url( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int)" + } + } + { + \@@_draw_literal:x + { <path ~ d=" \g_@@_draw_path_tl " ~ #1 /> } + } + \tl_gclear:N \g_@@_draw_path_tl + \bool_gset_false:N \g_@@_draw_clip_bool + } +\int_new:N \g_@@_path_int +\cs_new_protected:Npn \driver_draw_stroke: + { \@@_draw_path:n { style="fill:none" } } +\cs_new_protected:Npn \driver_draw_closestroke: + { + \driver_draw_closepath: + \driver_draw_stroke: + } +\cs_new_protected:Npn \driver_draw_fill: + { \@@_draw_path:n { style="stroke:none" } } +\cs_new_protected:Npn \driver_draw_fillstroke: + { \@@_draw_path:n { } } +\cs_new_protected:Npn \driver_draw_clip: + { \bool_gset_true:N \g_@@_draw_clip_bool } +\bool_new:N \g_@@_draw_clip_bool +\cs_new_protected:Npn \driver_draw_discardpath: + { + \bool_if:NT \g_@@_draw_clip_bool + { + \int_gincr:N \g_@@_clip_path_int + \@@_draw_literal:x + { + < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > + { ?nl } + <path~d=" \g_@@_draw_path_tl "/> { ?nl } + < /clipPath > + } + \@@_draw_scope:x + { + clip-path = + "url( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int)" + } + } + \tl_gclear:N \g_@@_draw_path_tl + \bool_gset_false:N \g_@@_draw_clip_bool + } +% \end{macrocode} +% \end{variable} +% \end{variable} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_dash_pattern:nn} +% \begin{macro}{\@@_draw_dash:n} +% \begin{macro}{\@@_draw_dash_aux:nn} +% \begin{macro}{\driver_draw_linewidth:n} +% \begin{macro}{\driver_draw_miterlimit:n} +% \begin{macro} +% { +% \driver_draw_cap_butt:, \driver_draw_cap_round:, \driver_draw_cap_rectangle:, +% \driver_draw_join_miter:, \driver_draw_join_round:, \driver_draw_join_bevel: +% } +% All of these ideas are properties of scopes in SVG. The only slight +% complexity is converting the dash array properly (doing any required +% maths). +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 + { + \use:x + { + \@@_draw_dash_aux:nn + { \clist_map_function:nn {#1} \@@_draw_dash:n } + { \dim_to_decimal:n {#2} } + } + } +\cs_new:Npn \@@_draw_dash:n #1 + { , \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \@@_draw_dash_aux:nn #1#2 + { + \@@_draw_scope:x + { + stroke-dasharray = + " + \tl_if_empty:oTF { \use_none:n #1 } + { none } + { \use_none:n #1 } + " ~ + stroke-offset=" #2 " + } + } +\cs_new_protected:Npn \driver_draw_linewidth:n #1 + { \@@_draw_scope:x { stroke-width=" \dim_to_decimal:n {#1} " } } +\cs_new_protected:Npn \driver_draw_miterlimit:n #1 + { \@@_draw_scope:x { stroke-miterlimit=" \fp_eval:n {#1} " } } +\cs_new_protected:Npn \driver_draw_cap_butt: + { \@@_draw_scope:n { stroke-linecap="butt" } } +\cs_new_protected:Npn \driver_draw_cap_round: + { \@@_draw_scope:n { stroke-linecap="round" } } +\cs_new_protected:Npn \driver_draw_cap_rectangle: + { \@@_draw_scope:n { stroke-linecap="square" } } +\cs_new_protected:Npn \driver_draw_join_miter: + { \@@_draw_scope:n { stroke-linejoin="miter" } } +\cs_new_protected:Npn \driver_draw_join_round: + { \@@_draw_scope:n { stroke-linejoin="round" } } +\cs_new_protected:Npn \driver_draw_join_bevel: + { \@@_draw_scope:n { stroke-linejoin="bevel" } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \driver_draw_color_fill_cmyk:nnnn , +% \driver_draw_color_stroke_cmyk:nnnn +% } +% \begin{macro} +% { +% \driver_draw_color_fill_gray:n , +% \driver_draw_color_stroke_gray:n +% } +% \begin{macro} +% { +% \driver_draw_color_fill_rgb:nnn , +% \driver_draw_color_stroke_rgb:nnn +% } +% \begin{macro}{\@@_draw_color_fill:nnn} +% SVG fill color has to be covered outside of the stack, as for +% \texttt{dvips}. Here, we are only allowed RGB colors so there is some +% conversion to do. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 + { + \use:x + { + \@@_draw_color_fill:nnn + { \fp_eval:n { -100 * ( (#1) * ( 1 - (#4) ) - 1 ) } } + { \fp_eval:n { -100 * ( (#2) * ( 1 - (#4) ) + #4 - 1 ) } } + { \fp_eval:n { -100 * ( (#3) * ( 1 - (#4) ) + #4 - 1 ) } } + } + } +\cs_new_eq:NN \driver_draw_color_stroke_cmyk:nnnn \driver_color_cmyk:nnnn +\cs_new_protected:Npn \driver_draw_color_gray:n #1 + { + \use:x + { + \@@_draw_color_gray_aux:n + { \fp_eval:n { 100 * (#3) } } + } + } +\cs_new_protected:Npn \@@_draw_color_gray_aux:n #1 + { \@@_draw_color_fill:nnn {#1} {#1} {#1} } +\cs_new_eq:NN \driver_draw_color_stroke_gray:n \driver_color_gray:n +\cs_new_protected:Npn \driver_draw_color_rgb:nnn #1#2#3 + { + \use:x + { + \@@_draw_color_fill:nnn + { \fp_eval:n { 100 * (#1) } } + { \fp_eval:n { 100 * (#2) } } + { \fp_eval:n { 100 * (#3) } } + } + } +\cs_new_protected:Npn \@@_draw_color_fill:nnn #1#2#3 + { + \@@_draw_scope:x + { + fill = + " + rgb + ( + #1 \c_percent_str , + #2 \c_percent_str , + #3 \c_percent_str + ) + " + } + } +\cs_new_eq:NN \driver_draw_color_stroke_rgb:nnn \driver_color_rgb:nnn +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_draw_cm:nnnn} +% The four arguments here are floats (the affine matrix), the last +% two are a displacement vector. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 + { + \@@_draw_scope:n + { + transform = + " + matrix + ( + \fp_eval:n {#1} , \fp_eval:n {#2} , + \fp_eval:n {#3} , \fp_eval:n {#4} , + 0pt , 0pt + ) + " + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_draw_box_use:Nnnnn} +% No special savings can be made here: simply displace the box inside +% a scope. As there is nothing to re-box, just make the box passed of +% zero size. +% \begin{macrocode} +\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5#6#7 + { + \@@_scope_begin: + \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} + \@@_literal_svg:n + { + < g~ + stroke="none"~ + transform="scale(-1,1)~translate({?x},{?y})~scale(-1,-1)" + > + } + \box_set_wd:Nn #1 { 0pt } + \box_set_ht:Nn #1 { 0pt } + \box_set_dp:Nn #1 { 0pt } + \box_use:N #1 + \@@_literal_svg:n { </g> } + \@@_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvisvgm> +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers-image.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers-image.dtx new file mode 100644 index 00000000000..ef2eea9f56d --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers-image.dtx @@ -0,0 +1,504 @@ +% \iffalse meta-comment +% +%% File: l3drivers-image.dtx +% +% Copyright (C) 2011-2019 The LaTeX3 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 "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full,kernel]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3drivers-image} package\\ Driver image support^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-04-21} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3drivers-image} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=driver> +% \end{macrocode} +% +% \subsection{\texttt{dvips} driver} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_image_getbb_eps:n} +% Simply use the generic function. +% \begin{macrocode} +\cs_new_eq:NN \@@_image_getbb_eps:n \image_read_bb:n +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_image_include_eps:n} +% The special syntax is relatively clear here: remember we need PostScript +% sizes here. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_eps:n #1 + { \@@_literal:n { PSfile = #1 } } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} driver} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \begin{variable}{\l_@@_image_attr_tl} +% In PDF mode, additional attributes of an image (such as page number) are +% needed both to obtain the bounding box and when inserting the image: this +% occurs as the image dictionary approach means they are read as part of +% the bounding box operation. As such, it is easier to track additional +% attributes using a dedicated |tl| rather than build up the same data +% twice. +% \begin{macrocode} +\tl_new:N \l_@@_image_attr_tl +% \end{macrocode} +% \end{variable} +% +% \begin{macro} +% {\@@_image_getbb_jpg:n, \@@_image_getbb_pdf:n, \@@_image_getbb_png:n} +% \begin{macro} +% {\@@_image_getbb_auxi:n, \@@_image_getbb_auxii:n} +% Getting the bounding box here requires us to box up the image and +% measure it. To deal with the difference in feature support in bitmap +% and vector images but keeping the common parts, there is a little work +% to do in terms of auxiliaries. The key here is to notice that we need +% two forms of the attributes: a \enquote{short} set to allow us to +% track for caching, and the full form to pass to the primitive. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 + { + \int_zero:N \l_image_page_int + \tl_clear:N \l_image_pagebox_tl + \tl_set:Nx \l_@@_image_attr_tl + { + \tl_if_empty:NF \l_image_decode_tl + { :D \l_image_decodearray_tl } + \bool_if:NT \l_image_interpolate_bool + { :I } + } + \tl_clear:N \l_@@_image_attr_tl + \@@_image_getbb_auxi:n {#1} + } +\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n +\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 + { + \tl_clear:N \l_image_decode_tl + \bool_set_false:N \l_image_interpolate_bool + \tl_set:Nx \l_@@_image_attr_tl + { + : \l_image_pagebox_tl + \int_compare:nNnT \l_image_page_int > 1 + { :P \int_use:N \l_image_page_int } + } + \@@_image_getbb_auxi:n {#1} + } +\cs_new_protected:Npn \@@_image_getbb_auxi:n #1 + { + \image_bb_restore:xF { #1 \l_@@_image_attr_tl } + { \@@_image_getbb_auxii:n {#1} } + } +% \begin{macrocode} +% Measuring the image is done by boxing up: for PDF images we could +% use |\tex_pdfximagebbox:D|, but if doesn't work for other types. +% As the box always starts at $(0,0)$ there is no need to worry about +% the lower-left position. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_getbb_auxii:n #1 + { + \tex_immediate:D \tex_pdfximage:D + \bool_lazy_or:nnT + { \l_image_interpolate_bool } + { ! \tl_if_empty_p:N \l_image_decodearray_tl } + { + attr ~ + { + \tl_if_empty:NF \l_image_decode_tl + { /Decode~[ \l_image_decodearray_tl ] } + \bool_if:NT \l_image_interpolate_bool + { /Interpolate~true } + } + } + \int_compare:nNnT \l_image_page_int > 0 + { page ~ \int_use:N \l_image_page_int } + \tl_if_empty:NF \l_image_pagebox_tl + { \l_image_pagebox_tl } + {#1} + \hbox_set:Nn \l_@@_tmp_box + { \tex_pdfrefximage:D \tex_pdflastximage:D } + \dim_set:Nn \l_image_urx_dim { \box_wd:N \l_@@_tmp_box } + \dim_set:Nn \l_image_ury_dim { \box_ht:N \l_@@_tmp_box } + \int_const:cn { c_@@_image_ #1 \l_@@_image_attr_tl _int } + { \tex_the:D \tex_pdflastximage:D } + \image_bb_save:x { #1 \l_@@_image_attr_tl } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\@@_image_include_jpg:n, \@@_image_include_pdf:n, \@@_image_include_png:n} +% Images are already loaded for the measurement part of the code, so +% inclusion is straight-forward, with only any attributes to worry about. The +% latter carry through from determination of the bounding box. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_jpg:n #1 + { + \tex_pdfrefximage:D + \int_use:c { c_@@_image_ #1 \l_@@_image_attr_tl _int } + } +\cs_new_eq:NN \@@_image_include_pdf:n \@@_image_include_jpg:n +\cs_new_eq:NN \@@_image_include_png:n \@@_image_include_jpg:n +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} driver} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro} +% { +% \@@_image_getbb_eps:n, \@@_image_getbb_jpg:n, +% \@@_image_getbb_pdf:n, \@@_image_getbb_png:n +% } +% Simply use the generic functions: only for \texttt{dvipdfmx} in the +% extraction cases. +% \begin{macrocode} +\cs_new_eq:NN \@@_image_getbb_eps:n \image_read_bb:n +%<*dvipdfmx> +\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 + { + \int_zero:N \l_image_page_int + \tl_clear:N \l_image_pagebox_tl + \image_extract_bb:n {#1} + } +\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n +\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 + { + \tl_clear:N \l_image_decode_tl + \bool_set_false:N \l_image_interpolate_bool + \image_extract_bb:n {#1} + } +%</dvipdfmx> +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\g_@@_image_int} +% Used to track the object number associated with each image. +% \begin{macrocode} +\int_new:N \g_@@_image_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro} +% { +% \@@_image_include_eps:n, \@@_image_include_jpg:n, +% \@@_image_include_pdf:n, \@@_image_include_png:n +% } +% \begin{macro}{\@@_image_include_auxi:nn} +% \begin{macro}{\@@_image_include_auxii:nnn, \@@_image_include_auxii:xnn} +% \begin{macro}{\@@_image_include_auxiii:nn} +% The special syntax depends on the file type. There is a difference in +% how PDF images are best handled between |dvipdfmx| and |xdvipdfmx|: for +% the latter it is better to use the primitive route. The relevant code for +% that is included later in this file. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_eps:n #1 + { + \@@_literal:n { PSfile = #1 } + } +\cs_new_protected:Npn \@@_image_include_jpg:n #1 + { \@@_image_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \@@_image_include_png:n \@@_image_include_jpg:n +%<*dvipdfmx> +\cs_new_protected:Npn \@@_image_include_pdf:n #1 + { \@@_image_include_auxi:nn {#1} { epdf } } +%</dvipdfmx> +% \end{macrocode} +% Image inclusion is set up to use the fact that each image is stored in +% the PDF as an XObject. This means that we can include repeated images +% only once and refer to them. To allow that, track the nature of each +% image: much the same as for the direct PDF mode case. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_auxi:nn #1#2 + { + \@@_image_include_auxii:xnn + { + \tl_if_empty:NF \l_image_pagebox_tl + { : \l_image_pagebox_tl } + \int_compare:nNnT \l_image_page_int > 1 + { :P \int_use:N \l_image_page_int } + \tl_if_empty:NF \l_image_decode_tl + { :D \l_image_decodearray_tl } + \bool_if:NT \l_image_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \@@_image_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c_@@_image_ #2#1 _int } + { + \@@_literal:x + { pdf:usexobj~@image \int_use:c { c_@@_image_ #2#1 _int } } + } + { \@@_image_include_auxiii:nn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \@@_image_include_auxii:nnn { x } +% \end{macrocode} +% Inclusion using the specials is relatively straight-forward, but there +% is one wrinkle. To get the |pagebox| correct for PDF images in all cases, +% it is necessary to provide both that information and the |bbox| argument: +% odd things happen otherwise! +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g_@@_image_int + \int_const:cn { c_@@_image_ #1#2 _int } { \g_@@_image_int } + \@@_literal:x + { + pdf:#3~ + @image \int_use:c { c_@@_image_ #1#2 _int } + \int_compare:nNnT \l_image_page_int > 1 + { page ~ \int_use:N \l_image_page_int \c_space_tl } + \tl_if_empty:NF \l_image_pagebox_tl + { + pagebox ~ \l_image_pagebox_tl \c_space_tl + bbox ~ + \dim_to_decimal_in_bp:n \l_image_llx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_lly_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_urx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_ury_dim \c_space_tl + } + (#1) + \bool_lazy_or:nnT + { \l_image_interpolate_bool } + { ! \tl_if_empty_p:N \l_image_decodearray_tl } + { + << + \tl_if_empty:NF \l_image_decode_tl + { /Decode~[ \l_image_decodearray_tl ] } + \bool_if:NT \l_image_interpolate_bool + { /Interpolate~true> } + >> + } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{xdvipdfmx} driver} +% +% \begin{macrocode} +%<*xdvipdfmx> +% \end{macrocode} +% +% \subsubsection{Images} +% +% \begin{macro} +% {\@@_image_getbb_jpg:n, \@@_image_getbb_pdf:n, \@@_image_getbb_png:n} +% \begin{macro}{\@@_image_getbb_auxi:nN} +% \begin{macro}{\@@_image_getbb_auxii:nnN, \@@_image_getbb_auxii:VnN} +% \begin{macro}{\@@_image_getbb_auxiii:nNnn} +% \begin{macro}{\@@_image_getbb_auxiv:nnNnn, \@@_image_getbb_auxiv:VnNnn} +% \begin{macro}{\@@_image_getbb_auxv:nNnn, \@@_image_getbb_auxv:nNnn} +% \begin{macro}[EXP]{\@@_image_getbb_pagebox:w} +% For \texttt{xdvipdfmx}, there are two primitives that allow us to obtain +% the bounding box without needing \texttt{extractbb}. The only complexity +% is passing the various minor variations to a common core process. The +% \XeTeX{} primitive omits the text |box| from the page box specification, +% so there is also some \enquote{trimming} to do here. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 + { + \int_zero:N \l_image_page_int + \tl_clear:N \l_image_pagebox_tl + \@@_image_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D + } +\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n +\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 + { + \tl_clear:N \l_image_decode_tl + \bool_set_false:N \l_image_interpolate_bool + \@@_image_getbb_auxi:nN {#1} \tex_XeTeXpdffile:D + } +\cs_new_protected:Npn \@@_image_getbb_auxi:nN #1#2 + { + \int_compare:nNnTF \l_image_page_int > 1 + { \@@_image_getbb_auxii:VnN \l_image_page_int {#1} #2 } + { \@@_image_getbb_auxiii:nNnn {#1} #2 } + } +\cs_new_protected:Npn \@@_image_getbb_auxii:nnN #1#2#3 + { \@@_image_getbb_aux:nNnn {#2} #3 { :P #1 } { page #1 } } +\cs_generate_variant:Nn \@@_image_getbb_auxii:nnN { V } +\cs_new_protected:Npn \@@_image_getbb_auxiii:nNnn #1#2#3#4 + { + \tl_if_empty:NTF \l_image_pagebox_tl + { \@@_image_getbb_auxiv:VnNnn \l_image_pagebox_tl } + { \@@_image_getbb_auxv:nNnn } + {#1} #2 {#3} {#4} + } +\cs_new_protected:Npn \@@_image_getbb_auxiv:nnNnn #1#2#3#4#5 + { + \use:x + { + \@@_image_getbb_auxv:nNnn {#2} #3 { : #1 #4 } + { #5 ~ \@@_image_getbb_pagebox:w #1 } + } + } +\cs_generate_variant:Nn \@@_image_getbb_auxiv:nnNnn { V } +\cs_new_protected:Npn \@@_image_getbb_auxv:nNnn #1#2#3#4 + { + \image_bb_restore:nF {#1#3} + { \@@_image_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } + } +\cs_new_protected:Npn \@@_image_getbb_auxvi:nNnn #1#2#3#4 + { + \hbox_set:Nn \l_@@_tmp_box { #2 #1 ~ #4 } + \dim_set:Nn \l_image_utx_dim { \box_wd:N \l_@@_tmp_box } + \dim_set:Nn \l_image_ury_dim { \box_ht:N \l_@@_tmp_box } + \image_bb_save:n {#1#3} + } +\cs_new:Npn \@@_image_getbb_pagebox:w #1 box {#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_image_include_pdf:n} +% For PDF images, properly supporting the |pagebox| concept in \XeTeX{} +% is best done using the |\tex_XeTeXpdffile:D| primitive. The syntax here +% is the same as for the image measurement part, although we know at this +% stage that there must be some valid setting for \cs{l_image_pagebox_tl}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_pdf:n #1 + { + \tex_XeTeXpdffile:D "#1" ~ + \int_compare:nNnT \l_image_page_int > 0 + { page~ \int_use:N \l_image_page_int } + \@@_image_getbb_auxiv:VnNnn \l_image_pagebox_tl + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} driver} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\@@_image_getbb_png:n, \@@_image_getbb_jpg:n} +% These can be included by extracting the bounding box data. +% \begin{macrocode} +\cs_new_eq:NN \@@_image_getbb_png:n \image_extract_bb:n +\cs_new_eq:NN \@@_image_getbb_jpg:n \image_extract_bb:n +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_image_include_png:n, \@@_image_include_jpg:n} +% \begin{macro}{\@@_image_include_bitmap_quote:w} +% The driver here has built-in support for basic image inclusion (see +% \texttt{dvisvgm.def} for a more complex approach, needed if clipping, +% \emph{etc.}, is covered at the image driver level). The only issue is +% that |#1| must be quote-corrected. The \texttt{dvisvgm:img} operation +% quotes the file name, but if it is already quoted (contains spaces) +% then we have an issue: we simply strip off any quotes as a result. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_png:n #1 + { + \@@_literal:x + { + dvisvgm:img~ + \dim_to_decimal:n { \l_image_ury_dim } ~ + \dim_to_decimal:n { \l_image_ury_dim } ~ + \@@_image_include_bitmap_quote:w #1 " #1 " \q_stop + } + } +\cs_new_eq:NN \@@_image_include_jpg:n \@@_image_include_png:n +\cs_new:Npn \@@_image_include_bitmap_quote:w #1 " #2 " #3 \q_stop + { " #2 " } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</dvisvgm> +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers-pdf.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers-pdf.dtx new file mode 100644 index 00000000000..a1275e4f4fc --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers-pdf.dtx @@ -0,0 +1,1647 @@ +% \iffalse meta-comment +% +%% File: l3drivers-pdf.dtx +% +% Copyright (C) 2011-2019 The LaTeX3 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 "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full,kernel]{l3doc} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3drivers-pdf} package\\ Driver PDF features^^A +% } +% +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Released 2019-04-21} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3drivers-pdf} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=driver> +% \end{macrocode} +% +% \subsection{Shared code} +% +% A very small number of items that belong at the driver level but which +% are common to all drivers. +% +% \begin{variable}{\c_@@_pdf_AR_fix_tl} +% Part of a fix for a bug in Adobe Reader: see +% \url{https://forums.adobe.com/message/5787612#5787612}. The workaround +% is taken from \pkg{pdfbase}: this \enquote{magic} dictionary entry has to +% be passed correctly to each driver. +% \begin{macrocode} +\tl_const:Nn \c_@@_pdf_AR_fix_tl + { /Ff ~ 65537 /FT /Btn /Subtype /Widget } +% \end{macrocode} +% \end{variable} +% +% \subsection{\texttt{dvips} driver} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \subsubsection{Objects} +% +% \begin{variable}{\g_@@_pdf_object_int, \g_@@_pdf_object_prop} +% For tracking objects to allow finalisation. +% \begin{macrocode} +\int_new:N \g_@@_pdf_object_int +\prop_new:N \g_@@_pdf_object_prop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_pdf_object_new:nn} +% \begin{macro}[EXP]{\driver_pdf_object_ref:n} +% Tracking objects is similar to \texttt{dvipdfmx}. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 + { + \int_gincr:N \g_@@_pdf_object_int + \int_const:cn + { g_@@_pdf_object_ \tl_to_str:n {#1} _int } + { \g_@@_pdf_object_int } + \prop_gput:Nnn \g_@@_pdf_object_prop {#1} {#2} + } +\cs_new:Npn \driver_pdf_object_ref:n #1 + { { driver.obj \int_use:c { g_@@_pdf_object_ \tl_to_str:n {#1} _int } } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_pdf_object_write:nn} +% \begin{macro} +% { +% \@@_pdf_object_write_array:nn , +% \@@_pdf_object_write_dict:nn , +% \@@_pdf_object_write_stream:nn +% } +% \begin{macro}{\@@_pdf_object_write_stream:nnn} +% This is where we choose the actual type: some work to get things +% right. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 + { + \@@_postscript:x + { + mark /_objdef ~ \driver_pdf_object_ref:n {#1} + /type + \str_case_e:nn + { \prop_item:Nn \g_@@_pdf_object_prop {#1} } + { + { array } { /array } + { dict } { /dict } + { fstream } { /stream } + { stream } { /stream } + } + /OBJ ~ pdfmark + } + \use:c + { @@_pdf_object_write_ \prop_item:Nn \g_@@_pdf_object_prop {#1} :nn } + {#1} {#2} + } +\cs_new_protected:Npn \@@_pdf_object_write_array:nn #1#2 + { + \@@_postscript:x + { + mark ~ \driver_pdf_object_ref:n {#1} + [ ~ \exp_not:n {#2} ~ ] ~ /PUTINTERVAL ~ pdfmark + } + } +\cs_new_protected:Npn \@@_pdf_object_write_dict:nn #1#2 + { + \@@_postscript:x + { + mark ~ \driver_pdf_object_ref:n {#1} + << \exp_not:n {#2} >> /PUT ~ pdfmark + } + } +\cs_new_protected:Npn \@@_pdf_object_write_stream:nn #1#2 + { + \exp_args:Nx + \@@_pdf_object_write_stream:nnn + { \driver_pdf_object_ref:n {#1} } + #2 + } +\cs_new_protected:Npn \@@_pdf_object_write_stream:nnn #1#2#3 + { + \@@_postscript:n + { + [nobreak] + mark ~ #1 ~ ( #3 ) /PUT ~ pdfmark ~ + mark ~ #1 ~ << #2 >> /PUT ~ pdfmark + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Annotations} +% +% In \texttt{dvips}, annotations have to be constructed manually. As such, +% we need the object code above for some definitions. +% +% \begin{macro}{driver.globaldict} +% A small global dictionary for driver use. +% \begin{macrocode} +\@@_postscript_header:n + { + true ~ setglobal ~ + /driver.globaldict ~ 4 ~ dict ~ def ~ + false ~ setglobal + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% driver.cvs , +% driver.rect.ht , +% driver.pt.dvi +% } +% Small utilities for PostScript manipulations. Conversion to DVI dimensions +% is done here to allow for |Resolution|. The total height of a rectangle +% (an array) needs a little maths, in contrast to simply extracting a value. +% \begin{macrocode} +\@@_postscript_header:n + { + /driver.cvs { 65534 ~ string ~ cvs } def + /driver.pt.dvi { 72.27 ~ div ~ Resolution ~ mul } def + /driver.rect.ht { dup ~ 1 ~ get ~ neg ~ exch ~ 3 ~ get ~ add } def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{driver.linkmargin, driver.linkdp.pad, driver.linkht.pad} +% Settings which are defined up-front in |SDict|. +% \begin{macrocode} +\@@_postscript_header:n + { + /driver.linkmargin { 1 ~ driver.pt.dvi } def + /driver.linkdp.pad { 0 } def + /driver.linkht.pad { 0 } def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% driver.annotation.border , +% driver.annotation.ll , +% driver.annotation.ur , +% driver.link.ll , +% driver.link.ur , +% } +% Functions for marking the limits of an annotation/link, plus drawing the +% border. We separate links for generic annotations to support adding a +% margin and setting a minimal size. +% \begin{macrocode} +\@@_postscript_header:n + { + /driver.annotation.border + { /Rect [ driver.llx ~ driver.lly ~ driver.urx ~ driver.ury ] } def + /driver.annotation.ll + { + currentpoint + /driver.lly ~ exch ~ def + /driver.llx ~ exch ~ def + } + def + /driver.annotation.ur + { + currentpoint + /driver.ury ~ exch ~ def + /driver.urx ~ exch ~ def + } + def + /driver.link.ll + { + currentpoint ~ + driver.linkmargin ~ add ~ + driver.linkdp.pad ~ add + /driver.lly ~ exch ~ def ~ + driver.linkmargin ~ sub + /driver.llx ~ exch ~ def + } + def + /driver.link.ur + { + currentpoint ~ + driver.linkmargin ~ sub ~ + driver.linkht.pad ~ sub + /driver.ury ~ exch ~ def ~ + driver.linkmargin ~ add + /driver.urx ~ exch ~ def + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% driver.bordertracking , +% driver.bordertracking.begin , +% driver.bordertracking.end , +% driver.leftboundary , +% driver.rightboundary , +% driver.brokenlink.rect , +% driver.brokenlink.skip , +% driver.brokenlink.dict , +% driver.bordertracking.endpage , +% driver.bordertracking.continue , +% driver.originx , +% driver.originy +% } +% To know where a breakable link can go, we need to track the boundary +% rectangle. That can be done by hooking into |a| and |x| operations: +% those names have to be retained. The boundary is stored at the end of +% the operation. Special effort is needed at the start and end of pages +% (or rather galleys), such that everything works properly. +% \begin{macrocode} +\@@_postscript_header:n + { + /driver.bordertracking ~ false ~ def + /driver.bordertracking.begin + { + SDict ~ /driver.bordertracking ~ true ~ put ~ + SDict ~ /driver.leftboundary ~ undef ~ + SDict ~ /driver.rightboundary ~ undef ~ + /a ~ where + { + /a + { + currentpoint ~ pop ~ + SDict /driver.rightboundary ~ known ~ dup + { + SDict /driver.rightboundary ~ get ~ 2 ~ index ~ lt + { not } + if + } + if + { pop } + { SDict ~ exch /driver.rightboundary ~ exch ~ put } + ifelse ~ + moveto ~ + currentpoint ~ pop ~ + SDict /driver.leftboundary ~ known ~ dup + { + SDict /driver.leftboundary ~ get ~ 2 ~ index ~ gt + { not } + if + } + if + { pop } + { SDict ~ exch /driver.leftboundary ~ exch ~ put } + ifelse + } + put + } + if + } + def + /driver.bordertracking.end + { + /a ~ where { /a { moveto } put } if + /x ~ where { /x { 0 ~ exch ~ rmoveto } put } if ~ + SDict /driver.leftboundary ~ known + { driver.outerbox ~ 0 ~ driver.leftboundary ~ put } + if ~ + SDict /driver.rightboundary ~ known + { driver.outerbox ~ 2 ~ driver.rightboundary ~ put } + if ~ + SDict /driver.bordertracking ~ false ~ put + } + def + /driver.bordertracking.endpage + { + driver.bordertracking + { + driver.bordertracking.end ~ + true ~ setglobal ~ + driver.globaldict + /driver.brokenlink.rect [ driver.outerbox ~ aload ~ pop ] put ~ + driver.globaldict + /driver.brokenlink.skip ~ driver.baselineskip ~ put ~ + driver.globaldict + /driver.brokenlink.dict ~ + driver.link.dict ~ driver.cvs ~ put ~ + false ~ setglobal ~ + mark ~ driver.link.dict ~ cvx ~ exec ~ /Rect + [ + driver.llx ~ + driver.lly ~ + driver.outerbox ~ 2 ~ get ~ driver.linkmargin ~ add ~ + currentpoint ~ exch ~ pop ~ + driver.outerbox ~ driver.rect.ht ~ sub ~ driver.linkmargin ~ sub + ] + /ANN ~ driver.pdfmark + } + if + } + def + /driver.bordertracking.continue + { + /driver.link.dict ~ driver.globaldict + /driver.brokenlink.dict ~ get ~ def + /driver.outerbox ~ driver.globaldict + /driver.brokenlink.rect ~ get ~ def + /driver.baselineskip ~ driver.globaldict + /driver.brokenlink.skip ~ get ~ def ~ + driver.globaldict ~ dup ~ dup + /driver.brokenlink.dict ~ undef + /driver.brokenlink.skip ~ undef + /driver.brokenlink.rect ~ undef ~ + currentpoint + /driver.originy ~ exch ~ def + /driver.originx ~ exch ~ def + /a ~ where + { + /a + { + moveto ~ + SDict ~ + begin ~ + currentpoint ~ driver.originy ~ ne ~ exch ~ + driver.originx ~ ne ~ or + { + driver.link.ll + /driver.lly ~ + driver.lly ~ driver.outerbox ~ 1 ~ get ~ sub ~ def ~ + driver.bordertracking.begin + } + if ~ + end + } + put + } + if + /x ~ where + { + /x + { + 0 ~ exch ~ rmoveto ~ + SDict~ + begin ~ + currentpoint ~ + driver.originy ~ ne ~ exch ~ driver.originx ~ ne ~ or + { + driver.link.ll + /driver.lly ~ + driver.lly ~ driver.outerbox ~ 1 ~ get ~ sub ~ def ~ + driver.bordertracking.begin + } + if ~ + end + } + put + } + if + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% driver.breaklink , +% driver.breaklink.write , +% driver.count , +% driver.currentrect +% } +% Dealing with link breaking itself has multiple stage. The first step is to +% find the |Rect| entry in the dictionary, looping over key--value pairs. +% The first line is handled first, adjusting the rectangle to stay inside the +% text area. The second phase is a loop over the height of the bulk of the +% link area, done on the basis of a number of baselines. Finally, the end of +% the link area is tidied up, again from the boundary of the text area. +% \begin{macrocode} +\@@_postscript_header:n + { + /driver.breaklink + { + pop ~ + counttomark ~ 2 ~ mod ~ 0 ~ eq + { + counttomark /driver.count ~ exch ~ def + { + driver.count ~ 0 ~ eq { exit } if ~ + counttomark ~ 2 ~ roll ~ + 1 ~ index ~ /Rect ~ eq + { + dup ~ 4 ~ array ~ copy ~ + dup ~ dup ~ + 1 ~ get ~ + driver.outerbox ~ driver.rect.ht ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ sub ~ + 3 ~ exch ~ put ~ + dup ~ + driver.outerbox ~ 2 ~ get ~ + driver.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + driver.outerbox ~ driver.rect.ht ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ add ~ + 1 ~ exch ~ put + /driver.currentrect ~ exch ~ def ~ + driver.breaklink.write + { + driver.currentrect ~ + dup ~ + driver.outerbox ~ 0 ~ get ~ + driver.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ + driver.outerbox ~ 2 ~ get ~ + driver.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + driver.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + driver.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + /driver.currentrect ~ exch ~ def ~ + driver.breaklink.write + } + 1 ~ index ~ 3 ~ get ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ + driver.outerbox ~ driver.rect.ht ~ add ~ + 2 ~ index ~ 1 ~ get ~ sub ~ + driver.baselineskip ~ div ~ round ~ cvi ~ 1 ~ sub ~ + exch ~ + repeat ~ + driver.currentrect ~ + dup ~ + driver.outerbox ~ 0 ~ get ~ + driver.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + driver.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + driver.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + dup ~ 2 ~ index ~ 2 ~ get ~ 2 ~ exch ~ put + /driver.currentrect ~ exch ~ def ~ + driver.breaklink.write ~ + SDict /driver.pdfmark.good ~ false ~ put ~ + exit + } + { driver.count ~ 2 ~ sub /driver.count ~ exch ~ def } + ifelse + } + loop + } + if + /ANN + } + def + /driver.breaklink.write + { + counttomark ~ 1 ~ add ~ copy ~ + pop ~ driver.currentrect + /ANN ~ pdfmark + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% driver.pdfmark , +% driver.pdfmark.good , +% driver.outerbox , +% driver.baselineskip , +% driver.pdfmark.dict , +% driver.pdfmark.obj +% } +% The business end of breaking links starts by hooking into |pdfmarks|. +% Unlike \pkg{hypdvips}, we avoid altering any links we have not created +% by using a copy of the core |pdfmarks| function. Only mark types which +% are known are altered. At present, this is purely |ANN| marks, which are +% measured relative to the size of the baseline skip. If they are +% more than one apparent line high, breaking is applied. +% \begin{macrocode} +\@@_postscript_header:n + { + /driver.pdfmark + { + SDict /driver.pdfmark.good ~ true ~ put ~ + dup /ANN ~ eq + { + driver.pdfmark.store ~ + driver.pdfmark.dict ~ + begin ~ + Subtype /Link ~ eq ~ + currentdict /Rect ~ known ~ and ~ + SDict /driver.outerbox ~ known ~ and ~ + SDict /driver.baselineskip ~ known ~ and ~ + { + Rect ~ 3 ~ get ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ + driver.outerbox ~ driver.rect.ht ~ add ~ + Rect ~ 1 ~ get ~ sub ~ + driver.baselineskip ~ div ~ round ~ cvi ~ 0 ~ gt + { driver.breaklink } + { driver.pdfmark.obj } + ifelse + } + { driver.pdfmark.obj } + ifelse ~ + end ~ + SDict /driver.outerbox ~ undef ~ + SDict /driver.baselineskip ~ undef ~ + currentdict /driver.pdfmark.dict ~ undef ~ + } + if ~ + driver.pdfmark.good + { pdfmark } + { cleartomark } + ifelse + } + def + /driver.pdfmark.store + { + /driver.pdfmark.dict ~ 65534 ~ dict ~ def ~ + counttomark ~ 1 ~ add ~ copy ~ + pop + { + dup ~ mark ~ eq + { + pop ~ + exit + } + { + driver.pdfmark.dict ~ + begin ~ def ~ end + } + ifelse + } + loop + } + def + /driver.pdfmark.obj + { /_objdef ~ exch ~ driver.link.obj ~ exch } def + } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\l_@@_pdf_content_box} +% The content of an annotation. +% \begin{macrocode} +\box_new:N \l_@@_pdf_content_box +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_@@_pdf_model_box} +% For creating model sizing for links. +% \begin{macrocode} +\box_new:N \l_@@_pdf_model_box +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_pdf_annotation_int} +% Needed as objects which are not annotations could be created. +% \begin{macrocode} +\int_new:N \g_@@_pdf_annotation_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_pdf_annotation:nnnn, \@@_pdf_annotation:nnnn} +% \begin{macro}{driver.llx, driver.lly, driver.urx, driver.ury} +% Annotations are objects, but we track them separately. Notably, they are +% not in the object data lists. Here, to get the co-ordinates of the +% annotation, we need to have the data collected at the PostScript level. +% That requires a bit of box trickery (effectively a \LaTeXe{} |picture| +% of zero size). Once the data is collected, use it to set up the annotation +% border. There is a split into two parts here to allow an easy way of +% applying the Adobe Reader fix. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4 + { + \@@_pdf_annotation:nnnn {#1} {#2} {#3} {#4} + \int_gincr:N \g_@@_pdf_object_int + \int_gset_eq:NN \g_@@_pdf_annotation_int \g_@@_pdf_object_int + \@@_postscript:x + { + mark + /_objdef { driver.obj \int_use:N \g_@@_pdf_object_int } + driver.annotation.border ~ + #4 ~ + /ANN ~ pdfmark + } + } +\cs_new_protected:Npn \@@_pdf_annotation:nnnn #1#2#3#4 + { + \box_move_down:nn {#3} + { \hbox:n { \@@_postscript:n { driver.annotation.ll } } } + \hbox:n {#4} + \box_move_up:nn {#2} + { + \hbox:n + { + \tex_kern:D \dim_eval:n {#1} \scan_stop: + \@@_postscript:n { driver.annotation.ur } + } + } + \int_gincr:N \g_@@_pdf_object_int + \int_gset_eq:NN \g_@@_pdf_annotation_int \g_@@_pdf_object_int + \@@_postscript:x + { + mark + /_objdef { driver.obj \int_use:N \g_@@_pdf_object_int } + driver.annotation.border ~ + \c_@@_pdf_AR_fix_tl + /ANN ~ pdfmark + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[EXP]{\driver_pdf_annotation_last:} +% Provide the last annotation we created: could get tricky of course if +% other packages are loaded. +% \begin{macrocode} +\cs_new:Npn \driver_pdf_annotation_last: + { { driver.obj \int_use:N \g_@@_pdf_annotation_int } } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\g_@@_pdf_link_int} +% To track annotations which are links. +% \begin{macrocode} +\int_new:N \g_@@_pdf_link_int +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_pdf_link_dict_tl} +% To pass information to the end-of-link function. +% \begin{macrocode} +\tl_new:N \g_@@_pdf_link_dict_tl +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_pdf_link_sf_int} +% Needed to save/restore space factor, which is needed to deal with the face +% we need a box. +% \begin{macrocode} +\int_new:N \g_@@_pdf_link_sf_int +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_pdf_link_math_bool} +% Needed to save/restore math mode. +% \begin{macrocode} +\bool_new:N \g_@@_pdf_link_math_bool +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_pdf_link_bool} +% Track link formation: we cannot nest at all. +% \begin{macrocode} +\bool_new:N \g_@@_pdf_link_bool +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_pdf_link_begin_goto:nnw, \driver_pdf_link_begin_user:nnw} +% \begin{macro}{\@@_pdf_link:nw, \@@_pdf_link_aux:nw} +% \begin{macro}{\driver_pdf_link_end:, \@@_pdf_link_end:} +% \begin{macro}{\@@_pdf_link_minima:} +% \begin{macro}{\@@_pdf_link_outerbox:n} +% \begin{macro}{\@@_pdf_link_sf_save:, \@@_pdf_link_sf_restore:} +% \begin{macro} +% { +% driver.linkdp.pad , +% driver.linkht.pad , +% driver.llx, driver.lly , +% driver.ury, driver.ury , +% driver.link.dict , +% driver.link.obj , +% driver.outerbox , +% driver.baselineskip +% } +% Links are crated like annotations but with dedicated code to allow for +% adjusting the size of the rectangle. In contrast to \pkg{hyperref}, we +% grab the link content as a box which can then unbox: this allows the same +% interface as for \pdfTeX{}. +% +% Taking the idea of |evenboxes| from \pkg{hypdvips}, we implement a minimum +% box height and depth for link placement. This means that \enquote{underlining} +% with a hyperlink will generally give an even appearance. However, to ensure +% that the full content is always above the link border, we do not allow +% this to be negative (contrast \pkg{hypdvips} approach). The result should +% be similar to \pdfTeX{} in the vast majority of foreseeable cases. +% +% The object number for a link is saved separately from the rest of the +% dictionary as this allows us to insert it just once, at either an +% unbroken link or only in the first line of a broken one. That makes the +% code clearer but also avoids a low-level PostScript error with the code +% as taken from \pkg{hypdvips}. +% +% Getting the outer dimensions of the text area may be better using a two-pass +% approach and |\tex_savepos:D|. That plus format mode are still to re-examine. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \@@_pdf_link_begin:nw { #1 /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \@@_pdf_link_begin:nw {#1#2} } +\cs_new_protected:Npn \@@_pdf_link_begin:nw #1 + { + \bool_if:NF \g_@@_pdf_link_bool + { \@@_pdf_link_begin_aux:nw {#1} } + } +\cs_new_protected:Npn \@@_pdf_link_begin_aux:nw #1 + { + \bool_gset_true:N \g_@@_pdf_link_bool + \@@_pdf_annotation:nnnn { 3pt } { 3pt } { 0pt } { } + \@@_postscript:n + { /driver.link.dict ( /Subtype /Link #1 ) def } + \int_gincr:N \g_@@_pdf_object_int + \int_gset_eq:NN \g_@@_pdf_link_int \g_@@_pdf_object_int + \@@_postscript:x + { + /driver.link.obj + { + { driver.obj \int_use:N \g_@@_pdf_link_int \c_space_tl driver.cvs } + } + def + } + \tl_gset:Nn \g_@@_pdf_link_dict_tl {#1} + \@@_pdf_link_sf_save: + \mode_if_math:TF + { \bool_gset_true:N \g_@@_pdf_link_math_bool } + { \bool_gset_false:N \g_@@_pdf_link_math_bool } + \hbox_set:Nw \l_@@_pdf_content_box + \@@_pdf_link_sf_restore: + \bool_if:NT \g_@@_pdf_link_math_bool + { \c_math_toggle_token } + } +\cs_new_protected:Npn \driver_pdf_link_end: + { + \bool_if:NT \g_@@_pdf_link_bool + { \@@_pdf_link_end: } + } +\cs_new_protected:Npn \@@_pdf_link_end: + { + \bool_if:NT \g_@@_pdf_link_math_bool + { \c_math_toggle_token } + \@@_pdf_link_sf_save: + \hbox_set_end: + \@@_pdf_link_minima: + \hbox_set:Nn \l_@@_pdf_model_box { Gg } + \exp_args:Nx \@@_driver_link_outerbox:n + { +%<*initex> + \l_galley_total_left_margin_dim +%</initex> +%<*package> + \int_if_odd:nTF { \value { page } } + { \oddsidemargin } + { \evensidemargin } +%</package> + } + \box_move_down:nn { \box_dp:N \l_@@_pdf_content_box } + { \hbox:n { \@@_postscript:n { driver.link.ll } } } + \@@_postscript:n { driver.bordertracking.begin } + \hbox_unpack:N \l_@@_pdf_content_box + \@@_postscript:n { driver.bordertracking.end } + \box_move_up:nn { \box_ht:N \l_@@_pdf_content_box } + { + \hbox:n + { \@@_postscript:n { driver.link.ur } } + } + \@@_postscript:x + { + mark + \g_@@_pdf_link_dict_tl /Subtype /Link ~ + driver.annotation.border + /ANN ~ driver.pdfmark + } + \@@_pdf_link_sf_restore: + \bool_gset_false:N \g_@@_pdf_link_bool + } +\cs_new_protected:Npn \@@_pdf_link_minima: + { + \hbox_set:Nn \l_@@_pdf_model_box { Gg } + \@@_postscript:x + { + /driver.linkdp.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_dp:N \l_@@_pdf_model_box + - \box_dp:N \l_@@_pdf_content_box + } + { 0pt } + } ~ + driver.pt.dvi ~ def + /driver.linkht.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_ht:N \l_@@_pdf_model_box + - \box_ht:N \l_@@_pdf_content_box + } + { 0pt } + } ~ + driver.pt.dvi ~ def + } + } +\cs_new_protected:Npn \@@_driver_link_outerbox:n #1 + { + \@@_postscript:x + { + /driver.outerbox + [ + \dim_to_decimal:n {#1} ~ + \dim_to_decimal:n { -\box_dp:N \l_@@_pdf_model_box } ~ +%<*initex> + \dim_to_decimal:n { #1 + \l_galley_text_width_dim } ~ +%</initex> +%<*package> + \dim_to_decimal:n { #1 + \textwidth } ~ +%</package> + \dim_to_decimal:n { \box_ht:N \l_@@_pdf_model_box } + ] + [ exch { driver.pt.dvi } forall ] def + /driver.baselineskip ~ + \dim_to_decimal:n { \tex_baselineskip:D } ~ dup ~ 0 ~ gt + { driver.pt.dvi ~ def } + { pop ~ pop } + ifelse + } + } +\cs_new_protected:Npn \@@_pdf_link_sf_save: + { + \int_gset:Nn \g_@@_pdf_link_sf_int + { + \mode_if_horizontal:TF + { \tex_spacefactor:D } + { 0 } + } + } +\cs_new_protected:Npn \@@_pdf_link_sf_restore: + { + \mode_if_horizontal:T + { + \int_compare:nNnT \g_@@_pdf_link_sf_int > { 0 } + { \int_set_eq:NN \tex_spacefactor:D \g_@@_pdf_link_sf_int } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@startcolumn, \@makecol} +% Hooks to allow link breaking: something will be needed in format mode +% at some stage. +% \begin{macrocode} +%<*package> +\tl_gput_left:Nn \@startcolumn + { + \@@_postscript:n + { + driver.globaldict /driver.brokenlink.rect ~ known + { driver.bordertracking.continue } + if + } + } +\tl_gput_left:Nn \@makecol + { + \vbox_set:Nn \@cclv + { + \vbox_unpack_drop:N \@cclv + \@@_postscript:n + { driver.bordertracking.endpage } + } + } +%</package> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_pdf_link_last:} +% The same as annotations, but with a custom integer. +% \begin{macrocode} +\cs_new:Npn \driver_pdf_link_last: + { { driver.obj \int_use:N \g_@@_pdf_link_int } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_pdf_link_margin:n} +% Convert to big points and pass to PostScript. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_link_margin:n #1 + { + \@@_postscript:x + { + /driver.linkmargin { \dim_to_decimal:n {#1} ~ driver.pt.dvi } def + } + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\driver_pdf_compresslevel:n} +% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} +% These are all no-ops. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } +\cs_new_protected:Npn \driver_pdf_objects_enable: { } +\cs_new_protected:Npn \driver_pdf_objects_disable: { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\driver_pdf_version_major_gset:n, \driver_pdf_version_minor_gset:n} +% Data not available! +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_version_major_gset:n #1 { } +\cs_new_protected:Npn \driver_pdf_version_minor_gset:n #1 { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\driver_pdf_version_major:, \driver_pdf_version_minor:} +% Data not available! +% \begin{macrocode} +\cs_new:Npn \driver_pdf_version_major: { -1 } +\cs_new:Npn \driver_pdf_version_minor: { -1 } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} driver} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \subsubsection{Annotations} +% +% \begin{macro}{\@@_pdf_AR_fix:} +% The fix for the Adobe Reader bug: needed for generic annotations and links. +% \begin{macrocode} +\cs_new_protected:Npx \@@_pdf_AR_fix: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D annot ~ } + { \tex_pdfannot:D } + width ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt + { \c_@@_pdf_AR_fix_tl } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_pdf_annotation:nnnn} +% Simply pass the raw data through, just dealing with evaluation of dimensions. +% \begin{macrocode} +\cs_new_protected:Npx \driver_pdf_annotation:nnnn #1#2#3#4 + { + \@@_pdf_AR_fix: + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D annot ~ } + { \tex_pdfannot:D } + width ~ \exp_not:N \dim_eval:n {#1} ~ + height ~ \exp_not:N \dim_eval:n {#2} ~ + depth ~ \exp_not:N \dim_eval:n {#3} ~ + {#4} + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\driver_pdf_annotation_last:} +% A tiny amount of extra data gets added here. +% \begin{macrocode} +\cs_new:Npx \driver_pdf_annotation_last: + { + \exp_not:N \tex_the:D + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D annot ~ } + { \exp_not:N \tex_pdflastannot:D } + 0 ~ R + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% {\driver_pdf_link_begin_goto:nnw, \driver_pdf_link_begin_user:nnw} +% \begin{macro}{\@@_pdf_link_begin:nnnw} +% \begin{macro}{\driver_pdf_link_end:} +% Links are all created using the same internals. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \@@_pdf_link_begin:nnnw {#1} { goto~name } {#2} } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \@@_pdf_link_begin:nnnw {#1} { user } { /Subtype /Link #2 } } +\cs_new_protected:Npx \@@_pdf_link_begin:nnnw #1#2#3 + { + \@@_pdf_AR_fix: + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D startlink ~ } + { \tex_pdfstartlink:D } + attr {#1} + #2 {#3} + } +\cs_new_protected:Npx \driver_pdf_link_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D endlink \scan_stop: } + { \tex_pdfendlink:D } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_pdf_link_last:} +% Formatted for direct use. +% \begin{macrocode} +\cs_new:Npx \driver_pdf_link_last: + { + \exp_not:N \tex_the:D + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastlink \scan_stop: } + { \exp_not:N \tex_pdflastlink:D } + ~ 0 ~ R + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_pdf_link_margin:n} +% A simple task: pass the data to the primitive. +% \begin{macrocode} +\cs_new_protected:Npx \driver_pdf_link_margin:n #1 + { + \cs_if_exist:NTF \tex_pdfvariable:D + { \exp_not:N \tex_pdfvariable:D linkmargin } + { \exp_not:N \tex_pdflinkmargin:D } + \exp_not:N \dim_eval:n {#1} \scan_stop: + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Objects} +% +% \begin{variable}{\g_@@_pdf_object_prop} +% For tracking objects to allow finalisation. +% \begin{macrocode} +\prop_new:N \g_@@_pdf_object_prop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_pdf_object_new:nn} +% \begin{macro}[EXP]{\driver_pdf_object_ref:n} +% Declaring objects means reserving at the PDF level plus starting +% tracking. +% \begin{macrocode} +\group_begin: + \cs_set_protected:Npn \@@_tmp:w #1#2 + { + \cs_new_protected:Npx \driver_pdf_object_new:nn ##1##2 + { + #1 reserveobjnum ~ + \int_const:cn + { g_@@_pdf_object_ \exp_not:N \tl_to_str:n {##1} _int } + {#2} + \prop_gput:Nnn \exp_not:N \g_@@_pdf_object_prop {##1} {##2} + } + } + \cs_if_exist:NTF \tex_pdfextension:D + { + \@@_tmp:w + { \tex_pdfextension:D obj ~ } + { \tex_pdffeedback:D lastobj \scan_stop: } + } + { \@@_tmp:w { \tex_pdfobj:D } { \tex_pdflastobj:D } } +\group_end: +\cs_new:Npn \driver_pdf_object_ref:n #1 + { \int_use:c { g_@@_pdf_object_ \tl_to_str:n {#1} _int } ~ 0 ~ R } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_pdf_object_write:nn} +% \begin{macro}[EXP]{\@@_exp_not_i:nn, \@@_exp_not_ii:nn} +% Writing the data needs a little information about the structure of the +% object. +% \begin{macrocode} +\group_begin: + \cs_set_protected:Npn \@@_tmp:w #1 + { + \cs_new_protected:Npn \driver_pdf_object_write:nn ##1##2 + { + \tex_immediate:D #1 useobjnum ~ + \int_use:c + { g_@@_pdf_object_ \tl_to_str:n {##1} _int } + \str_case_e:nn + { \prop_item:Nn \g_@@_pdf_object_prop {##1} } + { + { array } { { [ ~ \exp_not:n {##2} ~ ] } } + { dict } { { << ~ \exp_not:n {##2} ~ >> } } + { fstream } + { + stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~ + file ~ { \@@_exp_not_ii:nn ##2 } + } + { stream } + { + stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~ + { \@@_exp_not_ii:nn ##2 } + } + } + } + } + \cs_if_exist:NTF \tex_pdfextension:D + { \@@_tmp:w { \tex_pdfextension:D obj ~ } } + { \@@_tmp:w { \tex_pdfobj:D } } +\group_end: +\cs_new:Npn \@@_exp_not_i:nn #1#2 { \exp_not:n {#1} } +\cs_new:Npn \@@_exp_not_ii:nn #1#2 { \exp_not:n {#2} } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\driver_pdf_compresslevel:n} +% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} +% \begin{macro}{\@@_pdf_objectlevel:n} +% Simply pass data to the engine. +% \begin{macrocode} +\cs_new_protected:Npx \driver_pdf_compresslevel:n #1 + { + \cs_if_exist:NTF \tex_pdfcompresslevel:D + { \tex_pdfcompresslevel:D } + { \tex_pdfvariable:D compresslevel } + \exp_not:N \int_value:w \exp_not:N \int_eval:n {#1} \scan_stop: + } +\cs_new_protected:Npn \driver_pdf_objects_enable: + { \@@_pdf_objectlevel:n { 2 } } +\cs_new_protected:Npn \driver_pdf_objects_disable: + { \@@_pdf_objectlevel:n { 0 } } +\cs_new_protected:Npx \@@_pdf_objectlevel:n #1 + { + \cs_if_exist:NTF \tex_pdfobjcompresslevel:D + { \tex_pdfobjcompresslevel:D } + { \tex_pdfvariable:D objcompresslevel } + #1 \scan_stop: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\driver_pdf_version_major_gset:n, \driver_pdf_version_minor_gset:n} +% At present, we don't have a primitive for the major version in \pdfTeX{}, +% but we anticipate one \ldots +% \begin{macrocode} +\cs_new_protected:Npx \driver_pdf_version_major_gset:n #1 + { + \cs_if_exist:NTF \tex_pdfvariable:D + { + \int_compare:nNnT \tex_luatexversion:D > { 106 } + { + \exp_not:N \tex_global:D \tex_pdfvariable:D majorversion + \exp_not:N \int_eval:n {#1} \scan_stop: + } + } + { + \cs_if_exist:NT \tex_pdfmajorversion:D + { + \exp_not:N \tex_global:D \tex_pdfmajorversion:D + \exp_not:N \int_eval:n {#1} \scan_stop: + } + } + } +\cs_new_protected:Npx \driver_pdf_version_minor_gset:n #1 + { + \exp_not:N \tex_global:D + \cs_if_exist:NTF \tex_pdfminorversion:D + { \exp_not:N \tex_pdfminorversion:D } + { \tex_pdfvariable:D minorversion } + \exp_not:N \int_eval:n {#1} \scan_stop: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\driver_pdf_version_major:, \driver_pdf_version_minor:} +% At present, we don't have a primitive for the major version! +% \begin{macrocode} +\cs_new:Npx \driver_pdf_version_major: + { + \cs_if_exist:NTF \tex_pdfvariable:D + { + \int_compare:nNnTF \tex_luatexversion:D > { 106 } + { \exp_not:N \tex_the:D \tex_pdfvariable:D majorversion } + { 1 } + } + { + \cs_if_exist:NTF \tex_pdfmajorversion:D + { \exp_not:N \tex_the:D \tex_pdfmajorversion:D } + { 1 } + } + } +\cs_new:Npx \driver_pdf_version_minor: + { + \exp_not:N \tex_the:D + \cs_if_exist:NTF \tex_pdfminorversion:D + { \exp_not:N \tex_pdfminorversion:D } + { \tex_pdfvariable:D minorversion } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} driver} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro}{\@@_pdf:n, \@@_pdf:x} +% A generic function for the driver PDF specials: used where we can. +% \begin{macrocode} +\cs_new_protected:Npx \@@_pdf:n #1 + { \@@_literal:n { pdf: #1 } } +\cs_generate_variant:Nn \@@_pdf:n { x } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Objects} +% +% \begin{variable}{\g_@@_pdf_object_int, \g_@@_pdf_object_prop} +% For tracking objects to allow finalisation. +% \begin{macrocode} +\int_new:N \g_@@_pdf_object_int +\prop_new:N \g_@@_pdf_object_prop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_pdf_object_new:nn} +% \begin{macro}[EXP]{\driver_pdf_object_ref:n} +% Objects are tracked at the macro level, but we don't have to do anything +% at this stage. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 + { + \int_gincr:N \g_@@_pdf_object_int + \int_const:cn + { g_@@_pdf_object_ \tl_to_str:n {#1} _int } + { \g_@@_pdf_object_int } + \prop_gput:Nnn \g_@@_pdf_object_prop {#1} {#2} + } +\cs_new:Npn \driver_pdf_object_ref:n #1 + { @driver.obj \int_use:c { g_@@_pdf_object_ \tl_to_str:n {#1} _int } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_pdf_object_write:nn} +% \begin{macro}{\@@_pdf_object_write:nnn} +% \begin{macro} +% { +% \@@_pdf_object_write_array:nn , +% \@@_pdf_object_write_dict:nn , +% \@@_pdf_object_write_fstream:nn , +% \@@_pdf_object_write_stream:nn +% } +% \begin{macro}{\@@_pdf_object_write_stream:nnnn} +% This is where we choose the actual type. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 + { + \exp_args:Nx \@@_pdf_object_write:nnn + { \prop_item:Nn \g_@@_pdf_object_prop {#1} } {#1} {#2} + } +\cs_new_protected:Npn \@@_pdf_object_write:nnn #1#2#3 + { \use:c { @@_pdf_object_write_ #1 :nn } {#2} {#3} } +\cs_new_protected:Npn \@@_pdf_object_write_array:nn #1#2 + { + \@@_pdf:x + { + obj ~ \driver_pdf_object_ref:n {#1} ~ + [ ~ \exp_not:n {#2} ~ ] + } + } +\cs_new_protected:Npn \@@_pdf_object_write_dict:nn #1#2 + { + \@@_pdf:x + { + obj ~ \driver_pdf_object_ref:n {#1} ~ + << ~ \exp_not:n {#2} ~ >> + } + } +\cs_new_protected:Npn \@@_pdf_object_write_fstream:nn #1#2 + { \@@_pdf_object_write_stream:nnnn { f } {#1} #2 } +\cs_new_protected:Npn \@@_pdf_object_write_stream:nn #1#2 + { \@@_pdf_object_write_stream:nnnn { } {#1} #2 } +\cs_new_protected:Npn \@@_pdf_object_write_stream:nnnn #1#2#3#4 + { + \@@_pdf:x + { + #1 stream ~ \driver_pdf_object_ref:n {#2} ~ + ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> + + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Annotations} +% +% \begin{variable}{\g_@@_landscape_bool} +% There is a bug in \texttt{(x)dvipdfmx} which means annotations do +% not rotate. As such, we need to know if landscape is active. +% \begin{macrocode} +\bool_new:N \g_@@_landscape_bool +%<*package> +\AtBeginDocument + { + \cs_if_exist:NT \landscape + { + \tl_put_right:Nn \landscape + { \bool_gset_true:N \g_@@_landscape_bool } + \tl_put_left:Nn \endlandscape + { \bool_gset_false:N \g_@@_landscape_bool } + } + } +%</package> +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_pdf_AR_fix:} +% The fix for the Adobe Reader bug: needed for generic annotations and links. +% \begin{macrocode} +\cs_new_protected:Npx \@@_pdf_AR_fix: + { + \@@_pdf:n + { + ann ~ width ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt + << \c_@@_pdf_AR_fix_tl >> + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\g_@@_pdf_annotation_int} +% Needed as objects which are not annotations could be created. +% \begin{macrocode} +\int_new:N \g_@@_pdf_annotation_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\driver_pdf_annotation:nnnn, \@@_pdf_annotation:nnnn} +% Simply pass the raw data through, just dealing with evaluation of dimensions. +% The only wrinkle is landscape: we have to adjust by hand. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4 + { + \bool_if:NTF \g_@@_landscape_bool + { + \box_move_up:nn {#2} + { + \vbox:n + { + \@@_pdf_annotation:nnnn + { #2 + #3 } {#1} { 0pt } {#4} + } + } + } + { \@@_pdf_annotation:nnnn {#1} {#2} {#3} {#4} } + } +\cs_new_protected:Npn \@@_pdf_annotation:nnnn #1#2#3#4 + { + \@@_pdf_AR_fix: + \int_gincr:N \g_@@_pdf_object_int + \int_gset_eq:NN \g_@@_pdf_annotation_int \g_@@_pdf_object_int + \@@_pdf:x + { + ann ~ @driver.obj \int_use:N \g_@@_pdf_object_int \c_space_tl + width ~ \dim_eval:n {#1} ~ + height ~ \dim_eval:n {#2} ~ + depth ~ \dim_eval:n {#3} ~ + << #4 >> + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% {\driver_pdf_link_begin_goto:nnw, \driver_pdf_link_begin_user:nnw} +% \begin{macro}{\@@_pdf_link_begin:n} +% \begin{macro}{\driver_pdf_link_end:} +% All created using the same internals. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \@@_pdf_link_begin:n { #1 /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \@@_pdf_link_begin:n {#1#2} } +\cs_new_protected:Npn \@@_pdf_link_begin:n #1 + { + \@@_pdf_AR_fix: + \@@_pdf:n + { + bann + << + /Type /Annot + /Subtype /Link + #1 + >> + } + } +\cs_new_protected:Npn \driver_pdf_link_end: + { \@@_pdf:n { eann } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\driver_pdf_link_last:} +% Data not available. +% \begin{macrocode} +\cs_new:Npn \driver_pdf_link_last: { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\driver_pdf_link_margin:n} +% Nope. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_link_margin:n #1 { } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\driver_pdf_compresslevel:n} +% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} +% Pass data to the driver: these are a one-shot. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 + { \@@_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } +\cs_new_protected:Npn \driver_pdf_objects_enable: { } +\cs_new_protected:Npn \driver_pdf_objects_disable: + { \@@_literal:n { dvipdfmx:config~C~0x40 } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\driver_pdf_version_major_gset:n, \driver_pdf_version_minor_gset:n} +% We start with the assumption that the default is active. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_version_major:n #1 + { + \cs_gset:Npx \driver_pdf_version_major: { \int_eval:n {#1} } + \@@_literal:x { pdf:majorversion \driver_pdf_version_major: } + } +\cs_new_protected:Npn \driver_pdf_version_minor:n #1 + { + \cs_gset:Npx \driver_pdf_version_minor: { \int_eval:n {#1} } + \@@_literal:x { pdf:minorversion \driver_pdf_version_minor: } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\driver_pdf_version_major:, \driver_pdf_version_minor:} +% We start with the assumption that the default is active. +% \begin{macrocode} +\cs_new:Npn \driver_pdf_version_major: { 1 } +\cs_new:Npn \driver_pdf_version_minor: { 5 } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} driver} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \subsubsection{Objects} +% +% \begin{macro}{\driver_pdf_object_new:nn} +% \begin{macro}[EXP]{\driver_pdf_object_ref:n} +% \begin{macro}{\driver_pdf_object_write:nn} +% All no-ops here. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 { } +\cs_new:Npn \driver_pdf_object_ref:n #1 { } +\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\driver_pdf_compresslevel:n} +% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} +% These are all no-ops. +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } +\cs_new_protected:Npn \driver_pdf_objects_enable: { } +\cs_new_protected:Npn \driver_pdf_objects_disable: { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\driver_pdf_version_major_gset:n, \driver_pdf_version_minor_gset:n} +% Data not available! +% \begin{macrocode} +\cs_new_protected:Npn \driver_pdf_version_major_gset:n #1 { } +\cs_new_protected:Npn \driver_pdf_version_minor_gset:n #1 { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\driver_pdf_version_major:, \driver_pdf_version_minor:} +% Data not available! +% \begin{macrocode} +\cs_new:Npn \driver_pdf_version_major: { -1 } +\cs_new:Npn \driver_pdf_version_minor: { -1 } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvisvgm> +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx index c7b6b85bc8f..687f8c93dd8 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % @@ -79,11 +79,13 @@ % concepts to be used corrected as they take \enquote{raw} arguments, similar % in format to those used by the underlying driver. % -% The functions in this module should be regarded as experimental with -% the following exceptions: -% \begin{itemize} -% \item \dots -% \end{itemize} +% Given the close coupling of these functions to higher-level interfaces, at +% present the functions given here may change if this is useful for higher-level +% changes. However, equivalent \emph{functionality} will be provided for any +% higher-level function which is itself stable. For example, +% \cs{driver_box_use_rotate:Nn} is needed to implement the stable box rotation +% functions. As such, even if \cs{driver_box_use_rotate:Nn} were to be removed, +% a replacement would be provided. % % \section{Box clipping} % @@ -167,7 +169,7 @@ % % \section{Drawing} % -% The drawing functions provided here are \emph{highly} experimental. They +% These functions % are inspired heavily by the system layer of \pkg{pgf} (most have the % same interface as the same functions in the latter's \cs{pgfsys@\ldots} % namespace). They are intended to form the basis for higher level drawing @@ -469,6 +471,52 @@ % are generated by \texttt{dvips}: this depends on being able to pass % information through correctly. % +% \subsection{PDF Annotations} +% +% \begin{function}[added = 2019-04-10] +% {\driver_pdf_annotation:nnnn} +% \begin{syntax} +% \cs{driver_pdf_annotation:nnnn} \Arg{width} \Arg{height} \Arg{depth} \Arg{dictionary} +% \end{syntax} +% Creates a generic PDF annotation of the given \meta{height}, \meta{width} +% and \meta{depth} and featuring the \meta{dictionary}. +% \end{function} +% +% \begin{function}[added = 2019-04-17] +% { +% \driver_pdf_link_begin_goto:nnw, +% \driver_pdf_link_begin_user:nnw, +% \driver_pdf_link_end: +% } +% \begin{syntax} +% \cs{driver_pdf_link_begin_user:nnw} \Arg{attributes} \Arg{action} +% \Arg{content} +% \cs{driver_pdf_link_end:} +% \end{syntax} +% Creates a link of the \meta{type} |goto| or |user| with the given +% \meta{attributes}, points toward the \meta{action} and surround the +% \TeX{} \meta{content}. The |begin| and |end| functions must be given +% at the same box level. Depending upon the back-end in use, the +% \meta{content} may be placed in a hbox as part of processing. +% \end{function} +% +% \begin{function}[EXP, added = 2019-04-09]{\driver_pdf_link_last:} +% \begin{syntax} +% \cs{driver_pdf_link_last:} +% \end{syntax} +% Expands to the object reference +% \end{function} +% +% \begin{function}[EXP, added = 2019-04-11]{\driver_pdf_link_margin:n} +% \begin{syntax} +% \cs{driver_pdf_link_margin:} \Arg{dimen} +% \end{syntax} +% Sets the length of the margin between content and the border of a link. +% Different back-ends treat the scoping of this value in different ways: +% \pdfTeX{} and \LuaTeX{} treat it as scoped by \TeX{}, whilst with +% \texttt{dvips} the scope is managed at the PostScript level. +% \end{function} +% % \subsection{PDF Objects} % % Objects are used to provide a range of data structures in a PDF. At the @@ -533,2898 +581,35 @@ % be set only once. % \end{function} % +% \begin{function}[EXP, added = 2019-04-11] +% {\driver_pdf_version_major:, \driver_pdf_version_minor:} +% \begin{syntax} +% \cs{driver_pdf_version_major:} +% \cs{driver_pdf_version_minor:} +% \end{syntax} +% Expands to the current value of the major or minor version of PDF being +% created, a non-negative integer. Where a value is not available at the +% \TeX{} run level, the result is $-1$. (This is necessary as the minor +% version may be $0$.) +% \end{function} +% +% \begin{function}[EXP, added = 2019-04-11] +% {\driver_pdf_version_major_gset:n, \driver_pdf_version_minor_gset:n} +% \begin{syntax} +% \cs{driver_pdf_version_major_gset:n} \Arg{integer} +% \cs{driver_pdf_version_minor_gset:n} \Arg{integer} +% \end{syntax} +% Sets the PDF version as specified: the allowable range is not checked +% at this level. +% \end{function} +% % \end{documentation} % % \begin{implementation} % % \section{\pkg{l3drivers} Implementation} % -% \begin{macrocode} -%<*initex|package> -%<@@=driver> -% \end{macrocode} -% -% Whilst there is a reasonable amount of code overlap between drivers, -% it is much clearer to have the blocks more-or-less separated than run -% in together and DocStripped out in parts. As such, most of the following -% is set up on a per-driver basis, though there is some common code (again -% given in blocks not interspersed with other material). -% -% All the file identifiers are up-front so that they come out in the right -% place in the files. -% \begin{macrocode} -%<*package> -\ProvidesExplFile -%<*dvipdfmx> - {l3dvipdfmx.def}{2019-04-06}{} - {L3 Experimental driver: dvipdfmx} -%</dvipdfmx> -%<*dvips> - {l3dvips.def}{2019-04-06}{} - {L3 Experimental driver: dvips} -%</dvips> -%<*dvisvgm> - {l3dvisvgm.def}{2019-04-06}{} - {L3 Experimental driver: dvisvgm} -%</dvisvgm> -%<*pdfmode> - {l3pdfmode.def}{2019-04-06}{} - {L3 Experimental driver: PDF mode} -%</pdfmode> -%<*xdvipdfmx> - {l3xdvipdfmx.def}{2019-04-06}{} - {L3 Experimental driver: xdvipdfmx} -%</xdvipdfmx> -%</package> -% \end{macrocode} -% -% The order of the driver code here is such that we get somewhat logical -% outcomes in terms of code sharing whilst keeping things readable. (Trying to -% mix all of the code by concept is almost unmanageable.) The key parts which -% are shared are -% \begin{itemize} -% \item Color support is either \texttt{dvips}-like or \texttt{pdfmode}-like. -% \item \texttt{pdfmode} and \texttt{(x)dvipdfmx} share drawing routines. -% \item \texttt{xdvipdfmx} is largely the same as \texttt{dvipdfmx} so -% takes most of the same code. -% \end{itemize} -% -% \begin{macro}{\@@_literal:e, \@@_literal:n, \@@_literal:x} -% The one shared function for all drivers is access to the basic -% \tn{special} primitive: it has slightly odd expansion behaviour -% so a wrapper is provided. -% \begin{macrocode} -\cs_new_eq:NN \@@_literal:e \tex_special:D -\cs_new_protected:Npn \@@_literal:n #1 - { \@@_literal:e { \exp_not:n {#1} } } -\cs_generate_variant:Nn \@@_literal:n { x } -% \end{macrocode} -% \end{macro} -% -% \subsection{Color support} -% -% Color support is split into two parts: a \enquote{general} concept and -% one directly linked to drawings (or rather the split between filling -% and stroking). General color is relatively easy to handle: we have a color -% stack available with all modern drivers, and can use that.% -% Whilst \texttt{(x)dvipdfmx} does have its own approach to color specials, -% it is easier to use \texttt{dvips}-like ones for all cases except direct -% PDF output. -% -% \subsubsection{\texttt{dvips}-style} -% -% \begin{macrocode} -%<*dvisvgm|dvipdfmx|dvips|xdvipdfmx> -% \end{macrocode} -% -% \begin{macro}{\driver_color_pickup:N} -% \begin{macro}{\@@_color_pickup:w} -% Allow for \LaTeXe{} color. Here, the possible input values are limited: -% \texttt{dvips}-style colors can mainly be taken as-is with the exception -% spot ones (here we need a model and a tint). -% \begin{macrocode} -%<*package> -\cs_new_protected:Npn \driver_color_pickup:N #1 { } -\AtBeginDocument - { - \@ifpackageloaded { color } - { - \cs_set_protected:Npn \driver_color_pickup:N #1 - { - \exp_args:NV \tl_if_head_is_space:nTF \current@color - { - \tl_set:Nx #1 - { - spot ~ - \exp_after:wN \use:n \current@color \c_space_tl 1 - } - } - { - \exp_last_unbraced:Nx \@@_color_pickup:w - { \current@color } \q_stop #1 - } - } - \cs_new_protected:Npn \@@_color_pickup:w #1 ~ #2 \q_stop #3 - { \tl_set:Nn #3 { #1 ~ #2 } } - } - { } - } -%</package> -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_color_cmyk:nnnn} -% \begin{macro}{\driver_color_gray:n} -% \begin{macro}{\driver_color_rgb:nnn} -% \begin{macro}{\driver_color_spot:nn} -% \begin{macro}{\@@_color_select:n, \@@_color_select:x} -% \begin{macro}{\@@_color_reset:} -% Push the data to the stack. In the case of \texttt{dvips} also reset the -% drawing fill color in raw PostScript. -% \begin{macrocode} -\cs_new_protected:Npn \driver_color_cmyk:nnnn #1#2#3#4 - { - \@@_color_select:x - { - cmyk~ - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} - } - } -\cs_new_protected:Npn \driver_color_gray:n #1 - { \@@_color_select:x { gray~ \fp_eval:n {#1} } } -\cs_new_protected:Npn \driver_color_rgb:nnn #1#2#3 - { - \@@_color_select:x - { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } - } -\cs_new_protected:Npn \driver_color_spot:nn #1#2 - { \@@_color_select:n { #1 } } -\cs_new_protected:Npn \@@_color_select:n #1 - { - \@@_literal:n { color~push~ #1 } -%<*dvips> - \@@_literal_postscript:n { /l3fc~{ }~def } -%</dvips> - \group_insert_after:N \@@_color_reset: - } -\cs_generate_variant:Nn \@@_color_select:n { x } -\cs_new_protected:Npn \@@_color_reset: - { \@@_literal:n { color~pop } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macrocode} -%</dvisvgm|dvipdfmx|dvips|xdvipdfmx> -% \end{macrocode} -% -% \subsubsection{\texttt{pdfmode}} -% -% \begin{macrocode} -%<*pdfmode> -% \end{macrocode} -% -% \begin{macro}{\driver_color_pickup:N} -% \begin{macro}{\@@_color_pickup:w} -% The current color in driver-dependent format: pick up the package-mode -% data if available. We end up converting back and forward in this route as -% we store our color data in \texttt{dvips} format. -% The \tn{current@color} needs to be \texttt{x}-expanded before -% \cs{@@_color_pickup:w} breaks it apart, because for instance -% \pkg{xcolor} sets it to be instructions to generate a colour -% \begin{macrocode} -%<*package> -\cs_new_protected:Npn \driver_color_pickup:N #1 { } -\AtBeginDocument - { - \@ifpackageloaded { color } - { - \cs_set_protected:Npn \driver_color_pickup:N #1 - { - \exp_last_unbraced:Nx \@@_color_pickup:w - { \current@color } ~ 0 ~ 0 ~ 0 \q_stop #1 - } - \cs_new_protected:Npn \@@_color_pickup:w - #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 \q_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 } } - { - \str_if_eq:nnTF {#2} { cs } - { - \tl_set:Nx #7 { spot ~ \use_none:n #1 ~ #5 } - } - { - \tl_set:Nn #7 { gray ~ 0 } - } - } - } - } - } - } - { } - } -%</package> -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{variable}{\l_@@_color_stack_int} -% \pdfTeX{} and \LuaTeX{} have multiple stacks available, and to track -% which one is in use a variable is required. -% \begin{macrocode} -\int_new:N \l_@@_color_stack_int -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\driver_color_cmyk:nnnn, \@@_color_cmyk:nnnn} -% \begin{macro}{\driver_color_gray:n, \@@_color_gray:n} -% \begin{macro}{\driver_color_rgb:nnn, \@@_color_rgb:nnn} -% \begin{macro}{\driver_color_spot:nn} -% \begin{macro}{\@@_color_select:n, \@@_color_select:x} -% \begin{macro}{\@@_color_reset:} -% Simply dump the data, but allowing for \LuaTeX{}. -% \begin{macrocode} -\cs_new_protected:Npn \driver_color_cmyk:nnnn #1#2#3#4 - { - \use:x - { - \@@_color_cmyk:nnnn - { \fp_eval:n {#1} } - { \fp_eval:n {#2} } - { \fp_eval:n {#3} } - { \fp_eval:n {#4} } - } - } -\cs_new_protected:Npn \@@_color_cmyk:nnnn #1#2#3#4 - { - \@@_color_select:n - { #1 ~ #2 ~ #3 ~ #4 ~ k ~ #1 ~ #2 ~ #3 ~ #4 ~ K } - } -\cs_new_protected:Npn \driver_color_gray:n #1 - { \exp_args:Nx \@@_color_gray:n { \fp_eval:n {#1} } } -\cs_new_protected:Npn \@@_color_gray:n #1 - { \@@_color_select:n { #1 ~ g ~ #1 ~ G } } -\cs_new_protected:Npn \driver_color_rgb:nnn #1#2#3 - { - \use:x - { - \@@_color_rgb:nnn - { \fp_eval:n {#1} } - { \fp_eval:n {#2} } - { \fp_eval:n {#3} } - } - } -\cs_new_protected:Npn \@@_color_rgb:nnn #1#2#3 - { \@@_color_select:n { #1 ~ #2 ~ #3 ~ rg ~ #1 ~ #2 ~ #3 ~ RG } } -\cs_new_protected:Npn \driver_color_spot:nn #1#2 - { \@@_color_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ sc ~ #2 ~ SC } } -\cs_new_protected:Npx \@@_color_select:n #1 - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D colorstack } - { \tex_pdfcolorstack:D } - \exp_not:N \l_@@_color_stack_int push {#1} - \group_insert_after:N \exp_not:N \@@_color_reset: - } -\cs_generate_variant:Nn \@@_color_select:n { x } -\cs_new_protected:Npx \@@_color_reset: - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D colorstack } - { \tex_pdfcolorstack:D } - \exp_not:N \l_@@_color_stack_int pop \scan_stop: - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macrocode} -%</pdfmode> -% \end{macrocode} -% -% \subsection{\texttt{dvips} driver} -% -% \begin{macrocode} -%<*dvips> -% \end{macrocode} -% -% \subsubsection{Basics} -% -% \begin{macro}{\@@_literal_postscript:n, \@@_literal_postscript:x} -% Literal PostScript can be included using a few low-level formats. Here, -% we use the form with no positioning: this is overall more convenient as -% a wrapper. Note that this does require that where position is important, -% an appropriate wrapper is included. -% \begin{macrocode} -\cs_new_protected:Npn \@@_literal_postscript:n #1 - { \@@_literal:n { ps:: #1 } } -\cs_generate_variant:Nn \@@_literal_postscript:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_align_currentpoint_begin:, \@@_align_currentpoint_end:} -% In \texttt{dvips} there is no build-in saving of the current -% position, and so some additional PostScript is required to set up the -% transformation matrix and also to restore it afterwards. Notice the use -% of the stack to save the current position \enquote{up front} and to -% move back to it at the end of the process. Notice that the |[begin]|/^^A -% |[end]| pair here mean that we can use a run of PostScript statements -% in separate lines: not \emph{required} but does make the code and -% output more clear. -% \begin{macrocode} -\cs_new_protected:Npn \@@_align_currentpoint_begin: - { - \@@_literal:n { ps::[begin] } - \@@_literal_postscript:n { currentpoint } - \@@_literal_postscript:n { currentpoint~translate } - } -\cs_new_protected:Npn \@@_align_currentpoint_end: - { - \@@_literal_postscript:n { neg~exch~neg~exch~translate } - \@@_literal:n { ps::[end] } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} -% Saving/restoring scope for general operations needs to be done with -% \texttt{dvips} positioning (try without to see this!). Thus we need the -% |ps:| version of the special here. As only the graphics state is ever -% altered within this pairing, we use the lower-cost |g|-versions. -% \begin{macrocode} -\cs_new_protected:Npn \@@_scope_begin: - { \@@_literal:n { ps:gsave } } -\cs_new_protected:Npn \@@_scope_end: - { \@@_literal:n { ps:grestore } } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Box operations} -% -% \begin{macro}{\driver_box_use_clip:N} -% The \texttt{dvips} driver scales all absolute dimensions based on the -% output resolution selected and any \TeX{} magnification. Thus for any -% operation involving absolute lengths there is a correction to make. See -% \texttt{normalscale} from \texttt{special.pro} for the variables, noting -% that here everything is saved on the stack rather than as a separate -% variable. Once all of that is done, the actual clipping is trivial. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_clip:N #1 - { - \@@_scope_begin: - \@@_align_currentpoint_begin: - \@@_literal_postscript:n { matrix~currentmatrix } - \@@_literal_postscript:n - { Resolution~72~div~VResolution~72~div~scale } - \@@_literal_postscript:n { DVImag~dup~scale } - \@@_literal_postscript:x - { - 0 ~ - \dim_to_decimal_in_bp:n { \box_dp:N #1 } ~ - \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ - \dim_to_decimal_in_bp:n { -\box_ht:N #1 - \box_dp:N #1 } ~ - rectclip - } - \@@_literal_postscript:n { setmatrix } - \@@_align_currentpoint_end: - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - \skip_horizontal:n { \box_wd:N #1 } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_box_use_rotate:Nn} -% \begin{macro}{\@@_box_use_rotate:Nn} -% Rotating using \texttt{dvips} does not require that the box dimensions -% are altered and has a very convenient built-in operation. Zero rotation -% must be written as |0| not |-0| so there is a quick test. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 - { \exp_args:NNf \@@_box_use_rotate:Nn #1 { \fp_eval:n {#2} } } -\cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 - { - \@@_scope_begin: - \@@_align_currentpoint_begin: - \@@_literal_postscript:x - { - \fp_compare:nNnTF {#2} = \c_zero_fp - { 0 } - { \fp_eval:n { round ( -(#2) , 5 ) } } ~ - rotate - } - \@@_align_currentpoint_end: - \box_use:N #1 - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_box_use_scale:Nnn} -% The \texttt{dvips} driver once again has a dedicated operation we can -% use here. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 - { - \@@_scope_begin: - \@@_align_currentpoint_begin: - \@@_literal_postscript:x - { - \fp_eval:n { round ( #2 , 5 ) } ~ - \fp_eval:n { round ( #3 , 5 ) } ~ - scale - } - \@@_align_currentpoint_end: - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Images} -% -% \begin{macro}{\@@_image_getbb_eps:n} -% Simply use the generic function. -% \begin{macrocode} -\cs_new_eq:NN \@@_image_getbb_eps:n \image_read_bb:n -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_image_include_eps:n} -% The special syntax is relatively clear here: remember we need PostScript -% sizes here. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_eps:n #1 - { \@@_literal:n { PSfile = #1 } } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Drawing} -% -% \begin{macro}{\@@_draw_literal:n, \@@_draw_literal:x} -% The same as literal PostScript: same arguments about positioning apply -% her. -% \begin{macrocode} -\cs_new_eq:NN \@@_draw_literal:n \@@_literal_postscript:n -\cs_generate_variant:Nn \@@_draw_literal:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_begin:, \driver_draw_end:} -% The |ps::[begin]| special here deals with positioning but allows us to -% continue on to a matching |ps::[end]|: contrast with |ps:|, which positions -% but where we can't split material between separate calls. The -% |@beginspecial|/|@endspecial| pair are from |special.pro| and correct the -% scale and $y$-axis direction. The definition of |/l3fc| deals with fill -% color in paths. In contrast to \pkg{pgf}, we don't save the current point: -% discussion with Tom Rokici suggested a better way to handle the necessary -% translations (see \cs{driver_draw_box_use:Nnnnn}). (Note that -% |@beginspecial|/|@endspecial| forms a driver scope.) The |[begin]|/^^A -% |[end]| lines are handled differently from the rest as they are -% conceptually different: not really drawing literals but instructions to -% \texttt{dvips} itself. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_begin: - { - \@@_literal:n { ps::[begin] } - \@@_draw_literal:n { @beginspecial } - \@@_draw_literal:n { /l3fc~{ }~def } - } -\cs_new_protected:Npn \driver_draw_end: - { - \@@_draw_literal:n { @endspecial } - \@@_literal:n { ps::[end] } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_scope_begin:, \driver_draw_scope_end:} -% Scope here may need to contain saved definitions, so the entire memory -% rather than just the graphic state has to be sent to the stack. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_scope_begin: - { \@@_draw_literal:n { save } } -\cs_new_protected:Npn \driver_draw_scope_end: - { \@@_draw_literal:n { restore } } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_moveto:nn, \driver_draw_lineto:nn} -% \begin{macro}{\driver_draw_rectangle:nnnn} -% \begin{macro}{\driver_draw_curveto:nnnnnn} -% Path creation operations mainly resolve directly to PostScript primitive -% steps, with only the need to convert to \texttt{bp}. Notice that -% \texttt{x}-type expansion is included here to ensure that any variable -% values are forced to literals before any possible caching. There is -% no native rectangular path command (without also clipping, filling or -% stroking), so that task is done using a small amount of PostScript. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 - { - \@@_draw_literal:x - { - \dim_to_decimal_in_bp:n {#1} ~ - \dim_to_decimal_in_bp:n {#2} ~ moveto - } - } -\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 - { - \@@_draw_literal:x - { - \dim_to_decimal_in_bp:n {#1} ~ - \dim_to_decimal_in_bp:n {#2} ~ lineto - } - } -\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 - { - \@@_draw_literal:x - { - \dim_to_decimal_in_bp:n {#4} ~ \dim_to_decimal_in_bp:n {#3} ~ - \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ - moveto~dup~0~rlineto~exch~0~exch~rlineto~neg~0~rlineto~closepath - } - } -\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 - { - \@@_draw_literal:x - { - \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ - \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ - \dim_to_decimal_in_bp:n {#5} ~ \dim_to_decimal_in_bp:n {#6} ~ - curveto - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_evenodd_rule:, \driver_draw_nonzero_rule:} -% \begin{variable}{\g_@@_draw_eor_bool} -% The even-odd rule here can be implemented as a simply switch. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_evenodd_rule: - { \bool_gset_true:N \g_@@_draw_eor_bool } -\cs_new_protected:Npn \driver_draw_nonzero_rule: - { \bool_gset_false:N \g_@@_draw_eor_bool } -\bool_new:N \g_@@_draw_eor_bool -% \end{macrocode} -% \end{variable} -% \end{macro} -% -% \begin{macro} -% { -% \driver_draw_closepath: , -% \driver_draw_stroke: , -% \driver_draw_closestroke: , -% \driver_draw_fill: , -% \driver_draw_fillstroke: , -% \driver_draw_clip: , -% \driver_draw_discardpath: -% } -% \begin{variable}{\g_@@_draw_clip_bool} -% Unlike PDF, PostScript doesn't track separate colors for strokes and other -% elements. It is also desirable to have the |clip| keyword after a stroke or -% fill. To achieve those outcomes, there is some work to do. For color, the -% stoke color is simple but the fill one has to be inserted by hand. For -% clipping, the required ordering is achieved using a \TeX{} switch. All of -% the operations end with a new path instruction as they do not terminate -% (again in contrast to PDF). -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_closepath: - { \@@_draw_literal:n { closepath } } -\cs_new_protected:Npn \driver_draw_stroke: - { - \@@_draw_literal:n { stroke } - \bool_if:NT \g_@@_draw_clip_bool - { - \@@_draw_literal:x - { - \bool_if:NT \g_@@_draw_eor_bool { eo } - clip - } - } - \@@_draw_literal:n { newpath } - \bool_gset_false:N \g_@@_draw_clip_bool - } -\cs_new_protected:Npn \driver_draw_closestroke: - { - \driver_draw_closepath: - \driver_draw_stroke: - } -\cs_new_protected:Npn \driver_draw_fill: - { - \@@_draw_literal:n { gsave } - \@@_draw_literal:n { l3fc } - \@@_draw_literal:x - { - \bool_if:NT \g_@@_draw_eor_bool { eo } - fill - } - \@@_draw_literal:n { grestore } - \bool_if:NT \g_@@_draw_clip_bool - { - \@@_draw_literal:x - { - \bool_if:NT \g_@@_draw_eor_bool { eo } - clip - } - } - \@@_draw_literal:n { newpath } - \bool_gset_false:N \g_@@_draw_clip_bool - } -\cs_new_protected:Npn \driver_draw_fillstroke: - { - \@@_draw_literal:n { gsave } - \@@_draw_literal:n { l3fc } - \@@_draw_literal:x - { - \bool_if:NT \g_@@_draw_eor_bool { eo } - fill - } - \@@_draw_literal:n { grestore } - \@@_draw_literal:n { stroke } - \bool_if:NT \g_@@_draw_clip_bool - { - \@@_draw_literal:x - { - \bool_if:NT \g_@@_draw_eor_bool { eo } - clip - } - } - \@@_draw_literal:n { newpath } - \bool_gset_false:N \g_@@_draw_clip_bool - } -\cs_new_protected:Npn \driver_draw_clip: - { \bool_gset_true:N \g_@@_draw_clip_bool } -\bool_new:N \g_@@_draw_clip_bool -\cs_new_protected:Npn \driver_draw_discardpath: - { - \bool_if:NT \g_@@_draw_clip_bool - { - \@@_draw_literal:x - { - \bool_if:NT \g_@@_draw_eor_bool { eo } - clip - } - } - \@@_draw_literal:n { newpath } - \bool_gset_false:N \g_@@_draw_clip_bool - } -% \end{macrocode} -% \end{variable} -% \end{macro} -% -% \begin{macro}{\driver_draw_dash_pattern:nn} -% \begin{macro}{\@@_draw_dash:n} -% \begin{macro}{\driver_draw_linewidth:n} -% \begin{macro}{\driver_draw_miterlimit:n} -% \begin{macro} -% { -% \driver_draw_cap_butt:, \driver_draw_cap_round:, \driver_draw_cap_rectangle:, -% \driver_draw_join_miter:, \driver_draw_join_round:, \driver_draw_join_bevel: -% } -% Converting paths to output is again a case of mapping directly to -% PostScript operations. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 - { - \@@_draw_literal:x - { - [ - \exp_args:Nf \use:n - { \clist_map_function:nN {#1} \@@_draw_dash:n } - ] ~ - \dim_to_decimal_in_bp:n {#2} ~ setdash - } - } -\cs_new:Npn \@@_draw_dash:n #1 - { ~ \dim_to_decimal_in_bp:n {#1} } -\cs_new_protected:Npn \driver_draw_linewidth:n #1 - { - \@@_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ setlinewidth } - } -\cs_new_protected:Npn \driver_draw_miterlimit:n #1 - { \@@_draw_literal:x { \fp_eval:n {#1} ~ setmiterlimit } } -\cs_new_protected:Npn \driver_draw_cap_butt: - { \@@_draw_literal:n { 0 ~ setlinecap } } -\cs_new_protected:Npn \driver_draw_cap_round: - { \@@_draw_literal:n { 1 ~ setlinecap } } -\cs_new_protected:Npn \driver_draw_cap_rectangle: - { \@@_draw_literal:n { 2 ~ setlinecap } } -\cs_new_protected:Npn \driver_draw_join_miter: - { \@@_draw_literal:n { 0 ~ setlinejoin } } -\cs_new_protected:Npn \driver_draw_join_round: - { \@@_draw_literal:n { 1 ~ setlinejoin } } -\cs_new_protected:Npn \driver_draw_join_bevel: - { \@@_draw_literal:n { 2 ~ setlinejoin } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro} -% { -% \driver_draw_color_fill_cmyk:nnnn , -% \driver_draw_color_stroke_cmyk:nnnn -% } -% \begin{macro} -% { -% \driver_draw_color_fill_gray:n , -% \driver_draw_color_stroke_gray:n -% } -% \begin{macro} -% { -% \driver_draw_color_fill_rgb:nnn , -% \driver_draw_color_stroke_rgb:nnn -% } -% \begin{macro} -% { -% \@@_draw_color_fill:n, \@@_draw_color_fill:x, -% \@@_draw_color_stroke:n, \@@_draw_color_stroke:x -% } -% For \texttt{dvips}, we can use the standard color stack to deal with -% stroke color, but for fills have to switch to raw PostScript. This is -% thus not handled by the stack, but the context is very restricted. See -% also how fills are implemented. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_color_fill_cmyk:nnnn #1#2#3#4 - { - \@@_draw_color_fill:x - { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ - setcmykcolor - } - } -\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 - { - \@@_draw_color_stroke:x - { - cmyk ~ - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} - } - } -\cs_new_protected:Npn \driver_draw_color_fill_gray:n #1 - { \@@_draw_color_fill:x { \fp_eval:n {#1} ~ setgray } } -\cs_new_protected:Npn \driver_draw_color_stroke_gray:n #1 - { \@@_draw_color_stroke:x { gray ~ \fp_eval:n {#1} } } -\cs_new_protected:Npn \driver_draw_color_fill_rgb:nnn #1#2#3 - { - \@@_draw_color_fill:x - { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ setrgbcolor } - } -\cs_new_protected:Npn \driver_draw_color_stroke_rgb:nnn #1#2#3 - { - \@@_draw_color_stroke:x - { rgb ~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } - } -\cs_new_protected:Npn \@@_draw_color_fill:n #1 - { \@@_draw_literal:n { /l3fc ~ { #1 } ~ def } } -\cs_generate_variant:Nn \@@_draw_color_fill:n { x } -\cs_new_protected:Npn \@@_draw_color_stroke:n #1 - { - \@@_literal:n { color~push~#1 } - \group_insert_after:N \@@_color_reset: - } -\cs_generate_variant:Nn \@@_draw_color_stroke:n { x } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_cm:nnnn} -% In \texttt{dvips}, keeping the transformations in line with the engine -% is unfortunately not possible for scaling and rotations: even if we -% decompose the matrix into those operations, there is still no driver -% tracking (\emph{cf.}~\texttt{(x)dvipdfmx}). Thus we take the shortest -% path available and simply dump the matrix as given. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 - { - \@@_draw_literal:n - { - [ - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ - 0 ~ 0 - ] ~ - concat - } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_box_use:Nnnnn} -% Inside a picture |@beginspecial|/|@endspecial| are active, which is -% normally a good thing but means that the position and scaling would be off -% if the box was inserted directly. To deal with that, there are a number of -% possible approaches. The implementation here was suggested by Tom Rokici -% (author of \texttt{dvips}). We end the current special placement, then -% set the current point with a literal |[begin]|. As for general -% literals, we then use the stack to store the current point and move to -% it. To insert the required transformation, we have to flip the $y$-axis, -% once before and once after it. Then we get back to the \TeX{} reference -% point to insert our content. The clean up has to happen in the right -% places, hence the |[begin]|/|[end]| pair around |restore|. Finally, -% we can return to \enquote{normal} drawing mode. Notice that the set up -% here is very similar to that in \cs{@@_align_currentpoint_\ldots}, but -% the ordering of saving and restoring is different (intermixed). -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5 - { - \@@_draw_literal:n { @endspecial } - \@@_draw_literal:n { [end] } - \@@_draw_literal:n { [begin] } - \@@_draw_literal:n { save } - \@@_draw_literal:n { currentpoint } - \@@_draw_literal:n { currentpoint~translate } - \driver_draw_cm:nnnn { 1 } { 0 } { 0 } { -1 } - \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} - \driver_draw_cm:nnnn { 1 } { 0 } { 0 } { -1 } - \@@_draw_literal:n { neg~exch~neg~exch~translate } - \@@_draw_literal:n { [end] } - \hbox_overlap_right:n { \box_use:N #1 } - \@@_draw_literal:n { [begin] } - \@@_draw_literal:n { restore } - \@@_draw_literal:n { [end] } - \@@_draw_literal:n { [begin] } - \@@_draw_literal:n { @beginspecial } - } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{PDF Features} -% -% \begin{variable}{\g_@@_pdf_object_int, \g_@@_pdf_object_prop} -% For tracking objects to allow finalisation. -% \begin{macrocode} -\int_new:N \g_@@_pdf_object_int -\prop_new:N \g_@@_pdf_object_prop -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\driver_pdf_object_new:nn} -% \begin{macro}[EXP]{\driver_pdf_object_ref:n} -% Tracking objects is similar to \texttt{dvipdfmx}. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 - { - \int_gincr:N \g_@@_pdf_object_int - \int_const:cn - { g_@@_pdf_object_ \tl_to_str:n {#1} _int } - { \g_@@_pdf_object_int } - \prop_gput:Nnn \g_@@_pdf_object_prop {#1} {#2} - } -\cs_new:Npn \driver_pdf_object_ref:n #1 - { { l3obj \int_use:c { g_@@_pdf_object_ \tl_to_str:n {#1} _int } } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_pdf_object_write:nn} -% \begin{macro} -% { -% \@@_pdf_object_write_array:nn , -% \@@_pdf_object_write_dict:nn , -% \@@_pdf_object_write_stream:nn -% } -% \begin{macro}{\@@_pdf_object_write_stream:nnn} -% This is where we choose the actual type: some work to get things -% right. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 - { - \@@_literal_postscript:x - { - mark ~ /_objdef ~ \driver_pdf_object_ref:n {#1} ~ - /type - \str_case_e:nn - { \prop_item:Nn \g_@@_pdf_object_prop {#1} } - { - { array } { /array } - { dict } { /dict } - { fstream } { /stream } - { stream } { /stream } - } - /OBJ ~ pdfmark - } - \use:c - { @@_pdf_object_write_ \prop_item:Nn \g_@@_pdf_object_prop {#1} :nn } - {#1} {#2} - } -\cs_new_protected:Npn \@@_pdf_object_write_array:nn #1#2 - { - \@@_literal_postscript:x - { - mark ~ \driver_pdf_object_ref:n {#1} ~ - [ ~ \exp_not:n {#2} ~ ] ~ /PUTINTERVAL ~ pdfmark - } - } -\cs_new_protected:Npn \@@_pdf_object_write_dict:nn #1#2 - { - \@@_literal_postscript:x - { - mark ~ \driver_pdf_object_ref:n {#1} ~ - << ~ \exp_not:n {#2} ~ >> ~ /PUT ~ pdfmark - } - } -\cs_new_protected:Npn \@@_pdf_object_write_stream:nn #1#2 - { - \exp_args:Nx - \@@_pdf_object_write_stream:nnn - { \driver_pdf_object_ref:n {#1} } - #2 - } -\cs_new_protected:Npn \@@_pdf_object_write_stream:nnn #1#2#3 - { - \@@_literal_postscript:n - { - [nobreak] ~ - mark ~ #1 ~ ( #3 ) ~ /PUT ~ pdfmark ~ - mark ~ #1 ~ << #2 >> ~ /PUT ~ pdfmark - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_pdf_compresslevel:n} -% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} -% These are all no-ops. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } -\cs_new_protected:Npn \driver_pdf_objects_enable: { } -\cs_new_protected:Npn \driver_pdf_objects_disable: { } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macrocode} -%</dvips> -% \end{macrocode} -% -% \subsection{\texttt{pdfmode} driver} -% -% \begin{macrocode} -%<*pdfmode> -% \end{macrocode} -% -% The direct PDF driver covers both \pdfTeX{} and \LuaTeX{}. The latter -% renames and restructures the driver primitives but this can be handled -% at one level of abstraction. As such, we avoid using two separate drivers -% for this material at the cost of some \texttt{x}-type definitions to get -% everything expanded up-front. -% -% \subsubsection{Basics} -% -% \begin{macro}{\@@_literal_pdf:n, \@@_literal_pdf:x} -% This is equivalent to \verb|\special{pdf:}| but the engine can -% track it. Without the \texttt{direct} keyword everything is kept in -% sync: the transformation matrix is set to the current point automatically. -% Note that this is still inside the text (\texttt{BT} \dots \texttt{ET} -% block). -% \begin{macrocode} -\cs_new_protected:Npx \@@_literal_pdf:n #1 - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D literal } - { \tex_pdfliteral:D } - { \exp_not:N \exp_not:n {#1} } - } -\cs_generate_variant:Nn \@@_literal_pdf:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} -% Higher-level interfaces for saving and restoring the graphic state. -% \begin{macrocode} -\cs_new_protected:Npx \@@_scope_begin: - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D save \scan_stop: } - { \tex_pdfsave:D } - } -\cs_new_protected:Npx \@@_scope_end: - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D restore \scan_stop: } - { \tex_pdfrestore:D } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_matrix:n, \@@_matrix:x} -% Here the appropriate function is set up to insert an affine matrix -% into the PDF. With \pdfTeX{} and \LuaTeX{} in direct PDF output mode there -% is a primitive for this, which only needs the rotation/scaling/skew part. -% \begin{macrocode} -\cs_new_protected:Npx \@@_matrix:n #1 - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D setmatrix } - { \tex_pdfsetmatrix:D } - { \exp_not:N \exp_not:n {#1} } - } -\cs_generate_variant:Nn \@@_matrix:n { x } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Box operations} -% -% \begin{macro}{\driver_box_use_clip:N} -% The general method is to save the current location, define a clipping path -% equivalent to the bounding box, then insert the content at the current -% position and in a zero width box. The \enquote{real} width is then made up -% using a horizontal skip before tidying up. There are other approaches that -% can be taken (for example using XForm objects), but the logic here shares -% as much code as possible and uses the same conversions (and so same -% rounding errors) in all cases. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_clip:N #1 - { - \@@_scope_begin: - \@@_literal_pdf:x - { - 0~ - \dim_to_decimal_in_bp:n { -\box_dp:N #1 } ~ - \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ - \dim_to_decimal_in_bp:n { \box_ht:N #1 + \box_dp:N #1 } ~ - re~W~n - } - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - \skip_horizontal:n { \box_wd:N #1 } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_box_use_rotate:Nn} -% \begin{macro}{\@@_box_use_rotate:Nn} -% \begin{variable}{\l_@@_cos_fp, \l_@@_sin_fp} -% Rotations are set using an affine transformation matrix which therefore -% requires sine/cosine values not the angle itself. We store the rounded -% values to avoid rounding twice. There are also a couple of comparisons to -% ensure that |-0| is not written to the output, as this avoids any issues -% with problematic display programs. Note that numbers are compared to~$0$ -% after rounding. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 - { \exp_args:NNf \@@_box_use_rotate:Nn #1 { \fp_eval:n {#2} } } -\cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 - { - \@@_scope_begin: - \box_set_wd:Nn #1 { 0pt } - \fp_set:Nn \l_@@_cos_fp { round ( cosd ( #2 ) , 5 ) } - \fp_compare:nNnT \l_@@_cos_fp = \c_zero_fp - { \fp_zero:N \l_@@_cos_fp } - \fp_set:Nn \l_@@_sin_fp { round ( sind ( #2 ) , 5 ) } - \@@_matrix:x - { - \fp_use:N \l_@@_cos_fp \c_space_tl - \fp_compare:nNnTF \l_@@_sin_fp = \c_zero_fp - { 0~0 } - { - \fp_use:N \l_@@_sin_fp - \c_space_tl - \fp_eval:n { -\l_@@_sin_fp } - } - \c_space_tl - \fp_use:N \l_@@_cos_fp - } - \box_use:N #1 - \@@_scope_end: - } -\fp_new:N \l_@@_cos_fp -\fp_new:N \l_@@_sin_fp -% \end{macrocode} -% \end{variable} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_box_use_scale:Nnn} -% The same idea as for rotation but without the complexity of signs and -% cosines. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 - { - \@@_scope_begin: - \@@_matrix:x - { - \fp_eval:n { round ( #2 , 5 ) } ~ - 0~0~ - \fp_eval:n { round ( #3 , 5 ) } - } - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Images} -% -% \begin{variable}{\l_@@_image_attr_tl} -% In PDF mode, additional attributes of an image (such as page number) are -% needed both to obtain the bounding box and when inserting the image: this -% occurs as the image dictionary approach means they are read as part of -% the bounding box operation. As such, it is easier to track additional -% attributes using a dedicated |tl| rather than build up the same data -% twice. -% \begin{macrocode} -\tl_new:N \l_@@_image_attr_tl -% \end{macrocode} -% \end{variable} -% -% \begin{macro} -% {\@@_image_getbb_jpg:n, \@@_image_getbb_pdf:n, \@@_image_getbb_png:n} -% \begin{macro} -% {\@@_image_getbb_auxi:n, \@@_image_getbb_auxii:n} -% Getting the bounding box here requires us to box up the image and -% measure it. To deal with the difference in feature support in bitmap -% and vector images but keeping the common parts, there is a little work -% to do in terms of auxiliaries. The key here is to notice that we need -% two forms of the attributes: a \enquote{short} set to allow us to -% track for caching, and the full form to pass to the primitive. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 - { - \int_zero:N \l_image_page_int - \tl_clear:N \l_image_pagebox_tl - \tl_set:Nx \l_@@_image_attr_tl - { - \tl_if_empty:NF \l_image_decode_tl - { :D \l_image_decodearray_tl } - \bool_if:NT \l_image_interpolate_bool - { :I } - } - \tl_clear:N \l_@@_image_attr_tl - \@@_image_getbb_auxi:n {#1} - } -\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n -\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 - { - \tl_clear:N \l_image_decode_tl - \bool_set_false:N \l_image_interpolate_bool - \tl_set:Nx \l_@@_image_attr_tl - { - : \l_image_pagebox_tl - \int_compare:nNnT \l_image_page_int > 1 - { :P \int_use:N \l_image_page_int } - } - \@@_image_getbb_auxi:n {#1} - } -\cs_new_protected:Npn \@@_image_getbb_auxi:n #1 - { - \image_bb_restore:xF { #1 \l_@@_image_attr_tl } - { \@@_image_getbb_auxii:n {#1} } - } -% \begin{macrocode} -% Measuring the image is done by boxing up: for PDF images we could -% use |\tex_pdfximagebbox:D|, but if doesn't work for other types. -% As the box always starts at $(0,0)$ there is no need to worry about -% the lower-left position. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_getbb_auxii:n #1 - { - \tex_immediate:D \tex_pdfximage:D - \bool_lazy_or:nnT - { \l_image_interpolate_bool } - { ! \tl_if_empty_p:N \l_image_decodearray_tl } - { - attr ~ - { - \tl_if_empty:NF \l_image_decode_tl - { /Decode~[ \l_image_decodearray_tl ] } - \bool_if:NT \l_image_interpolate_bool - { /Interpolate~true } - } - } - \int_compare:nNnT \l_image_page_int > 0 - { page ~ \int_use:N \l_image_page_int } - \tl_if_empty:NF \l_image_pagebox_tl - { \l_image_pagebox_tl } - {#1} - \hbox_set:Nn \l_@@_tmp_box - { \tex_pdfrefximage:D \tex_pdflastximage:D } - \dim_set:Nn \l_image_urx_dim { \box_wd:N \l_@@_tmp_box } - \dim_set:Nn \l_image_ury_dim { \box_ht:N \l_@@_tmp_box } - \int_const:cn { c_@@_image_ #1 \l_@@_image_attr_tl _int } - { \tex_the:D \tex_pdflastximage:D } - \image_bb_save:x { #1 \l_@@_image_attr_tl } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro} -% {\@@_image_include_jpg:n, \@@_image_include_pdf:n, \@@_image_include_png:n} -% Images are already loaded for the measurement part of the code, so -% inclusion is straight-forward, with only any attributes to worry about. The -% latter carry through from determination of the bounding box. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_jpg:n #1 - { - \tex_pdfrefximage:D - \int_use:c { c_@@_image_ #1 \l_@@_image_attr_tl _int } - } -\cs_new_eq:NN \@@_image_include_pdf:n \@@_image_include_jpg:n -\cs_new_eq:NN \@@_image_include_png:n \@@_image_include_jpg:n -% \end{macrocode} -% \end{macro} -% -% \subsubsection{PDF Objects} -% -% \begin{variable}{\g_@@_pdf_object_prop} -% For tracking objects to allow finalisation. -% \begin{macrocode} -\prop_new:N \g_@@_pdf_object_prop -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\driver_pdf_object_new:nn} -% \begin{macro}[EXP]{\driver_pdf_object_ref:n} -% Declaring objects means reserving at the PDF level plus starting -% tracking. -% \begin{macrocode} -\group_begin: - \cs_set_protected:Npn \@@_tmp:w #1#2 - { - \cs_new_protected:Npx \driver_pdf_object_new:nn ##1##2 - { - #1 reserveobjnum ~ - \int_const:cn - { g_@@_pdf_object_ \exp_not:N \tl_to_str:n {##1} _int } - {#2} - \prop_gput:Nnn \exp_not:N \g_@@_pdf_object_prop {##1} {##2} - } - } - \cs_if_exist:NTF \tex_pdfextension:D - { - \@@_tmp:w - { \tex_pdfextension:D obj ~ } - { \tex_pdffeedback:D lastobj \scan_stop: } - } - { \@@_tmp:w { \tex_pdfobj:D } { \tex_pdflastobj:D } } -\group_end: -\cs_new:Npn \driver_pdf_object_ref:n #1 - { \int_use:c { g_@@_pdf_object_ \tl_to_str:n {#1} _int } ~ 0 ~ R } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_pdf_object_write:nn} -% \begin{macro}[EXP]{\@@_exp_not_i:nn, \@@_exp_not_ii:nn} -% Writing the data needs a little information about the structure of the -% object. -% \begin{macrocode} -\group_begin: - \cs_set_protected:Npn \@@_tmp:w #1 - { - \cs_new_protected:Npn \driver_pdf_object_write:nn ##1##2 - { - \tex_immediate:D #1 useobjnum ~ - \int_use:c - { g_@@_pdf_object_ \tl_to_str:n {##1} _int } - \str_case_e:nn - { \prop_item:Nn \g_@@_pdf_object_prop {##1} } - { - { array } { { [ ~ \exp_not:n {##2} ~ ] } } - { dict } { { << ~ \exp_not:n {##2} ~ >> } } - { fstream } - { - stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~ - file ~ { \@@_exp_not_ii:nn ##2 } - } - { stream } - { - stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~ - { \@@_exp_not_ii:nn ##2 } - } - } - } - } - \cs_if_exist:NTF \tex_pdfextension:D - { \@@_tmp:w { \tex_pdfextension:D obj ~ } } - { \@@_tmp:w { \tex_pdfobj:D } } -\group_end: -\cs_new:Npn \@@_exp_not_i:nn #1#2 { \exp_not:n {#1} } -\cs_new:Npn \@@_exp_not_ii:nn #1#2 { \exp_not:n {#2} } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \subsubsection{PDF Structure} -% -% \begin{macro}{\driver_pdf_compresslevel:n} -% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} -% \begin{macro}{\@@_pdf_objectlevel:n} -% Simply pass data to the engine. -% \begin{macrocode} -\cs_new_protected:Npx \driver_pdf_compresslevel:n #1 - { - \cs_if_exist:NTF \tex_pdfcompresslevel:D - { \tex_pdfcompresslevel:D } - { \tex_pdfvariable:D compresslevel } - \exp_not:N \int_value:w \exp_not:N \int_eval:n {#1} \scan_stop: - } -\cs_new_protected:Npn \driver_pdf_objects_enable: - { \@@_pdf_objectlevel:n { 2 } } -\cs_new_protected:Npn \driver_pdf_objects_disable: - { \@@_pdf_objectlevel:n { 0 } } -\cs_new_protected:Npx \@@_pdf_objectlevel:n #1 - { - \cs_if_exist:NTF \tex_pdfobjcompresslevel:D - { \tex_pdfobjcompresslevel:D } - { \tex_pdfvariable:D objcompresslevel } - #1 \scan_stop: - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macrocode} -%</pdfmode> -% \end{macrocode} -% -% \subsection{\texttt{dvipdfmx} driver} -% -% \begin{macrocode} -%<*dvipdfmx|xdvipdfmx> -% \end{macrocode} -% -% The \texttt{dvipdfmx} shares code with the PDF mode one (using the common -% section to this file) but also with \texttt{xdvipdfmx}. The latter is close -% to identical to \texttt{dvipdfmx} and so all of the code here is extracted -% for both drivers, with some \texttt{clean up} for \texttt{xdvipdfmx} as -% required. -% -% \subsubsection{Basics} -% -% \begin{macro}{\@@_literal_pdf:n, \@@_literal_pdf:x} -% Equivalent to \texttt{pdf:content} but favored as the link to -% the \pdfTeX{} primitive approach is clearer. -% \begin{macrocode} -\cs_new_protected:Npn \@@_literal_pdf:n #1 - { \@@_literal:n { pdf:literal~ #1 } } -\cs_generate_variant:Nn \@@_literal_pdf:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} -% Scoping is done using the driver-specific specials. -% \begin{macrocode} -\cs_new_protected:Npn \@@_scope_begin: - { \@@_literal:n { x:gsave } } -\cs_new_protected:Npn \@@_scope_end: - { \@@_literal:n { x:grestore } } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Box operations} -% -% \begin{macro}{\driver_box_use_clip:N} -% The code here is identical to that for \texttt{pdfmode}: unlike rotation and -% scaling, there is no higher-level support in the driver for clipping. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_clip:N #1 - { - \@@_scope_begin: - \@@_literal_pdf:x - { - 0~ - \dim_to_decimal_in_bp:n { -\box_dp:N #1 } ~ - \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ - \dim_to_decimal_in_bp:n { \box_ht:N #1 + \box_dp:N #1 } ~ - re~W~n - } - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - \skip_horizontal:n { \box_wd:N #1 } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_box_use_rotate:Nn} -% \begin{macro}{\@@_box_use_rotate:Nn} -% Rotating in \texttt{(x)}dvipdmfx can be implemented using either PDF or -% driver-specific code. The former approach however is not \enquote{aware} -% of the content of boxes: this means that any embedded links would not be -% adjusted by the rotation. As such, the driver-native approach is preferred: -% the code therefore is similar (though not identical) to the \texttt{dvips} -% version (notice the rotation angle here is positive). As for -% \texttt{dvips}, zero rotation is written as |0| not |-0|. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 - { \exp_args:NNf \@@_box_use_rotate:Nn #1 { \fp_eval:n {#2} } } -\cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 - { - \@@_scope_begin: - \@@_literal:x - { - x:rotate~ - \fp_compare:nNnTF {#2} = \c_zero_fp - { 0 } - { \fp_eval:n { round ( #2 , 5 ) } } - } - \box_use:N #1 - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_box_use_scale:Nnn} -% Much the same idea for scaling: use the higher-level driver operation to allow -% for box content. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 - { - \@@_scope_begin: - \@@_literal:x - { - x:scale~ - \fp_eval:n { round ( #2 , 5 ) } ~ - \fp_eval:n { round ( #3 , 5 ) } - } - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Images} -% -% \begin{macro} -% { -% \@@_image_getbb_eps:n, \@@_image_getbb_jpg:n, -% \@@_image_getbb_pdf:n, \@@_image_getbb_png:n -% } -% Simply use the generic functions: only for \texttt{dvipdfmx} in the -% extraction cases. -% \begin{macrocode} -\cs_new_eq:NN \@@_image_getbb_eps:n \image_read_bb:n -%<*dvipdfmx> -\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 - { - \int_zero:N \l_image_page_int - \tl_clear:N \l_image_pagebox_tl - \image_extract_bb:n {#1} - } -\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n -\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 - { - \tl_clear:N \l_image_decode_tl - \bool_set_false:N \l_image_interpolate_bool - \image_extract_bb:n {#1} - } -%</dvipdfmx> -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{\g_@@_image_int} -% Used to track the object number associated with each image. -% \begin{macrocode} -\int_new:N \g_@@_image_int -% \end{macrocode} -% \end{variable} -% -% \begin{macro} -% { -% \@@_image_include_eps:n, \@@_image_include_jpg:n, -% \@@_image_include_pdf:n, \@@_image_include_png:n -% } -% \begin{macro}{\@@_image_include_auxi:nn} -% \begin{macro}{\@@_image_include_auxii:nnn, \@@_image_include_auxii:xnn} -% \begin{macro}{\@@_image_include_auxiii:nn} -% The special syntax depends on the file type. There is a difference in -% how PDF images are best handled between |dvipdfmx| and |xdvipdfmx|: for -% the latter it is better to use the primitive route. The relevant code for -% that is included later in this file. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_eps:n #1 - { - \@@_literal:n { PSfile = #1 } - } -\cs_new_protected:Npn \@@_image_include_jpg:n #1 - { \@@_image_include_auxi:nn {#1} { image } } -\cs_new_eq:NN \@@_image_include_png:n \@@_image_include_jpg:n -%<*dvipdfmx> -\cs_new_protected:Npn \@@_image_include_pdf:n #1 - { \@@_image_include_auxi:nn {#1} { epdf } } -%</dvipdfmx> -% \end{macrocode} -% Image inclusion is set up to use the fact that each image is stored in -% the PDF as an XObject. This means that we can include repeated images -% only once and refer to them. To allow that, track the nature of each -% image: much the same as for the direct PDF mode case. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_auxi:nn #1#2 - { - \@@_image_include_auxii:xnn - { - \tl_if_empty:NF \l_image_pagebox_tl - { : \l_image_pagebox_tl } - \int_compare:nNnT \l_image_page_int > 1 - { :P \int_use:N \l_image_page_int } - \tl_if_empty:NF \l_image_decode_tl - { :D \l_image_decodearray_tl } - \bool_if:NT \l_image_interpolate_bool - { :I } - } - {#1} {#2} - } -\cs_new_protected:Npn \@@_image_include_auxii:nnn #1#2#3 - { - \int_if_exist:cTF { c_@@_image_ #2#1 _int } - { - \@@_literal:x - { pdf:usexobj~@image \int_use:c { c_@@_image_ #2#1 _int } } - } - { \@@_image_include_auxiii:nn {#2} {#1} {#3} } - } -\cs_generate_variant:Nn \@@_image_include_auxii:nnn { x } -% \end{macrocode} -% Inclusion using the specials is relatively straight-forward, but there -% is one wrinkle. To get the |pagebox| correct for PDF images in all cases, -% it is necessary to provide both that information and the |bbox| argument: -% odd things happen otherwise! -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_auxiii:nnn #1#2#3 - { - \int_gincr:N \g_@@_image_int - \int_const:cn { c_@@_image_ #1#2 _int } { \g_@@_image_int } - \@@_literal:x - { - pdf:#3~ - @image \int_use:c { c_@@_image_ #1#2 _int } - \int_compare:nNnT \l_image_page_int > 1 - { page ~ \int_use:N \l_image_page_int \c_space_tl } - \tl_if_empty:NF \l_image_pagebox_tl - { - pagebox ~ \l_image_pagebox_tl \c_space_tl - bbox ~ - \dim_to_decimal_in_bp:n \l_image_llx_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_lly_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_urx_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_ury_dim \c_space_tl - } - (#1) - \bool_lazy_or:nnT - { \l_image_interpolate_bool } - { ! \tl_if_empty_p:N \l_image_decodearray_tl } - { - << - \tl_if_empty:NF \l_image_decode_tl - { /Decode~[ \l_image_decodearray_tl ] } - \bool_if:NT \l_image_interpolate_bool - { /Interpolate~true> } - >> - } - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \subsubsection{PDF Objects} -% -% \begin{variable}{\g_@@_pdf_object_int, \g_@@_pdf_object_prop} -% For tracking objects to allow finalisation. -% \begin{macrocode} -\int_new:N \g_@@_pdf_object_int -\prop_new:N \g_@@_pdf_object_prop -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\driver_pdf_object_new:nn} -% \begin{macro}[EXP]{\driver_pdf_object_ref:n} -% Objects are tracked at the macro level, but we don't have to do anything -% at this stage. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 - { - \int_gincr:N \g_@@_pdf_object_int - \int_const:cn - { g_@@_pdf_object_ \tl_to_str:n {#1} _int } - { \g_@@_pdf_object_int } - \prop_gput:Nnn \g_@@_pdf_object_prop {#1} {#2} - } -\cs_new:Npn \driver_pdf_object_ref:n #1 - { @l3obj \int_use:c { g_@@_pdf_object_ \tl_to_str:n {#1} _int } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_pdf_object_write:nn} -% \begin{macro}{\@@_pdf_object_write:nnn} -% \begin{macro} -% { -% \@@_pdf_object_write_array:nn , -% \@@_pdf_object_write_dict:nn , -% \@@_pdf_object_write_fstream:nn , -% \@@_pdf_object_write_stream:nn -% } -% \begin{macro}{\@@_pdf_object_write_stream:nnnn} -% This is where we choose the actual type. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 - { - \exp_args:Nx \@@_pdf_object_write:nnn - { \prop_item:Nn \g_@@_pdf_object_prop {#1} } {#1} {#2} - } -\cs_new_protected:Npn \@@_pdf_object_write:nnn #1#2#3 - { \use:c { @@_pdf_object_write_ #1 :nn } {#2} {#3} } -\cs_new_protected:Npn \@@_pdf_object_write_array:nn #1#2 - { - \@@_literal:x - { - pdf:obj ~ \driver_pdf_object_ref:n {#1} ~ - [ ~ \exp_not:n {#2} ~ ] - } - } -\cs_new_protected:Npn \@@_pdf_object_write_dict:nn #1#2 - { - \@@_literal:x - { - pdf:obj ~ \driver_pdf_object_ref:n {#1} ~ - << ~ \exp_not:n {#2} ~ >> - } - } -\cs_new_protected:Npn \@@_pdf_object_write_fstream:nn #1#2 - { \@@_pdf_object_write_stream:nnnn { f } {#1} #2 } -\cs_new_protected:Npn \@@_pdf_object_write_stream:nn #1#2 - { \@@_pdf_object_write_stream:nnnn { } {#1} #2 } -\cs_new_protected:Npn \@@_pdf_object_write_stream:nnnn #1#2#3#4 - { - \@@_literal:x - { - pdf: #1 stream ~ \driver_pdf_object_ref:n {#2} ~ - ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> - - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \subsubsection{PDF Structure} -% -% \begin{macro}{\driver_pdf_compresslevel:n} -% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} -% Pass data to the driver: these are a one-shot. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 - { \@@_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } -\cs_new_protected:Npn \driver_pdf_objects_enable: { } -\cs_new_protected:Npn \driver_pdf_objects_disable: - { \@@_literal:n { dvipdfmx:config~C~0x40 } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macrocode} -%</dvipdfmx|xdvipdfmx> -% \end{macrocode} -% -% \subsection{\texttt{xdvipdfmx} driver} -% -% \begin{macrocode} -%<*xdvipdfmx> -% \end{macrocode} -% -% \subsubsection{Images} -% -% \begin{macro} -% {\@@_image_getbb_jpg:n, \@@_image_getbb_pdf:n, \@@_image_getbb_png:n} -% \begin{macro}{\@@_image_getbb_auxi:nN} -% \begin{macro}{\@@_image_getbb_auxii:nnN, \@@_image_getbb_auxii:VnN} -% \begin{macro}{\@@_image_getbb_auxiii:nNnn} -% \begin{macro}{\@@_image_getbb_auxiv:nnNnn, \@@_image_getbb_auxiv:VnNnn} -% \begin{macro}{\@@_image_getbb_auxv:nNnn, \@@_image_getbb_auxv:nNnn} -% \begin{macro}[EXP]{\@@_image_getbb_pagebox:w} -% For \texttt{xdvipdfmx}, there are two primitives that allow us to obtain -% the bounding box without needing \texttt{extractbb}. The only complexity -% is passing the various minor variations to a common core process. The -% \XeTeX{} primitive omits the text |box| from the page box specification, -% so there is also some \enquote{trimming} to do here. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 - { - \int_zero:N \l_image_page_int - \tl_clear:N \l_image_pagebox_tl - \@@_image_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D - } -\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n -\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 - { - \tl_clear:N \l_image_decode_tl - \bool_set_false:N \l_image_interpolate_bool - \@@_image_getbb_auxi:nN {#1} \tex_XeTeXpdffile:D - } -\cs_new_protected:Npn \@@_image_getbb_auxi:nN #1#2 - { - \int_compare:nNnTF \l_image_page_int > 1 - { \@@_image_getbb_auxii:VnN \l_image_page_int {#1} #2 } - { \@@_image_getbb_auxiii:nNnn {#1} #2 } - } -\cs_new_protected:Npn \@@_image_getbb_auxii:nnN #1#2#3 - { \@@_image_getbb_aux:nNnn {#2} #3 { :P #1 } { page #1 } } -\cs_generate_variant:Nn \@@_image_getbb_auxii:nnN { V } -\cs_new_protected:Npn \@@_image_getbb_auxiii:nNnn #1#2#3#4 - { - \tl_if_empty:NTF \l_image_pagebox_tl - { \@@_image_getbb_auxiv:VnNnn \l_image_pagebox_tl } - { \@@_image_getbb_auxv:nNnn } - {#1} #2 {#3} {#4} - } -\cs_new_protected:Npn \@@_image_getbb_auxiv:nnNnn #1#2#3#4#5 - { - \use:x - { - \@@_image_getbb_auxv:nNnn {#2} #3 { : #1 #4 } - { #5 ~ \@@_image_getbb_pagebox:w #1 } - } - } -\cs_generate_variant:Nn \@@_image_getbb_auxiv:nnNnn { V } -\cs_new_protected:Npn \@@_image_getbb_auxv:nNnn #1#2#3#4 - { - \image_bb_restore:nF {#1#3} - { \@@_image_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } - } -\cs_new_protected:Npn \@@_image_getbb_auxvi:nNnn #1#2#3#4 - { - \hbox_set:Nn \l_@@_tmp_box { #2 #1 ~ #4 } - \dim_set:Nn \l_image_utx_dim { \box_wd:N \l_@@_tmp_box } - \dim_set:Nn \l_image_ury_dim { \box_ht:N \l_@@_tmp_box } - \image_bb_save:n {#1#3} - } -\cs_new:Npn \@@_image_getbb_pagebox:w #1 box {#1} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\@@_image_include_pdf:n} -% For PDF images, properly supporting the |pagebox| concept in \XeTeX{} -% is best done using the |\tex_XeTeXpdffile:D| primitive. The syntax here -% is the same as for the image measurement part, although we know at this -% stage that there must be some valid setting for \cs{l_image_pagebox_tl}. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_pdf:n #1 - { - \tex_XeTeXpdffile:D "#1" ~ - \int_compare:nNnT \l_image_page_int > 0 - { page~ \int_use:N \l_image_page_int } - \@@_image_getbb_auxiv:VnNnn \l_image_pagebox_tl - } -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -%</xdvipdfmx> -% \end{macrocode} -% -% \subsection{Drawing commands: \texttt{pdfmode} and \texttt{(x)dvipdfmx}} -% -% Both \texttt{pdfmode} and \texttt{(x)dvipdfmx} directly produce PDF output -% and understand a shared set of specials for drawing commands. -% -% \begin{macrocode} -%<*dvipdfmx|pdfmode|xdvipdfmx> -% \end{macrocode} -% -% \subsubsection{Drawing} -% -% \begin{macro}{\@@_draw_literal:n, \@@_draw_literal:x} -% Pass data through using a dedicated interface. -% \begin{macrocode} -\cs_new_eq:NN \@@_draw_literal:n \@@_literal_pdf:n -\cs_generate_variant:Nn \@@_draw_literal:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_begin:, \driver_draw_end:} -% No special requirements here, so simply set up a drawing scope. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_begin: - { \driver_draw_scope_begin: } -\cs_new_protected:Npn \driver_draw_end: - { \driver_draw_scope_end: } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_scope_begin:, \driver_draw_scope_end:} -% Use the driver-level scope mechanisms. -% \begin{macrocode} -\cs_new_eq:NN \driver_draw_scope_begin: \@@_scope_begin: -\cs_new_eq:NN \driver_draw_scope_end: \@@_scope_end: -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_moveto:nn, \driver_draw_lineto:nn} -% \begin{macro}{\driver_draw_curveto:nnnnnn} -% \begin{macro}{\driver_draw_rectangle:nnnn} -% Path creation operations all resolve directly to PDF primitive steps, with -% only the need to convert to \texttt{bp}. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 - { - \@@_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } - } -\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 - { - \@@_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } - } -\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 - { - \@@_draw_literal:x - { - \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ - \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ - \dim_to_decimal_in_bp:n {#5} ~ \dim_to_decimal_in_bp:n {#6} ~ - c - } - } -\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 - { - \@@_draw_literal:x - { - \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ - \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ - re - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_evenodd_rule:, \driver_draw_nonzero_rule:} -% \begin{variable}{\g_@@_draw_eor_bool} -% The even-odd rule here can be implemented as a simply switch. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_evenodd_rule: - { \bool_gset_true:N \g_@@_draw_eor_bool } -\cs_new_protected:Npn \driver_draw_nonzero_rule: - { \bool_gset_false:N \g_@@_draw_eor_bool } -\bool_new:N \g_@@_draw_eor_bool -% \end{macrocode} -% \end{variable} -% \end{macro} -% -% \begin{macro} -% { -% \driver_draw_closepath: , -% \driver_draw_stroke: , -% \driver_draw_closestroke: , -% \driver_draw_fill: , -% \driver_draw_fillstroke: , -% \driver_draw_clip: , -% \driver_draw_discardpath: -% } -% Converting paths to output is again a case of mapping directly to -% PDF operations. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_closepath: - { \@@_draw_literal:n { h } } -\cs_new_protected:Npn \driver_draw_stroke: - { \@@_draw_literal:n { S } } -\cs_new_protected:Npn \driver_draw_closestroke: - { \@@_draw_literal:n { s } } -\cs_new_protected:Npn \driver_draw_fill: - { - \@@_draw_literal:x - { f \bool_if:NT \g_@@_draw_eor_bool * } - } -\cs_new_protected:Npn \driver_draw_fillstroke: - { - \@@_draw_literal:x - { B \bool_if:NT \g_@@_draw_eor_bool * } - } -\cs_new_protected:Npn \driver_draw_clip: - { - \@@_draw_literal:x - { W \bool_if:NT \g_@@_draw_eor_bool * } - } -\cs_new_protected:Npn \driver_draw_discardpath: - { \@@_draw_literal:n { n } } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_dash_pattern:nn} -% \begin{macro}{\@@_draw_dash:n} -% \begin{macro}{\driver_draw_linewidth:n} -% \begin{macro}{\driver_draw_miterlimit:n} -% \begin{macro} -% { -% \driver_draw_cap_butt:, \driver_draw_cap_round:, \driver_draw_cap_rectangle:, -% \driver_draw_join_miter:, \driver_draw_join_round:, \driver_draw_join_bevel: -% } -% Converting paths to output is again a case of mapping directly to -% PDF operations. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 - { - \@@_draw_literal:x - { - [ - \exp_args:Nf \use:n - { \clist_map_function:nN {#1} \@@_draw_dash:n } - ] ~ - \dim_to_decimal_in_bp:n {#2} ~ d - } - } -\cs_new:Npn \@@_draw_dash:n #1 - { ~ \dim_to_decimal_in_bp:n {#1} } -\cs_new_protected:Npn \driver_draw_linewidth:n #1 - { - \@@_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ w } - } -\cs_new_protected:Npn \driver_draw_miterlimit:n #1 - { \@@_draw_literal:x { \fp_eval:n {#1} ~ M } } -\cs_new_protected:Npn \driver_draw_cap_butt: - { \@@_draw_literal:n { 0 ~ J } } -\cs_new_protected:Npn \driver_draw_cap_round: - { \@@_draw_literal:n { 1 ~ J } } -\cs_new_protected:Npn \driver_draw_cap_rectangle: - { \@@_draw_literal:n { 2 ~ J } } -\cs_new_protected:Npn \driver_draw_join_miter: - { \@@_draw_literal:n { 0 ~ j } } -\cs_new_protected:Npn \driver_draw_join_round: - { \@@_draw_literal:n { 1 ~ j } } -\cs_new_protected:Npn \driver_draw_join_bevel: - { \@@_draw_literal:n { 2 ~ j } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro} -% { -% \driver_draw_color_fill_cmyk:nnnn , -% \driver_draw_color_stroke_cmyk:nnnn -% } -% \begin{macro} -% { -% \driver_draw_color_fill_gray:n , -% \driver_draw_color_stroke_gray:n -% } -% \begin{macro} -% { -% \driver_draw_color_fill_rgb:nnn , -% \driver_draw_color_stroke_rgb:nnn -% } -% \begin{macro}{\@@_color_fill_select:n, \@@_color_fill_select:x} -% For the stroke color, all engines here can use the color stack to handle -% the setting. However, that is not the case for fill color: the stack in -% \texttt{(x)dvipdfmx} only covers one type of color. So we have to use -% different approaches for the two sets of engines. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_color_fill_cmyk:nnnn #1#2#3#4 - { - \@@_color_fill_select:x - { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ - k - } - } -\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 - { - \@@_color_select:x - { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ - k - } - } -\cs_new_protected:Npn \driver_draw_color_fill_gray:n #1 - { \@@_color_fill_select:x { \fp_eval:n {#1} ~ g } } -\cs_new_protected:Npn \driver_draw_color_stroke_gray:n #1 - { \@@_color_select:x { \fp_eval:n {#1} ~ G } } -\cs_new_protected:Npn \driver_draw_color_fill_rgb:nnn #1#2#3 - { - \@@_color_fill_select:x - { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } - } -\cs_new_protected:Npn \driver_draw_color_stroke_rgb:nnn #1#2#3 - { - \@@_color_select:x - { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } - } -%<*pdfmode> -\cs_new_eq:NN \@@_color_fill_select:n \@@_color_select:n -%</pdfmode> -%<*dvipdfmx|xdvipdfmx> -\cs_new_eq:NN \@@_color_fill_select:n \@@_draw_literal:n -%</dvipdfmx|xdvipdfmx> -\cs_generate_variant:Nn \@@_color_fill_select:n { x } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_cm:nnnn} -% \begin{macro}{\@@_draw_cm:nnnn} -% Another split here between \texttt{pdfmode} and \texttt{(x)dvipdfmx}. -% In the former, we have a direct method to maintain alignment: the driver -% can use a matrix itself. For \texttt{(x)dvipdfmx}, we can to decompose the -% matrix into rotations and a scaling, then use those operations as they -% are handled by the driver. (There is driver support for matrix operations in -% \texttt{(x)dvipdfmx}, but as a matched pair so not suitable for the -% \enquote{stand alone} transformation set up here.) -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 - { -%<*pdfmode> - \@@_matrix:x - { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} - } -%</pdfmode> -%<*dvipdfmx|xdvipdfmx> - \@@_draw_cm_decompose:nnnnN {#1} {#2} {#3} {#4} - \@@_draw_cm:nnnn -%</dvipdfmx|xdvipdfmx> - } -%<*dvipdfmx|xdvipdfmx> -\cs_new_protected:Npn \@@_draw_cm:nnnn #1#2#3#4 - { - \@@_literal:x - { - x:rotate~ - \fp_compare:nNnTF {#1} = \c_zero_fp - { 0 } - { \fp_eval:n { round ( -#1 , 5 ) } } - } - \@@_literal:x - { - x:scale~ - \fp_eval:n { round ( #2 , 5 ) } ~ - \fp_eval:n { round ( #3 , 5 ) } - } - \@@_literal:x - { - x:rotate~ - \fp_compare:nNnTF {#4} = \c_zero_fp - { 0 } - { \fp_eval:n { round ( -#4 , 5 ) } } - } - } -%</dvipdfmx|xdvipdfmx> -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\@@_draw_cm_decompose:nnnnN} -% \begin{macro} -% { -% \@@_draw_cm_decompose_auxi:nnnnN, -% \@@_draw_cm_decompose_auxii:nnnnN, -% \@@_draw_cm_decompose_auxiii:nnnnN, -% } -% Internally, transformations for drawing are tracked as a matrix. Not all -% engines provide a way of dealing with this: if we use a raw matrix, the -% engine looses track of positions (for example for hyperlinks), and this is -% not desirable. They do, however, allow us to track rotations and scalings. -% Luckily, we can decompose any (two-dimensional) matrix into two rotations -% and a single scaling: -% \[ -% \begin{bmatrix} -% A & B \\ C & D -% \end{bmatrix} -% = -% \begin{bmatrix} -% \cos\beta & \sin\beta \\ -\sin\beta & \cos\beta -% \end{bmatrix} -% \begin{bmatrix} -% w_{1} & 0 \\ 0 & w_{2} -% \end{bmatrix} -% \begin{bmatrix} -% \cos\gamma & \sin\gamma \\ -\sin\gamma & \cos\gamma -% \end{bmatrix} -% \] -% The parent matrix can be converted to -% \[ -% \begin{bmatrix} -% A & B \\ C & D -% \end{bmatrix} -% = -% \begin{bmatrix} -% E & H \\-H & E -% \end{bmatrix} -% + -% \begin{bmatrix} -% F & G \\ G & -F -% \end{bmatrix} -% \] -% From these, we can find that -% \begin{align*} -% \frac{w_{1} + w_{2}}{2} &= \sqrt{E^{2} + H^{2}} \\ -% \frac{w_{1} - w_{2}}{2} &= \sqrt{F^{2} + G^{2}} \\ -% \gamma - \beta &= \tan^{-1}(G/F) \\ -% \gamma + \beta &= \tan^{-1}(H/E) -% \end{align*} -% at which point we just have to do various pieces of re-arrangement to -% get all of the values. (See J.~Blinn, \emph{IEEE Comput.\ Graph.\ Appl.}, -% 1996, \textbf{16}, 82--88.) There is one wrinkle: the PostScript (and PDF) -% way of specifying a transformation matrix exchanges where one would -% normally expect $B$ and $C$ to be. -% \begin{macrocode} -%<*dvipdfmx|xdvipdfmx> -\cs_new_protected:Npn \@@_draw_cm_decompose:nnnnN #1#2#3#4#5 - { - \use:x - { - \@@_draw_cm_decompose_auxi:nnnnN - { \fp_eval:n { (#1 + #4) / 2 } } - { \fp_eval:n { (#1 - #4) / 2 } } - { \fp_eval:n { (#3 + #2) / 2 } } - { \fp_eval:n { (#3 - #2) / 2 } } - } - #5 - } -\cs_new_protected:Npn \@@_draw_cm_decompose_auxi:nnnnN #1#2#3#4#5 - { - \use:x - { - \@@_draw_cm_decompose_auxii:nnnnN - { \fp_eval:n { 2 * sqrt ( #1 * #1 + #4 * #4 ) } } - { \fp_eval:n { 2 * sqrt ( #2 * #2 + #3 * #3 ) } } - { \fp_eval:n { atand ( #3 , #2 ) } } - { \fp_eval:n { atand ( #4 , #1 ) } } - } - #5 - } -\cs_new_protected:Npn \@@_draw_cm_decompose_auxii:nnnnN #1#2#3#4#5 - { - \use:x - { - \@@_draw_cm_decompose_auxiii:nnnnN - { \fp_eval:n { ( #4 - #3 ) / 2 } } - { \fp_eval:n { ( #1 + #2 ) / 2 } } - { \fp_eval:n { ( #1 - #2 ) / 2 } } - { \fp_eval:n { ( #4 + #3 ) / 2 } } - } - #5 - } -\cs_new_protected:Npn \@@_draw_cm_decompose_auxiii:nnnnN #1#2#3#4#5 - { - \fp_compare:nNnTF { abs( #2 ) } > { abs ( #3 ) } - { #5 {#1} {#2} {#3} {#4} } - { #5 {#1} {#3} {#2} {#4} } - } -%</dvipdfmx|xdvipdfmx> -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_box_use:Nnnnn} -% Inserting a \TeX{} box transformed to the requested position and using -% the current matrix is done using a mixture of \TeX{} and low-level -% manipulation. The offset can be handled by \TeX{}, so only any rotation/^^A -% skew/scaling component needs to be done using the matrix operation. As this -% operation can never be cached, the scope is set directly not using the -% \texttt{draw} version. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5 - { - \@@_scope_begin: -%<*pdfmode> - \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} -%</pdfmode> -%<*dvipdfmx|xdvipdfmx> - \@@_literal:x - { - pdf:btrans~matrix~ - \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ - \fp_eval:n {#4} ~ \fp_eval:n {#5} ~ - 0 ~ 0 - } -%</dvipdfmx|xdvipdfmx> - \hbox_overlap_right:n { \box_use:N #1 } -%<*dvipdfmx|xdvipdfmx> - \@@_literal:n { pdf:etrans } -%</dvipdfmx|xdvipdfmx> - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -%</dvipdfmx|pdfmode|xdvipdfmx> -% \end{macrocode} -% -% \subsection{\texttt{dvisvgm} driver} -% -% \begin{macrocode} -%<*dvisvgm> -% \end{macrocode} -% -% \subsubsection{Basics} -% -% \begin{macro}{\@@_literal_svg:n, \@@_literal_svg:x} -% Unlike the other drivers, the requirements for making SVG files mean -% that we can't conveniently transform all operations to the current point. -% That makes life a bit more tricky later as that needs to be accounted for. -% A new line is added after each call to help to keep the output readable -% for debugging. -% \begin{macrocode} -\cs_new_protected:Npn \@@_literal_svg:n #1 - { \@@_literal:n { dvisvgm:raw~ #1 { ?nl } } } -\cs_generate_variant:Nn \@@_literal_svg:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_scope_begin:, \@@_scope_end:} -% A scope in SVG terms is slightly different to the other drivers as -% operations have to be \enquote{tied} to these not simply inside them. -% \begin{macrocode} -\cs_new_protected:Npn \@@_scope_begin: - { \@@_literal_svg:n { <g> } } -\cs_new_protected:Npn \@@_scope_end: - { \@@_literal_svg:n { </g> } } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Driver-specific auxiliaries} -% -% \begin{macro}{\@@_scope_begin:n, \@@_scope_begin:x} -% In SVG transformations, clips and so on are attached directly to scopes so -% we need a way or allowing for that. This is rather more useful than -% \cs{@@_scope_begin:} as a result. No assumptions are made about the nature -% of the scoped operation(s). -% \begin{macrocode} -\cs_new_protected:Npn \@@_scope_begin:n #1 - { \@@_literal_svg:n { <g~ #1 > } } -\cs_generate_variant:Nn \@@_scope_begin:n { x } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Box operations} -% -% \begin{macro}{\driver_box_use_clip:N} -% \begin{variable}{\g_@@_clip_path_int} -% Clipping in SVG is more involved than with other drivers. The first issue -% is that the clipping path must be defined separately from where it is used, -% so we need to track how many paths have applied. The naming here uses -% \texttt{l3cp} as the namespace with a number following. Rather than use -% a rectangular operation, we define the path manually as this allows it to -% have a depth: easier than the alternative approach of shifting content -% up and down using scopes to allow for the depth of the \TeX{} box and -% keep the reference point the same! -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_clip:N #1 - { - \int_gincr:N \g_@@_clip_path_int - \@@_literal_svg:x - { < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > } - \@@_literal_svg:x - { - < - path ~ d = - " - M ~ 0 ~ - \dim_to_decimal:n { -\box_dp:N #1 } ~ - L ~ \dim_to_decimal:n { \box_wd:N #1 } ~ - \dim_to_decimal:n { -\box_dp:N #1 } ~ - L ~ \dim_to_decimal:n { \box_wd:N #1 } ~ - \dim_to_decimal:n { \box_ht:N #1 + \box_dp:N #1 } ~ - L ~ 0 ~ - \dim_to_decimal:n { \box_ht:N #1 + \box_dp:N #1 } ~ - Z - " - /> - } - \@@_literal_svg:n - { < /clipPath > } -% \end{macrocode} -% In general the SVG set up does not try to transform coordinates to the -% current point. For clipping we need to do that, so have a transformation -% here to get us to the right place, and a matching one just before the -% \TeX{} box is inserted to get things back on track. The clip path needs to -% come between those two such that if lines up with the current point, as -% does the \TeX{} box. -% \begin{macrocode} - \@@_scope_begin:n - { - transform = - " - translate ( { ?x } , { ?y } ) ~ - scale ( 1 , -1 ) - " - } - \@@_scope_begin:x - { - clip-path = - "url ( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int ) " - } - \@@_scope_begin:n - { - transform = - " - scale ( -1 , 1 ) ~ - translate ( { ?x } , { ?y } ) ~ - scale ( -1 , -1 ) - " - } - \box_use:N #1 - \@@_scope_end: - \@@_scope_end: - \@@_scope_end: -% \skip_horizontal:n { \box_wd:N #1 } - } -\int_new:N \g_@@_clip_path_int -% \end{macrocode} -% \end{variable} -% \end{macro} -% -% \begin{macro}{\driver_box_use_rotate:Nn} -% Rotation has a dedicated operation which includes a centre-of-rotation -% optional pair. That can be picked up from the driver syntax, so there is -% no need to worry about the transformation matrix. -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_rotate:Nn #1#2 - { - \@@_scope_begin:x - { - transform = - " - rotate - ( \fp_eval:n { round ( -(#2) , 5 ) } , ~ { ?x } , ~ { ?y } ) - " - } - \box_use:N #1 - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_box_use_scale:Nnn} -% In contrast to rotation, we have to account for the current position in this -% case. That is done using a couple of translations in addition to the scaling -% (which is therefore done backward with a flip). -% \begin{macrocode} -\cs_new_protected:Npn \driver_box_use_scale:Nnn #1#2#3 - { - \@@_scope_begin:x - { - transform = - " - translate ( { ?x } , { ?y } ) ~ - scale - ( - \fp_eval:n { round ( -#2 , 5 ) } , - \fp_eval:n { round ( -#3 , 5 ) } - ) ~ - translate ( { ?x } , { ?y } ) ~ - scale ( -1 ) - " - } - \hbox_overlap_right:n { \box_use:N #1 } - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Images} -% -% \begin{macro}{\@@_image_getbb_png:n, \@@_image_getbb_jpg:n} -% These can be included by extracting the bounding box data. -% \begin{macrocode} -\cs_new_eq:NN \@@_image_getbb_png:n \image_extract_bb:n -\cs_new_eq:NN \@@_image_getbb_jpg:n \image_extract_bb:n -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_image_include_png:n, \@@_image_include_jpg:n} -% \begin{macro}{\@@_image_include_bitmap_quote:w} -% The driver here has built-in support for basic image inclusion (see -% \texttt{dvisvgm.def} for a more complex approach, needed if clipping, -% \emph{etc.}, is covered at the image driver level). The only issue is -% that |#1| must be quote-corrected. The \texttt{dvisvgm:img} operation -% quotes the file name, but if it is already quoted (contains spaces) -% then we have an issue: we simply strip off any quotes as a result. -% \begin{macrocode} -\cs_new_protected:Npn \@@_image_include_png:n #1 - { - \@@_literal:x - { - dvisvgm:img~ - \dim_to_decimal:n { \l_image_ury_dim } ~ - \dim_to_decimal:n { \l_image_ury_dim } ~ - \@@_image_include_bitmap_quote:w #1 " " \q_stop - } - } -\cs_new_eq:NN \@@_image_include_jpg:n \@@_image_include_png:n -\cs_new:Npn \@@_image_include_bitmap_quote:w #1 " #2 " #3 \q_stop - { #1#2 } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \subsubsection{PDF Features} -% -% \begin{macro}{\driver_pdf_object_new:n} -% \begin{macro}[EXP]{\driver_pdf_object_ref:n} -% \begin{macro}{\driver_pdf_ojbect_write:nn} -% \begin{macro}{\driver_pdf_compresslevel:n} -% \begin{macro}{\driver_pdf_objects_enable:, \driver_pdf_objects_disable:} -% These are all no-ops. -% \begin{macrocode} -\cs_new_protected:Npn \driver_pdf_object_new:n #1 { } -\cs_new:Npn \driver_pdf_object_ref:n #1 { } -\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 { } -\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } -\cs_new_protected:Npn \driver_pdf_objects_enable: { } -\cs_new_protected:Npn \driver_pdf_objects_disable: { } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \subsubsection{Drawing} -% -% \begin{macro}{\@@_draw_literal:n, \@@_draw_literal:x} -% The same as the more general literal call. -% \begin{macrocode} -\cs_new_eq:NN \@@_draw_literal:n \@@_literal_svg:n -\cs_generate_variant:Nn \@@_draw_literal:n { x } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_begin:, \driver_draw_end:} -% A drawing needs to be set up such that the co-ordinate system is -% translated. That is done inside a scope, which as described below -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_begin: - { - \driver_draw_scope_begin: - \@@_draw_scope:n { transform="translate({?x},{?y})~scale(1,-1)" } - } -\cs_new_protected:Npn \driver_draw_end: - { \driver_draw_scope_end: } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_scope_begin:, \driver_draw_scope_end:} -% \begin{macro}{\@@_draw_scope:n, \@@_draw_scope:x} -% \begin{variable}{\g_@@_draw_scope_int, \l_@@_draw_scope_int} -% Several settings that with other drivers are \enquote{stand alone} have -% to be given as part of a scope in SVG. As a result, there is a need to -% provide a mechanism to automatically close these extra scopes. That is -% done using a dedicated function and a pair of tracking variables. Within -% each graphics scope we use a global variable to do the work, with a group -% used to save the value between scopes. The result is that no direct action -% is needed when creating a scope. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_scope_begin: - { - \int_set_eq:NN - \l_@@_draw_scope_int - \g_@@_draw_scope_int - \group_begin: - \int_gzero:N \g_@@_draw_scope_int - } -\cs_new_protected:Npn \driver_draw_scope_end: - { - \prg_replicate:nn - { \g_@@_draw_scope_int } - { \@@_draw_literal:n { </g> } } - \group_end: - \int_gset_eq:NN - \g_@@_draw_scope_int - \l_@@_draw_scope_int - } -\cs_new_protected:Npn \@@_draw_scope:n #1 - { - \@@_draw_literal:n { <g~ #1 > } - \int_gincr:N \g_@@_draw_scope_int - } -\cs_generate_variant:Nn \@@_draw_scope:n { x } -\int_new:N \g_@@_draw_scope_int -\int_new:N \l_@@_draw_scope_int -% \end{macrocode} -% \end{variable} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_moveto:nn, \driver_draw_lineto:nn} -% \begin{macro}{\driver_draw_rectangle:nnnn} -% \begin{macro}{\driver_draw_curveto:nnnnnn} -% \begin{macro}{\@@_draw_add_to_path:n} -% \begin{variable}{\g_@@_draw_path_tl} -% Once again, some work is needed to get path constructs correct. Rather -% then write the values as they are given, the entire path needs to be -% collected up before being output in one go. For that we use a dedicated -% storage routine, which adds spaces as required. Since paths should -% be fully expanded there is no need to worry about the internal -% \texttt{x}-type expansion. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 - { - \@@_draw_add_to_path:n - { M ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } - } -\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 - { - \@@_draw_add_to_path:n - { L ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } - } -\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 - { - \@@_draw_add_to_path:n - { - M ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} - h ~ \dim_to_decimal:n {#3} ~ - v ~ \dim_to_decimal:n {#4} ~ - h ~ \dim_to_decimal:n { -#3 } ~ - Z - } - } -\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 - { - \@@_draw_add_to_path:n - { - C ~ - \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} ~ - \dim_to_decimal:n {#3} ~ \dim_to_decimal:n {#4} ~ - \dim_to_decimal:n {#5} ~ \dim_to_decimal:n {#6} - } - } -\cs_new_protected:Npn \@@_draw_add_to_path:n #1 - { - \tl_gset:Nx \g_@@_draw_path_tl - { - \g_@@_draw_path_tl - \tl_if_empty:NF \g_@@_draw_path_tl { \c_space_tl } - #1 - } - } -\tl_new:N \g_@@_draw_path_tl -% \end{macrocode} -% \end{variable} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_evenodd_rule:, \driver_draw_nonzero_rule:} -% The fill rules here have to be handled as scopes. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_evenodd_rule: - { \@@_draw_scope:n { fill-rule="evenodd" } } -\cs_new_protected:Npn \driver_draw_nonzero_rule: - { \@@_draw_scope:n { fill-rule="nonzero" } } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_draw_path:n} -% \begin{macro} -% { -% \driver_draw_closepath: , -% \driver_draw_stroke: , -% \driver_draw_closestroke: , -% \driver_draw_fill: , -% \driver_draw_fillstroke: , -% \driver_draw_clip: , -% \driver_draw_discardpath: -% } -% \begin{variable}{\g_@@_draw_clip_bool} -% \begin{variable}{\g_@@_draw_path_int} -% Setting fill and stroke effects and doing clipping all has to be done using -% scopes. This means setting up the various requirements in a shared -% auxiliary which deals with the bits and pieces. Clipping paths are reused -% for path drawing: not essential but avoids constructing them twice. -% Discarding a path needs a separate function as it's not quite the same. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_closepath: - { \@@_draw_add_to_path:n { Z } } -\cs_new_protected:Npn \@@_draw_path:n #1 - { - \bool_if:NTF \g_@@_draw_clip_bool - { - \int_gincr:N \g_@@_clip_path_int - \@@_draw_literal:x - { - < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > - { ?nl } - <path~d=" \g_@@_draw_path_tl "/> { ?nl } - < /clipPath > { ? nl } - < - use~xlink:href = - "\c_hash_str l3path \int_use:N \g_@@_path_int " ~ - #1 - /> - } - \@@_draw_scope:x - { - clip-path = - "url( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int)" - } - } - { - \@@_draw_literal:x - { <path ~ d=" \g_@@_draw_path_tl " ~ #1 /> } - } - \tl_gclear:N \g_@@_draw_path_tl - \bool_gset_false:N \g_@@_draw_clip_bool - } -\int_new:N \g_@@_path_int -\cs_new_protected:Npn \driver_draw_stroke: - { \@@_draw_path:n { style="fill:none" } } -\cs_new_protected:Npn \driver_draw_closestroke: - { - \driver_draw_closepath: - \driver_draw_stroke: - } -\cs_new_protected:Npn \driver_draw_fill: - { \@@_draw_path:n { style="stroke:none" } } -\cs_new_protected:Npn \driver_draw_fillstroke: - { \@@_draw_path:n { } } -\cs_new_protected:Npn \driver_draw_clip: - { \bool_gset_true:N \g_@@_draw_clip_bool } -\bool_new:N \g_@@_draw_clip_bool -\cs_new_protected:Npn \driver_draw_discardpath: - { - \bool_if:NT \g_@@_draw_clip_bool - { - \int_gincr:N \g_@@_clip_path_int - \@@_draw_literal:x - { - < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > - { ?nl } - <path~d=" \g_@@_draw_path_tl "/> { ?nl } - < /clipPath > - } - \@@_draw_scope:x - { - clip-path = - "url( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int)" - } - } - \tl_gclear:N \g_@@_draw_path_tl - \bool_gset_false:N \g_@@_draw_clip_bool - } -% \end{macrocode} -% \end{variable} -% \end{variable} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_dash_pattern:nn} -% \begin{macro}{\@@_draw_dash:n} -% \begin{macro}{\@@_draw_dash_aux:nn} -% \begin{macro}{\driver_draw_linewidth:n} -% \begin{macro}{\driver_draw_miterlimit:n} -% \begin{macro} -% { -% \driver_draw_cap_butt:, \driver_draw_cap_round:, \driver_draw_cap_rectangle:, -% \driver_draw_join_miter:, \driver_draw_join_round:, \driver_draw_join_bevel: -% } -% All of these ideas are properties of scopes in SVG. The only slight -% complexity is converting the dash array properly (doing any required -% maths). -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 - { - \use:x - { - \@@_draw_dash_aux:nn - { \clist_map_function:nn {#1} \@@_draw_dash:n } - { \dim_to_decimal:n {#2} } - } - } -\cs_new:Npn \@@_draw_dash:n #1 - { , \dim_to_decimal_in_bp:n {#1} } -\cs_new_protected:Npn \@@_draw_dash_aux:nn #1#2 - { - \@@_draw_scope:x - { - stroke-dasharray = - " - \tl_if_empty:oTF { \use_none:n #1 } - { none } - { \use_none:n #1 } - " ~ - stroke-offset=" #2 " - } - } -\cs_new_protected:Npn \driver_draw_linewidth:n #1 - { \@@_draw_scope:x { stroke-width=" \dim_to_decimal:n {#1} " } } -\cs_new_protected:Npn \driver_draw_miterlimit:n #1 - { \@@_draw_scope:x { stroke-miterlimit=" \fp_eval:n {#1} " } } -\cs_new_protected:Npn \driver_draw_cap_butt: - { \@@_draw_scope:n { stroke-linecap="butt" } } -\cs_new_protected:Npn \driver_draw_cap_round: - { \@@_draw_scope:n { stroke-linecap="round" } } -\cs_new_protected:Npn \driver_draw_cap_rectangle: - { \@@_draw_scope:n { stroke-linecap="square" } } -\cs_new_protected:Npn \driver_draw_join_miter: - { \@@_draw_scope:n { stroke-linejoin="miter" } } -\cs_new_protected:Npn \driver_draw_join_round: - { \@@_draw_scope:n { stroke-linejoin="round" } } -\cs_new_protected:Npn \driver_draw_join_bevel: - { \@@_draw_scope:n { stroke-linejoin="bevel" } } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro} -% { -% \driver_draw_color_fill_cmyk:nnnn , -% \driver_draw_color_stroke_cmyk:nnnn -% } -% \begin{macro} -% { -% \driver_draw_color_fill_gray:n , -% \driver_draw_color_stroke_gray:n -% } -% \begin{macro} -% { -% \driver_draw_color_fill_rgb:nnn , -% \driver_draw_color_stroke_rgb:nnn -% } -% \begin{macro}{\@@_draw_color_fill:nnn} -% SVG fill color has to be covered outside of the stack, as for -% \texttt{dvips}. Here, we are only allowed RGB colors so there is some -% conversion to do. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 - { - \use:x - { - \@@_draw_color_fill:nnn - { \fp_eval:n { -100 * ( (#1) * ( 1 - (#4) ) - 1 ) } } - { \fp_eval:n { -100 * ( (#2) * ( 1 - (#4) ) + #4 - 1 ) } } - { \fp_eval:n { -100 * ( (#3) * ( 1 - (#4) ) + #4 - 1 ) } } - } - } -\cs_new_eq:NN \driver_draw_color_stroke_cmyk:nnnn \driver_color_cmyk:nnnn -\cs_new_protected:Npn \driver_draw_color_gray:n #1 - { - \use:x - { - \@@_draw_color_gray_aux:n - { \fp_eval:n { 100 * (#3) } } - } - } -\cs_new_protected:Npn \@@_draw_color_gray_aux:n #1 - { \@@_draw_color_fill:nnn {#1} {#1} {#1} } -\cs_new_eq:NN \driver_draw_color_stroke_gray:n \driver_color_gray:n -\cs_new_protected:Npn \driver_draw_color_rgb:nnn #1#2#3 - { - \use:x - { - \@@_draw_color_fill:nnn - { \fp_eval:n { 100 * (#1) } } - { \fp_eval:n { 100 * (#2) } } - { \fp_eval:n { 100 * (#3) } } - } - } -\cs_new_protected:Npn \@@_draw_color_fill:nnn #1#2#3 - { - \@@_draw_scope:x - { - fill = - " - rgb - ( - #1 \c_percent_str , - #2 \c_percent_str , - #3 \c_percent_str - ) - " - } - } -\cs_new_eq:NN \driver_draw_color_stroke_rgb:nnn \driver_color_rgb:nnn -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\driver_draw_cm:nnnn} -% The four arguments here are floats (the affine matrix), the last -% two are a displacement vector. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 - { - \@@_draw_scope:n - { - transform = - " - matrix - ( - \fp_eval:n {#1} , \fp_eval:n {#2} , - \fp_eval:n {#3} , \fp_eval:n {#4} , - 0pt , 0pt - ) - " - } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\driver_draw_box_use:Nnnnn} -% No special savings can be made here: simply displace the box inside -% a scope. As there is nothing to re-box, just make the box passed of -% zero size. -% \begin{macrocode} -\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5#6#7 - { - \@@_scope_begin: - \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} - \@@_literal_svg:n - { - < g~ - stroke="none"~ - transform="scale(-1,1)~translate({?x},{?y})~scale(-1,-1)" - > - } - \box_set_wd:Nn #1 { 0pt } - \box_set_ht:Nn #1 { 0pt } - \box_set_dp:Nn #1 { 0pt } - \box_use:N #1 - \@@_literal_svg:n { </g> } - \@@_scope_end: - } -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -%</dvisvgm> -% \end{macrocode} -% -% \begin{macrocode} -%</initex|package> -% \end{macrocode} +% Nothing to see here: everything is in the subfiles! % % \end{implementation} % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx b/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx index 640e75c609f..31f2e717cd3 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx index a5710fed62e..1788f805cc0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3final.dtx b/Master/texmf-dist/source/latex/l3kernel/l3final.dtx index 7d9c2d70dda..83c0a9e06c9 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3final.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3final.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx b/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx index d16397bdcbe..dc677b17047 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3format.ins b/Master/texmf-dist/source/latex/l3kernel/l3format.ins index 1af3587b031..facad3048b4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3format.ins +++ b/Master/texmf-dist/source/latex/l3kernel/l3format.ins @@ -2,7 +2,7 @@ File l3format.ins -Copyright (C) 2011,2012,2014-2018 The LaTeX3 Project +Copyright (C) 2011,2012,2014-2019 The LaTeX3 Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -111,11 +111,71 @@ and all files in that bundle must be distributed together. } } -\generate{\file{l3dvipdfmx.ltx} {\from{l3drivers.dtx}{initex,dvipdfmx} }} -\generate{\file{l3dvips.ltx} {\from{l3drivers.dtx}{initex,dvips} }} -\generate{\file{l3dvisvgm.ltx} {\from{l3drivers.dtx}{initex,dvisvgm} }} -\generate{\file{l3pdfmode.ltx} {\from{l3drivers.dtx}{initex,pdfmode} }} -\generate{\file{l3xdvipdfmx.ltx}{\from{l3drivers.dtx}{initex,xdvipdfmx}}} +\generate + { + \file{l3dvipdfmx.ltx} + { + \from{l3drivers.dtx} {initex,dvipdfmx} + \from{l3drivers-basics.dtx}{initex,dvipdfmx} + \from{l3drivers-color.dtx} {initex,dvipdfmx} + \from{l3drivers-box.dtx} {initex,dvipdfmx} + \from{l3drivers-draw.dtx} {initex,dvipdfmx} + \from{l3drivers-image.dtx} {initex,dvipdfmx} + \from{l3drivers-pdf.dtx} {initex,dvipdfmx} + } + } +\generate + { + \file{l3dvips.ltx} + { + \from{l3drivers.dtx} {initex,dvips} + \from{l3drivers-basics.dtx}{initex,dvips} + \from{l3drivers-color.dtx} {initex,dvips} + \from{l3drivers-box.dtx} {initex,dvips} + \from{l3drivers-draw.dtx} {initex,dvips} + \from{l3drivers-image.dtx} {initex,dvips} + \from{l3drivers-pdf.dtx} {initex,dvips} + } + } +\generate + { + \file{l3dvisvgm.ltx} + { + \from{l3drivers.dtx} {initex,dvisvgm} + \from{l3drivers-basics.dtx}{initex,dvisvgm} + \from{l3drivers-color.dtx} {initex,dvisvgm} + \from{l3drivers-box.dtx} {initex,dvisvgm} + \from{l3drivers-draw.dtx} {initex,dvisvgm} + \from{l3drivers-image.dtx} {initex,dvisvgm} + \from{l3drivers-pdf.dtx} {initex,dvisvgm} + } + } +\generate + { + \file{l3pdfmode.ltx} + { + \from{l3drivers.dtx} {initex,pdfmode} + \from{l3drivers-basics.dtx}{initex,pdfmode} + \from{l3drivers-color.dtx} {initex,pdfmode} + \from{l3drivers-box.dtx} {initex,pdfmode} + \from{l3drivers-draw.dtx} {initex,pdfmode} + \from{l3drivers-image.dtx} {initex,pdfmode} + \from{l3drivers-pdf.dtx} {initex,pdfmode} + } + } +\generate + { + \file{l3xdvipdfmx.ltx} + { + \from{l3drivers.dtx} {initex,xdvipdfmx} + \from{l3drivers-basics.dtx}{initex,xdvipdfmx} + \from{l3drivers-color.dtx} {initex,xdvipdfmx} + \from{l3drivers-box.dtx} {initex,xdvipdfmx} + \from{l3drivers-draw.dtx} {initex,xdvipdfmx} + \from{l3drivers-image.dtx} {initex,xdvipdfmx} + \from{l3drivers-pdf.dtx} {initex,xdvipdfmx} + } + } \generate{\file{l3docstrip.tex}{\from{l3docstrip.dtx}{program}}} @@ -124,7 +184,7 @@ and all files in that bundle must be distributed together. \def\MetaPrefix{--} \preamble -Copyright (C) 1990-2017 The LaTeX3 Project +Copyright (C) 1990-2019 The LaTeX3 Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx index e6076353e7d..b125f5ea225 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % \maketitle % % \begin{documentation} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx index 68245401711..a91ba3739ef 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx index e1dd67628c3..acf8a9730e9 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx index e8cbbd7f3fc..19579e1178a 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx index b9e0f030867..5f4855a1e00 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx index 7eee24882c3..827ef37a567 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx index 18bf4d3be5f..4ac7c2b31b7 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx index 7549f8ba84e..49b590ecb14 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx index 35ab233c74e..c54d211f315 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx index aa47a54a059..ce271732d57 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx index 5404b52b8d3..308ef31eddb 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % \maketitle % % \begin{documentation} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx index c5198dc8873..7364871989c 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx index f8040314ece..57ed60854bb 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx @@ -49,7 +49,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fparray.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fparray.dtx index 1529b05e7ba..524a6f3664b 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fparray.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fparray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx index 79cbc1f25c8..a7d092c5d3f 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3intarray.dtx b/Master/texmf-dist/source/latex/l3kernel/l3intarray.dtx index 2fd96a35a91..fca4e4d1871 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3intarray.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3intarray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3kernel-functions.dtx b/Master/texmf-dist/source/latex/l3kernel/l3kernel-functions.dtx index 937909439b3..a97f81dec26 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3kernel-functions.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3kernel-functions.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx index b13c8cc04d8..3ed79a5a6f0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx index 272c0580221..1f65299275c 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx b/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx index ef474b56734..12b28ac9126 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3names.dtx b/Master/texmf-dist/source/latex/l3kernel/l3names.dtx index e8a90154628..3f28662217f 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3names.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3names.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx b/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx index fe86d50bade..a1a56553da0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx index 076e09e4bf5..52f5eba505f 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx b/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx index 9b663a538e1..6e08abab51e 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx index 94895525546..ced12c3404f 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx index 336ffdc327d..b22030d34cc 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx index 9b6c49c2c83..2a929db3037 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx b/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx index 23f8b34f3bc..7cab64d19f0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3str.dtx b/Master/texmf-dist/source/latex/l3kernel/l3str.dtx index 18f8ba46ffb..0e45bc3f008 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3str.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3str.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx b/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx index 8b2310a2be1..644a578cca8 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3tl-analysis.dtx b/Master/texmf-dist/source/latex/l3kernel/l3tl-analysis.dtx index e9ddfa0b424..19e5e939ccb 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3tl-analysis.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3tl-analysis.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx index c9d8c8b4825..1f75ca2c18c 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3token.dtx b/Master/texmf-dist/source/latex/l3kernel/l3token.dtx index 410473230d4..f8d6b75ffac 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3token.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3token.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx b/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx index 35911365f33..5c826977390 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3unicode.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-04-06} +% \date{Released 2019-04-21} % % \maketitle % diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex index 715c3637b3d..0710918dfaf 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex @@ -63,7 +63,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2019-04-06}% +\def\ExplFileDate{2019-04-21}% \begingroup \def\next{\endgroup}% \expandafter\ifx\csname PackageError\endcsname\relax diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex index 2865a66e848..81c56d71765 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2019-04-06}% +\def\ExplFileDate{2019-04-21}% \let\ExplLoaderFileDate\ExplFileDate \begingroup \def\tempa{LaTeX2e}% diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3.lua b/Master/texmf-dist/tex/latex/l3kernel/expl3.lua index 06b3edd8384..48b4a266506 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3.lua +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3.lua @@ -6,7 +6,7 @@ -- -- l3luatex.dtx (with options: `package,lua') -- --- Copyright (C) 1990-2017 The LaTeX3 Project +-- Copyright (C) 1990-2019 The LaTeX3 Project -- -- It may be distributed and/or modified under the conditions of -- the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3.sty b/Master/texmf-dist/tex/latex/l3kernel/expl3.sty index 4a7c73d8299..d084dafa2fe 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3.sty @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2019-04-06}% +\def\ExplFileDate{2019-04-21}% \let\ExplLoaderFileDate\ExplFileDate \ProvidesPackage{expl3} [% diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def b/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def index 95b580d4e66..7071cac3a1f 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def @@ -5,6 +5,12 @@ %% The original source files were: %% %% l3drivers.dtx (with options: `package,dvipdfmx') +%% l3drivers-basics.dtx (with options: `package,dvipdfmx') +%% l3drivers-color.dtx (with options: `package,dvipdfmx') +%% l3drivers-box.dtx (with options: `package,dvipdfmx') +%% l3drivers-draw.dtx (with options: `package,dvipdfmx') +%% l3drivers-image.dtx (with options: `package,dvipdfmx') +%% l3drivers-pdf.dtx (with options: `package,dvipdfmx') %% %% Copyright (C) 1990-2019 The LaTeX3 Project %% @@ -19,6 +25,7 @@ %% and all files in that bundle must be distributed together. %% %% File: l3drivers.dtx +%% File: l3drivers-basics.dtx \ProvidesExplFile {l3dvipdfmx.def}{2019-04-06}{} {L3 Experimental driver: dvipdfmx} @@ -26,6 +33,14 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \__driver_literal:e { \exp_not:n {#1} } } \cs_generate_variant:Nn \__driver_literal:n { x } +\cs_new_protected:Npn \__driver_literal_pdf:n #1 + { \__driver_literal:n { pdf:literal~ #1 } } +\cs_generate_variant:Nn \__driver_literal_pdf:n { x } +\cs_new_protected:Npn \__driver_scope_begin: + { \__driver_literal:n { x:gsave } } +\cs_new_protected:Npn \__driver_scope_end: + { \__driver_literal:n { x:grestore } } +%% File: l3drivers-color.dtx \cs_new_protected:Npn \driver_color_pickup:N #1 { } \AtBeginDocument { @@ -77,13 +92,7 @@ \cs_generate_variant:Nn \__driver_color_select:n { x } \cs_new_protected:Npn \__driver_color_reset: { \__driver_literal:n { color~pop } } -\cs_new_protected:Npn \__driver_literal_pdf:n #1 - { \__driver_literal:n { pdf:literal~ #1 } } -\cs_generate_variant:Nn \__driver_literal_pdf:n { x } -\cs_new_protected:Npn \__driver_scope_begin: - { \__driver_literal:n { x:gsave } } -\cs_new_protected:Npn \__driver_scope_end: - { \__driver_literal:n { x:grestore } } +%% File: l3drivers-box.dtx \cs_new_protected:Npn \driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -126,141 +135,7 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } -\cs_new_eq:NN \__driver_image_getbb_eps:n \image_read_bb:n -\cs_new_protected:Npn \__driver_image_getbb_jpg:n #1 - { - \int_zero:N \l_image_page_int - \tl_clear:N \l_image_pagebox_tl - \image_extract_bb:n {#1} - } -\cs_new_eq:NN \__driver_image_getbb_png:n \__driver_image_getbb_jpg:n -\cs_new_protected:Npn \__driver_image_getbb_pdf:n #1 - { - \tl_clear:N \l_image_decode_tl - \bool_set_false:N \l_image_interpolate_bool - \image_extract_bb:n {#1} - } -\int_new:N \g__driver_image_int -\cs_new_protected:Npn \__driver_image_include_eps:n #1 - { - \__driver_literal:n { PSfile = #1 } - } -\cs_new_protected:Npn \__driver_image_include_jpg:n #1 - { \__driver_image_include_auxi:nn {#1} { image } } -\cs_new_eq:NN \__driver_image_include_png:n \__driver_image_include_jpg:n -\cs_new_protected:Npn \__driver_image_include_pdf:n #1 - { \__driver_image_include_auxi:nn {#1} { epdf } } -\cs_new_protected:Npn \__driver_image_include_auxi:nn #1#2 - { - \__driver_image_include_auxii:xnn - { - \tl_if_empty:NF \l_image_pagebox_tl - { : \l_image_pagebox_tl } - \int_compare:nNnT \l_image_page_int > 1 - { :P \int_use:N \l_image_page_int } - \tl_if_empty:NF \l_image_decode_tl - { :D \l_image_decodearray_tl } - \bool_if:NT \l_image_interpolate_bool - { :I } - } - {#1} {#2} - } -\cs_new_protected:Npn \__driver_image_include_auxii:nnn #1#2#3 - { - \int_if_exist:cTF { c__driver_image_ #2#1 _int } - { - \__driver_literal:x - { pdf:usexobj~@image \int_use:c { c__driver_image_ #2#1 _int } } - } - { \__driver_image_include_auxiii:nn {#2} {#1} {#3} } - } -\cs_generate_variant:Nn \__driver_image_include_auxii:nnn { x } -\cs_new_protected:Npn \__driver_image_include_auxiii:nnn #1#2#3 - { - \int_gincr:N \g__driver_image_int - \int_const:cn { c__driver_image_ #1#2 _int } { \g__driver_image_int } - \__driver_literal:x - { - pdf:#3~ - @image \int_use:c { c__driver_image_ #1#2 _int } - \int_compare:nNnT \l_image_page_int > 1 - { page ~ \int_use:N \l_image_page_int \c_space_tl } - \tl_if_empty:NF \l_image_pagebox_tl - { - pagebox ~ \l_image_pagebox_tl \c_space_tl - bbox ~ - \dim_to_decimal_in_bp:n \l_image_llx_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_lly_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_urx_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_ury_dim \c_space_tl - } - (#1) - \bool_lazy_or:nnT - { \l_image_interpolate_bool } - { ! \tl_if_empty_p:N \l_image_decodearray_tl } - { - << - \tl_if_empty:NF \l_image_decode_tl - { /Decode~[ \l_image_decodearray_tl ] } - \bool_if:NT \l_image_interpolate_bool - { /Interpolate~true> } - >> - } - } - } -\int_new:N \g__driver_pdf_object_int -\prop_new:N \g__driver_pdf_object_prop -\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 - { - \int_gincr:N \g__driver_pdf_object_int - \int_const:cn - { g__driver_pdf_object_ \tl_to_str:n {#1} _int } - { \g__driver_pdf_object_int } - \prop_gput:Nnn \g__driver_pdf_object_prop {#1} {#2} - } -\cs_new:Npn \driver_pdf_object_ref:n #1 - { @l3obj \int_use:c { g__driver_pdf_object_ \tl_to_str:n {#1} _int } } -\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 - { - \exp_args:Nx \__driver_pdf_object_write:nnn - { \prop_item:Nn \g__driver_pdf_object_prop {#1} } {#1} {#2} - } -\cs_new_protected:Npn \__driver_pdf_object_write:nnn #1#2#3 - { \use:c { __driver_pdf_object_write_ #1 :nn } {#2} {#3} } -\cs_new_protected:Npn \__driver_pdf_object_write_array:nn #1#2 - { - \__driver_literal:x - { - pdf:obj ~ \driver_pdf_object_ref:n {#1} ~ - [ ~ \exp_not:n {#2} ~ ] - } - } -\cs_new_protected:Npn \__driver_pdf_object_write_dict:nn #1#2 - { - \__driver_literal:x - { - pdf:obj ~ \driver_pdf_object_ref:n {#1} ~ - << ~ \exp_not:n {#2} ~ >> - } - } -\cs_new_protected:Npn \__driver_pdf_object_write_fstream:nn #1#2 - { \__driver_pdf_object_write_stream:nnnn { f } {#1} #2 } -\cs_new_protected:Npn \__driver_pdf_object_write_stream:nn #1#2 - { \__driver_pdf_object_write_stream:nnnn { } {#1} #2 } -\cs_new_protected:Npn \__driver_pdf_object_write_stream:nnnn #1#2#3#4 - { - \__driver_literal:x - { - pdf: #1 stream ~ \driver_pdf_object_ref:n {#2} ~ - ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> - - } - } -\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 - { \__driver_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } -\cs_new_protected:Npn \driver_pdf_objects_enable: { } -\cs_new_protected:Npn \driver_pdf_objects_disable: - { \__driver_literal:n { dvipdfmx:config~C~0x40 } } +%% File: l3drivers-draw.dtx \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal_pdf:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \driver_draw_begin: @@ -476,6 +351,230 @@ \__driver_literal:n { pdf:etrans } \__driver_scope_end: } +%% File: l3drivers-image.dtx +\cs_new_eq:NN \__driver_image_getbb_eps:n \image_read_bb:n +\cs_new_protected:Npn \__driver_image_getbb_jpg:n #1 + { + \int_zero:N \l_image_page_int + \tl_clear:N \l_image_pagebox_tl + \image_extract_bb:n {#1} + } +\cs_new_eq:NN \__driver_image_getbb_png:n \__driver_image_getbb_jpg:n +\cs_new_protected:Npn \__driver_image_getbb_pdf:n #1 + { + \tl_clear:N \l_image_decode_tl + \bool_set_false:N \l_image_interpolate_bool + \image_extract_bb:n {#1} + } +\int_new:N \g__driver_image_int +\cs_new_protected:Npn \__driver_image_include_eps:n #1 + { + \__driver_literal:n { PSfile = #1 } + } +\cs_new_protected:Npn \__driver_image_include_jpg:n #1 + { \__driver_image_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \__driver_image_include_png:n \__driver_image_include_jpg:n +\cs_new_protected:Npn \__driver_image_include_pdf:n #1 + { \__driver_image_include_auxi:nn {#1} { epdf } } +\cs_new_protected:Npn \__driver_image_include_auxi:nn #1#2 + { + \__driver_image_include_auxii:xnn + { + \tl_if_empty:NF \l_image_pagebox_tl + { : \l_image_pagebox_tl } + \int_compare:nNnT \l_image_page_int > 1 + { :P \int_use:N \l_image_page_int } + \tl_if_empty:NF \l_image_decode_tl + { :D \l_image_decodearray_tl } + \bool_if:NT \l_image_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \__driver_image_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c__driver_image_ #2#1 _int } + { + \__driver_literal:x + { pdf:usexobj~@image \int_use:c { c__driver_image_ #2#1 _int } } + } + { \__driver_image_include_auxiii:nn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \__driver_image_include_auxii:nnn { x } +\cs_new_protected:Npn \__driver_image_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g__driver_image_int + \int_const:cn { c__driver_image_ #1#2 _int } { \g__driver_image_int } + \__driver_literal:x + { + pdf:#3~ + @image \int_use:c { c__driver_image_ #1#2 _int } + \int_compare:nNnT \l_image_page_int > 1 + { page ~ \int_use:N \l_image_page_int \c_space_tl } + \tl_if_empty:NF \l_image_pagebox_tl + { + pagebox ~ \l_image_pagebox_tl \c_space_tl + bbox ~ + \dim_to_decimal_in_bp:n \l_image_llx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_lly_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_urx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_ury_dim \c_space_tl + } + (#1) + \bool_lazy_or:nnT + { \l_image_interpolate_bool } + { ! \tl_if_empty_p:N \l_image_decodearray_tl } + { + << + \tl_if_empty:NF \l_image_decode_tl + { /Decode~[ \l_image_decodearray_tl ] } + \bool_if:NT \l_image_interpolate_bool + { /Interpolate~true> } + >> + } + } + } +%% File: l3drivers-pdf.dtx +\tl_const:Nn \c__driver_pdf_AR_fix_tl + { /Ff ~ 65537 /FT /Btn /Subtype /Widget } +\cs_new_protected:Npx \__driver_pdf:n #1 + { \__driver_literal:n { pdf: #1 } } +\cs_generate_variant:Nn \__driver_pdf:n { x } +\int_new:N \g__driver_pdf_object_int +\prop_new:N \g__driver_pdf_object_prop +\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 + { + \int_gincr:N \g__driver_pdf_object_int + \int_const:cn + { g__driver_pdf_object_ \tl_to_str:n {#1} _int } + { \g__driver_pdf_object_int } + \prop_gput:Nnn \g__driver_pdf_object_prop {#1} {#2} + } +\cs_new:Npn \driver_pdf_object_ref:n #1 + { @driver.obj \int_use:c { g__driver_pdf_object_ \tl_to_str:n {#1} _int } } +\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 + { + \exp_args:Nx \__driver_pdf_object_write:nnn + { \prop_item:Nn \g__driver_pdf_object_prop {#1} } {#1} {#2} + } +\cs_new_protected:Npn \__driver_pdf_object_write:nnn #1#2#3 + { \use:c { __driver_pdf_object_write_ #1 :nn } {#2} {#3} } +\cs_new_protected:Npn \__driver_pdf_object_write_array:nn #1#2 + { + \__driver_pdf:x + { + obj ~ \driver_pdf_object_ref:n {#1} ~ + [ ~ \exp_not:n {#2} ~ ] + } + } +\cs_new_protected:Npn \__driver_pdf_object_write_dict:nn #1#2 + { + \__driver_pdf:x + { + obj ~ \driver_pdf_object_ref:n {#1} ~ + << ~ \exp_not:n {#2} ~ >> + } + } +\cs_new_protected:Npn \__driver_pdf_object_write_fstream:nn #1#2 + { \__driver_pdf_object_write_stream:nnnn { f } {#1} #2 } +\cs_new_protected:Npn \__driver_pdf_object_write_stream:nn #1#2 + { \__driver_pdf_object_write_stream:nnnn { } {#1} #2 } +\cs_new_protected:Npn \__driver_pdf_object_write_stream:nnnn #1#2#3#4 + { + \__driver_pdf:x + { + #1 stream ~ \driver_pdf_object_ref:n {#2} ~ + ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> + + } + } +\bool_new:N \g__driver_landscape_bool +\AtBeginDocument + { + \cs_if_exist:NT \landscape + { + \tl_put_right:Nn \landscape + { \bool_gset_true:N \g__driver_landscape_bool } + \tl_put_left:Nn \endlandscape + { \bool_gset_false:N \g__driver_landscape_bool } + } + } +\cs_new_protected:Npx \__driver_pdf_AR_fix: + { + \__driver_pdf:n + { + ann ~ width ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt + << \c__driver_pdf_AR_fix_tl >> + } + } +\int_new:N \g__driver_pdf_annotation_int +\cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4 + { + \bool_if:NTF \g__driver_landscape_bool + { + \box_move_up:nn {#2} + { + \vbox:n + { + \__driver_pdf_annotation:nnnn + { #2 + #3 } {#1} { 0pt } {#4} + } + } + } + { \__driver_pdf_annotation:nnnn {#1} {#2} {#3} {#4} } + } +\cs_new_protected:Npn \__driver_pdf_annotation:nnnn #1#2#3#4 + { + \__driver_pdf_AR_fix: + \int_gincr:N \g__driver_pdf_object_int + \int_gset_eq:NN \g__driver_pdf_annotation_int \g__driver_pdf_object_int + \__driver_pdf:x + { + ann ~ @driver.obj \int_use:N \g__driver_pdf_object_int \c_space_tl + width ~ \dim_eval:n {#1} ~ + height ~ \dim_eval:n {#2} ~ + depth ~ \dim_eval:n {#3} ~ + << #4 >> + } + } +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \__driver_pdf_link_begin:n { #1 /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \__driver_pdf_link_begin:n {#1#2} } +\cs_new_protected:Npn \__driver_pdf_link_begin:n #1 + { + \__driver_pdf_AR_fix: + \__driver_pdf:n + { + bann + << + /Type /Annot + /Subtype /Link + #1 + >> + } + } +\cs_new_protected:Npn \driver_pdf_link_end: + { \__driver_pdf:n { eann } } +\cs_new:Npn \driver_pdf_link_last: { } +\cs_new_protected:Npn \driver_pdf_link_margin:n #1 { } +\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 + { \__driver_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } +\cs_new_protected:Npn \driver_pdf_objects_enable: { } +\cs_new_protected:Npn \driver_pdf_objects_disable: + { \__driver_literal:n { dvipdfmx:config~C~0x40 } } +\cs_new_protected:Npn \driver_pdf_version_major:n #1 + { + \cs_gset:Npx \driver_pdf_version_major: { \int_eval:n {#1} } + \__driver_literal:x { pdf:majorversion \driver_pdf_version_major: } + } +\cs_new_protected:Npn \driver_pdf_version_minor:n #1 + { + \cs_gset:Npx \driver_pdf_version_minor: { \int_eval:n {#1} } + \__driver_literal:x { pdf:minorversion \driver_pdf_version_minor: } + } +\cs_new:Npn \driver_pdf_version_major: { 1 } +\cs_new:Npn \driver_pdf_version_minor: { 5 } %% %% %% End of file `l3dvipdfmx.def'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3dvips.def b/Master/texmf-dist/tex/latex/l3kernel/l3dvips.def index db72b671eff..bc9cdcd2874 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3dvips.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3dvips.def @@ -5,6 +5,12 @@ %% The original source files were: %% %% l3drivers.dtx (with options: `package,dvips') +%% l3drivers-basics.dtx (with options: `package,dvips') +%% l3drivers-color.dtx (with options: `package,dvips') +%% l3drivers-box.dtx (with options: `package,dvips') +%% l3drivers-draw.dtx (with options: `package,dvips') +%% l3drivers-image.dtx (with options: `package,dvips') +%% l3drivers-pdf.dtx (with options: `package,dvips') %% %% Copyright (C) 1990-2019 The LaTeX3 Project %% @@ -19,6 +25,7 @@ %% and all files in that bundle must be distributed together. %% %% File: l3drivers.dtx +%% File: l3drivers-basics.dtx \ProvidesExplFile {l3dvips.def}{2019-04-06}{} {L3 Experimental driver: dvips} @@ -26,6 +33,30 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \__driver_literal:e { \exp_not:n {#1} } } \cs_generate_variant:Nn \__driver_literal:n { x } +\cs_new_protected:Npn \__driver_literal_postscript:n #1 + { \__driver_literal:n { ps:: #1 } } +\cs_generate_variant:Nn \__driver_literal_postscript:n { x } +\cs_new_protected:Npn \__driver_postscript:n #1 + { \__driver_literal:n { ps: SDict ~ begin ~ #1 ~ end } } +\cs_generate_variant:Nn \__driver_postscript:n { x } +\cs_new_protected:Npn \__driver_postscript_header:n #1 + { \__driver_literal:n { ! #1 } } +\cs_new_protected:Npn \__driver_align_currentpoint_begin: + { + \__driver_literal:n { ps::[begin] } + \__driver_literal_postscript:n { currentpoint } + \__driver_literal_postscript:n { currentpoint~translate } + } +\cs_new_protected:Npn \__driver_align_currentpoint_end: + { + \__driver_literal_postscript:n { neg~exch~neg~exch~translate } + \__driver_literal:n { ps::[end] } + } +\cs_new_protected:Npn \__driver_scope_begin: + { \__driver_literal:n { ps:gsave } } +\cs_new_protected:Npn \__driver_scope_end: + { \__driver_literal:n { ps:grestore } } +%% File: l3drivers-color.dtx \cs_new_protected:Npn \driver_color_pickup:N #1 { } \AtBeginDocument { @@ -72,30 +103,13 @@ \cs_new_protected:Npn \__driver_color_select:n #1 { \__driver_literal:n { color~push~ #1 } - \__driver_literal_postscript:n { /l3fc~{ }~def } + \__driver_postscript:n { /driver.fc~{ }~def } \group_insert_after:N \__driver_color_reset: } \cs_generate_variant:Nn \__driver_color_select:n { x } \cs_new_protected:Npn \__driver_color_reset: { \__driver_literal:n { color~pop } } -\cs_new_protected:Npn \__driver_literal_postscript:n #1 - { \__driver_literal:n { ps:: #1 } } -\cs_generate_variant:Nn \__driver_literal_postscript:n { x } -\cs_new_protected:Npn \__driver_align_currentpoint_begin: - { - \__driver_literal:n { ps::[begin] } - \__driver_literal_postscript:n { currentpoint } - \__driver_literal_postscript:n { currentpoint~translate } - } -\cs_new_protected:Npn \__driver_align_currentpoint_end: - { - \__driver_literal_postscript:n { neg~exch~neg~exch~translate } - \__driver_literal:n { ps::[end] } - } -\cs_new_protected:Npn \__driver_scope_begin: - { \__driver_literal:n { ps:gsave } } -\cs_new_protected:Npn \__driver_scope_end: - { \__driver_literal:n { ps:grestore } } +%% File: l3drivers-box.dtx \cs_new_protected:Npn \driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -149,16 +163,14 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } -\cs_new_eq:NN \__driver_image_getbb_eps:n \image_read_bb:n -\cs_new_protected:Npn \__driver_image_include_eps:n #1 - { \__driver_literal:n { PSfile = #1 } } +%% File: l3drivers-draw.dtx \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal_postscript:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \driver_draw_begin: { \__driver_literal:n { ps::[begin] } \__driver_draw_literal:n { @beginspecial } - \__driver_draw_literal:n { /l3fc~{ }~def } + \__driver_darw_literal:n { SDict ~ begin ~ /driver.fc ~ { } ~ def ~ end } } \cs_new_protected:Npn \driver_draw_end: { @@ -233,7 +245,7 @@ \cs_new_protected:Npn \driver_draw_fill: { \__driver_draw_literal:n { gsave } - \__driver_draw_literal:n { l3fc } + \__driver_draw_literal:n { driver.fc } \__driver_draw_literal:x { \bool_if:NT \g__driver_draw_eor_bool { eo } @@ -254,7 +266,7 @@ \cs_new_protected:Npn \driver_draw_fillstroke: { \__driver_draw_literal:n { gsave } - \__driver_draw_literal:n { l3fc } + \__driver_draw_literal:n { driver.fc } \__driver_draw_literal:x { \bool_if:NT \g__driver_draw_eor_bool { eo } @@ -354,7 +366,7 @@ { rgb ~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } } \cs_new_protected:Npn \__driver_draw_color_fill:n #1 - { \__driver_draw_literal:n { /l3fc ~ { #1 } ~ def } } + { \__driver_postscript:n { SDict ~ begin ~ /driver.fc ~ { #1 } ~ def ~ end } } \cs_generate_variant:Nn \__driver_draw_color_fill:n { x } \cs_new_protected:Npn \__driver_draw_color_stroke:n #1 { @@ -394,6 +406,13 @@ \__driver_draw_literal:n { [begin] } \__driver_draw_literal:n { @beginspecial } } +%% File: l3drivers-image.dtx +\cs_new_eq:NN \__driver_image_getbb_eps:n \image_read_bb:n +\cs_new_protected:Npn \__driver_image_include_eps:n #1 + { \__driver_literal:n { PSfile = #1 } } +%% File: l3drivers-pdf.dtx +\tl_const:Nn \c__driver_pdf_AR_fix_tl + { /Ff ~ 65537 /FT /Btn /Subtype /Widget } \int_new:N \g__driver_pdf_object_int \prop_new:N \g__driver_pdf_object_prop \cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 @@ -405,12 +424,12 @@ \prop_gput:Nnn \g__driver_pdf_object_prop {#1} {#2} } \cs_new:Npn \driver_pdf_object_ref:n #1 - { { l3obj \int_use:c { g__driver_pdf_object_ \tl_to_str:n {#1} _int } } } + { { driver.obj \int_use:c { g__driver_pdf_object_ \tl_to_str:n {#1} _int } } } \cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 { - \__driver_literal_postscript:x + \__driver_postscript:x { - mark ~ /_objdef ~ \driver_pdf_object_ref:n {#1} ~ + mark /_objdef ~ \driver_pdf_object_ref:n {#1} /type \str_case_e:nn { \prop_item:Nn \g__driver_pdf_object_prop {#1} } @@ -428,18 +447,18 @@ } \cs_new_protected:Npn \__driver_pdf_object_write_array:nn #1#2 { - \__driver_literal_postscript:x + \__driver_postscript:x { - mark ~ \driver_pdf_object_ref:n {#1} ~ + mark ~ \driver_pdf_object_ref:n {#1} [ ~ \exp_not:n {#2} ~ ] ~ /PUTINTERVAL ~ pdfmark } } \cs_new_protected:Npn \__driver_pdf_object_write_dict:nn #1#2 { - \__driver_literal_postscript:x + \__driver_postscript:x { - mark ~ \driver_pdf_object_ref:n {#1} ~ - << ~ \exp_not:n {#2} ~ >> ~ /PUT ~ pdfmark + mark ~ \driver_pdf_object_ref:n {#1} + << \exp_not:n {#2} >> /PUT ~ pdfmark } } \cs_new_protected:Npn \__driver_pdf_object_write_stream:nn #1#2 @@ -451,16 +470,587 @@ } \cs_new_protected:Npn \__driver_pdf_object_write_stream:nnn #1#2#3 { - \__driver_literal_postscript:n + \__driver_postscript:n + { + [nobreak] + mark ~ #1 ~ ( #3 ) /PUT ~ pdfmark ~ + mark ~ #1 ~ << #2 >> /PUT ~ pdfmark + } + } +\__driver_postscript_header:n + { + true ~ setglobal ~ + /driver.globaldict ~ 4 ~ dict ~ def ~ + false ~ setglobal + } +\__driver_postscript_header:n + { + /driver.cvs { 65534 ~ string ~ cvs } def + /driver.pt.dvi { 72.27 ~ div ~ Resolution ~ mul } def + /driver.rect.ht { dup ~ 1 ~ get ~ neg ~ exch ~ 3 ~ get ~ add } def + } +\__driver_postscript_header:n + { + /driver.linkmargin { 1 ~ driver.pt.dvi } def + /driver.linkdp.pad { 0 } def + /driver.linkht.pad { 0 } def + } +\__driver_postscript_header:n + { + /driver.annotation.border + { /Rect [ driver.llx ~ driver.lly ~ driver.urx ~ driver.ury ] } def + /driver.annotation.ll + { + currentpoint + /driver.lly ~ exch ~ def + /driver.llx ~ exch ~ def + } + def + /driver.annotation.ur + { + currentpoint + /driver.ury ~ exch ~ def + /driver.urx ~ exch ~ def + } + def + /driver.link.ll + { + currentpoint ~ + driver.linkmargin ~ add ~ + driver.linkdp.pad ~ add + /driver.lly ~ exch ~ def ~ + driver.linkmargin ~ sub + /driver.llx ~ exch ~ def + } + def + /driver.link.ur + { + currentpoint ~ + driver.linkmargin ~ sub ~ + driver.linkht.pad ~ sub + /driver.ury ~ exch ~ def ~ + driver.linkmargin ~ add + /driver.urx ~ exch ~ def + } + def + } +\__driver_postscript_header:n + { + /driver.bordertracking ~ false ~ def + /driver.bordertracking.begin + { + SDict ~ /driver.bordertracking ~ true ~ put ~ + SDict ~ /driver.leftboundary ~ undef ~ + SDict ~ /driver.rightboundary ~ undef ~ + /a ~ where + { + /a + { + currentpoint ~ pop ~ + SDict /driver.rightboundary ~ known ~ dup + { + SDict /driver.rightboundary ~ get ~ 2 ~ index ~ lt + { not } + if + } + if + { pop } + { SDict ~ exch /driver.rightboundary ~ exch ~ put } + ifelse ~ + moveto ~ + currentpoint ~ pop ~ + SDict /driver.leftboundary ~ known ~ dup + { + SDict /driver.leftboundary ~ get ~ 2 ~ index ~ gt + { not } + if + } + if + { pop } + { SDict ~ exch /driver.leftboundary ~ exch ~ put } + ifelse + } + put + } + if + } + def + /driver.bordertracking.end + { + /a ~ where { /a { moveto } put } if + /x ~ where { /x { 0 ~ exch ~ rmoveto } put } if ~ + SDict /driver.leftboundary ~ known + { driver.outerbox ~ 0 ~ driver.leftboundary ~ put } + if ~ + SDict /driver.rightboundary ~ known + { driver.outerbox ~ 2 ~ driver.rightboundary ~ put } + if ~ + SDict /driver.bordertracking ~ false ~ put + } + def + /driver.bordertracking.endpage + { + driver.bordertracking + { + driver.bordertracking.end ~ + true ~ setglobal ~ + driver.globaldict + /driver.brokenlink.rect [ driver.outerbox ~ aload ~ pop ] put ~ + driver.globaldict + /driver.brokenlink.skip ~ driver.baselineskip ~ put ~ + driver.globaldict + /driver.brokenlink.dict ~ + driver.link.dict ~ driver.cvs ~ put ~ + false ~ setglobal ~ + mark ~ driver.link.dict ~ cvx ~ exec ~ /Rect + [ + driver.llx ~ + driver.lly ~ + driver.outerbox ~ 2 ~ get ~ driver.linkmargin ~ add ~ + currentpoint ~ exch ~ pop ~ + driver.outerbox ~ driver.rect.ht ~ sub ~ driver.linkmargin ~ sub + ] + /ANN ~ driver.pdfmark + } + if + } + def + /driver.bordertracking.continue + { + /driver.link.dict ~ driver.globaldict + /driver.brokenlink.dict ~ get ~ def + /driver.outerbox ~ driver.globaldict + /driver.brokenlink.rect ~ get ~ def + /driver.baselineskip ~ driver.globaldict + /driver.brokenlink.skip ~ get ~ def ~ + driver.globaldict ~ dup ~ dup + /driver.brokenlink.dict ~ undef + /driver.brokenlink.skip ~ undef + /driver.brokenlink.rect ~ undef ~ + currentpoint + /driver.originy ~ exch ~ def + /driver.originx ~ exch ~ def + /a ~ where + { + /a + { + moveto ~ + SDict ~ + begin ~ + currentpoint ~ driver.originy ~ ne ~ exch ~ + driver.originx ~ ne ~ or + { + driver.link.ll + /driver.lly ~ + driver.lly ~ driver.outerbox ~ 1 ~ get ~ sub ~ def ~ + driver.bordertracking.begin + } + if ~ + end + } + put + } + if + /x ~ where + { + /x + { + 0 ~ exch ~ rmoveto ~ + SDict~ + begin ~ + currentpoint ~ + driver.originy ~ ne ~ exch ~ driver.originx ~ ne ~ or + { + driver.link.ll + /driver.lly ~ + driver.lly ~ driver.outerbox ~ 1 ~ get ~ sub ~ def ~ + driver.bordertracking.begin + } + if ~ + end + } + put + } + if + } + def + } +\__driver_postscript_header:n + { + /driver.breaklink + { + pop ~ + counttomark ~ 2 ~ mod ~ 0 ~ eq + { + counttomark /driver.count ~ exch ~ def + { + driver.count ~ 0 ~ eq { exit } if ~ + counttomark ~ 2 ~ roll ~ + 1 ~ index ~ /Rect ~ eq + { + dup ~ 4 ~ array ~ copy ~ + dup ~ dup ~ + 1 ~ get ~ + driver.outerbox ~ driver.rect.ht ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ sub ~ + 3 ~ exch ~ put ~ + dup ~ + driver.outerbox ~ 2 ~ get ~ + driver.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + driver.outerbox ~ driver.rect.ht ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ add ~ + 1 ~ exch ~ put + /driver.currentrect ~ exch ~ def ~ + driver.breaklink.write + { + driver.currentrect ~ + dup ~ + driver.outerbox ~ 0 ~ get ~ + driver.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ + driver.outerbox ~ 2 ~ get ~ + driver.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + driver.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + driver.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + /driver.currentrect ~ exch ~ def ~ + driver.breaklink.write + } + 1 ~ index ~ 3 ~ get ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ + driver.outerbox ~ driver.rect.ht ~ add ~ + 2 ~ index ~ 1 ~ get ~ sub ~ + driver.baselineskip ~ div ~ round ~ cvi ~ 1 ~ sub ~ + exch ~ + repeat ~ + driver.currentrect ~ + dup ~ + driver.outerbox ~ 0 ~ get ~ + driver.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + driver.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + driver.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + dup ~ 2 ~ index ~ 2 ~ get ~ 2 ~ exch ~ put + /driver.currentrect ~ exch ~ def ~ + driver.breaklink.write ~ + SDict /driver.pdfmark.good ~ false ~ put ~ + exit + } + { driver.count ~ 2 ~ sub /driver.count ~ exch ~ def } + ifelse + } + loop + } + if + /ANN + } + def + /driver.breaklink.write + { + counttomark ~ 1 ~ add ~ copy ~ + pop ~ driver.currentrect + /ANN ~ pdfmark + } + def + } +\__driver_postscript_header:n + { + /driver.pdfmark + { + SDict /driver.pdfmark.good ~ true ~ put ~ + dup /ANN ~ eq + { + driver.pdfmark.store ~ + driver.pdfmark.dict ~ + begin ~ + Subtype /Link ~ eq ~ + currentdict /Rect ~ known ~ and ~ + SDict /driver.outerbox ~ known ~ and ~ + SDict /driver.baselineskip ~ known ~ and ~ + { + Rect ~ 3 ~ get ~ + driver.linkmargin ~ 2 ~ mul ~ add ~ + driver.outerbox ~ driver.rect.ht ~ add ~ + Rect ~ 1 ~ get ~ sub ~ + driver.baselineskip ~ div ~ round ~ cvi ~ 0 ~ gt + { driver.breaklink } + { driver.pdfmark.obj } + ifelse + } + { driver.pdfmark.obj } + ifelse ~ + end ~ + SDict /driver.outerbox ~ undef ~ + SDict /driver.baselineskip ~ undef ~ + currentdict /driver.pdfmark.dict ~ undef ~ + } + if ~ + driver.pdfmark.good + { pdfmark } + { cleartomark } + ifelse + } + def + /driver.pdfmark.store + { + /driver.pdfmark.dict ~ 65534 ~ dict ~ def ~ + counttomark ~ 1 ~ add ~ copy ~ + pop + { + dup ~ mark ~ eq + { + pop ~ + exit + } + { + driver.pdfmark.dict ~ + begin ~ def ~ end + } + ifelse + } + loop + } + def + /driver.pdfmark.obj + { /_objdef ~ exch ~ driver.link.obj ~ exch } def + } +\box_new:N \l__driver_pdf_content_box +\box_new:N \l__driver_pdf_model_box +\int_new:N \g__driver_pdf_annotation_int +\cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4 + { + \__driver_pdf_annotation:nnnn {#1} {#2} {#3} {#4} + \int_gincr:N \g__driver_pdf_object_int + \int_gset_eq:NN \g__driver_pdf_annotation_int \g__driver_pdf_object_int + \__driver_postscript:x + { + mark + /_objdef { driver.obj \int_use:N \g__driver_pdf_object_int } + driver.annotation.border ~ + #4 ~ + /ANN ~ pdfmark + } + } +\cs_new_protected:Npn \__driver_pdf_annotation:nnnn #1#2#3#4 + { + \box_move_down:nn {#3} + { \hbox:n { \__driver_postscript:n { driver.annotation.ll } } } + \hbox:n {#4} + \box_move_up:nn {#2} + { + \hbox:n + { + \tex_kern:D \dim_eval:n {#1} \scan_stop: + \__driver_postscript:n { driver.annotation.ur } + } + } + \int_gincr:N \g__driver_pdf_object_int + \int_gset_eq:NN \g__driver_pdf_annotation_int \g__driver_pdf_object_int + \__driver_postscript:x + { + mark + /_objdef { driver.obj \int_use:N \g__driver_pdf_object_int } + driver.annotation.border ~ + \c__driver_pdf_AR_fix_tl + /ANN ~ pdfmark + } + } +\cs_new:Npn \driver_pdf_annotation_last: + { { driver.obj \int_use:N \g__driver_pdf_annotation_int } } +\int_new:N \g__driver_pdf_link_int +\tl_new:N \g__driver_pdf_link_dict_tl +\int_new:N \g__driver_pdf_link_sf_int +\bool_new:N \g__driver_pdf_link_math_bool +\bool_new:N \g__driver_pdf_link_bool +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \__driver_pdf_link_begin:nw { #1 /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \__driver_pdf_link_begin:nw {#1#2} } +\cs_new_protected:Npn \__driver_pdf_link_begin:nw #1 + { + \bool_if:NF \g__driver_pdf_link_bool + { \__driver_pdf_link_begin_aux:nw {#1} } + } +\cs_new_protected:Npn \__driver_pdf_link_begin_aux:nw #1 + { + \bool_gset_true:N \g__driver_pdf_link_bool + \__driver_pdf_annotation:nnnn { 3pt } { 3pt } { 0pt } { } + \__driver_postscript:n + { /driver.link.dict ( /Subtype /Link #1 ) def } + \int_gincr:N \g__driver_pdf_object_int + \int_gset_eq:NN \g__driver_pdf_link_int \g__driver_pdf_object_int + \__driver_postscript:x + { + /driver.link.obj + { + { driver.obj \int_use:N \g__driver_pdf_link_int \c_space_tl driver.cvs } + } + def + } + \tl_gset:Nn \g__driver_pdf_link_dict_tl {#1} + \__driver_pdf_link_sf_save: + \mode_if_math:TF + { \bool_gset_true:N \g__driver_pdf_link_math_bool } + { \bool_gset_false:N \g__driver_pdf_link_math_bool } + \hbox_set:Nw \l__driver_pdf_content_box + \__driver_pdf_link_sf_restore: + \bool_if:NT \g__driver_pdf_link_math_bool + { \c_math_toggle_token } + } +\cs_new_protected:Npn \driver_pdf_link_end: + { + \bool_if:NT \g__driver_pdf_link_bool + { \__driver_pdf_link_end: } + } +\cs_new_protected:Npn \__driver_pdf_link_end: + { + \bool_if:NT \g__driver_pdf_link_math_bool + { \c_math_toggle_token } + \__driver_pdf_link_sf_save: + \hbox_set_end: + \__driver_pdf_link_minima: + \hbox_set:Nn \l__driver_pdf_model_box { Gg } + \exp_args:Nx \__driver_driver_link_outerbox:n + { + \int_if_odd:nTF { \value { page } } + { \oddsidemargin } + { \evensidemargin } + } + \box_move_down:nn { \box_dp:N \l__driver_pdf_content_box } + { \hbox:n { \__driver_postscript:n { driver.link.ll } } } + \__driver_postscript:n { driver.bordertracking.begin } + \hbox_unpack:N \l__driver_pdf_content_box + \__driver_postscript:n { driver.bordertracking.end } + \box_move_up:nn { \box_ht:N \l__driver_pdf_content_box } + { + \hbox:n + { \__driver_postscript:n { driver.link.ur } } + } + \__driver_postscript:x + { + mark + \g__driver_pdf_link_dict_tl /Subtype /Link ~ + driver.annotation.border + /ANN ~ driver.pdfmark + } + \__driver_pdf_link_sf_restore: + \bool_gset_false:N \g__driver_pdf_link_bool + } +\cs_new_protected:Npn \__driver_pdf_link_minima: + { + \hbox_set:Nn \l__driver_pdf_model_box { Gg } + \__driver_postscript:x + { + /driver.linkdp.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_dp:N \l__driver_pdf_model_box + - \box_dp:N \l__driver_pdf_content_box + } + { 0pt } + } ~ + driver.pt.dvi ~ def + /driver.linkht.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_ht:N \l__driver_pdf_model_box + - \box_ht:N \l__driver_pdf_content_box + } + { 0pt } + } ~ + driver.pt.dvi ~ def + } + } +\cs_new_protected:Npn \__driver_driver_link_outerbox:n #1 + { + \__driver_postscript:x + { + /driver.outerbox + [ + \dim_to_decimal:n {#1} ~ + \dim_to_decimal:n { -\box_dp:N \l__driver_pdf_model_box } ~ + \dim_to_decimal:n { #1 + \textwidth } ~ + \dim_to_decimal:n { \box_ht:N \l__driver_pdf_model_box } + ] + [ exch { driver.pt.dvi } forall ] def + /driver.baselineskip ~ + \dim_to_decimal:n { \tex_baselineskip:D } ~ dup ~ 0 ~ gt + { driver.pt.dvi ~ def } + { pop ~ pop } + ifelse + } + } +\cs_new_protected:Npn \__driver_pdf_link_sf_save: + { + \int_gset:Nn \g__driver_pdf_link_sf_int + { + \mode_if_horizontal:TF + { \tex_spacefactor:D } + { 0 } + } + } +\cs_new_protected:Npn \__driver_pdf_link_sf_restore: + { + \mode_if_horizontal:T + { + \int_compare:nNnT \g__driver_pdf_link_sf_int > { 0 } + { \int_set_eq:NN \tex_spacefactor:D \g__driver_pdf_link_sf_int } + } + } +\tl_gput_left:Nn \@startcolumn + { + \__driver_postscript:n + { + driver.globaldict /driver.brokenlink.rect ~ known + { driver.bordertracking.continue } + if + } + } +\tl_gput_left:Nn \@makecol + { + \vbox_set:Nn \@cclv + { + \vbox_unpack_drop:N \@cclv + \__driver_postscript:n + { driver.bordertracking.endpage } + } + } +\cs_new:Npn \driver_pdf_link_last: + { { driver.obj \int_use:N \g__driver_pdf_link_int } } +\cs_new_protected:Npn \driver_pdf_link_margin:n #1 + { + \__driver_postscript:x { - [nobreak] ~ - mark ~ #1 ~ ( #3 ) ~ /PUT ~ pdfmark ~ - mark ~ #1 ~ << #2 >> ~ /PUT ~ pdfmark + /driver.linkmargin { \dim_to_decimal:n {#1} ~ driver.pt.dvi } def } } \cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } \cs_new_protected:Npn \driver_pdf_objects_enable: { } \cs_new_protected:Npn \driver_pdf_objects_disable: { } +\cs_new_protected:Npn \driver_pdf_version_major_gset:n #1 { } +\cs_new_protected:Npn \driver_pdf_version_minor_gset:n #1 { } +\cs_new:Npn \driver_pdf_version_major: { -1 } +\cs_new:Npn \driver_pdf_version_minor: { -1 } %% %% %% End of file `l3dvips.def'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3dvisvgm.def b/Master/texmf-dist/tex/latex/l3kernel/l3dvisvgm.def index 010d500238d..8594ca95919 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3dvisvgm.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3dvisvgm.def @@ -5,6 +5,12 @@ %% The original source files were: %% %% l3drivers.dtx (with options: `package,dvisvgm') +%% l3drivers-basics.dtx (with options: `package,dvisvgm') +%% l3drivers-color.dtx (with options: `package,dvisvgm') +%% l3drivers-box.dtx (with options: `package,dvisvgm') +%% l3drivers-draw.dtx (with options: `package,dvisvgm') +%% l3drivers-image.dtx (with options: `package,dvisvgm') +%% l3drivers-pdf.dtx (with options: `package,dvisvgm') %% %% Copyright (C) 1990-2019 The LaTeX3 Project %% @@ -19,6 +25,7 @@ %% and all files in that bundle must be distributed together. %% %% File: l3drivers.dtx +%% File: l3drivers-basics.dtx \ProvidesExplFile {l3dvisvgm.def}{2019-04-06}{} {L3 Experimental driver: dvisvgm} @@ -26,6 +33,17 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \__driver_literal:e { \exp_not:n {#1} } } \cs_generate_variant:Nn \__driver_literal:n { x } +\cs_new_protected:Npn \__driver_literal_svg:n #1 + { \__driver_literal:n { dvisvgm:raw~ #1 { ?nl } } } +\cs_generate_variant:Nn \__driver_literal_svg:n { x } +\cs_new_protected:Npn \__driver_scope_begin: + { \__driver_literal_svg:n { <g> } } +\cs_new_protected:Npn \__driver_scope_end: + { \__driver_literal_svg:n { </g> } } +\cs_new_protected:Npn \__driver_scope_begin:n #1 + { \__driver_literal_svg:n { <g~ #1 > } } +\cs_generate_variant:Nn \__driver_scope_begin:n { x } +%% File: l3drivers-color.dtx \cs_new_protected:Npn \driver_color_pickup:N #1 { } \AtBeginDocument { @@ -77,16 +95,7 @@ \cs_generate_variant:Nn \__driver_color_select:n { x } \cs_new_protected:Npn \__driver_color_reset: { \__driver_literal:n { color~pop } } -\cs_new_protected:Npn \__driver_literal_svg:n #1 - { \__driver_literal:n { dvisvgm:raw~ #1 { ?nl } } } -\cs_generate_variant:Nn \__driver_literal_svg:n { x } -\cs_new_protected:Npn \__driver_scope_begin: - { \__driver_literal_svg:n { <g> } } -\cs_new_protected:Npn \__driver_scope_end: - { \__driver_literal_svg:n { </g> } } -\cs_new_protected:Npn \__driver_scope_begin:n #1 - { \__driver_literal_svg:n { <g~ #1 > } } -\cs_generate_variant:Nn \__driver_scope_begin:n { x } +%% File: l3drivers-box.dtx \cs_new_protected:Npn \driver_box_use_clip:N #1 { \int_gincr:N \g__driver_clip_path_int @@ -171,27 +180,7 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } -\cs_new_eq:NN \__driver_image_getbb_png:n \image_extract_bb:n -\cs_new_eq:NN \__driver_image_getbb_jpg:n \image_extract_bb:n -\cs_new_protected:Npn \__driver_image_include_png:n #1 - { - \__driver_literal:x - { - dvisvgm:img~ - \dim_to_decimal:n { \l_image_ury_dim } ~ - \dim_to_decimal:n { \l_image_ury_dim } ~ - \__driver_image_include_bitmap_quote:w #1 " " \q_stop - } - } -\cs_new_eq:NN \__driver_image_include_jpg:n \__driver_image_include_png:n -\cs_new:Npn \__driver_image_include_bitmap_quote:w #1 " #2 " #3 \q_stop - { #1#2 } -\cs_new_protected:Npn \driver_pdf_object_new:n #1 { } -\cs_new:Npn \driver_pdf_object_ref:n #1 { } -\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 { } -\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } -\cs_new_protected:Npn \driver_pdf_objects_enable: { } -\cs_new_protected:Npn \driver_pdf_objects_disable: { } +%% File: l3drivers-draw.dtx \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal_svg:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \driver_draw_begin: @@ -461,6 +450,35 @@ \__driver_literal_svg:n { </g> } \__driver_scope_end: } +%% File: l3drivers-image.dtx +\cs_new_eq:NN \__driver_image_getbb_png:n \image_extract_bb:n +\cs_new_eq:NN \__driver_image_getbb_jpg:n \image_extract_bb:n +\cs_new_protected:Npn \__driver_image_include_png:n #1 + { + \__driver_literal:x + { + dvisvgm:img~ + \dim_to_decimal:n { \l_image_ury_dim } ~ + \dim_to_decimal:n { \l_image_ury_dim } ~ + \__driver_image_include_bitmap_quote:w #1 " #1 " \q_stop + } + } +\cs_new_eq:NN \__driver_image_include_jpg:n \__driver_image_include_png:n +\cs_new:Npn \__driver_image_include_bitmap_quote:w #1 " #2 " #3 \q_stop + { " #2 " } +%% File: l3drivers-pdf.dtx +\tl_const:Nn \c__driver_pdf_AR_fix_tl + { /Ff ~ 65537 /FT /Btn /Subtype /Widget } +\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 { } +\cs_new:Npn \driver_pdf_object_ref:n #1 { } +\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 { } +\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 { } +\cs_new_protected:Npn \driver_pdf_objects_enable: { } +\cs_new_protected:Npn \driver_pdf_objects_disable: { } +\cs_new_protected:Npn \driver_pdf_version_major_gset:n #1 { } +\cs_new_protected:Npn \driver_pdf_version_minor_gset:n #1 { } +\cs_new:Npn \driver_pdf_version_major: { -1 } +\cs_new:Npn \driver_pdf_version_minor: { -1 } %% %% %% End of file `l3dvisvgm.def'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def b/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def index 8ce7bcf5e52..1f1d6f61676 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def @@ -5,6 +5,12 @@ %% The original source files were: %% %% l3drivers.dtx (with options: `package,pdfmode') +%% l3drivers-basics.dtx (with options: `package,pdfmode') +%% l3drivers-color.dtx (with options: `package,pdfmode') +%% l3drivers-box.dtx (with options: `package,pdfmode') +%% l3drivers-draw.dtx (with options: `package,pdfmode') +%% l3drivers-image.dtx (with options: `package,pdfmode') +%% l3drivers-pdf.dtx (with options: `package,pdfmode') %% %% Copyright (C) 1990-2019 The LaTeX3 Project %% @@ -19,6 +25,7 @@ %% and all files in that bundle must be distributed together. %% %% File: l3drivers.dtx +%% File: l3drivers-basics.dtx \ProvidesExplFile {l3pdfmode.def}{2019-04-06}{} {L3 Experimental driver: PDF mode} @@ -26,6 +33,35 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \__driver_literal:e { \exp_not:n {#1} } } \cs_generate_variant:Nn \__driver_literal:n { x } +\cs_new_protected:Npx \__driver_literal_pdf:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D literal } + { \tex_pdfliteral:D } + { \exp_not:N \exp_not:n {#1} } + } +\cs_generate_variant:Nn \__driver_literal_pdf:n { x } +\cs_new_protected:Npx \__driver_scope_begin: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D save \scan_stop: } + { \tex_pdfsave:D } + } +\cs_new_protected:Npx \__driver_scope_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D restore \scan_stop: } + { \tex_pdfrestore:D } + } +\cs_new_protected:Npx \__driver_matrix:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D setmatrix } + { \tex_pdfsetmatrix:D } + { \exp_not:N \exp_not:n {#1} } + } +\cs_generate_variant:Nn \__driver_matrix:n { x } +%% File: l3drivers-color.dtx \cs_new_protected:Npn \driver_color_pickup:N #1 { } \AtBeginDocument { @@ -113,34 +149,7 @@ { \tex_pdfcolorstack:D } \exp_not:N \l__driver_color_stack_int pop \scan_stop: } -\cs_new_protected:Npx \__driver_literal_pdf:n #1 - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D literal } - { \tex_pdfliteral:D } - { \exp_not:N \exp_not:n {#1} } - } -\cs_generate_variant:Nn \__driver_literal_pdf:n { x } -\cs_new_protected:Npx \__driver_scope_begin: - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D save \scan_stop: } - { \tex_pdfsave:D } - } -\cs_new_protected:Npx \__driver_scope_end: - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D restore \scan_stop: } - { \tex_pdfrestore:D } - } -\cs_new_protected:Npx \__driver_matrix:n #1 - { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D setmatrix } - { \tex_pdfsetmatrix:D } - { \exp_not:N \exp_not:n {#1} } - } -\cs_generate_variant:Nn \__driver_matrix:n { x } +%% File: l3drivers-box.dtx \cs_new_protected:Npn \driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -196,6 +205,154 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } +%% File: l3drivers-draw.dtx +\cs_new_eq:NN \__driver_draw_literal:n \__driver_literal_pdf:n +\cs_generate_variant:Nn \__driver_draw_literal:n { x } +\cs_new_protected:Npn \driver_draw_begin: + { \driver_draw_scope_begin: } +\cs_new_protected:Npn \driver_draw_end: + { \driver_draw_scope_end: } +\cs_new_eq:NN \driver_draw_scope_begin: \__driver_scope_begin: +\cs_new_eq:NN \driver_draw_scope_end: \__driver_scope_end: +\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 + { + \__driver_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } + } +\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 + { + \__driver_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } + } +\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 + { + \__driver_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ + \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ + \dim_to_decimal_in_bp:n {#5} ~ \dim_to_decimal_in_bp:n {#6} ~ + c + } + } +\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 + { + \__driver_draw_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ + \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ + re + } + } +\cs_new_protected:Npn \driver_draw_evenodd_rule: + { \bool_gset_true:N \g__driver_draw_eor_bool } +\cs_new_protected:Npn \driver_draw_nonzero_rule: + { \bool_gset_false:N \g__driver_draw_eor_bool } +\bool_new:N \g__driver_draw_eor_bool +\cs_new_protected:Npn \driver_draw_closepath: + { \__driver_draw_literal:n { h } } +\cs_new_protected:Npn \driver_draw_stroke: + { \__driver_draw_literal:n { S } } +\cs_new_protected:Npn \driver_draw_closestroke: + { \__driver_draw_literal:n { s } } +\cs_new_protected:Npn \driver_draw_fill: + { + \__driver_draw_literal:x + { f \bool_if:NT \g__driver_draw_eor_bool * } + } +\cs_new_protected:Npn \driver_draw_fillstroke: + { + \__driver_draw_literal:x + { B \bool_if:NT \g__driver_draw_eor_bool * } + } +\cs_new_protected:Npn \driver_draw_clip: + { + \__driver_draw_literal:x + { W \bool_if:NT \g__driver_draw_eor_bool * } + } +\cs_new_protected:Npn \driver_draw_discardpath: + { \__driver_draw_literal:n { n } } +\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 + { + \__driver_draw_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \__driver_draw_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ d + } + } +\cs_new:Npn \__driver_draw_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \driver_draw_linewidth:n #1 + { + \__driver_draw_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ w } + } +\cs_new_protected:Npn \driver_draw_miterlimit:n #1 + { \__driver_draw_literal:x { \fp_eval:n {#1} ~ M } } +\cs_new_protected:Npn \driver_draw_cap_butt: + { \__driver_draw_literal:n { 0 ~ J } } +\cs_new_protected:Npn \driver_draw_cap_round: + { \__driver_draw_literal:n { 1 ~ J } } +\cs_new_protected:Npn \driver_draw_cap_rectangle: + { \__driver_draw_literal:n { 2 ~ J } } +\cs_new_protected:Npn \driver_draw_join_miter: + { \__driver_draw_literal:n { 0 ~ j } } +\cs_new_protected:Npn \driver_draw_join_round: + { \__driver_draw_literal:n { 1 ~ j } } +\cs_new_protected:Npn \driver_draw_join_bevel: + { \__driver_draw_literal:n { 2 ~ j } } +\cs_new_protected:Npn \driver_draw_color_fill_cmyk:nnnn #1#2#3#4 + { + \__driver_color_fill_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 + { + \__driver_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \driver_draw_color_fill_gray:n #1 + { \__driver_color_fill_select:x { \fp_eval:n {#1} ~ g } } +\cs_new_protected:Npn \driver_draw_color_stroke_gray:n #1 + { \__driver_color_select:x { \fp_eval:n {#1} ~ G } } +\cs_new_protected:Npn \driver_draw_color_fill_rgb:nnn #1#2#3 + { + \__driver_color_fill_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } + } +\cs_new_protected:Npn \driver_draw_color_stroke_rgb:nnn #1#2#3 + { + \__driver_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } + } +\cs_new_eq:NN \__driver_color_fill_select:n \__driver_color_select:n +\cs_generate_variant:Nn \__driver_color_fill_select:n { x } +\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 + { + \__driver_matrix:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5 + { + \__driver_scope_begin: + \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} + \hbox_overlap_right:n { \box_use:N #1 } + \__driver_scope_end: + } +%% File: l3drivers-image.dtx \tl_new:N \l__driver_image_attr_tl \cs_new_protected:Npn \__driver_image_getbb_jpg:n #1 { @@ -264,6 +421,70 @@ } \cs_new_eq:NN \__driver_image_include_pdf:n \__driver_image_include_jpg:n \cs_new_eq:NN \__driver_image_include_png:n \__driver_image_include_jpg:n +%% File: l3drivers-pdf.dtx +\tl_const:Nn \c__driver_pdf_AR_fix_tl + { /Ff ~ 65537 /FT /Btn /Subtype /Widget } +\cs_new_protected:Npx \__driver_pdf_AR_fix: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D annot ~ } + { \tex_pdfannot:D } + width ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt + { \c__driver_pdf_AR_fix_tl } + } +\cs_new_protected:Npx \driver_pdf_annotation:nnnn #1#2#3#4 + { + \__driver_pdf_AR_fix: + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D annot ~ } + { \tex_pdfannot:D } + width ~ \exp_not:N \dim_eval:n {#1} ~ + height ~ \exp_not:N \dim_eval:n {#2} ~ + depth ~ \exp_not:N \dim_eval:n {#3} ~ + {#4} + } +\cs_new:Npx \driver_pdf_annotation_last: + { + \exp_not:N \tex_the:D + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D annot ~ } + { \exp_not:N \tex_pdflastannot:D } + 0 ~ R + } +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \__driver_pdf_link_begin:nnnw {#1} { goto~name } {#2} } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \__driver_pdf_link_begin:nnnw {#1} { user } { /Subtype /Link #2 } } +\cs_new_protected:Npx \__driver_pdf_link_begin:nnnw #1#2#3 + { + \__driver_pdf_AR_fix: + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D startlink ~ } + { \tex_pdfstartlink:D } + attr {#1} + #2 {#3} + } +\cs_new_protected:Npx \driver_pdf_link_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D endlink \scan_stop: } + { \tex_pdfendlink:D } + } +\cs_new:Npx \driver_pdf_link_last: + { + \exp_not:N \tex_the:D + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastlink \scan_stop: } + { \exp_not:N \tex_pdflastlink:D } + ~ 0 ~ R + } +\cs_new_protected:Npx \driver_pdf_link_margin:n #1 + { + \cs_if_exist:NTF \tex_pdfvariable:D + { \exp_not:N \tex_pdfvariable:D linkmargin } + { \exp_not:N \tex_pdflinkmargin:D } + \exp_not:N \dim_eval:n {#1} \scan_stop: + } \prop_new:N \g__driver_pdf_object_prop \group_begin: \cs_set_protected:Npn \__driver_tmp:w #1#2 @@ -337,151 +558,52 @@ { \tex_pdfvariable:D objcompresslevel } #1 \scan_stop: } -\cs_new_eq:NN \__driver_draw_literal:n \__driver_literal_pdf:n -\cs_generate_variant:Nn \__driver_draw_literal:n { x } -\cs_new_protected:Npn \driver_draw_begin: - { \driver_draw_scope_begin: } -\cs_new_protected:Npn \driver_draw_end: - { \driver_draw_scope_end: } -\cs_new_eq:NN \driver_draw_scope_begin: \__driver_scope_begin: -\cs_new_eq:NN \driver_draw_scope_end: \__driver_scope_end: -\cs_new_protected:Npn \driver_draw_moveto:nn #1#2 - { - \__driver_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } - } -\cs_new_protected:Npn \driver_draw_lineto:nn #1#2 - { - \__driver_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } - } -\cs_new_protected:Npn \driver_draw_curveto:nnnnnn #1#2#3#4#5#6 +\cs_new_protected:Npx \driver_pdf_version_major_gset:n #1 { - \__driver_draw_literal:x + \cs_if_exist:NTF \tex_pdfvariable:D { - \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ - \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ - \dim_to_decimal_in_bp:n {#5} ~ \dim_to_decimal_in_bp:n {#6} ~ - c + \int_compare:nNnT \tex_luatexversion:D > { 106 } + { + \exp_not:N \tex_global:D \tex_pdfvariable:D majorversion + \exp_not:N \int_eval:n {#1} \scan_stop: + } } - } -\cs_new_protected:Npn \driver_draw_rectangle:nnnn #1#2#3#4 - { - \__driver_draw_literal:x { - \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ - \dim_to_decimal_in_bp:n {#3} ~ \dim_to_decimal_in_bp:n {#4} ~ - re - } - } -\cs_new_protected:Npn \driver_draw_evenodd_rule: - { \bool_gset_true:N \g__driver_draw_eor_bool } -\cs_new_protected:Npn \driver_draw_nonzero_rule: - { \bool_gset_false:N \g__driver_draw_eor_bool } -\bool_new:N \g__driver_draw_eor_bool -\cs_new_protected:Npn \driver_draw_closepath: - { \__driver_draw_literal:n { h } } -\cs_new_protected:Npn \driver_draw_stroke: - { \__driver_draw_literal:n { S } } -\cs_new_protected:Npn \driver_draw_closestroke: - { \__driver_draw_literal:n { s } } -\cs_new_protected:Npn \driver_draw_fill: - { - \__driver_draw_literal:x - { f \bool_if:NT \g__driver_draw_eor_bool * } - } -\cs_new_protected:Npn \driver_draw_fillstroke: - { - \__driver_draw_literal:x - { B \bool_if:NT \g__driver_draw_eor_bool * } - } -\cs_new_protected:Npn \driver_draw_clip: - { - \__driver_draw_literal:x - { W \bool_if:NT \g__driver_draw_eor_bool * } - } -\cs_new_protected:Npn \driver_draw_discardpath: - { \__driver_draw_literal:n { n } } -\cs_new_protected:Npn \driver_draw_dash_pattern:nn #1#2 - { - \__driver_draw_literal:x - { - [ - \exp_args:Nf \use:n - { \clist_map_function:nN {#1} \__driver_draw_dash:n } - ] ~ - \dim_to_decimal_in_bp:n {#2} ~ d + \cs_if_exist:NT \tex_pdfmajorversion:D + { + \exp_not:N \tex_global:D \tex_pdfmajorversion:D + \exp_not:N \int_eval:n {#1} \scan_stop: + } } } -\cs_new:Npn \__driver_draw_dash:n #1 - { ~ \dim_to_decimal_in_bp:n {#1} } -\cs_new_protected:Npn \driver_draw_linewidth:n #1 +\cs_new_protected:Npx \driver_pdf_version_minor_gset:n #1 { - \__driver_draw_literal:x - { \dim_to_decimal_in_bp:n {#1} ~ w } + \exp_not:N \tex_global:D + \cs_if_exist:NTF \tex_pdfminorversion:D + { \exp_not:N \tex_pdfminorversion:D } + { \tex_pdfvariable:D minorversion } + \exp_not:N \int_eval:n {#1} \scan_stop: } -\cs_new_protected:Npn \driver_draw_miterlimit:n #1 - { \__driver_draw_literal:x { \fp_eval:n {#1} ~ M } } -\cs_new_protected:Npn \driver_draw_cap_butt: - { \__driver_draw_literal:n { 0 ~ J } } -\cs_new_protected:Npn \driver_draw_cap_round: - { \__driver_draw_literal:n { 1 ~ J } } -\cs_new_protected:Npn \driver_draw_cap_rectangle: - { \__driver_draw_literal:n { 2 ~ J } } -\cs_new_protected:Npn \driver_draw_join_miter: - { \__driver_draw_literal:n { 0 ~ j } } -\cs_new_protected:Npn \driver_draw_join_round: - { \__driver_draw_literal:n { 1 ~ j } } -\cs_new_protected:Npn \driver_draw_join_bevel: - { \__driver_draw_literal:n { 2 ~ j } } -\cs_new_protected:Npn \driver_draw_color_fill_cmyk:nnnn #1#2#3#4 +\cs_new:Npx \driver_pdf_version_major: { - \__driver_color_fill_select:x + \cs_if_exist:NTF \tex_pdfvariable:D { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ - k + \int_compare:nNnTF \tex_luatexversion:D > { 106 } + { \exp_not:N \tex_the:D \tex_pdfvariable:D majorversion } + { 1 } } - } -\cs_new_protected:Npn \driver_draw_color_stroke_cmyk:nnnn #1#2#3#4 - { - \__driver_color_select:x { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ - k + \cs_if_exist:NTF \tex_pdfmajorversion:D + { \exp_not:N \tex_the:D \tex_pdfmajorversion:D } + { 1 } } } -\cs_new_protected:Npn \driver_draw_color_fill_gray:n #1 - { \__driver_color_fill_select:x { \fp_eval:n {#1} ~ g } } -\cs_new_protected:Npn \driver_draw_color_stroke_gray:n #1 - { \__driver_color_select:x { \fp_eval:n {#1} ~ G } } -\cs_new_protected:Npn \driver_draw_color_fill_rgb:nnn #1#2#3 +\cs_new:Npx \driver_pdf_version_minor: { - \__driver_color_fill_select:x - { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } - } -\cs_new_protected:Npn \driver_draw_color_stroke_rgb:nnn #1#2#3 - { - \__driver_color_select:x - { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } - } -\cs_new_eq:NN \__driver_color_fill_select:n \__driver_color_select:n -\cs_generate_variant:Nn \__driver_color_fill_select:n { x } -\cs_new_protected:Npn \driver_draw_cm:nnnn #1#2#3#4 - { - \__driver_matrix:x - { - \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ - \fp_eval:n {#3} ~ \fp_eval:n {#4} - } - } -\cs_new_protected:Npn \driver_draw_box_use:Nnnnn #1#2#3#4#5 - { - \__driver_scope_begin: - \driver_draw_cm:nnnn {#2} {#3} {#4} {#5} - \hbox_overlap_right:n { \box_use:N #1 } - \__driver_scope_end: + \exp_not:N \tex_the:D + \cs_if_exist:NTF \tex_pdfminorversion:D + { \exp_not:N \tex_pdfminorversion:D } + { \tex_pdfvariable:D minorversion } } %% %% diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def b/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def index 069f8ff0696..17fd5e7aff5 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def @@ -5,6 +5,12 @@ %% The original source files were: %% %% l3drivers.dtx (with options: `package,xdvipdfmx') +%% l3drivers-basics.dtx (with options: `package,xdvipdfmx') +%% l3drivers-color.dtx (with options: `package,xdvipdfmx') +%% l3drivers-box.dtx (with options: `package,xdvipdfmx') +%% l3drivers-draw.dtx (with options: `package,xdvipdfmx') +%% l3drivers-image.dtx (with options: `package,xdvipdfmx') +%% l3drivers-pdf.dtx (with options: `package,xdvipdfmx') %% %% Copyright (C) 1990-2019 The LaTeX3 Project %% @@ -19,6 +25,7 @@ %% and all files in that bundle must be distributed together. %% %% File: l3drivers.dtx +%% File: l3drivers-basics.dtx \ProvidesExplFile {l3xdvipdfmx.def}{2019-04-06}{} {L3 Experimental driver: xdvipdfmx} @@ -26,6 +33,14 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \__driver_literal:e { \exp_not:n {#1} } } \cs_generate_variant:Nn \__driver_literal:n { x } +\cs_new_protected:Npn \__driver_literal_pdf:n #1 + { \__driver_literal:n { pdf:literal~ #1 } } +\cs_generate_variant:Nn \__driver_literal_pdf:n { x } +\cs_new_protected:Npn \__driver_scope_begin: + { \__driver_literal:n { x:gsave } } +\cs_new_protected:Npn \__driver_scope_end: + { \__driver_literal:n { x:grestore } } +%% File: l3drivers-color.dtx \cs_new_protected:Npn \driver_color_pickup:N #1 { } \AtBeginDocument { @@ -77,13 +92,7 @@ \cs_generate_variant:Nn \__driver_color_select:n { x } \cs_new_protected:Npn \__driver_color_reset: { \__driver_literal:n { color~pop } } -\cs_new_protected:Npn \__driver_literal_pdf:n #1 - { \__driver_literal:n { pdf:literal~ #1 } } -\cs_generate_variant:Nn \__driver_literal_pdf:n { x } -\cs_new_protected:Npn \__driver_scope_begin: - { \__driver_literal:n { x:gsave } } -\cs_new_protected:Npn \__driver_scope_end: - { \__driver_literal:n { x:grestore } } +%% File: l3drivers-box.dtx \cs_new_protected:Npn \driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -126,184 +135,7 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } -\cs_new_eq:NN \__driver_image_getbb_eps:n \image_read_bb:n -\int_new:N \g__driver_image_int -\cs_new_protected:Npn \__driver_image_include_eps:n #1 - { - \__driver_literal:n { PSfile = #1 } - } -\cs_new_protected:Npn \__driver_image_include_jpg:n #1 - { \__driver_image_include_auxi:nn {#1} { image } } -\cs_new_eq:NN \__driver_image_include_png:n \__driver_image_include_jpg:n -\cs_new_protected:Npn \__driver_image_include_auxi:nn #1#2 - { - \__driver_image_include_auxii:xnn - { - \tl_if_empty:NF \l_image_pagebox_tl - { : \l_image_pagebox_tl } - \int_compare:nNnT \l_image_page_int > 1 - { :P \int_use:N \l_image_page_int } - \tl_if_empty:NF \l_image_decode_tl - { :D \l_image_decodearray_tl } - \bool_if:NT \l_image_interpolate_bool - { :I } - } - {#1} {#2} - } -\cs_new_protected:Npn \__driver_image_include_auxii:nnn #1#2#3 - { - \int_if_exist:cTF { c__driver_image_ #2#1 _int } - { - \__driver_literal:x - { pdf:usexobj~@image \int_use:c { c__driver_image_ #2#1 _int } } - } - { \__driver_image_include_auxiii:nn {#2} {#1} {#3} } - } -\cs_generate_variant:Nn \__driver_image_include_auxii:nnn { x } -\cs_new_protected:Npn \__driver_image_include_auxiii:nnn #1#2#3 - { - \int_gincr:N \g__driver_image_int - \int_const:cn { c__driver_image_ #1#2 _int } { \g__driver_image_int } - \__driver_literal:x - { - pdf:#3~ - @image \int_use:c { c__driver_image_ #1#2 _int } - \int_compare:nNnT \l_image_page_int > 1 - { page ~ \int_use:N \l_image_page_int \c_space_tl } - \tl_if_empty:NF \l_image_pagebox_tl - { - pagebox ~ \l_image_pagebox_tl \c_space_tl - bbox ~ - \dim_to_decimal_in_bp:n \l_image_llx_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_lly_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_urx_dim \c_space_tl - \dim_to_decimal_in_bp:n \l_image_ury_dim \c_space_tl - } - (#1) - \bool_lazy_or:nnT - { \l_image_interpolate_bool } - { ! \tl_if_empty_p:N \l_image_decodearray_tl } - { - << - \tl_if_empty:NF \l_image_decode_tl - { /Decode~[ \l_image_decodearray_tl ] } - \bool_if:NT \l_image_interpolate_bool - { /Interpolate~true> } - >> - } - } - } -\int_new:N \g__driver_pdf_object_int -\prop_new:N \g__driver_pdf_object_prop -\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 - { - \int_gincr:N \g__driver_pdf_object_int - \int_const:cn - { g__driver_pdf_object_ \tl_to_str:n {#1} _int } - { \g__driver_pdf_object_int } - \prop_gput:Nnn \g__driver_pdf_object_prop {#1} {#2} - } -\cs_new:Npn \driver_pdf_object_ref:n #1 - { @l3obj \int_use:c { g__driver_pdf_object_ \tl_to_str:n {#1} _int } } -\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 - { - \exp_args:Nx \__driver_pdf_object_write:nnn - { \prop_item:Nn \g__driver_pdf_object_prop {#1} } {#1} {#2} - } -\cs_new_protected:Npn \__driver_pdf_object_write:nnn #1#2#3 - { \use:c { __driver_pdf_object_write_ #1 :nn } {#2} {#3} } -\cs_new_protected:Npn \__driver_pdf_object_write_array:nn #1#2 - { - \__driver_literal:x - { - pdf:obj ~ \driver_pdf_object_ref:n {#1} ~ - [ ~ \exp_not:n {#2} ~ ] - } - } -\cs_new_protected:Npn \__driver_pdf_object_write_dict:nn #1#2 - { - \__driver_literal:x - { - pdf:obj ~ \driver_pdf_object_ref:n {#1} ~ - << ~ \exp_not:n {#2} ~ >> - } - } -\cs_new_protected:Npn \__driver_pdf_object_write_fstream:nn #1#2 - { \__driver_pdf_object_write_stream:nnnn { f } {#1} #2 } -\cs_new_protected:Npn \__driver_pdf_object_write_stream:nn #1#2 - { \__driver_pdf_object_write_stream:nnnn { } {#1} #2 } -\cs_new_protected:Npn \__driver_pdf_object_write_stream:nnnn #1#2#3#4 - { - \__driver_literal:x - { - pdf: #1 stream ~ \driver_pdf_object_ref:n {#2} ~ - ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> - - } - } -\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 - { \__driver_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } -\cs_new_protected:Npn \driver_pdf_objects_enable: { } -\cs_new_protected:Npn \driver_pdf_objects_disable: - { \__driver_literal:n { dvipdfmx:config~C~0x40 } } -\cs_new_protected:Npn \__driver_image_getbb_jpg:n #1 - { - \int_zero:N \l_image_page_int - \tl_clear:N \l_image_pagebox_tl - \__driver_image_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D - } -\cs_new_eq:NN \__driver_image_getbb_png:n \__driver_image_getbb_jpg:n -\cs_new_protected:Npn \__driver_image_getbb_pdf:n #1 - { - \tl_clear:N \l_image_decode_tl - \bool_set_false:N \l_image_interpolate_bool - \__driver_image_getbb_auxi:nN {#1} \tex_XeTeXpdffile:D - } -\cs_new_protected:Npn \__driver_image_getbb_auxi:nN #1#2 - { - \int_compare:nNnTF \l_image_page_int > 1 - { \__driver_image_getbb_auxii:VnN \l_image_page_int {#1} #2 } - { \__driver_image_getbb_auxiii:nNnn {#1} #2 } - } -\cs_new_protected:Npn \__driver_image_getbb_auxii:nnN #1#2#3 - { \__driver_image_getbb_aux:nNnn {#2} #3 { :P #1 } { page #1 } } -\cs_generate_variant:Nn \__driver_image_getbb_auxii:nnN { V } -\cs_new_protected:Npn \__driver_image_getbb_auxiii:nNnn #1#2#3#4 - { - \tl_if_empty:NTF \l_image_pagebox_tl - { \__driver_image_getbb_auxiv:VnNnn \l_image_pagebox_tl } - { \__driver_image_getbb_auxv:nNnn } - {#1} #2 {#3} {#4} - } -\cs_new_protected:Npn \__driver_image_getbb_auxiv:nnNnn #1#2#3#4#5 - { - \use:x - { - \__driver_image_getbb_auxv:nNnn {#2} #3 { : #1 #4 } - { #5 ~ \__driver_image_getbb_pagebox:w #1 } - } - } -\cs_generate_variant:Nn \__driver_image_getbb_auxiv:nnNnn { V } -\cs_new_protected:Npn \__driver_image_getbb_auxv:nNnn #1#2#3#4 - { - \image_bb_restore:nF {#1#3} - { \__driver_image_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } - } -\cs_new_protected:Npn \__driver_image_getbb_auxvi:nNnn #1#2#3#4 - { - \hbox_set:Nn \l__driver_tmp_box { #2 #1 ~ #4 } - \dim_set:Nn \l_image_utx_dim { \box_wd:N \l__driver_tmp_box } - \dim_set:Nn \l_image_ury_dim { \box_ht:N \l__driver_tmp_box } - \image_bb_save:n {#1#3} - } -\cs_new:Npn \__driver_image_getbb_pagebox:w #1 box {#1} -\cs_new_protected:Npn \__driver_image_include_pdf:n #1 - { - \tex_XeTeXpdffile:D "#1" ~ - \int_compare:nNnT \l_image_page_int > 0 - { page~ \int_use:N \l_image_page_int } - \__driver_image_getbb_auxiv:VnNnn \l_image_pagebox_tl - } +%% File: l3drivers-draw.dtx \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal_pdf:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \driver_draw_begin: @@ -519,6 +351,273 @@ \__driver_literal:n { pdf:etrans } \__driver_scope_end: } +%% File: l3drivers-image.dtx +\cs_new_eq:NN \__driver_image_getbb_eps:n \image_read_bb:n +\int_new:N \g__driver_image_int +\cs_new_protected:Npn \__driver_image_include_eps:n #1 + { + \__driver_literal:n { PSfile = #1 } + } +\cs_new_protected:Npn \__driver_image_include_jpg:n #1 + { \__driver_image_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \__driver_image_include_png:n \__driver_image_include_jpg:n +\cs_new_protected:Npn \__driver_image_include_auxi:nn #1#2 + { + \__driver_image_include_auxii:xnn + { + \tl_if_empty:NF \l_image_pagebox_tl + { : \l_image_pagebox_tl } + \int_compare:nNnT \l_image_page_int > 1 + { :P \int_use:N \l_image_page_int } + \tl_if_empty:NF \l_image_decode_tl + { :D \l_image_decodearray_tl } + \bool_if:NT \l_image_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \__driver_image_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c__driver_image_ #2#1 _int } + { + \__driver_literal:x + { pdf:usexobj~@image \int_use:c { c__driver_image_ #2#1 _int } } + } + { \__driver_image_include_auxiii:nn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \__driver_image_include_auxii:nnn { x } +\cs_new_protected:Npn \__driver_image_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g__driver_image_int + \int_const:cn { c__driver_image_ #1#2 _int } { \g__driver_image_int } + \__driver_literal:x + { + pdf:#3~ + @image \int_use:c { c__driver_image_ #1#2 _int } + \int_compare:nNnT \l_image_page_int > 1 + { page ~ \int_use:N \l_image_page_int \c_space_tl } + \tl_if_empty:NF \l_image_pagebox_tl + { + pagebox ~ \l_image_pagebox_tl \c_space_tl + bbox ~ + \dim_to_decimal_in_bp:n \l_image_llx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_lly_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_urx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_image_ury_dim \c_space_tl + } + (#1) + \bool_lazy_or:nnT + { \l_image_interpolate_bool } + { ! \tl_if_empty_p:N \l_image_decodearray_tl } + { + << + \tl_if_empty:NF \l_image_decode_tl + { /Decode~[ \l_image_decodearray_tl ] } + \bool_if:NT \l_image_interpolate_bool + { /Interpolate~true> } + >> + } + } + } +\cs_new_protected:Npn \__driver_image_getbb_jpg:n #1 + { + \int_zero:N \l_image_page_int + \tl_clear:N \l_image_pagebox_tl + \__driver_image_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D + } +\cs_new_eq:NN \__driver_image_getbb_png:n \__driver_image_getbb_jpg:n +\cs_new_protected:Npn \__driver_image_getbb_pdf:n #1 + { + \tl_clear:N \l_image_decode_tl + \bool_set_false:N \l_image_interpolate_bool + \__driver_image_getbb_auxi:nN {#1} \tex_XeTeXpdffile:D + } +\cs_new_protected:Npn \__driver_image_getbb_auxi:nN #1#2 + { + \int_compare:nNnTF \l_image_page_int > 1 + { \__driver_image_getbb_auxii:VnN \l_image_page_int {#1} #2 } + { \__driver_image_getbb_auxiii:nNnn {#1} #2 } + } +\cs_new_protected:Npn \__driver_image_getbb_auxii:nnN #1#2#3 + { \__driver_image_getbb_aux:nNnn {#2} #3 { :P #1 } { page #1 } } +\cs_generate_variant:Nn \__driver_image_getbb_auxii:nnN { V } +\cs_new_protected:Npn \__driver_image_getbb_auxiii:nNnn #1#2#3#4 + { + \tl_if_empty:NTF \l_image_pagebox_tl + { \__driver_image_getbb_auxiv:VnNnn \l_image_pagebox_tl } + { \__driver_image_getbb_auxv:nNnn } + {#1} #2 {#3} {#4} + } +\cs_new_protected:Npn \__driver_image_getbb_auxiv:nnNnn #1#2#3#4#5 + { + \use:x + { + \__driver_image_getbb_auxv:nNnn {#2} #3 { : #1 #4 } + { #5 ~ \__driver_image_getbb_pagebox:w #1 } + } + } +\cs_generate_variant:Nn \__driver_image_getbb_auxiv:nnNnn { V } +\cs_new_protected:Npn \__driver_image_getbb_auxv:nNnn #1#2#3#4 + { + \image_bb_restore:nF {#1#3} + { \__driver_image_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } + } +\cs_new_protected:Npn \__driver_image_getbb_auxvi:nNnn #1#2#3#4 + { + \hbox_set:Nn \l__driver_tmp_box { #2 #1 ~ #4 } + \dim_set:Nn \l_image_utx_dim { \box_wd:N \l__driver_tmp_box } + \dim_set:Nn \l_image_ury_dim { \box_ht:N \l__driver_tmp_box } + \image_bb_save:n {#1#3} + } +\cs_new:Npn \__driver_image_getbb_pagebox:w #1 box {#1} +\cs_new_protected:Npn \__driver_image_include_pdf:n #1 + { + \tex_XeTeXpdffile:D "#1" ~ + \int_compare:nNnT \l_image_page_int > 0 + { page~ \int_use:N \l_image_page_int } + \__driver_image_getbb_auxiv:VnNnn \l_image_pagebox_tl + } +%% File: l3drivers-pdf.dtx +\tl_const:Nn \c__driver_pdf_AR_fix_tl + { /Ff ~ 65537 /FT /Btn /Subtype /Widget } +\cs_new_protected:Npx \__driver_pdf:n #1 + { \__driver_literal:n { pdf: #1 } } +\cs_generate_variant:Nn \__driver_pdf:n { x } +\int_new:N \g__driver_pdf_object_int +\prop_new:N \g__driver_pdf_object_prop +\cs_new_protected:Npn \driver_pdf_object_new:nn #1#2 + { + \int_gincr:N \g__driver_pdf_object_int + \int_const:cn + { g__driver_pdf_object_ \tl_to_str:n {#1} _int } + { \g__driver_pdf_object_int } + \prop_gput:Nnn \g__driver_pdf_object_prop {#1} {#2} + } +\cs_new:Npn \driver_pdf_object_ref:n #1 + { @driver.obj \int_use:c { g__driver_pdf_object_ \tl_to_str:n {#1} _int } } +\cs_new_protected:Npn \driver_pdf_object_write:nn #1#2 + { + \exp_args:Nx \__driver_pdf_object_write:nnn + { \prop_item:Nn \g__driver_pdf_object_prop {#1} } {#1} {#2} + } +\cs_new_protected:Npn \__driver_pdf_object_write:nnn #1#2#3 + { \use:c { __driver_pdf_object_write_ #1 :nn } {#2} {#3} } +\cs_new_protected:Npn \__driver_pdf_object_write_array:nn #1#2 + { + \__driver_pdf:x + { + obj ~ \driver_pdf_object_ref:n {#1} ~ + [ ~ \exp_not:n {#2} ~ ] + } + } +\cs_new_protected:Npn \__driver_pdf_object_write_dict:nn #1#2 + { + \__driver_pdf:x + { + obj ~ \driver_pdf_object_ref:n {#1} ~ + << ~ \exp_not:n {#2} ~ >> + } + } +\cs_new_protected:Npn \__driver_pdf_object_write_fstream:nn #1#2 + { \__driver_pdf_object_write_stream:nnnn { f } {#1} #2 } +\cs_new_protected:Npn \__driver_pdf_object_write_stream:nn #1#2 + { \__driver_pdf_object_write_stream:nnnn { } {#1} #2 } +\cs_new_protected:Npn \__driver_pdf_object_write_stream:nnnn #1#2#3#4 + { + \__driver_pdf:x + { + #1 stream ~ \driver_pdf_object_ref:n {#2} ~ + ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> + + } + } +\bool_new:N \g__driver_landscape_bool +\AtBeginDocument + { + \cs_if_exist:NT \landscape + { + \tl_put_right:Nn \landscape + { \bool_gset_true:N \g__driver_landscape_bool } + \tl_put_left:Nn \endlandscape + { \bool_gset_false:N \g__driver_landscape_bool } + } + } +\cs_new_protected:Npx \__driver_pdf_AR_fix: + { + \__driver_pdf:n + { + ann ~ width ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt + << \c__driver_pdf_AR_fix_tl >> + } + } +\int_new:N \g__driver_pdf_annotation_int +\cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4 + { + \bool_if:NTF \g__driver_landscape_bool + { + \box_move_up:nn {#2} + { + \vbox:n + { + \__driver_pdf_annotation:nnnn + { #2 + #3 } {#1} { 0pt } {#4} + } + } + } + { \__driver_pdf_annotation:nnnn {#1} {#2} {#3} {#4} } + } +\cs_new_protected:Npn \__driver_pdf_annotation:nnnn #1#2#3#4 + { + \__driver_pdf_AR_fix: + \int_gincr:N \g__driver_pdf_object_int + \int_gset_eq:NN \g__driver_pdf_annotation_int \g__driver_pdf_object_int + \__driver_pdf:x + { + ann ~ @driver.obj \int_use:N \g__driver_pdf_object_int \c_space_tl + width ~ \dim_eval:n {#1} ~ + height ~ \dim_eval:n {#2} ~ + depth ~ \dim_eval:n {#3} ~ + << #4 >> + } + } +\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2 + { \__driver_pdf_link_begin:n { #1 /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2 + { \__driver_pdf_link_begin:n {#1#2} } +\cs_new_protected:Npn \__driver_pdf_link_begin:n #1 + { + \__driver_pdf_AR_fix: + \__driver_pdf:n + { + bann + << + /Type /Annot + /Subtype /Link + #1 + >> + } + } +\cs_new_protected:Npn \driver_pdf_link_end: + { \__driver_pdf:n { eann } } +\cs_new:Npn \driver_pdf_link_last: { } +\cs_new_protected:Npn \driver_pdf_link_margin:n #1 { } +\cs_new_protected:Npn \driver_pdf_compresslevel:n #1 + { \__driver_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } +\cs_new_protected:Npn \driver_pdf_objects_enable: { } +\cs_new_protected:Npn \driver_pdf_objects_disable: + { \__driver_literal:n { dvipdfmx:config~C~0x40 } } +\cs_new_protected:Npn \driver_pdf_version_major:n #1 + { + \cs_gset:Npx \driver_pdf_version_major: { \int_eval:n {#1} } + \__driver_literal:x { pdf:majorversion \driver_pdf_version_major: } + } +\cs_new_protected:Npn \driver_pdf_version_minor:n #1 + { + \cs_gset:Npx \driver_pdf_version_minor: { \int_eval:n {#1} } + \__driver_literal:x { pdf:minorversion \driver_pdf_version_minor: } + } +\cs_new:Npn \driver_pdf_version_major: { 1 } +\cs_new:Npn \driver_pdf_version_minor: { 5 } %% %% %% End of file `l3xdvipdfmx.def'. |