diff options
author | Karl Berry <karl@freefriends.org> | 2019-07-02 21:02:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-07-02 21:02:28 +0000 |
commit | 0eeaf7545f37a529bbc7549c23ec0f2160e509e0 (patch) | |
tree | d8f47b054358a54d88a1d8a412187d2bbd19dc7e | |
parent | df6cfce397c37144838d66b3b464c97557bb86c1 (diff) |
l3backend (2jul19)
git-svn-id: svn://tug.org/texlive/trunk@51533 c570f23f-e606-0410-a88d-b1316a301751
19 files changed, 9280 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/l3backend/CHANGELOG.md b/Master/texmf-dist/doc/latex/l3backend/CHANGELOG.md new file mode 100644 index 00000000000..d3237c687d1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/l3backend/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog +All notable changes to the `l3backend` bundle will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +this project uses date-based 'snapshot' version identifiers. + +## [Unreleased] + +## [2019-07-01] + +### Added + +- Driver support for anonymous objects + +### Changed + +- Moved backend code to separate release module `l3backend` +- Include `l3backend` in file names +- Moved backend code to internal for each 'parent' module + +[Unreleased]: https://github.com/latex3/latex3/compare/2019-07-01...HEAD +[2019-07-01]: https://github.com/latex3/latex3/compare/2019-05-28...2019-07-01 diff --git a/Master/texmf-dist/doc/latex/l3backend/README.md b/Master/texmf-dist/doc/latex/l3backend/README.md new file mode 100644 index 00000000000..30c5214b0d5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/l3backend/README.md @@ -0,0 +1,16 @@ +LaTeX3 Backend Drivers +====================== + +Release 2019-07-01 + +This package forms parts of `expl3`, and contains the code used to interface +with backends (drivers) across the `expl3` codebase. The functions here are +defined differently depending on the engine in use. As such, these are +distributed separately from `l3kernel` to allow this code to be updated +on an independent schedule. + +----- + +<p>Copyright (C) 2019 The LaTeX3 Project <br /> +<a href="http://latex-project.org/">http://latex-project.org/</a> <br /> +All rights reserved.</p> diff --git a/Master/texmf-dist/doc/latex/l3backend/l3backend-code.pdf b/Master/texmf-dist/doc/latex/l3backend/l3backend-code.pdf Binary files differnew file mode 100644 index 00000000000..a1bf87ba067 --- /dev/null +++ b/Master/texmf-dist/doc/latex/l3backend/l3backend-code.pdf diff --git a/Master/texmf-dist/doc/latex/l3backend/l3backend-code.tex b/Master/texmf-dist/doc/latex/l3backend/l3backend-code.tex new file mode 100644 index 00000000000..62a6bf5e2a0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/l3backend/l3backend-code.tex @@ -0,0 +1,61 @@ +\iffalse meta-comment + +File: l3backend-code.tex + +Copyright (C) 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 "l3backend bundle" (The Work in LPPL) +and all files in that bundle must be distributed together. + +The released version of this bundle is available from CTAN. + +----------------------------------------------------------------------- + +The development version of the bundle can be found at + + https://github.com/latex3/latex3 + +for those people who are interested. + +\fi + +\documentclass{l3doc} + +\begin{document} + +\makeatletter +\let\DelayPrintIndex\PrintIndex +\let\PrintIndex\@empty +\makeatother + +\ExplSyntaxOn +\clist_gput_right:Nn \g_docinput_clist + { + l3backend-basics.dtx , + l3backend-box.dtx , + l3backend-color.dtx , + l3backend-draw.dtx , + l3backend-graphics.dtx , + l3backend-pdf.dtx + } +\ExplSyntaxOff + +\part{Implementation} + +\def\maketitle{} +\EnableImplementation +\DisableDocumentation +\DocInputAgain + +\clearpage + +\DelayPrintIndex + +\end{document} diff --git a/Master/texmf-dist/source/latex/l3backend/l3backend-basics.dtx b/Master/texmf-dist/source/latex/l3backend/l3backend-basics.dtx new file mode 100644 index 00000000000..04df933c831 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend-basics.dtx @@ -0,0 +1,400 @@ +% \iffalse meta-comment +% +%% File: l3backend-basics.dtx +% +% Copyright (C) 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 "l3backend 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{l3backend-basics} package\\ Backend 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-07-01} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3backend-basics} Implementation} +% +% \begin{macrocode} +%<*initex|package> +% \end{macrocode} +% +% Whilst there is a reasonable amount of code overlap between backends, +% 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-backed 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> + {l3backend-dvipdfmx.def}{2019-04-06}{} + {L3 Experimental backend support: dvipdfmx} +%</dvipdfmx> +%<*dvips> + {l3backend-dvips.def}{2019-04-06}{} + {L3 Experimental backend support: dvips} +%</dvips> +%<*dvisvgm> + {l3backend-dvisvgm.def}{2019-04-06}{} + {L3 Experimental backend support: dvisvgm} +%</dvisvgm> +%<*pdfmode> + {l3backend-pdfmode.def}{2019-04-06}{} + {L3 Experimental backend support: PDF mode} +%</pdfmode> +%<*xdvipdfmx> + {l3backend-xdvipdfmx.def}{2019-04-06}{} + {L3 Experimental backend support: xdvipdfmx} +%</xdvipdfmx> +%</package> +% \end{macrocode} +% +% The order of the backend 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} +% { +% \__kernel_backend_literal:e, +% \__kernel_backend_literal:n, +% \__kernel_backend_literal:x +% } +% The one shared function for all backends 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 \__kernel_backend_literal:e \tex_special:D +\cs_new_protected:Npn \__kernel_backend_literal:n #1 + { \__kernel_backend_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \__kernel_backend_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \subsection{\texttt{dvips} backend} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro} +% {\__kernel_backend_literal_postscript:n, \__kernel_backend_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 \__kernel_backend_literal_postscript:n #1 + { \__kernel_backend_literal:n { ps:: #1 } } +\cs_generate_variant:Nn \__kernel_backend_literal_postscript:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_postscript:n, \__kernel_backend_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 \__kernel_backend_postscript:n #1 + { \__kernel_backend_literal:n { ps: SDict ~ begin ~ #1 ~ end } } +\cs_generate_variant:Nn \__kernel_backend_postscript:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_postscript_header:n} +% PostScript for the header: a small saving but makes the code clearer. +% This is held until the start of shipout such that a document with no +% actual output does not write anything. +% \begin{macrocode} +\cs_new_protected:Npx \__kernel_backend_postscript_header:n #1 +%<*initex> + { \__kernel_backend_literal:n { ! #1 } } +%</initex> +%<*package> + { + \cs_if_exist:NTF \AtBeginDvi + { \exp_not:N \AtBeginDvi } + { \use:n } + { \__kernel_backend_literal:n { ! #1 } } + } +%</package> +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% \__kernel_backend_align_begin:, +% \__kernel_backend_align_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 \__kernel_backend_align_begin: + { + \__kernel_backend_literal:n { ps::[begin] } + \__kernel_backend_literal_postscript:n { currentpoint } + \__kernel_backend_literal_postscript:n { currentpoint~translate } + } +\cs_new_protected:Npn \__kernel_backend_align_end: + { + \__kernel_backend_literal_postscript:n { neg~exch~neg~exch~translate } + \__kernel_backend_literal:n { ps::[end] } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_scope_begin:, \__kernel_backend_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 \__kernel_backend_scope_begin: + { \__kernel_backend_literal:n { ps:gsave } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal:n { ps:grestore } } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} backend} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% The direct PDF backend covers both \pdfTeX{} and \LuaTeX{}. The latter +% renames and restructures the backend primitives but this can be handled +% at one level of abstraction. As such, we avoid using two separate backends +% for this material at the cost of some \texttt{x}-type definitions to get +% everything expanded up-front. +% +% \begin{macro}{\__kernel_backend_literal_pdf:n, \__kernel_backend_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 \__kernel_backend_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 \__kernel_backend_literal_pdf:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_literal_page:n} +% Page literals are pretty simple. To avoid an expansion, we write out +% by hand. +% \begin{macrocode} +\cs_new_protected:Npx \__kernel_backend_literal_page:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D literal ~ } + { \tex_pdfliteral:D } + page + { \exp_not:N \exp_not:n {#1} } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_scope_begin:, \__kernel_backend_scope_end:} +% Higher-level interfaces for saving and restoring the graphic state. +% \begin{macrocode} +\cs_new_protected:Npx \__kernel_backend_scope_begin: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D save \scan_stop: } + { \tex_pdfsave:D } + } +\cs_new_protected:Npx \__kernel_backend_scope_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D restore \scan_stop: } + { \tex_pdfrestore:D } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_matrix:n, \__kernel_backend_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 \__kernel_backend_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 \__kernel_backend_matrix:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} backend} +% +% \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 backends, with some \texttt{clean up} for \texttt{xdvipdfmx} as +% required. +% +% \begin{macro}{\__kernel_backend_literal_pdf:n, \__kernel_backend_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 \__kernel_backend_literal_pdf:n #1 + { \__kernel_backend_literal:n { pdf:literal~ #1 } } +\cs_generate_variant:Nn \__kernel_backend_literal_pdf:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_literal_page:n} +% Whilst the manual says this is like |literal direct| in \pdfTeX{}, +% it closes the |BT| block! +% \begin{macrocode} +\cs_new_protected:Npn \__kernel_backend_literal_page:n #1 + { \__kernel_backend_literal:n { pdf:literal~direct~ #1 } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_scope_begin:, \__kernel_backend_scope_end:} +% Scoping is done using the backend-specific specials. +% \begin{macrocode} +\cs_new_protected:Npn \__kernel_backend_scope_begin: + { \__kernel_backend_literal:n { x:gsave } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal:n { x:grestore } } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} backend} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\__kernel_backend_literal_svg:n, \__kernel_backend_literal_svg:x} +% Unlike the other backends, 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 \__kernel_backend_literal_svg:n #1 + { \__kernel_backend_literal:n { dvisvgm:raw~ #1 { ?nl } } } +\cs_generate_variant:Nn \__kernel_backend_literal_svg:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_scope_begin:, \__kernel_backend_scope_end:} +% A scope in SVG terms is slightly different to the other backends as +% operations have to be \enquote{tied} to these not simply inside them. +% \begin{macrocode} +\cs_new_protected:Npn \__kernel_backend_scope_begin: + { \__kernel_backend_literal_svg:n { <g> } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal_svg:n { </g> } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\__kernel_backend_scope_begin:n, \__kernel_backend_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{__kernel_backend_scope_begin:} as a result. +% No assumptions are made about the nature +% of the scoped operation(s). +% \begin{macrocode} +\cs_new_protected:Npn \__kernel_backend_scope_begin:n #1 + { \__kernel_backend_literal_svg:n { <g~ #1 > } } +\cs_generate_variant:Nn \__kernel_backend_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/l3backend/l3backend-box.dtx b/Master/texmf-dist/source/latex/l3backend/l3backend-box.dtx new file mode 100644 index 00000000000..ef25fe95e1e --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend-box.dtx @@ -0,0 +1,473 @@ +% \iffalse meta-comment +% +%% File: l3backend-box.dtx +% +% Copyright (C) 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 "l3backend 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{l3backend-box} package\\ Backend 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-07-01} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3backend-box} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=box> +% \end{macrocode} +% +% \subsection{\texttt{dvips} backend} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_clip:N} +% The \texttt{dvips} backend 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 \@@_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_align_begin: + \__kernel_backend_literal_postscript:n { matrix~currentmatrix } + \__kernel_backend_literal_postscript:n + { Resolution~72~div~VResolution~72~div~scale } + \__kernel_backend_literal_postscript:n { DVImag~dup~scale } + \__kernel_backend_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 + } + \__kernel_backend_literal_postscript:n { setmatrix } + \__kernel_backend_align_end: + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_rotate:Nn} +% \begin{macro}{\@@_backend_rotate_aux: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 \@@_backend_rotate:Nn #1#2 + { \exp_args:NNf \@@_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \@@_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \__kernel_backend_align_begin: + \__kernel_backend_literal_postscript:x + { + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -(#2) , 5 ) } } ~ + rotate + } + \__kernel_backend_align_end: + \box_use:N #1 + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_scale:Nnn} +% The \texttt{dvips} backend once again has a dedicated operation we can +% use here. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_align_begin: + \__kernel_backend_literal_postscript:x + { + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } ~ + scale + } + \__kernel_backend_align_end: + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} backend} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_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 \@@_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_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 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_rotate:Nn} +% \begin{macro}{\@@_backend_rotate_aux:Nn} +% \begin{variable}{\l_@@_backend_cos_fp, \l_@@_backend_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 \@@_backend_rotate:Nn #1#2 + { \exp_args:NNf \@@_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \@@_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \box_set_wd:Nn #1 { 0pt } + \fp_set:Nn \l_@@_backend_cos_fp { round ( cosd ( #2 ) , 5 ) } + \fp_compare:nNnT \l_@@_backend_cos_fp = \c_zero_fp + { \fp_zero:N \l_@@_backend_cos_fp } + \fp_set:Nn \l_@@_backend_sin_fp { round ( sind ( #2 ) , 5 ) } + \__kernel_backend_matrix:x + { + \fp_use:N \l_@@_backend_cos_fp \c_space_tl + \fp_compare:nNnTF \l_@@_backend_sin_fp = \c_zero_fp + { 0~0 } + { + \fp_use:N \l_@@_backend_sin_fp + \c_space_tl + \fp_eval:n { -\l_@@_backend_sin_fp } + } + \c_space_tl + \fp_use:N \l_@@_backend_cos_fp + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +\fp_new:N \l_@@_backend_cos_fp +\fp_new:N \l_@@_backend_sin_fp +% \end{macrocode} +% \end{variable} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_scale:Nnn} +% The same idea as for rotation but without the complexity of signs and +% cosines. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_matrix:x + { + \fp_eval:n { round ( #2 , 5 ) } ~ + 0~0~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} backend} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_clip:N} +% The code here is identical to that for \texttt{pdfmode}: unlike rotation and +% scaling, there is no higher-level support in the backend for clipping. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_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 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_rotate:Nn} +% \begin{macro}{\@@_backend_rotate_aux:Nn} +% Rotating in \texttt{(x)}dvipdmfx can be implemented using either PDF or +% backend-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 backend-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 \@@_backend_rotate:Nn #1#2 + { \exp_args:NNf \@@_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \@@_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( #2 , 5 ) } } + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_scale:Nnn} +% Much the same idea for scaling: use the higher-level backend operation to allow +% for box content. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} backend} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_clip:N} +% \begin{variable}{\g_@@_clip_path_int} +% Clipping in SVG is more involved than with other backends. 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 \@@_backend_clip:N #1 + { + \int_gincr:N \g_@@_clip_path_int + \__kernel_backend_literal_svg:x + { < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > } + \__kernel_backend_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 + " + /> + } + \__kernel_backend_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} + \__kernel_backend_scope_begin:n + { + transform = + " + translate ( { ?x } , { ?y } ) ~ + scale ( 1 , -1 ) + " + } + \__kernel_backend_scope_begin:x + { + clip-path = + "url ( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int ) " + } + \__kernel_backend_scope_begin:n + { + transform = + " + scale ( -1 , 1 ) ~ + translate ( { ?x } , { ?y } ) ~ + scale ( -1 , -1 ) + " + } + \box_use:N #1 + \__kernel_backend_scope_end: + \__kernel_backend_scope_end: + \__kernel_backend_scope_end: +% \skip_horizontal:n { \box_wd:N #1 } + } +\int_new:N \g_@@_clip_path_int +% \end{macrocode} +% \end{variable} +% \end{macro} +% +% \begin{macro}{\@@_backend_rotate:Nn} +% Rotation has a dedicated operation which includes a centre-of-rotation +% optional pair. That can be picked up from the backend syntax, so there is +% no need to worry about the transformation matrix. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_rotate:Nn #1#2 + { + \__kernel_backend_scope_begin:x + { + transform = + " + rotate + ( \fp_eval:n { round ( -(#2) , 5 ) } , ~ { ?x } , ~ { ?y } ) + " + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_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 \@@_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_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 } + \__kernel_backend_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/l3backend/l3backend-color.dtx b/Master/texmf-dist/source/latex/l3backend/l3backend-color.dtx new file mode 100644 index 00000000000..0e80de0117c --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend-color.dtx @@ -0,0 +1,307 @@ +% \iffalse meta-comment +% +%% File: l3backend-color.dtx +% +% Copyright (C) 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 "l3backend 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{l3backend-color} package\\ Backend 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-07-01} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3backend-color} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=color> +% \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}{\@@_backend_pickup:N} +% \begin{macro}{\@@_backend_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 \@@_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \@@_backend_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 \@@_backend_pickup:w + { \current@color } \q_stop #1 + } + } + \cs_new_protected:Npn \@@_backend_pickup:w #1 ~ #2 \q_stop #3 + { \tl_set:Nn #3 { #1 ~ #2 } } + } + { } + } +%</package> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_cmyk:nnnn} +% \begin{macro}{\@@_backend_gray:n} +% \begin{macro}{\@@_backend_rgb:nnn} +% \begin{macro}{\@@_backend_spot:nn} +% \begin{macro}{\@@_backend_select:n, \@@_backend_select:x} +% \begin{macro}{\@@_backend_reset:} +% \begin{macro}{color.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 \@@_backend_cmyk:nnnn #1#2#3#4 + { + \@@_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \@@_backend_gray:n #1 + { \@@_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \@@_backend_rgb:nnn #1#2#3 + { + \@@_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \@@_backend_spot:nn #1#2 + { \@@_backend_select:n { #1 } } +\cs_new_protected:Npn \@@_backend_select:n #1 + { + \__kernel_backend_literal:n { color~push~ #1 } +%<*dvips> + \__kernel_backend_postscript:n { /color.fc~{ }~def } +%</dvips> + \group_insert_after:N \@@_backend_reset: + } +\cs_generate_variant:Nn \@@_backend_select:n { x } +\cs_new_protected:Npn \@@_backend_reset: + { \__kernel_backend_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}{\@@_backend_pickup:N} +% \begin{macro}{\@@_backend_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{@@_backend_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 \@@_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \@@_backend_pickup:N #1 + { + \exp_last_unbraced:Nx \@@_backend_pickup:w + { \current@color } ~ 0 ~ 0 ~ 0 \q_stop #1 + } + \cs_new_protected:Npn \@@_backend_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__kernel_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__kernel_color_stack_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_backend_cmyk:nnnn, \@@_backend_cmyk_aux:nnnn} +% \begin{macro}{\@@_backend_gray:n, \@@_backend_gray_aux:n} +% \begin{macro}{\@@_backend_rgb:nnn, \@@_backend_rgb_aux:nnn} +% \begin{macro}{\@@_backend_spot:nn} +% \begin{macro}{\@@_backend_select:n, \@@_backend_select:x} +% \begin{macro}{\@@_backend_reset:} +% Simply dump the data, but allowing for \LuaTeX{}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_cmyk:nnnn #1#2#3#4 + { + \use:x + { + \@@_backend_cmyk_aux:nnnn + { \fp_eval:n {#1} } + { \fp_eval:n {#2} } + { \fp_eval:n {#3} } + { \fp_eval:n {#4} } + } + } +\cs_new_protected:Npn \@@_backend_cmyk_aux:nnnn #1#2#3#4 + { + \@@_backend_select:n + { #1 ~ #2 ~ #3 ~ #4 ~ k ~ #1 ~ #2 ~ #3 ~ #4 ~ K } + } +\cs_new_protected:Npn \@@_backend_gray:n #1 + { \exp_args:Nx \@@_backend_gray_aux:n { \fp_eval:n {#1} } } +\cs_new_protected:Npn \@@_backend_gray_aux:n #1 + { \@@_backend_select:n { #1 ~ g ~ #1 ~ G } } +\cs_new_protected:Npn \@@_backend_rgb:nnn #1#2#3 + { + \use:x + { + \@@_backend_rgb_aux:nnn + { \fp_eval:n {#1} } + { \fp_eval:n {#2} } + { \fp_eval:n {#3} } + } + } +\cs_new_protected:Npn \@@_backend_rgb_aux:nnn #1#2#3 + { \@@_backend_select:n { #1 ~ #2 ~ #3 ~ rg ~ #1 ~ #2 ~ #3 ~ RG } } +\cs_new_protected:Npn \@@_backend_spot:nn #1#2 + { \@@_backend_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ sc ~ #2 ~ SC } } +\cs_new_protected:Npx \@@_backend_select:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int push {#1} + \group_insert_after:N \exp_not:N \@@_backend_reset: + } +\cs_generate_variant:Nn \@@_backend_select:n { x } +\cs_new_protected:Npx \@@_backend_reset: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_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/l3backend/l3backend-draw.dtx b/Master/texmf-dist/source/latex/l3backend/l3backend-draw.dtx new file mode 100644 index 00000000000..e451d30a3e6 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend-draw.dtx @@ -0,0 +1,1368 @@ +% \iffalse meta-comment +% +%% File: l3backend-draw.dtx +% +% Copyright (C) 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 "l3backend 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{l3backend-draw} package\\ Backend 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-07-01} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3backend-draw} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=draw> +% \end{macrocode} +% +% \subsection{\texttt{dvips} backend} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_literal:n, \@@_backend_literal:x} +% The same as literal PostScript: same arguments about positioning apply +% her. +% \begin{macrocode} +\cs_new_eq:NN \@@_backend_literal:n \__kernel_backend_literal_postscript:n +\cs_generate_variant:Nn \@@_backend_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_begin:, \@@_backend_end:} +% \begin{macro}{color.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 |/color.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{@@_backend_box_use:Nnnnn}). (Note that +% |@beginspecial|/|@endspecial| forms a backend 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 \@@_backend_begin: + { + \__kernel_backend_literal:n { ps::[begin] } + \@@_backend_literal:n { @beginspecial } + \@@_backend_literal:n { SDict ~ begin ~ /color.fc ~ { } ~ def ~ end } + } +\cs_new_protected:Npn \@@_backend_end: + { + \@@_backend_literal:n { @endspecial } + \__kernel_backend_literal:n { ps::[end] } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_scope_begin:, \@@_backend_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 \@@_backend_scope_begin: + { \@@_backend_literal:n { save } } +\cs_new_protected:Npn \@@_backend_scope_end: + { \@@_backend_literal:n { restore } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_moveto:nn, \@@_backend_lineto:nn} +% \begin{macro}{\@@_backend_rectangle:nnnn} +% \begin{macro}{\@@_backend_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 \@@_backend_moveto:nn #1#2 + { + \@@_backend_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ + \dim_to_decimal_in_bp:n {#2} ~ moveto + } + } +\cs_new_protected:Npn \@@_backend_lineto:nn #1#2 + { + \@@_backend_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ + \dim_to_decimal_in_bp:n {#2} ~ lineto + } + } +\cs_new_protected:Npn \@@_backend_rectangle:nnnn #1#2#3#4 + { + \@@_backend_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 \@@_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \@@_backend_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}{\@@_backend_evenodd_rule:, \@@_backend_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 \@@_backend_evenodd_rule: + { \bool_gset_true:N \g_@@_draw_eor_bool } +\cs_new_protected:Npn \@@_backend_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} +% { +% \@@_backend_closepath: , +% \@@_backend_stroke: , +% \@@_backend_closestroke: , +% \@@_backend_fill: , +% \@@_backend_fillstroke: , +% \@@_backend_clip: , +% \@@_backend_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 \@@_backend_closepath: + { \@@_backend_literal:n { closepath } } +\cs_new_protected:Npn \@@_backend_stroke: + { + \@@_backend_literal:n { stroke } + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_backend_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_backend_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +\cs_new_protected:Npn \@@_backend_closestroke: + { + \@@_backend_closepath: + \@@_backend_stroke: + } +\cs_new_protected:Npn \@@_backend_fill: + { + \@@_backend_literal:n { gsave } + \@@_backend_literal:n { color.fc } + \@@_backend_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + fill + } + \@@_backend_literal:n { grestore } + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_backend_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_backend_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +\cs_new_protected:Npn \@@_backend_fillstroke: + { + \@@_backend_literal:n { gsave } + \@@_backend_literal:n { color.fc } + \@@_backend_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + fill + } + \@@_backend_literal:n { grestore } + \@@_backend_literal:n { stroke } + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_backend_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_backend_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +\cs_new_protected:Npn \@@_backend_clip: + { \bool_gset_true:N \g_@@_draw_clip_bool } +\bool_new:N \g_@@_draw_clip_bool +\cs_new_protected:Npn \@@_backend_discardpath: + { + \bool_if:NT \g_@@_draw_clip_bool + { + \@@_backend_literal:x + { + \bool_if:NT \g_@@_draw_eor_bool { eo } + clip + } + } + \@@_backend_literal:n { newpath } + \bool_gset_false:N \g_@@_draw_clip_bool + } +% \end{macrocode} +% \end{variable} +% \end{macro} +% +% \begin{macro}{\@@_backend_dash_pattern:nn} +% \begin{macro}{\@@_backend_dash:n} +% \begin{macro}{\@@_backend_linewidth:n} +% \begin{macro}{\@@_backend_miterlimit:n} +% \begin{macro} +% { +% \@@_backend_cap_butt:, \@@_backend_cap_round:, \@@_backend_cap_rectangle:, +% \@@_backend_join_miter:, \@@_backend_join_round:, \@@_backend_join_bevel: +% } +% Converting paths to output is again a case of mapping directly to +% PostScript operations. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_dash_pattern:nn #1#2 + { + \@@_backend_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \@@_backend_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ setdash + } + } +\cs_new:Npn \@@_backend_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \@@_backend_linewidth:n #1 + { + \@@_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ setlinewidth } + } +\cs_new_protected:Npn \@@_backend_miterlimit:n #1 + { \@@_backend_literal:x { \fp_eval:n {#1} ~ setmiterlimit } } +\cs_new_protected:Npn \@@_backend_cap_butt: + { \@@_backend_literal:n { 0 ~ setlinecap } } +\cs_new_protected:Npn \@@_backend_cap_round: + { \@@_backend_literal:n { 1 ~ setlinecap } } +\cs_new_protected:Npn \@@_backend_cap_rectangle: + { \@@_backend_literal:n { 2 ~ setlinecap } } +\cs_new_protected:Npn \@@_backend_join_miter: + { \@@_backend_literal:n { 0 ~ setlinejoin } } +\cs_new_protected:Npn \@@_backend_join_round: + { \@@_backend_literal:n { 1 ~ setlinejoin } } +\cs_new_protected:Npn \@@_backend_join_bevel: + { \@@_backend_literal:n { 2 ~ setlinejoin } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \@@_backend_color_fill_cmyk:nnnn , +% \@@_backend_color_stroke_cmyk:nnnn +% } +% \begin{macro} +% { +% \@@_backend_color_fill_gray:n , +% \@@_backend_color_stroke_gray:n +% } +% \begin{macro} +% { +% \@@_backend_color_fill_rgb:nnn , +% \@@_backend_color_stroke_rgb:nnn +% } +% \begin{macro} +% { +% \@@_backend_color_fill:n, \@@_backend_color_fill:x, +% \@@_backend_color_stroke:n, \@@_backend_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 \@@_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \@@_backend_color_fill:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + setcmykcolor + } + } +\cs_new_protected:Npn \@@_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \@@_backend_color_stroke:x + { + cmyk ~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \@@_backend_color_fill_gray:n #1 + { \@@_backend_color_fill:x { \fp_eval:n {#1} ~ setgray } } +\cs_new_protected:Npn \@@_backend_color_stroke_gray:n #1 + { \@@_backend_color_stroke:x { gray ~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \@@_backend_color_fill_rgb:nnn #1#2#3 + { + \@@_backend_color_fill:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ setrgbcolor } + } +\cs_new_protected:Npn \@@_backend_color_stroke_rgb:nnn #1#2#3 + { + \@@_backend_color_stroke:x + { rgb ~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \@@_backend_color_fill:n #1 + { + \__kernel_backend_postscript:n + { SDict ~ begin ~ /color.fc ~ { #1 } ~ def ~ end } + } +\cs_generate_variant:Nn \@@_backend_color_fill:n { x } +\cs_new_protected:Npn \@@_backend_color_stroke:n #1 + { + \__kernel_backend_literal:n { color~push~#1 } + \group_insert_after:N \@@_color_reset: + } +\cs_generate_variant:Nn \@@_backend_color_stroke:n { x } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_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 backend +% 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 \@@_backend_cm:nnnn #1#2#3#4 + { + \@@_backend_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}{\@@_backend_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 \@@_backend_box_use:Nnnnn #1#2#3#4#5 + { + \@@_backend_literal:n { @endspecial } + \@@_backend_literal:n { [end] } + \@@_backend_literal:n { [begin] } + \@@_backend_literal:n { save } + \@@_backend_literal:n { currentpoint } + \@@_backend_literal:n { currentpoint~translate } + \@@_backend_cm:nnnn { 1 } { 0 } { 0 } { -1 } + \@@_backend_cm:nnnn {#2} {#3} {#4} {#5} + \@@_backend_cm:nnnn { 1 } { 0 } { 0 } { -1 } + \@@_backend_literal:n { neg~exch~neg~exch~translate } + \@@_backend_literal:n { [end] } + \hbox_overlap_right:n { \box_use:N #1 } + \@@_backend_literal:n { [begin] } + \@@_backend_literal:n { restore } + \@@_backend_literal:n { [end] } + \@@_backend_literal:n { [begin] } + \@@_backend_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}{\@@_backend_literal:n, \@@_backend_literal:x} +% Pass data through using a dedicated interface. +% \begin{macrocode} +\cs_new_eq:NN \@@_backend_literal:n \__kernel_backend_literal_pdf:n +\cs_generate_variant:Nn \@@_backend_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_begin:, \@@_backend_end:} +% No special requirements here, so simply set up a drawing scope. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_begin: + { \@@_backend_scope_begin: } +\cs_new_protected:Npn \@@_backend_end: + { \@@_backend_scope_end: } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_scope_begin:, \@@_backend_scope_end:} +% Use the backend-level scope mechanisms. +% \begin{macrocode} +\cs_new_eq:NN \@@_backend_scope_begin: \__kernel_backend_scope_begin: +\cs_new_eq:NN \@@_backend_scope_end: \__kernel_backend_scope_end: +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_moveto:nn, \@@_backend_lineto:nn} +% \begin{macro}{\@@_backend_curveto:nnnnnn} +% \begin{macro}{\@@_backend_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 \@@_backend_moveto:nn #1#2 + { + \@@_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } + } +\cs_new_protected:Npn \@@_backend_lineto:nn #1#2 + { + \@@_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } + } +\cs_new_protected:Npn \@@_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \@@_backend_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 \@@_backend_rectangle:nnnn #1#2#3#4 + { + \@@_backend_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}{\@@_backend_evenodd_rule:, \@@_backend_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 \@@_backend_evenodd_rule: + { \bool_gset_true:N \g_@@_draw_eor_bool } +\cs_new_protected:Npn \@@_backend_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} +% { +% \@@_backend_closepath: , +% \@@_backend_stroke: , +% \@@_backend_closestroke: , +% \@@_backend_fill: , +% \@@_backend_fillstroke: , +% \@@_backend_clip: , +% \@@_backend_discardpath: +% } +% Converting paths to output is again a case of mapping directly to +% PDF operations. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_closepath: + { \@@_backend_literal:n { h } } +\cs_new_protected:Npn \@@_backend_stroke: + { \@@_backend_literal:n { S } } +\cs_new_protected:Npn \@@_backend_closestroke: + { \@@_backend_literal:n { s } } +\cs_new_protected:Npn \@@_backend_fill: + { + \@@_backend_literal:x + { f \bool_if:NT \g_@@_draw_eor_bool * } + } +\cs_new_protected:Npn \@@_backend_fillstroke: + { + \@@_backend_literal:x + { B \bool_if:NT \g_@@_draw_eor_bool * } + } +\cs_new_protected:Npn \@@_backend_clip: + { + \@@_backend_literal:x + { W \bool_if:NT \g_@@_draw_eor_bool * } + } +\cs_new_protected:Npn \@@_backend_discardpath: + { \@@_backend_literal:n { n } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_dash_pattern:nn} +% \begin{macro}{\@@_backend_dash:n} +% \begin{macro}{\@@_backend_linewidth:n} +% \begin{macro}{\@@_backend_miterlimit:n} +% \begin{macro} +% { +% \@@_backend_cap_butt:, \@@_backend_cap_round:, \@@_backend_cap_rectangle:, +% \@@_backend_join_miter:, \@@_backend_join_round:, \@@_backend_join_bevel: +% } +% Converting paths to output is again a case of mapping directly to +% PDF operations. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_dash_pattern:nn #1#2 + { + \@@_backend_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \@@_backend_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ d + } + } +\cs_new:Npn \@@_backend_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \@@_backend_linewidth:n #1 + { + \@@_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ w } + } +\cs_new_protected:Npn \@@_backend_miterlimit:n #1 + { \@@_backend_literal:x { \fp_eval:n {#1} ~ M } } +\cs_new_protected:Npn \@@_backend_cap_butt: + { \@@_backend_literal:n { 0 ~ J } } +\cs_new_protected:Npn \@@_backend_cap_round: + { \@@_backend_literal:n { 1 ~ J } } +\cs_new_protected:Npn \@@_backend_cap_rectangle: + { \@@_backend_literal:n { 2 ~ J } } +\cs_new_protected:Npn \@@_backend_join_miter: + { \@@_backend_literal:n { 0 ~ j } } +\cs_new_protected:Npn \@@_backend_join_round: + { \@@_backend_literal:n { 1 ~ j } } +\cs_new_protected:Npn \@@_backend_join_bevel: + { \@@_backend_literal:n { 2 ~ j } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \@@_backend_color_fill_cmyk:nnnn , +% \@@_backend_color_stroke_cmyk:nnnn +% } +% \begin{macro} +% { +% \@@_backend_color_fill_gray:n , +% \@@_backend_color_stroke_gray:n +% } +% \begin{macro} +% { +% \@@_backend_color_fill_rgb:nnn , +% \@@_backend_color_stroke_rgb:nnn +% } +% \begin{macro}{\@@_backend_color_select:n, \@@_backend_color_select:x} +% \begin{macro}{\@@_backend_color_reset:} +% Color has to be split between \texttt{(x)dvipdfmx} and the PDF engines +% as there is no color stack for fill/stroke separation in the former. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \@@_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \@@_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \@@_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \@@_backend_color_fill_gray:n #1 + { \@@_backend_color_select:x { \fp_eval:n {#1} ~ g } } +\cs_new_protected:Npn \@@_backend_color_stroke_gray:n #1 + { \@@_backend_color_select:x { \fp_eval:n {#1} ~ G } } +\cs_new_protected:Npn \@@_backend_color_fill_rgb:nnn #1#2#3 + { + \@@_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } + } +\cs_new_protected:Npn \@@_backend_color_stroke_rgb:nnn #1#2#3 + { + \@@_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } + } +%<*pdfmode> +\cs_new_protected:Npx \@@_backend_color_select:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int push {#1} + \group_insert_after:N \exp_not:N \@@_backend_color_reset: + } +\cs_new_protected:Npx \@@_backend_color_reset: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int pop \scan_stop: + } +%</pdfmode> +%<*dvipdfmx|xdvipdfmx> +\cs_new_eq:NN \@@_backend_color_select:n \__kernel_backend_literal_pdf:n +%</dvipdfmx|xdvipdfmx> +\cs_generate_variant:Nn \@@_backend_color_select:n { x } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_cm:nnnn} +% \begin{macro}{\@@_backend_cm_aux:nnnn} +% Another split here between \texttt{pdfmode} and \texttt{(x)dvipdfmx}. +% In the former, we have a direct method to maintain alignment: the backend +% 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 backend. (There is backend 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 \@@_backend_cm:nnnn #1#2#3#4 + { +%<*pdfmode> + \__kernel_backend_matrix:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } +%</pdfmode> +%<*dvipdfmx|xdvipdfmx> + \@@_backend_cm_decompose:nnnnN {#1} {#2} {#3} {#4} + \@@_backend_cm_aux:nnnn +%</dvipdfmx|xdvipdfmx> + } +%<*dvipdfmx|xdvipdfmx> +\cs_new_protected:Npn \@@_backend_cm_aux:nnnn #1#2#3#4 + { + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#1} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#1 , 5 ) } } + } + \__kernel_backend_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \__kernel_backend_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}{\@@_backend_cm_decompose:nnnnN} +% \begin{macro} +% { +% \@@_backend_cm_decompose_auxi:nnnnN, +% \@@_backend_cm_decompose_auxii:nnnnN, +% \@@_backend_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 \@@_backend_cm_decompose:nnnnN #1#2#3#4#5 + { + \use:x + { + \@@_backend_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 \@@_backend_cm_decompose_auxi:nnnnN #1#2#3#4#5 + { + \use:x + { + \@@_backend_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 \@@_backend_cm_decompose_auxii:nnnnN #1#2#3#4#5 + { + \use:x + { + \@@_backend_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 \@@_backend_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}{\@@_backend_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 \@@_backend_box_use:Nnnnn #1#2#3#4#5 + { + \__kernel_backend_scope_begin: +%<*pdfmode> + \@@_backend_cm:nnnn {#2} {#3} {#4} {#5} +%</pdfmode> +%<*dvipdfmx|xdvipdfmx> + \__kernel_backend_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> + \__kernel_backend_literal:n { pdf:etrans } +%</dvipdfmx|xdvipdfmx> + \__kernel_backend_scope_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|pdfmode|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} backend} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_literal:n, \@@_backend_literal:x} +% The same as the more general literal call. +% \begin{macrocode} +\cs_new_eq:NN \@@_backend_literal:n \__kernel_backend_literal_svg:n +\cs_generate_variant:Nn \@@_backend_literal:n { x } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_begin:, \@@_backend_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 \@@_backend_begin: + { + \@@_backend_scope_begin: + \@@_backend_scope:n { transform="translate({?x},{?y})~scale(1,-1)" } + } +\cs_new_protected:Npn \@@_backend_end: + { \@@_backend_scope_end: } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_scope_begin:, \@@_backend_scope_end:} +% \begin{macro}{\@@_backend_scope:n, \@@_backend_scope:x} +% \begin{variable}{\g_@@_draw_scope_int, \l_@@_draw_scope_int} +% Several settings that with other backends 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 \@@_backend_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 \@@_backend_scope_end: + { + \prg_replicate:nn + { \g_@@_draw_scope_int } + { \@@_backend_literal:n { </g> } } + \group_end: + \int_gset_eq:NN + \g_@@_draw_scope_int + \l_@@_draw_scope_int + } +\cs_new_protected:Npn \@@_backend_scope:n #1 + { + \@@_backend_literal:n { <g~ #1 > } + \int_gincr:N \g_@@_draw_scope_int + } +\cs_generate_variant:Nn \@@_backend_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}{\@@_backend_moveto:nn, \@@_backend_lineto:nn} +% \begin{macro}{\@@_backend_rectangle:nnnn} +% \begin{macro}{\@@_backend_curveto:nnnnnn} +% \begin{macro}{\@@_backend_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 \@@_backend_moveto:nn #1#2 + { + \@@_backend_add_to_path:n + { M ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } + } +\cs_new_protected:Npn \@@_backend_lineto:nn #1#2 + { + \@@_backend_add_to_path:n + { L ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } + } +\cs_new_protected:Npn \@@_backend_rectangle:nnnn #1#2#3#4 + { + \@@_backend_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 \@@_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \@@_backend_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 \@@_backend_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}{\@@_backend_evenodd_rule:, \@@_backend_nonzero_rule:} +% The fill rules here have to be handled as scopes. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_evenodd_rule: + { \@@_backend_scope:n { fill-rule="evenodd" } } +\cs_new_protected:Npn \@@_backend_nonzero_rule: + { \@@_backend_scope:n { fill-rule="nonzero" } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_path:n} +% \begin{macro} +% { +% \@@_backend_closepath: , +% \@@_backend_stroke: , +% \@@_backend_closestroke: , +% \@@_backend_fill: , +% \@@_backend_fillstroke: , +% \@@_backend_clip: , +% \@@_backend_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 \@@_backend_closepath: + { \@@_backend_add_to_path:n { Z } } +\cs_new_protected:Npn \@@_backend_path:n #1 + { + \bool_if:NTF \g_@@_draw_clip_bool + { + \int_gincr:N \g_@@_clip_path_int + \@@_backend_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 + /> + } + \@@_backend_scope:x + { + clip-path = + "url( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int)" + } + } + { + \@@_backend_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 \@@_backend_stroke: + { \@@_backend_path:n { style="fill:none" } } +\cs_new_protected:Npn \@@_backend_closestroke: + { + \@@_backend_closepath: + \@@_backend_stroke: + } +\cs_new_protected:Npn \@@_backend_fill: + { \@@_backend_path:n { style="stroke:none" } } +\cs_new_protected:Npn \@@_backend_fillstroke: + { \@@_backend_path:n { } } +\cs_new_protected:Npn \@@_backend_clip: + { \bool_gset_true:N \g_@@_draw_clip_bool } +\bool_new:N \g_@@_draw_clip_bool +\cs_new_protected:Npn \@@_backend_discardpath: + { + \bool_if:NT \g_@@_draw_clip_bool + { + \int_gincr:N \g_@@_clip_path_int + \@@_backend_literal:x + { + < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > + { ?nl } + <path~d=" \g_@@_draw_path_tl "/> { ?nl } + < /clipPath > + } + \@@_backend_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}{\@@_backend_dash_pattern:nn} +% \begin{macro}{\@@_backend_dash:n} +% \begin{macro}{\@@_backend_dash_aux:nn} +% \begin{macro}{\@@_backend_linewidth:n} +% \begin{macro}{\@@_backend_miterlimit:n} +% \begin{macro} +% { +% \@@_backend_cap_butt:, \@@_backend_cap_round:, \@@_backend_cap_rectangle:, +% \@@_backend_join_miter:, \@@_backend_join_round:, \@@_backend_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 \@@_backend_dash_pattern:nn #1#2 + { + \use:x + { + \@@_backend_dash_aux:nn + { \clist_map_function:nn {#1} \@@_backend_dash:n } + { \dim_to_decimal:n {#2} } + } + } +\cs_new:Npn \@@_backend_dash:n #1 + { , \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \@@_backend_dash_aux:nn #1#2 + { + \@@_backend_scope:x + { + stroke-dasharray = + " + \tl_if_empty:oTF { \use_none:n #1 } + { none } + { \use_none:n #1 } + " ~ + stroke-offset=" #2 " + } + } +\cs_new_protected:Npn \@@_backend_linewidth:n #1 + { \@@_backend_scope:x { stroke-width=" \dim_to_decimal:n {#1} " } } +\cs_new_protected:Npn \@@_backend_miterlimit:n #1 + { \@@_backend_scope:x { stroke-miterlimit=" \fp_eval:n {#1} " } } +\cs_new_protected:Npn \@@_backend_cap_butt: + { \@@_backend_scope:n { stroke-linecap="butt" } } +\cs_new_protected:Npn \@@_backend_cap_round: + { \@@_backend_scope:n { stroke-linecap="round" } } +\cs_new_protected:Npn \@@_backend_cap_rectangle: + { \@@_backend_scope:n { stroke-linecap="square" } } +\cs_new_protected:Npn \@@_backend_join_miter: + { \@@_backend_scope:n { stroke-linejoin="miter" } } +\cs_new_protected:Npn \@@_backend_join_round: + { \@@_backend_scope:n { stroke-linejoin="round" } } +\cs_new_protected:Npn \@@_backend_join_bevel: + { \@@_backend_scope:n { stroke-linejoin="bevel" } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \@@_backend_color_fill_cmyk:nnnn , +% \@@_backend_color_stroke_cmyk:nnnn +% } +% \begin{macro} +% { +% \@@_backend_color_fill_gray:n , +% \@@_backend_color_stroke_gray:n +% } +% \begin{macro} +% { +% \@@_backend_color_fill_rgb:nnn , +% \@@_backend_color_stroke_rgb:nnn +% } +% \begin{macro}{\@@_backend_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 \@@_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \use:x + { + \@@_backend_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_protected:Npn \@@_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \@@_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \@@_backend_color_fill_gray:n #1 + { + \use:x + { + \@@_backend_color_gray_aux:n + { \fp_eval:n { 100 * (#1) } } + } + } +\cs_new_protected:Npn \@@_backend_color_gray_aux:n #1 + { \@@_backend_color_fill:nnn {#1} {#1} {#1} } +\cs_new_protected:Npn \@@_backend_color_stroke_gray:n #1 + { \@@_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \@@_backend_color_fill_rgb:nnn #1#2#3 + { + \use:x + { + \@@_backend_color_fill:nnn + { \fp_eval:n { 100 * (#1) } } + { \fp_eval:n { 100 * (#2) } } + { \fp_eval:n { 100 * (#3) } } + } + } +\cs_new_protected:Npn \@@_backend_color_fill:nnn #1#2#3 + { + \@@_backend_scope:x + { + fill = + " + rgb + ( + #1 \c_percent_str , + #2 \c_percent_str , + #3 \c_percent_str + ) + " + } + } +\cs_new_protected:Npn \@@_backend_color_stroke_rgb:nnn #1#2#3 + { + \@@_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_cm:nnnn} +% The four arguments here are floats (the affine matrix), the last +% two are a displacement vector. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_cm:nnnn #1#2#3#4 + { + \@@_backend_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}{\@@_backend_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 \@@_backend_box_use:Nnnnn #1#2#3#4#5#6#7 + { + \__kernel_backend_scope_begin: + \@@_backend_cm:nnnn {#2} {#3} {#4} {#5} + \__kernel_backend_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 + \__kernel_backend_literal_svg:n { </g> } + \__kernel_backend_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/l3backend/l3backend-graphics.dtx b/Master/texmf-dist/source/latex/l3backend/l3backend-graphics.dtx new file mode 100644 index 00000000000..b146bcdae69 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend-graphics.dtx @@ -0,0 +1,612 @@ +% \iffalse meta-comment +% +%% File: l3backend-graphics.dtx +% +% Copyright (C) 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 "l3backend 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{l3backend-graphics} package\\ Backend graphics 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-07-01} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3backend-graphics} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=graphics> +% \end{macrocode} +% +% \subsection{\texttt{dvips} backend} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_getbb_eps:n} +% Simply use the generic function. +% \begin{macrocode} +%<*initex> +\use:n +%</initex> +%<*package> +\AtBeginDocument +%</package> + { \cs_new_eq:NN \@@_backend_getbb_eps:n \graphics_read_bb:n } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_include_eps:n} +% The special syntax is relatively clear here: remember we need PostScript +% sizes here. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_include_eps:n #1 + { + \__kernel_backend_literal:x + { + PSfile = #1 \c_space_tl + llx = \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + lly = \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + urx = \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + ury = \dim_to_decimal_in_bp:n \l_graphics_ury_dim + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} backend} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \begin{variable}{\l_@@_graphics_attr_tl} +% In PDF mode, additional attributes of an graphic (such as page number) are +% needed both to obtain the bounding box and when inserting the graphic: this +% occurs as the graphic 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_@@_graphics_attr_tl +% \end{macrocode} +% \end{variable} +% +% \begin{macro} +% { +% \@@_backend_getbb_jpg:n, +% \@@_backend_getbb_pdf:n, +% \@@_backend_getbb_png:n +% } +% \begin{macro} +% {\@@_backend_getbb_auxi:n, \@@_backend_getbb_auxii:n} +% Getting the bounding box here requires us to box up the graphic and +% measure it. To deal with the difference in feature support in bitmap +% and vector graphics 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 \@@_backend_getbb_jpg:n #1 + { + \int_zero:N \l_graphics_page_int + \tl_clear:N \l_graphics_pagebox_tl + \tl_set:Nx \l_@@_graphics_attr_tl + { + \tl_if_empty:NF \l_graphics_decodearray_tl + { :D \l_graphics_decodearray_tl } + \bool_if:NT \l_graphics_interpolate_bool + { :I } + } + \tl_clear:N \l_@@_graphics_attr_tl + \@@_backend_getbb_auxi:n {#1} + } +\cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n +\cs_new_protected:Npn \@@_backend_getbb_pdf:n #1 + { + \tl_clear:N \l_graphics_decodearray_tl + \bool_set_false:N \l_graphics_interpolate_bool + \tl_set:Nx \l_@@_graphics_attr_tl + { + : \l_graphics_pagebox_tl + \int_compare:nNnT \l_graphics_page_int > 1 + { :P \int_use:N \l_graphics_page_int } + } + \@@_backend_getbb_auxi:n {#1} + } +\cs_new_protected:Npn \@@_backend_getbb_auxi:n #1 + { + \graphics_bb_restore:xF { #1 \l_@@_graphics_attr_tl } + { \@@_backend_getbb_auxii:n {#1} } + } +% \begin{macrocode} +% Measuring the graphic is done by boxing up: for PDF graphics 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 \@@_backend_getbb_auxii:n #1 + { + \tex_immediate:D \tex_pdfximage:D + \bool_lazy_or:nnT + { \l_graphics_interpolate_bool } + { ! \tl_if_empty_p:N \l_graphics_decodearray_tl } + { + attr ~ + { + \tl_if_empty:NF \l_graphics_decodearray_tl + { /Decode~[ \l_graphics_decodearray_tl ] } + \bool_if:NT \l_graphics_interpolate_bool + { /Interpolate~true } + } + } + \int_compare:nNnT \l_graphics_page_int > 0 + { page ~ \int_use:N \l_graphics_page_int } + \tl_if_empty:NF \l_graphics_pagebox_tl + { \l_graphics_pagebox_tl } + {#1} + \hbox_set:Nn \l_@@_internal_box + { \tex_pdfrefximage:D \tex_pdflastximage:D } + \dim_set:Nn \l_graphics_urx_dim { \box_wd:N \l_@@_internal_box } + \dim_set:Nn \l_graphics_ury_dim { \box_ht:N \l_@@_internal_box } + \int_const:cn { c_@@_graphics_ #1 \l_@@_graphics_attr_tl _int } + { \tex_the:D \tex_pdflastximage:D } + \graphics_bb_save:x { #1 \l_@@_graphics_attr_tl } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \@@_backend_include_jpg:n, +% \@@_backend_include_pdf:n, +% \@@_backend_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 \@@_backend_include_jpg:n #1 + { + \tex_pdfrefximage:D + \int_use:c { c_@@_graphics_ #1 \l_@@_graphics_attr_tl _int } + } +\cs_new_eq:NN \@@_backend_include_pdf:n \@@_backend_include_jpg:n +\cs_new_eq:NN \@@_backend_include_png:n \@@_backend_include_jpg:n +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_getbb_eps:n} +% \begin{macro}{\@@_backend_getbb_eps:nm} +% \begin{macro}{\@@_backend_include_eps:n} +% \begin{variable} +% {\l_@@_backend_dir_str, \l_@@_backend_name_str, \l_@@_backend_ext_str} +% EPS graphics may be included in \texttt{pdfmode} by conversion to +% PDF: this requires restricted shell escape. Modelled on the \pkg{epstopdf} +% \LaTeXe{} package, but simplified, conversion takes place here if we have +% shell access. +% \begin{macrocode} +\sys_if_shell:T + { + \str_new:N \l_@@_backend_dir_str + \str_new:N \l_@@_backend_name_str + \str_new:N \l_@@_backend_ext_str + \cs_new_protected:Npn \@@_backend_getbb_eps:n #1 + { + \file_parse_full_name:nNNN {#1} + \l_@@_backend_dir_str + \l_@@_backend_name_str + \l_@@_backend_ext_str + \exp_args:Nx \@@_backend_getbb_eps:nn + { + \l_@@_backend_name_str - \str_tail:N \l_@@_backend_ext_str + -converted-to.pdf + } + {#1} + } + \cs_new_protected:Npn \@@_backend_getbb_eps:nn #1#2 + { + \file_compare_timestamp:nNnT {#2} > {#1} + { + \sys_shell_now:n + { repstopdf ~ #2 ~ #1 } + } + \tl_set:Nn \l_graphics_name_tl {#1} + \@@_backend_getbb_pdf:n {#1} + } + \cs_new_protected:Npn \@@_backend_include_eps:n #1 + { + \file_parse_full_name:nNNN {#1} + \l_@@_backend_dir_str \l_@@_backend_name_str \l_@@_backend_ext_str + \exp_args:Nx \@@_backend_include_pdf:n + { + \l_@@_backend_name_str - \str_tail:N \l_@@_backend_ext_str + -converted-to.pdf + } + } + } +% \end{macrocode} +% \end{variable} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} backend} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro} +% { +% \@@_backend_getbb_eps:n, \@@_backend_getbb_jpg:n, +% \@@_backend_getbb_pdf:n, \@@_backend_getbb_png:n +% } +% Simply use the generic functions: only for \texttt{dvipdfmx} in the +% extraction cases. +% \begin{macrocode} +%<*initex> +\use:n +%</initex> +%<*package> +\AtBeginDocument +%</package> + { \cs_new_eq:NN \@@_backend_getbb_eps:n \graphics_read_bb:n } +%<*dvipdfmx> +\cs_new_protected:Npn \@@_backend_getbb_jpg:n #1 + { + \int_zero:N \l_graphics_page_int + \tl_clear:N \l_graphics_pagebox_tl + \graphics_extract_bb:n {#1} + } +\cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n +\cs_new_protected:Npn \@@_backend_getbb_pdf:n #1 + { + \tl_clear:N \l_graphics_decodearray_tl + \bool_set_false:N \l_graphics_interpolate_bool + \graphics_extract_bb:n {#1} + } +%</dvipdfmx> +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\g_@@_track_int} +% Used to track the object number associated with each graphic. +% \begin{macrocode} +\int_new:N \g_@@_track_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro} +% { +% \@@_backend_include_eps:n, \@@_backend_include_jpg:n, +% \@@_backend_include_pdf:n, \@@_backend_include_png:n +% } +% \begin{macro}{\@@_backend_include_auxi:nn} +% \begin{macro}{\@@_backend_include_auxii:nnn, \@@_backend_include_auxii:xnn} +% \begin{macro}{\@@_backend_include_auxiii:nnn} +% The special syntax depends on the file type. There is a difference in +% how PDF graphics 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 \@@_backend_include_eps:n #1 + { + \__kernel_backend_literal:x + { + PSfile = #1 \c_space_tl + llx = \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + lly = \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + urx = \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + ury = \dim_to_decimal_in_bp:n \l_graphics_ury_dim + } + } +\cs_new_protected:Npn \@@_backend_include_jpg:n #1 + { \@@_backend_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \@@_backend_include_png:n \@@_backend_include_jpg:n +%<*dvipdfmx> +\cs_new_protected:Npn \@@_backend_include_pdf:n #1 + { \@@_backend_include_auxi:nn {#1} { epdf } } +%</dvipdfmx> +% \end{macrocode} +% Graphic 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 \@@_backend_include_auxi:nn #1#2 + { + \@@_backend_include_auxii:xnn + { + \tl_if_empty:NF \l_graphics_pagebox_tl + { : \l_graphics_pagebox_tl } + \int_compare:nNnT \l_graphics_page_int > 1 + { :P \int_use:N \l_graphics_page_int } + \tl_if_empty:NF \l_graphics_decodearray_tl + { :D \l_graphics_decodearray_tl } + \bool_if:NT \l_graphics_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \@@_backend_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c_@@_graphics_ #2#1 _int } + { + \__kernel_backend_literal:x + { pdf:usexobj~@graphic \int_use:c { c_@@_graphics_ #2#1 _int } } + } + { \@@_backend_include_auxiii:nnn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \@@_backend_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 graphics 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 \@@_backend_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g_@@_track_int + \int_const:cn { c_@@_graphics_ #1#2 _int } { \g_@@_track_int } + \__kernel_backend_literal:x + { + pdf:#3~ + @graphic \int_use:c { c_@@_graphics_ #1#2 _int } ~ + \int_compare:nNnT \l_graphics_page_int > 1 + { page ~ \int_use:N \l_graphics_page_int \c_space_tl } + \tl_if_empty:NF \l_graphics_pagebox_tl + { + pagebox ~ \l_graphics_pagebox_tl \c_space_tl + bbox ~ + \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_ury_dim \c_space_tl + } + (#1) + \bool_lazy_or:nnT + { \l_graphics_interpolate_bool } + { ! \tl_if_empty_p:N \l_graphics_decodearray_tl } + { + << + \tl_if_empty:NF \l_graphics_decodearray_tl + { /Decode~[ \l_graphics_decodearray_tl ] } + \bool_if:NT \l_graphics_interpolate_bool + { /Interpolate~true> } + >> + } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{xdvipdfmx} backend} +% +% \begin{macrocode} +%<*xdvipdfmx> +% \end{macrocode} +% +% \subsubsection{Images} +% +% \begin{macro} +% { +% \@@_backend_getbb_jpg:n, +% \@@_backend_getbb_pdf:n, +% \@@_backend_getbb_png:n +% } +% \begin{macro}{\@@_backend_getbb_auxi:nN} +% \begin{macro}{\@@_backend_getbb_auxii:nnN, \@@_backend_getbb_auxii:VnN} +% \begin{macro}{\@@_backend_getbb_auxiii:nNnn} +% \begin{macro}{\@@_backend_getbb_auxiv:nnNnn, \@@_backend_getbb_auxiv:VnNnn} +% \begin{macro}{\@@_backend_getbb_auxv:nNnn, \@@_backend_getbb_auxv:nNnn} +% \begin{macro}[EXP]{\@@_backend_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 \@@_backend_getbb_jpg:n #1 + { + \int_zero:N \l_graphics_page_int + \tl_clear:N \l_graphics_pagebox_tl + \@@_backend_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D + } +\cs_new_eq:NN \@@_backend_getbb_png:n \@@_backend_getbb_jpg:n +\cs_new_protected:Npn \@@_backend_getbb_pdf:n #1 + { + \tl_clear:N \l_graphics_decodearray_tl + \bool_set_false:N \l_graphics_interpolate_bool + \@@_backend_getbb_auxi:nN {#1} \tex_XeTeXpdffile:D + } +\cs_new_protected:Npn \@@_backend_getbb_auxi:nN #1#2 + { + \int_compare:nNnTF \l_graphics_page_int > 1 + { \@@_backend_getbb_auxii:VnN \l_graphics_page_int {#1} #2 } + { \@@_backend_getbb_auxiii:nNnn {#1} #2 { :P 1 } { page 1 } } + } +\cs_new_protected:Npn \@@_backend_getbb_auxii:nnN #1#2#3 + { \@@_backend_getbb_auxiii:nNnn {#2} #3 { :P #1 } { page #1 } } +\cs_generate_variant:Nn \@@_backend_getbb_auxii:nnN { V } +\cs_new_protected:Npn \@@_backend_getbb_auxiii:nNnn #1#2#3#4 + { + \tl_if_empty:NTF \l_graphics_pagebox_tl + { \@@_backend_getbb_auxiv:VnNnn \l_graphics_pagebox_tl } + { \@@_backend_getbb_auxv:nNnn } + {#1} #2 {#3} {#4} + } +\cs_new_protected:Npn \@@_backend_getbb_auxiv:nnNnn #1#2#3#4#5 + { + \use:x + { + \@@_backend_getbb_auxv:nNnn {#2} #3 { : #1 #4 } + { #5 ~ \@@_backend_getbb_pagebox:w #1 } + } + } +\cs_generate_variant:Nn \@@_backend_getbb_auxiv:nnNnn { V } +\cs_new_protected:Npn \@@_backend_getbb_auxv:nNnn #1#2#3#4 + { + \graphics_bb_restore:nF {#1#3} + { \@@_backend_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } + } +\cs_new_protected:Npn \@@_backend_getbb_auxvi:nNnn #1#2#3#4 + { + \hbox_set:Nn \l_@@_internal_box { #2 #1 ~ #4 } + \dim_set:Nn \l_graphics_urx_dim { \box_wd:N \l_@@_internal_box } + \dim_set:Nn \l_graphics_ury_dim { \box_ht:N \l_@@_internal_box } + \graphics_bb_save:n {#1#3} + } +\cs_new:Npn \@@_backend_getbb_pagebox:w #1 box {#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_include_pdf:n} +% \begin{macro}{\@@_backend_include_bitmap_quote:w} +% For PDF graphics, 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 graphic measurement part, although we know at this +% stage that there must be some valid setting for \cs{l_graphics_pagebox_tl}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_include_pdf:n #1 + { + \tex_XeTeXpdffile:D + \@@_backend_include_pdf_quote:w #1 "#1" \q_stop \c_space_tl + \int_compare:nNnT \l_graphics_page_int > 0 + { page ~ \int_use:N \l_graphics_page_int \c_space_tl } + \exp_after:wN \@@_backend_getbb_pagebox:w \l_graphics_pagebox_tl + } +\cs_new:Npn \@@_backend_include_pdf_quote:w #1 " #2 " #3 \q_stop + { " #2 " } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} backend} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_getbb_png:n, \@@_backend_getbb_jpg:n} +% These can be included by extracting the bounding box data. +% \begin{macrocode} +%<*initex> +\use:n +%</initex> +%<*package> +\AtBeginDocument +%</package> + { + \cs_new_eq:NN \@@_backend_getbb_png:n \graphics_extract_bb:n + \cs_new_eq:NN \@@_backend_getbb_jpg:n \graphics_extract_bb:n + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_include_png:n, \@@_backend_include_jpg:n} +% \begin{macro}{\@@_backend_include_bitmap_quote:w} +% The backend here has built-in support for basic graphic inclusion (see +% \texttt{dvisvgm.def} for a more complex approach, needed if clipping, +% \emph{etc.}, is covered at the graphic backend 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 \@@_backend_include_png:n #1 + { + \__kernel_backend_literal:x + { + dvisvgm:img~ + \dim_to_decimal:n { \l_graphics_ury_dim } ~ + \dim_to_decimal:n { \l_graphics_ury_dim } ~ + \@@_backend_include_bitmap_quote:w #1 " #1 " \q_stop + } + } +\cs_new_eq:NN \@@_backend_include_jpg:n \@@_backend_include_png:n +\cs_new:Npn \@@_backend_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/l3backend/l3backend-pdf.dtx b/Master/texmf-dist/source/latex/l3backend/l3backend-pdf.dtx new file mode 100644 index 00000000000..63e993e16ea --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend-pdf.dtx @@ -0,0 +1,2106 @@ +% \iffalse meta-comment +% +%% File: l3backend-pdf.dtx +% +% Copyright (C) 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 "l3backend 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{l3backend-pdf} package\\ Backend 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-07-01} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3backend-pdf} Implementation} +% +% \begin{macrocode} +%<*initex|package> +%<@@=pdf> +% \end{macrocode} +% +% Setting up PDF resources is a complex area with only limited documentation +% in the engine manuals. The following code builds heavily on existing ideas +% from \pkg{hyperref} work by Sebastian Rahtz and Heiko Oberdiek, and +% significant contributions by Alexander Grahn, in addition to the specific +% code referenced a various points. +% +% \subsection{Shared code} +% +% A very small number of items that belong at the backend level but which +% are common to all backends. +% +% \begin{variable}{\l_@@_internal_boxf} +% \begin{macrocode} +\box_new:N \l_@@_internal_box +% \end{macrocode} +% \end{variable} +% +% \subsection{\texttt{dvips} backend} +% +% \begin{macrocode} +%<*dvips> +% \end{macrocode} +% +% \begin{macro}{\@@_backend_pdfmark:n, \@@_backend_pdfmark:x} +% Used often enough it should be a separate function. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_pdfmark:n #1 + { \__kernel_backend_postscript:n { mark #1 ~ pdfmark } } +\cs_generate_variant:Nn \@@_backend_pdfmark:n { x } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Catalogue entries} +% +% \begin{macro}{\@@_backend_catalog_gput:nn, \@@_backend_info_gput:nn} +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_catalog_gput:nn #1#2 + { \@@_backend_pdfmark:n { { Catalog } << /#1 ~ #2 >> /PUT } } +\cs_new_protected:Npn \@@_backend_info_gput:nn #1#2 + { \@@_backend_pdfmark:n { /#1 ~ #2 /DOCINFO } } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Objects} +% +% \begin{variable}{\g_@@_backend_object_int, \g_@@_backend_object_prop} +% For tracking objects to allow finalisation. +% \begin{macrocode} +\int_new:N \g_@@_backend_object_int +\prop_new:N \g_@@_backend_object_prop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_backend_object_new:nn} +% \begin{macro}[EXP]{\@@_backend_object_ref:n} +% Tracking objects is similar to \texttt{dvipdfmx}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_object_new:nn #1#2 + { + \int_gincr:N \g_@@_backend_object_int + \int_const:cn + { c_@@_backend_object_ \tl_to_str:n {#1} _int } + { \g_@@_backend_object_int } + \prop_gput:Nnn \g_@@_backend_object_prop {#1} {#2} + } +\cs_new:Npn \@@_backend_object_ref:n #1 + { { pdf.obj \int_use:c { c_@@_backend_object_ \tl_to_str:n {#1} _int } } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_object_write:nn, \@@_backend_object_write:nx} +% \begin{macro} +% { +% \@@_backend_object_write_array:nn , +% \@@_backend_object_write_dict:nn , +% \@@_backend_object_write_stream:nn +% } +% \begin{macro}{\@@_backend_object_write_stream:nnn} +% This is where we choose the actual type: some work to get things +% right. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_object_write:nn #1#2 + { + \@@_backend_pdfmark:x + { + /_objdef ~ \@@_backend_object_ref:n {#1} + /type + \str_case_e:nn + { \prop_item:Nn \g_@@_backend_object_prop {#1} } + { + { array } { /array } + { dict } { /dict } + { fstream } { /stream } + { stream } { /stream } + } + /OBJ + } + \use:c + { @@_backend_object_write_ \prop_item:Nn \g_@@_backend_object_prop {#1} :nn } + { \@@_backend_object_ref:n {#1} } {#2} + } +\cs_generate_variant:Nn \@@_backend_object_write:nn { nx } +\cs_new_protected:Npn \@@_backend_object_write_array:nn #1#2 + { + \@@_backend_pdfmark:x + { #1 [ ~ \exp_not:n {#2} ~ ] ~ /PUTINTERVAL } + } +\cs_new_protected:Npn \@@_backend_object_write_dict:nn #1#2 + { + \@@_backend_pdfmark:x + { #1 << \exp_not:n {#2} >> /PUT } + } +\cs_new_protected:Npn \@@_backend_object_write_stream:nn #1#2 + { + \exp_args:Nx + \@@_backend_object_write_stream:nnn {#1} #2 + } +\cs_new_protected:Npn \@@_backend_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} +% +% \begin{macro}{\@@_backend_object_now:nn, \@@_backend_object_now:nx} +% No anonymous objects, so things are done manually. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_object_now:nn #1#2 + { + \int_gincr:N \g_@@_backend_object_int + \@@_backend_pdfmark:x + { + /_objdef ~ { pdf.obj \int_use:N \g_@@_backend_object_int } + /type + \str_case:nn + {#1} + { + { array } { /array } + { dict } { /dict } + { fstream } { /stream } + { stream } { /stream } + } + /OBJ + } + \exp_args:Nnx \use:c { @@_backend_object_write_ #1 :nn } + { { pdf.obj \int_use:N \g_@@_backend_object_int } } {#2} + } +\cs_generate_variant:Nn \@@_backend_object_now:nn { nx } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\@@_backend_object_last:} +% Much like the annotation version. +% \begin{macrocode} +\cs_new:Npn \@@_backend_object_last: + { { pdf.obj \int_use:N \g_@@_backend_object_int } } +% \end{macrocode} +% \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}{pdf.globaldict} +% A small global dictionary for backend use. +% \begin{macrocode} +\__kernel_backend_postscript_header:n + { + true ~ setglobal ~ + /pdf.globaldict ~ 4 ~ dict ~ def ~ + false ~ setglobal + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% pdf.cvs , +% pdf.dvi.pt , +% pdf.pt.dvi , +% pdf.rect.ht +% } +% 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} +\__kernel_backend_postscript_header:n + { + /pdf.cvs { 65534 ~ string ~ cvs } def + /pdf.dvi.pt { 72.27 ~ mul ~ Resolution ~ div } def + /pdf.pt.dvi { 72.27 ~ div ~ Resolution ~ mul } def + /pdf.rect.ht { dup ~ 1 ~ get ~ neg ~ exch ~ 3 ~ get ~ add } def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{pdf.linkmargin, pdf.linkdp.pad, pdf.linkht.pad} +% Settings which are defined up-front in |SDict|. +% \begin{macrocode} +\__kernel_backend_postscript_header:n + { + /pdf.linkmargin { 1 ~ pdf.pt.dvi } def + /pdf.linkdp.pad { 0 } def + /pdf.linkht.pad { 0 } def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% pdf.rect , +% pdf.save.ll , +% pdf.save.ur , +% pdf.save.linkll , +% pdf.save.linkur , +% pdf.llx , +% pdf.lly , +% pdf.urx , +% pdf.ury +% } +% 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} +\__kernel_backend_postscript_header:n + { + /pdf.rect + { /Rect [ pdf.llx ~ pdf.lly ~ pdf.urx ~ pdf.ury ] } def + /pdf.save.ll + { + currentpoint + /pdf.lly ~ exch ~ def + /pdf.llx ~ exch ~ def + } + def + /pdf.save.ur + { + currentpoint + /pdf.ury ~ exch ~ def + /pdf.urx ~ exch ~ def + } + def + /pdf.save.linkll + { + currentpoint ~ + pdf.linkmargin ~ add ~ + pdf.linkdp.pad ~ add + /pdf.lly ~ exch ~ def ~ + pdf.linkmargin ~ sub + /pdf.llx ~ exch ~ def + } + def + /pdf.save.linkur + { + currentpoint ~ + pdf.linkmargin ~ sub ~ + pdf.linkht.pad ~ sub + /pdf.ury ~ exch ~ def ~ + pdf.linkmargin ~ add + /pdf.urx ~ exch ~ def + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% pdf.dest.anchor , +% pdf.dest.x , +% pdf.dest.y , +% pdf.dest.point , +% pdf.dest2device , +% pdf.dev.x , +% pdf.dev.y , +% pdf.tmpa , +% pdf.tmpb , +% pdf.tmpc , +% pdf.tmpd +% } +% For finding the anchor point of a destination link. We make the use case +% a separate function as it comes up a lot, and as this makes it easier to +% adjust if we need additional effects. We also need a more complex approach +% to convert a co-ordinate pair correctly when defining a rectangle: this +% can otherwise be out when using a landscape page. (Thanks to Alexander +% Grahn for the approach here.) +% \begin{macrocode} +\__kernel_backend_postscript_header:n + { + /pdf.dest.anchor + { + currentpoint ~ exch ~ + pdf.dvi.pt ~ 72 ~ add ~ + /pdf.dest.x ~ exch ~ def ~ + pdf.dvi.pt ~ + vsize ~ 72 ~ sub ~ exch ~ sub ~ + /pdf.dest.y ~ exch ~ def + } + def + /pdf.dest.point + { pdf.dest.x ~ pdf.dest.y } def + /pdf.dest2device + { + /pdf.dest.y ~ exch ~ def + /pdf.dest.x ~ exch ~ def ~ + matrix ~ currentmatrix ~ + matrix ~ defaultmatrix ~ + matrix ~ invertmatrix ~ + matrix ~ concatmatrix ~ + cvx ~ exec + /pdf.dev.y ~ exch ~ def + /pdf.dev.x ~ exch ~ def + /pdf.tmpd ~ exch ~ def + /pdf.tmpc ~ exch ~ def + /pdf.tmpb ~ exch ~ def + /pdf.tmpa ~ exch ~ def ~ + pdf.dest.x ~ pdf.tmpa ~ mul ~ + pdf.dest.y ~ pdf.tmpc ~ mul ~ add ~ + pdf.dev.x ~ add ~ + pdf.dest.x ~ pdf.tmpb ~ mul ~ + pdf.dest.y ~ pdf.tmpd ~ mul ~ add ~ + pdf.dev.y ~ add + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% pdf.bordertracking , +% pdf.bordertracking.begin , +% pdf.bordertracking.end , +% pdf.leftboundary , +% pdf.rightboundary , +% pdf.brokenlink.rect , +% pdf.brokenlink.skip , +% pdf.brokenlink.dict , +% pdf.bordertracking.endpage , +% pdf.bordertracking.continue , +% pdf.originx , +% pdf.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} +\__kernel_backend_postscript_header:n + { + /pdf.bordertracking ~ false ~ def + /pdf.bordertracking.begin + { + SDict ~ /pdf.bordertracking ~ true ~ put ~ + SDict ~ /pdf.leftboundary ~ undef ~ + SDict ~ /pdf.rightboundary ~ undef ~ + /a ~ where + { + /a + { + currentpoint ~ pop ~ + SDict /pdf.rightboundary ~ known ~ dup + { + SDict /pdf.rightboundary ~ get ~ 2 ~ index ~ lt + { not } + if + } + if + { pop } + { SDict ~ exch /pdf.rightboundary ~ exch ~ put } + ifelse ~ + moveto ~ + currentpoint ~ pop ~ + SDict /pdf.leftboundary ~ known ~ dup + { + SDict /pdf.leftboundary ~ get ~ 2 ~ index ~ gt + { not } + if + } + if + { pop } + { SDict ~ exch /pdf.leftboundary ~ exch ~ put } + ifelse + } + put + } + if + } + def + /pdf.bordertracking.end + { + /a ~ where { /a { moveto } put } if + /x ~ where { /x { 0 ~ exch ~ rmoveto } put } if ~ + SDict /pdf.leftboundary ~ known + { pdf.outerbox ~ 0 ~ pdf.leftboundary ~ put } + if ~ + SDict /pdf.rightboundary ~ known + { pdf.outerbox ~ 2 ~ pdf.rightboundary ~ put } + if ~ + SDict /pdf.bordertracking ~ false ~ put + } + def + /pdf.bordertracking.endpage + { + pdf.bordertracking + { + pdf.bordertracking.end ~ + true ~ setglobal ~ + pdf.globaldict + /pdf.brokenlink.rect [ pdf.outerbox ~ aload ~ pop ] put ~ + pdf.globaldict + /pdf.brokenlink.skip ~ pdf.baselineskip ~ put ~ + pdf.globaldict + /pdf.brokenlink.dict ~ + pdf.link.dict ~ pdf.cvs ~ put ~ + false ~ setglobal ~ + mark ~ pdf.link.dict ~ cvx ~ exec ~ /Rect + [ + pdf.llx ~ + pdf.lly ~ + pdf.outerbox ~ 2 ~ get ~ pdf.linkmargin ~ add ~ + currentpoint ~ exch ~ pop ~ + pdf.outerbox ~ pdf.rect.ht ~ sub ~ pdf.linkmargin ~ sub + ] + /ANN ~ pdf.pdfmark + } + if + } + def + /pdf.bordertracking.continue + { + /pdf.link.dict ~ pdf.globaldict + /pdf.brokenlink.dict ~ get ~ def + /pdf.outerbox ~ pdf.globaldict + /pdf.brokenlink.rect ~ get ~ def + /pdf.baselineskip ~ pdf.globaldict + /pdf.brokenlink.skip ~ get ~ def ~ + pdf.globaldict ~ dup ~ dup + /pdf.brokenlink.dict ~ undef + /pdf.brokenlink.skip ~ undef + /pdf.brokenlink.rect ~ undef ~ + currentpoint + /pdf.originy ~ exch ~ def + /pdf.originx ~ exch ~ def + /a ~ where + { + /a + { + moveto ~ + SDict ~ + begin ~ + currentpoint ~ pdf.originy ~ ne ~ exch ~ + pdf.originx ~ ne ~ or + { + pdf.save.linkll + /pdf.lly ~ + pdf.lly ~ pdf.outerbox ~ 1 ~ get ~ sub ~ def ~ + pdf.bordertracking.begin + } + if ~ + end + } + put + } + if + /x ~ where + { + /x + { + 0 ~ exch ~ rmoveto ~ + SDict~ + begin ~ + currentpoint ~ + pdf.originy ~ ne ~ exch ~ pdf.originx ~ ne ~ or + { + pdf.save.linkll + /pdf.lly ~ + pdf.lly ~ pdf.outerbox ~ 1 ~ get ~ sub ~ def ~ + pdf.bordertracking.begin + } + if ~ + end + } + put + } + if + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% pdf.breaklink , +% pdf.breaklink.write , +% pdf.count , +% pdf.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} +\__kernel_backend_postscript_header:n + { + /pdf.breaklink + { + pop ~ + counttomark ~ 2 ~ mod ~ 0 ~ eq + { + counttomark /pdf.count ~ exch ~ def + { + pdf.count ~ 0 ~ eq { exit } if ~ + counttomark ~ 2 ~ roll ~ + 1 ~ index ~ /Rect ~ eq + { + dup ~ 4 ~ array ~ copy ~ + dup ~ dup ~ + 1 ~ get ~ + pdf.outerbox ~ pdf.rect.ht ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ sub ~ + 3 ~ exch ~ put ~ + dup ~ + pdf.outerbox ~ 2 ~ get ~ + pdf.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + pdf.outerbox ~ pdf.rect.ht ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ add ~ + 1 ~ exch ~ put + /pdf.currentrect ~ exch ~ def ~ + pdf.breaklink.write + { + pdf.currentrect ~ + dup ~ + pdf.outerbox ~ 0 ~ get ~ + pdf.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ + pdf.outerbox ~ 2 ~ get ~ + pdf.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + pdf.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + pdf.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + /pdf.currentrect ~ exch ~ def ~ + pdf.breaklink.write + } + 1 ~ index ~ 3 ~ get ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ + pdf.outerbox ~ pdf.rect.ht ~ add ~ + 2 ~ index ~ 1 ~ get ~ sub ~ + pdf.baselineskip ~ div ~ round ~ cvi ~ 1 ~ sub ~ + exch ~ + repeat ~ + pdf.currentrect ~ + dup ~ + pdf.outerbox ~ 0 ~ get ~ + pdf.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + pdf.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + pdf.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + dup ~ 2 ~ index ~ 2 ~ get ~ 2 ~ exch ~ put + /pdf.currentrect ~ exch ~ def ~ + pdf.breaklink.write ~ + SDict /pdf.pdfmark.good ~ false ~ put ~ + exit + } + { pdf.count ~ 2 ~ sub /pdf.count ~ exch ~ def } + ifelse + } + loop + } + if + /ANN + } + def + /pdf.breaklink.write + { + counttomark ~ 1 ~ sub ~ + index /_objdef ~ eq + { + counttomark ~ -2 ~ roll ~ + dup ~ wcheck ~ + { + readonly ~ + counttomark ~ 2 ~ roll + } + { pop ~ pop } + ifelse + } + if ~ + counttomark ~ 1 ~ add ~ copy ~ + pop ~ pdf.currentrect + /ANN ~ pdfmark + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% { +% pdf.pdfmark , +% pdf.pdfmark.good , +% pdf.outerbox , +% pdf.baselineskip , +% pdf.pdfmark.dict +% } +% 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} +\__kernel_backend_postscript_header:n + { + /pdf.pdfmark + { + SDict /pdf.pdfmark.good ~ true ~ put ~ + dup /ANN ~ eq + { + pdf.pdfmark.store ~ + pdf.pdfmark.dict ~ + begin ~ + Subtype /Link ~ eq ~ + currentdict /Rect ~ known ~ and ~ + SDict /pdf.outerbox ~ known ~ and ~ + SDict /pdf.baselineskip ~ known ~ and ~ + { + Rect ~ 3 ~ get ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ + pdf.outerbox ~ pdf.rect.ht ~ add ~ + Rect ~ 1 ~ get ~ sub ~ + pdf.baselineskip ~ div ~ round ~ cvi ~ 0 ~ gt + { pdf.breaklink } + if + } + if ~ + end ~ + SDict /pdf.outerbox ~ undef ~ + SDict /pdf.baselineskip ~ undef ~ + currentdict /pdf.pdfmark.dict ~ undef ~ + } + if ~ + pdf.pdfmark.good + { pdfmark } + { cleartomark } + ifelse + } + def + /pdf.pdfmark.store + { + /pdf.pdfmark.dict ~ 65534 ~ dict ~ def ~ + counttomark ~ 1 ~ add ~ copy ~ + pop + { + dup ~ mark ~ eq + { + pop ~ + exit + } + { + pdf.pdfmark.dict ~ + begin ~ def ~ end + } + ifelse + } + loop + } + def + } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\l_@@_backend_content_box} +% The content of an annotation. +% \begin{macrocode} +\box_new:N \l_@@_backend_content_box +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_@@_backend_model_box} +% For creating model sizing for links. +% \begin{macrocode} +\box_new:N \l_@@_backend_model_box +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_backend_annotation_int} +% Needed as objects which are not annotations could be created. +% \begin{macrocode} +\int_new:N \g_@@_backend_annotation_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_backend_annotation:nnnn, \@@_backend_annotation_aux:nnnn} +% \begin{macro}{pdf.llx, pdf.lly, pdf.urx, pdf.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 \@@_backend_annotation:nnnn #1#2#3#4 + { + \@@_backend_annotation_aux:nnnn {#1} {#2} {#3} {#4} + \int_gincr:N \g_@@_backend_object_int + \int_gset_eq:NN \g_@@_backend_annotation_int \g_@@_backend_object_int + \@@_backend_pdfmark:x + { + + /_objdef { pdf.obj \int_use:N \g_@@_backend_object_int } + pdf.rect ~ + #4 ~ + /ANN + } + } +\cs_new_protected:Npn \@@_backend_annotation_aux:nnnn #1#2#3#4 + { + \box_move_down:nn {#3} + { \hbox:n { \@@_postscript:n { pdf.save.ll } } } + \hbox:n {#4} + \box_move_up:nn {#2} + { + \hbox:n + { + \tex_kern:D \dim_eval:n {#1} \scan_stop: + \@@_postscript:n { pdf.save.ur } + } + } + \int_gincr:N \g_@@_backend_object_int + \int_gset_eq:NN \g_@@_backend_annotation_int \g_@@_backend_object_int + \@@_backend_pdfmark:x + { + /_objdef { pdf.obj \int_use:N \g_@@_backend_object_int } + pdf.rect + /ANN + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[EXP]{\@@_backend_annotation_last:} +% Provide the last annotation we created: could get tricky of course if +% other packages are loaded. +% \begin{macrocode} +\cs_new:Npn \@@_backend_annotation_last: + { { pdf.obj \int_use:N \g_@@_backend_annotation_int } } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\g_@@_backend_link_int} +% To track annotations which are links. +% \begin{macrocode} +\int_new:N \g_@@_backend_link_int +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_backend_link_dict_tl} +% To pass information to the end-of-link function. +% \begin{macrocode} +\tl_new:N \g_@@_backend_link_dict_tl +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_backend_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_@@_backend_link_sf_int +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_backend_link_math_bool} +% Needed to save/restore math mode. +% \begin{macrocode} +\bool_new:N \g_@@_backend_link_math_bool +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\g_@@_backend_link_bool} +% Track link formation: we cannot nest at all. +% \begin{macrocode} +\bool_new:N \g_@@_backend_link_bool +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_@@_breaklink_pdfmark_tl} +% Swappable content for link breaking. +% \begin{macrocode} +\tl_new:N \l_@@_breaklink_pdfmark_tl +\tl_set:Nn \l_@@_breaklink_pdfmark_tl { pdfmark } +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_breaklink_postscript:n} +% To allow dropping material unless link breaking is active. +% \begin{macrocode} +\cs_new_protected:Npn \@@_breaklink_postscript:n #1 { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_breaklink_usebox:N} +% Swappable box unpacking or use. +% \begin{macrocode} +\cs_new_eq:NN \@@_breaklink_usebox:N \box_use:N +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_link_begin_goto:nnw, \@@_backend_link_begin_user:nnw} +% \begin{macro}{\@@_backend_link:nw, \@@_backend_link_aux:nw} +% \begin{macro}{\@@_backend_link_end:, \@@_backend_link_end_aux:} +% \begin{macro}{\@@_backend_link_minima:} +% \begin{macro}{\@@_backend_link_outerbox:n} +% \begin{macro}{\@@_backend_link_sf_save:, \@@_backend_link_sf_restore:} +% \begin{macro} +% { +% pdf.linkdp.pad , +% pdf.linkht.pad , +% pdf.llx, pdf.lly , +% pdf.ury, pdf.ury , +% pdf.link.dict , +% pdf.outerbox , +% pdf.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 \@@_backend_link_begin_goto:nnw #1#2 + { \@@_backend_link_begin:nw { #1 /Subtype /Link /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \@@_backend_link_begin_user:nnw #1#2 + { \@@_backend_link_begin:nw {#1#2} } +\cs_new_protected:Npn \@@_backend_link_begin:nw #1 + { + \bool_if:NF \g_@@_backend_link_bool + { \@@_backend_link_begin_aux:nw {#1} } + } +\cs_new_protected:Npn \@@_backend_link_begin_aux:nw #1 + { + \bool_gset_true:N \g_@@_backend_link_bool + \@@_postscript:n + { /pdf.link.dict ( #1 ) def } + \tl_gset:Nn \g_@@_backend_link_dict_tl {#1} + \@@_backend_link_sf_save: + \mode_if_math:TF + { \bool_gset_true:N \g_@@_backend_link_math_bool } + { \bool_gset_false:N \g_@@_backend_link_math_bool } + \hbox_set:Nw \l_@@_backend_content_box + \@@_backend_link_sf_restore: + \bool_if:NT \g_@@_backend_link_math_bool + { \c_math_toggle_token } + } +\cs_new_protected:Npn \@@_backend_link_end: + { + \bool_if:NT \g_@@_backend_link_bool + { \@@_backend_link_end_aux: } + } +\cs_new_protected:Npn \@@_backend_link_end_aux: + { + \bool_if:NT \g_@@_backend_link_math_bool + { \c_math_toggle_token } + \@@_backend_link_sf_save: + \hbox_set_end: + \@@_backend_link_minima: + \hbox_set:Nn \l_@@_backend_model_box { Gg } + \exp_args:Nx \@@_backend_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_@@_backend_content_box } + { \hbox:n { \@@_postscript:n { pdf.save.linkll } } } + \@@_breaklink_postscript:n { pdf.bordertracking.begin } + \@@_breaklink_usebox:N \l_@@_backend_content_box + \@@_breaklink_postscript:n { pdf.bordertracking.end } + \box_move_up:nn { \box_ht:N \l_@@_backend_content_box } + { + \hbox:n + { \@@_postscript:n { pdf.save.linkur } } + } + \int_gincr:N \g_@@_backend_object_int + \int_gset_eq:NN \g_@@_backend_link_int \g_@@_backend_object_int + \@@_postscript:x + { + mark + /_objdef { pdf.obj \int_use:N \g_@@_backend_link_int } + \g_@@_backend_link_dict_tl \c_space_tl + pdf.rect + /ANN ~ \l_@@_breaklink_pdfmark_tl + } + \@@_backend_link_sf_restore: + \bool_gset_false:N \g_@@_backend_link_bool + } +\cs_new_protected:Npn \@@_backend_link_minima: + { + \hbox_set:Nn \l_@@_backend_model_box { Gg } + \@@_postscript:x + { + /pdf.linkdp.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_dp:N \l_@@_backend_model_box + - \box_dp:N \l_@@_backend_content_box + } + { 0pt } + } ~ + pdf.pt.dvi ~ def + /pdf.linkht.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_ht:N \l_@@_backend_model_box + - \box_ht:N \l_@@_backend_content_box + } + { 0pt } + } ~ + pdf.pt.dvi ~ def + } + } +\cs_new_protected:Npn \@@_backend_link_outerbox:n #1 + { + \@@_postscript:x + { + /pdf.outerbox + [ + \dim_to_decimal:n {#1} ~ + \dim_to_decimal:n { -\box_dp:N \l_@@_backend_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_@@_backend_model_box } + ] + [ exch { pdf.pt.dvi } forall ] def + /pdf.baselineskip ~ + \dim_to_decimal:n { \tex_baselineskip:D } ~ dup ~ 0 ~ gt + { pdf.pt.dvi ~ def } + { pop ~ pop } + ifelse + } + } +\cs_new_protected:Npn \@@_backend_link_sf_save: + { + \int_gset:Nn \g_@@_backend_link_sf_int + { + \mode_if_horizontal:TF + { \tex_spacefactor:D } + { 0 } + } + } +\cs_new_protected:Npn \@@_backend_link_sf_restore: + { + \mode_if_horizontal:T + { + \int_compare:nNnT \g_@@_backend_link_sf_int > { 0 } + { \int_set_eq:NN \tex_spacefactor:D \g_@@_backend_link_sf_int } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@makecol@hook} +% Hooks to allow link breaking: something will be needed in format mode +% at some stage. At present this code is disabled as there is an open +% question about the name of the hook: to be resolved at the \LaTeXe{} +% end. +% \begin{macrocode} +%<*package> +\use_none:n + { + \cs_if_exist:NT \@makecol@hook + { + \tl_put_right:Nn \@makecol@hook + { + \box_if_empty:NF \@cclv + { + \vbox_set:Nn \@cclv + { + \@@_postscript:n + { + pdf.globaldict /pdf.brokenlink.rect ~ known + { pdf.bordertracking.continue } + if + } + \vbox_unpack_drop:N \@cclv + \@@_postscript:n + { pdf.bordertracking.endpage } + } + } + } + \tl_set:Nn \l_@@_breaklink_pdfmark_tl { pdf.pdfmark } + \cs_set_eq:NN \@@_breaklink_postscript:n \@@_postscript:n + \cs_set_eq:NN \@@_breaklink_usebox:N \hbox_unpack:N + } + } +%</package> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_link_last:} +% The same as annotations, but with a custom integer. +% \begin{macrocode} +\cs_new:Npn \@@_backend_link_last: + { { pdf.obj \int_use:N \g_@@_backend_link_int } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_link_margin:n} +% Convert to big points and pass to PostScript. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_link_margin:n #1 + { + \@@_postscript:x + { + /pdf.linkmargin { \dim_to_decimal:n {#1} ~ pdf.pt.dvi } def + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_destination:nn, \@@_backend_destination_rectangle:nn} +% Here, we need to turn the zoom into a scale. We also need to know where +% the current anchor point actually is: worked out in PostScript. For the +% rectangle version, we have a bit more PostScript: we need two points. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_destination:nn #1#2 + { + \@@_postscript:n { pdf.dest.anchor } + \@@_backend_pdfmark:x + { + /View + [ + \str_case:nnF {#2} + { + { xyz } { /XYZ ~ pdf.dest.point ~ null } + { fit } { /Fit } + { fitb } { /FitB } + { fitbh } { /FitBH ~ pdf.dest.y } + { fitbv } { /FitBV ~ pdf.dest.x } + { fith } { /FitH ~ pdf.dest.y } + { fitv } { /FitV ~ pdf.dest.x } + } + { + /XYZ ~ pdf.dest.point ~ \fp_eval:n { (#2) / 100 } + } + ] + /Dest ( \exp_not:n {#1} ) cvn + /DEST + } + } +\cs_new_protected:Npn \@@_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l_@@_internal_box {#2} + \box_move_down:nn + { \box_dp:N \l_@@_internal_box } + { \hbox:n { \@@_postscript:n { pdf.save.ll } } } + \box_use:N \l_@@_internal_box + \box_move_up:nn + { \box_ht:N \l_@@_internal_box } + { \hbox:n { \@@_postscript:n { pdf.save.ur } } } + \@@_backend_pdfmark:n + { + /View + [ + /FitR ~ + pdf.llx ~ pdf.lly ~ pdf.dest2device ~ + pdf.urx ~ pdf.ury ~ pdf.dest2device + ] + /Dest ( #1 ) cvn + /DEST + } + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\@@_backend_compresslevel:n} +% \begin{macro}{\@@_backend_compress_objects:n} +% These are all no-ops. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_compresslevel:n #1 { } +\cs_new_protected:Npn \@@_backend_compress_objects:n #1 { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\@@_backend_version_major_gset:n, \@@_backend_version_minor_gset:n} +% Data not available! +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_version_major_gset:n #1 { } +\cs_new_protected:Npn \@@_backend_version_minor_gset:n #1 { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\@@_backend_version_major:, \@@_backend_version_minor:} +% Data not available! +% \begin{macrocode} +\cs_new:Npn \@@_backend_version_major: { -1 } +\cs_new:Npn \@@_backend_version_minor: { -1 } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Marked content} +% +% \begin{macro}{\@@_backend_bdc:nn} +% \begin{macro}{\@@_backend_emc:} +% Simple wrappers. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_bdc:nn #1#2 + { \@@_backend_pdfmark:n { /#1 ~ #2 /BDC } } +\cs_new_protected:Npn \@@_backend_emc: + { \@@_backend_pdfmark:n { /EMC } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</dvips> +% \end{macrocode} +% +% \subsection{\texttt{pdfmode} backend} +% +% \begin{macrocode} +%<*pdfmode> +% \end{macrocode} +% +% \subsubsection{Annotations} +% +% \begin{macro}{\@@_backend_annotation:nnnn} +% Simply pass the raw data through, just dealing with evaluation of dimensions. +% \begin{macrocode} +\cs_new_protected:Npx \@@_backend_annotation:nnnn #1#2#3#4 + { + \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]{\@@_backend_annotation_last:} +% A tiny amount of extra data gets added here. +% \begin{macrocode} +\cs_new:Npx \@@_backend_annotation_last: + { + \exp_not:N \int_value:w + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastannot ~ } + { \exp_not:N \tex_pdflastannot:D } + \c_space_tl 0 ~ R + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% {\@@_backend_link_begin_goto:nnw, \@@_backend_link_begin_user:nnw} +% \begin{macro}{\@@_backend_link_begin:nnnw} +% \begin{macro}{\@@_backend_link_end:} +% Links are all created using the same internals. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_link_begin_goto:nnw #1#2 + { \@@_backend_link_begin:nnnw {#1} { goto~name } {#2} } +\cs_new_protected:Npn \@@_backend_link_begin_user:nnw #1#2 + { \@@_backend_link_begin:nnnw {#1} { user } {#2} } +\cs_new_protected:Npx \@@_backend_link_begin:nnnw #1#2#3 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D startlink ~ } + { \tex_pdfstartlink:D } + attr {#1} + #2 {#3} + } +\cs_new_protected:Npx \@@_backend_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}{\@@_backend_link_last:} +% Formatted for direct use. +% \begin{macrocode} +\cs_new:Npx \@@_backend_link_last: + { + \exp_not:N \int_value:w + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastlink ~ } + { \exp_not:N \tex_pdflastlink:D } + \c_space_tl 0 ~ R + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_link_margin:n} +% A simple task: pass the data to the primitive. +% \begin{macrocode} +\cs_new_protected:Npx \@@_backend_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} +% +% \begin{macro}{\@@_backend_destination:nn, \@@_backend_destination_rectangle:nn} +% A simple task: pass the data to the primitive. The |\scan_stop:| deals +% with the danger of an unterminated keyword. The zoom given here is a +% percentage, but we need to pass it as \emph{per mille}. The rectangle +% version is also easy as everything is build in. +% \begin{macrocode} +\cs_new_protected:Npx \@@_backend_destination:nn #1#2 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \exp_not:N \tex_pdfextension:D dest ~ } + { \exp_not:N \tex_pdfdest:D } + name {#1} + \exp_not:N \str_case:nnF {#2} + { + { xyz } { xyz } + { fit } { fit } + { fitb } { fitb } + { fitbh } { fitbh } + { fitbv } { fitbv } + { fith } { fith } + { fitv } { fitv } + } + { xyz ~ zoom \exp_not:N \fp_eval:n { #2 * 10 } } + \scan_stop: + } +\cs_new_protected:Npx \@@_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l_@@_internal_box {#2} + \cs_if_exist:NTF \tex_pdfextension:D + { \exp_not:N \tex_pdfextension:D dest ~ } + { \exp_not:N \tex_pdfdest:D } + name {#1} + fitr ~ + width \exp_not:N \box_wd:N \l_@@_internal_box + height \exp_not:N \box_ht:N \l_@@_internal_box + depth \exp_not:N \box_dp:N \l_@@_internal_box + \box_use:N \l_@@_internal_box + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Catalogue entries} +% +% \begin{macro}{\@@_backend_catalog_gput:nn, \@@_backend_info_gput:nn} +% \begin{macrocode} +\cs_new_protected:Npx \@@_backend_catalog_gput:nn #1#2 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D catalog } + { \tex_pdfcatalog:D } + { / #1 ~ #2 } + } +\cs_new_protected:Npx \@@_backend_info_gput:nn #1#2 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D info } + { \tex_pdfinfo:D } + { / #1 ~ #2 } + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Objects} +% +% \begin{variable}{\g_@@_backend_object_prop} +% For tracking objects to allow finalisation. +% \begin{macrocode} +\prop_new:N \g_@@_backend_object_prop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_backend_object_new:nn} +% \begin{macro}[EXP]{\@@_backend_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 \@@_backend_object_new:nn ##1##2 + { + #1 reserveobjnum ~ + \int_const:cn + { c_@@_backend_object_ \exp_not:N \tl_to_str:n {##1} _int } + {#2} + \prop_gput:Nnn \exp_not:N \g_@@_backend_object_prop {##1} {##2} + } + } + \cs_if_exist:NTF \tex_pdfextension:D + { + \@@_tmp:w + { \tex_pdfextension:D obj ~ } + { \exp_not:N \tex_pdffeedback:D lastobj } + } + { \@@_tmp:w { \tex_pdfobj:D } { \tex_pdflastobj:D } } +\group_end: +\cs_new:Npn \@@_backend_object_ref:n #1 + { \int_use:c { c_@@_backend_object_ \tl_to_str:n {#1} _int } ~ 0 ~ R } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_object_write:nn,\@@_backend_object_write:nx} +% \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 \@@_backend_object_write:nn ##1##2 + { + \tex_immediate:D #1 useobjnum ~ + \int_use:c + { c_@@_backend_object_ \tl_to_str:n {##1} _int } + \str_case_e:nn + { \prop_item:Nn \g_@@_backend_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_generate_variant:Nn \@@_backend_object_write:nn { nx } +\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} +% +% \begin{macro}{\@@_backend_object_now:nn, \@@_backend_object_now:nx} +% Much like writing, but direct creation. +% \begin{macrocode} +\group_begin: + \cs_set_protected:Npn \@@_tmp:w #1 + { + \cs_new_protected:Npn \@@_backend_object_now:nn ##1##2 + { + \tex_immediate:D #1 + \str_case:nn + {##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_generate_variant:Nn \@@_backend_object_now:nn { nx } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\@@_backend_object_last:} +% Much like annotation. +% \begin{macrocode} +\cs_new:Npx \@@_backend_object_last: + { + \exp_not:N \int_value:w + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastobj ~ } + { \exp_not:N \tex_pdflastobj:D } + \c_space_tl 0 ~ R + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\@@_backend_compresslevel:n} +% \begin{macro}{\@@_backend_compress_objects:n} +% \begin{macro}{\@@_backend_objcompresslevel:n} +% Simply pass data to the engine. +% \begin{macrocode} +\cs_new_protected:Npx \@@_backend_compresslevel:n #1 + { + \exp_not:N \tex_global:D + \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 \@@_backend_compress_objects:n #1 + { + \bool_if:nTF {#1} + { \@@_backend_objcompresslevel:n { 2 } } + { \@@_backend_objcompresslevel:n { 0 } } + } +\cs_new_protected:Npx \@@_backend_objcompresslevel:n #1 + { + \exp_not:N \tex_global:D + \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} +% {\@@_backend_version_major_gset:n, \@@_backend_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 \@@_backend_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 \@@_backend_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]{\@@_backend_version_major:, \@@_backend_version_minor:} +% At present, we don't have a primitive for the major version! +% \begin{macrocode} +\cs_new:Npx \@@_backend_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 \@@_backend_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} +% +% \subsubsection{Marked content} +% +% \begin{macro}{\@@_backend_bdc:nn} +% \begin{macro}{\@@_backend_emc:} +% Simple wrappers. May need refinement: see +% \url{https://chat.stackexchange.com/transcript/message/49970158#49970158}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_bdc:nn #1#2 + { \__kernel_backend_literal_page:n { /#1 ~ #2 ~ BDC } } +\cs_new_protected:Npn \@@_backend_emc: + { \__kernel_backend_literal_page:n { EMC } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</pdfmode> +% \end{macrocode} +% +% \subsection{\texttt{dvipdfmx} backend} +% +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \begin{macro}{\@@_backend:n, \@@_backend:x} +% A generic function for the backend PDF specials: used where we can. +% \begin{macrocode} +\cs_new_protected:Npx \@@_backend:n #1 + { \__kernel_backend_literal:n { pdf: #1 } } +\cs_generate_variant:Nn \@@_backend:n { x } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Catalogue entries} +% +% \begin{macro}{\@@_backend_catalog_gput:nn, \@@_backend_info_gput:nn} +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_catalog_gput:nn #1#2 + { \@@_backend:n { put ~ @catalog << /#1 ~ #2 >> } } +\cs_new_protected:Npn \@@_backend_info_gput:nn #1#2 + { \@@_backend:n { docinfo << /#1 ~ #2 >> } } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Objects} +% +% \begin{variable}{\g_@@_backend_object_int, \g_@@_backend_object_prop} +% For tracking objects to allow finalisation. +% \begin{macrocode} +\int_new:N \g_@@_backend_object_int +\prop_new:N \g_@@_backend_object_prop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_backend_object_new:nn} +% \begin{macro}[EXP]{\@@_backend_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 \@@_backend_object_new:nn #1#2 + { + \int_gincr:N \g_@@_backend_object_int + \int_const:cn + { c_@@_backend_object_ \tl_to_str:n {#1} _int } + { \g_@@_backend_object_int } + \prop_gput:Nnn \g_@@_backend_object_prop {#1} {#2} + } +\cs_new:Npn \@@_backend_object_ref:n #1 + { @pdf.obj \int_use:c { g_@@_backend_object_ \tl_to_str:n {#1} _int } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_object_write:nn, \@@_backend_object_write:nx} +% \begin{macro}{\@@_backend_object_write:nnn} +% \begin{macro} +% { +% \@@_backend_object_write_array:nn , +% \@@_backend_object_write_dict:nn , +% \@@_backend_object_write_fstream:nn , +% \@@_backend_object_write_stream:nn +% } +% \begin{macro}{\@@_backend_object_write_stream:nnnn} +% This is where we choose the actual type. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_object_write:nn #1#2 + { + \exp_args:Nx \@@_backend_object_write:nnn + { \prop_item:Nn \g_@@_backend_object_prop {#1} } {#1} {#2} + } +\cs_generate_variant:Nn \@@_backend_object_write:nn { nx } +\cs_new_protected:Npn \@@_backend_object_write:nnn #1#2#3 + { + \use:c { @@_backend_object_write_ #1 :nn } + { \@@_backend_object_ref:n {#2} } {#3} + } +\cs_new_protected:Npn \@@_backend_object_write_array:nn #1#2 + { + \@@_backend:x + { obj ~ #1 ~ [ ~ \exp_not:n {#2} ~ ] } + } +\cs_new_protected:Npn \@@_backend_object_write_dict:nn #1#2 + { + \@@_backend:x + { obj ~ #1 ~ << ~ \exp_not:n {#2} ~ >> } + } +\cs_new_protected:Npn \@@_backend_object_write_fstream:nn #1#2 + { \@@_backend_object_write_stream:nnnn { f } {#1} #2 } +\cs_new_protected:Npn \@@_backend_object_write_stream:nn #1#2 + { \@@_backend_object_write_stream:nnnn { } {#1} #2 } +\cs_new_protected:Npn \@@_backend_object_write_stream:nnnn #1#2#3#4 + { + \@@_backend:x + { + #1 stream ~ #2 ~ + ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_object_now:nn, \@@_backend_object_now:nx} +% No anonymous objects with \texttt{dvipdfmx} so we have to give an +% object name. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_object_now:nn #1#2 + { + \int_gincr:N \g_@@_backend_object_int + \exp_args:Nnx \use:c { @@_backend_object_write_ #1 :nn } + { @pdf.obj \int_use:N \g_@@_backend_object_int } + {#2} + } +\cs_generate_variant:Nn \@@_backend_object_now:nn { nx } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_object_last:} +% \begin{macrocode} +\cs_new:Npn \@@_backend_object_last: + { @pdf.obj \int_use:N \g_@@_backend_object_int } +% \end{macrocode} +% \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{variable}{\g_@@_backend_annotation_int} +% Needed as objects which are not annotations could be created. +% \begin{macrocode} +\int_new:N \g_@@_backend_annotation_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_backend_annotation:nnnn, \@@_backend_annotation_aux: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 \@@_backend_annotation:nnnn #1#2#3#4 + { + \bool_if:NTF \g_@@_landscape_bool + { + \box_move_up:nn {#2} + { + \vbox:n + { + \@@_backend_annotation_aux:nnnn + { #2 + #3 } {#1} { 0pt } {#4} + } + } + } + { \@@_backend_annotation_aux:nnnn {#1} {#2} {#3} {#4} } + } +\cs_new_protected:Npn \@@_backend_annotation_aux:nnnn #1#2#3#4 + { + \int_gincr:N \g_@@_backend_object_int + \int_gset_eq:NN \g_@@_backend_annotation_int \g_@@_backend_object_int + \@@_backend:x + { + ann ~ @pdf.obj \int_use:N \g_@@_backend_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}{\@@_backend_annotation_last:} +% \begin{macrocode} +\cs_new:Npn \@@_backend_annotation_last: + { @pdf.obj \int_use:N \g_@@_backend_annotation_int } +% \end{macrocode} +% \end{macro} +% +% \begin{macro} +% {\@@_backend_link_begin_goto:nnw, \@@_backend_link_begin_user:nnw} +% \begin{macro}{\@@_backend_link_begin:n} +% \begin{macro}{\@@_backend_link_end:} +% All created using the same internals. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_link_begin_goto:nnw #1#2 + { \@@_backend_link_begin:n { #1 /Subtype /Link /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \@@_backend_link_begin_user:nnw #1#2 + { \@@_backend_link_begin:n {#1#2} } +\cs_new_protected:Npn \@@_backend_link_begin:n #1 + { + \@@_backend:n + { + bann + << + /Type /Annot + #1 + >> + } + } +\cs_new_protected:Npn \@@_backend_link_end: + { \@@_backend:n { eann } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_backend_link_last:} +% Data not available. +% \begin{macrocode} +\cs_new:Npn \@@_backend_link_last: { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_link_margin:n} +% Pass to \texttt{dvipdfmx}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_link_margin:n #1 + { \__kernel_backend_literal:x { dvipdfmx:config~g~ \dim_eval:n {#1} } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_destination:nn, \@@_backend_destination_rectangle:nn} +% Here, we need to turn the zoom into a scale. The method for \texttt{FitR} +% is from Alexander Grahn: the idea is to avoid needing to do any calculations +% in \TeX{} by using the backend data for \texttt{@xpos} and \texttt{@ypos}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_destination:nn #1#2 + { + \@@_backend:x + { + dest ~ ( \exp_not:n {#1} ) + [ + @thispage + \str_case:nnF {#2} + { + { xyz } { /XYZ ~ @xpos ~ @ypos ~ null } + { fit } { /Fit } + { fitb } { /FitB } + { fitbh } { /FitBH } + { fitbv } { /FitBV ~ @xpos } + { fith } { /FitH ~ @ypos } + { fitv } { /FitV ~ @xpos } + } + { /XYZ ~ @xpos ~ @ypos ~ \fp_eval:n { (#2) / 100 } } + ] + } + } +\cs_new_protected:Npn \@@_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l_@@_internal_box {#2} + \box_move_down:nn { \box_dp:N \l_@@_internal_box } + { + \hbox:n + { + \@@_backend:n { obj ~ @pdf_ #1 _llx ~ @xpos } + \@@_backend:n { obj ~ @pdf_ #1 _lly ~ @ypos } + } + } + \box_use:N \l_@@_internal_box + \box_move_up:nn { \box_ht:N \l_@@_internal_box } + { + \hbox:n + { + \@@_backend:n + { + dest ~ (#1) + [ + @thispage + /FitR ~ + @pdf_ #1 _llx ~ @pdf_ #1 _lly ~ + @xpos ~ @ypos + ] + } + } + } + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\@@_backend_compresslevel:n} +% \begin{macro}{\@@_backend_compress_objects:n} +% Pass data to the backend: these are a one-shot. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_compresslevel:n #1 + { \__kernel_backend_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } +\cs_new_protected:Npn \@@_backend_compress_objects:n #1 + { + \bool_if:nF {#1} + { \__kernel_backend_literal:n { dvipdfmx:config~C~0x40 } } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\@@_backend_version_major_gset:n, \@@_backend_version_minor_gset:n} +% We start with the assumption that the default is active. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_version_major:n #1 + { + \cs_gset:Npx \@@_backend_version_major: { \int_eval:n {#1} } + \__kernel_backend_literal:x { pdf:majorversion \@@_backend_version_major: } + } +\cs_new_protected:Npn \@@_backend_version_minor:n #1 + { + \cs_gset:Npx \@@_backend_version_minor: { \int_eval:n {#1} } + \__kernel_backend_literal:x { pdf:minorversion \@@_backend_version_minor: } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\@@_backend_version_major:, \@@_backend_version_minor:} +% We start with the assumption that the default is active. +% \begin{macrocode} +\cs_new:Npn \@@_backend_version_major: { 1 } +\cs_new:Npn \@@_backend_version_minor: { 5 } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Marked content} +% +% \begin{macro}{\@@_backend_bdc:nn} +% \begin{macro}{\@@_backend_emc:} +% Simple wrappers. May need refinement: see +% \url{https://chat.stackexchange.com/transcript/message/49970158#49970158}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_bdc:nn #1#2 + { \__kernel_backend_literal_page:n { /#1 ~ #2 ~ BDC } } +\cs_new_protected:Npn \@@_backend_emc: + { \__kernel_backend_literal_page:n { EMC } } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +%</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% +% \subsection{\texttt{dvisvgm} backend} +% +% \begin{macrocode} +%<*dvisvgm> +% \end{macrocode} +% +% \subsubsection{Catalogue entries} +% +% \begin{macro}{\@@_backend_catalog_gput:nn, \@@_backend_info_gput:nn} +% No-op. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_catalog_gput:nn #1#2 { } +\cs_new_protected:Npn \@@_backend_info_gput:nn #1#2 { } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Objects} +% +% \begin{macro}{\@@_backend_object_new:nn} +% \begin{macro}[EXP]{\@@_backend_object_ref:n} +% \begin{macro}{\@@_backend_object_write:nn, , \@@_backend_object_write:nx} +% \begin{macro}{\@@_backend_object_now:nn, , \@@_backend_object_now:nx} +% \begin{macro}{\@@_backend_object_last:} +% All no-ops here. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_object_new:nn #1#2 { } +\cs_new:Npn \@@_backend_object_ref:n #1 { } +\cs_new_protected:Npn \@@_backend_object_write:nn #1#2 { } +\cs_new_protected:Npn \@@_backend_object_write:nx #1#2 { } +\cs_new_protected:Npn \@@_backend_object_now:nn #1#2 { } +\cs_new_protected:Npn \@@_backend_object_now:nx #1#2 { } +\cs_new:Npn \@@_backend_object_last: { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Structure} +% +% \begin{macro}{\@@_backend_compresslevel:n} +% \begin{macro}{\@@_backend_compress_objects:n} +% These are all no-ops. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_compresslevel:n #1 { } +\cs_new_protected:Npn \@@_backend_compress_objects:n #1 { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% {\@@_backend_version_major_gset:n, \@@_backend_version_minor_gset:n} +% Data not available! +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_version_major_gset:n #1 { } +\cs_new_protected:Npn \@@_backend_version_minor_gset:n #1 { } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\@@_backend_version_major:, \@@_backend_version_minor:} +% Data not available! +% \begin{macrocode} +\cs_new:Npn \@@_backend_version_major: { -1 } +\cs_new:Npn \@@_backend_version_minor: { -1 } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_backend_bdc:nn} +% \begin{macro}{\@@_backend_emc:} +% More no-ops. +% \begin{macrocode} +\cs_new_protected:Npn \@@_backend_bdc:nn #1#2 { } +\cs_new_protected:Npn \@@_backend_emc: { } +% \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/l3backend/l3backend.ins b/Master/texmf-dist/source/latex/l3backend/l3backend.ins new file mode 100644 index 00000000000..149f08b9ee8 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3backend/l3backend.ins @@ -0,0 +1,118 @@ +\iffalse meta-comment + +File l3backend.ins + +Copyright (C) 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 "l3backend 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. + +----------------------------------------------------------------------- + +Any modification of this file should ensure that the copyright and +license information is placed in the derived files. + +\fi + +\let\jobname\relax +\input l3docstrip.dtx +\askforoverwritefalse + +\preamble + +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 +this license or (at your option) any later version. The latest +version of this license is in the file: + + https://www.latex-project.org/lppl.txt + +This file is part of the "l3backend bundle" (The Work in LPPL) +and all files in that bundle must be distributed together. + +\endpreamble +% stop docstrip adding \endinput +\postamble +\endpostamble + +\keepsilent + +\generate + { + \file{l3backend-dvipdfmx.def} + { + \from{l3backend-basics.dtx} {package,dvipdfmx} + \from{l3backend-color.dtx} {package,dvipdfmx} + \from{l3backend-box.dtx} {package,dvipdfmx} + \from{l3backend-draw.dtx} {package,dvipdfmx} + \from{l3backend-graphics.dtx}{package,dvipdfmx} + \from{l3backend-pdf.dtx} {package,dvipdfmx} + } + } +\generate + { + \file{l3backend-dvips.def} + { + \from{l3backend-basics.dtx} {package,dvips} + \from{l3backend-color.dtx} {package,dvips} + \from{l3backend-box.dtx} {package,dvips} + \from{l3backend-draw.dtx} {package,dvips} + \from{l3backend-graphics.dtx}{package,dvips} + \from{l3backend-pdf.dtx} {package,dvips} + } + } +\generate + { + \file{l3backend-dvisvgm.def} + { + \from{l3backend-basics.dtx} {package,dvisvgm} + \from{l3backend-color.dtx} {package,dvisvgm} + \from{l3backend-box.dtx} {package,dvisvgm} + \from{l3backend-draw.dtx} {package,dvisvgm} + \from{l3backend-graphics.dtx}{package,dvisvgm} + \from{l3backend-pdf.dtx} {package,dvisvgm} + } + } +\generate + { + \file{l3backend-pdfmode.def} + { + \from{l3backend-basics.dtx} {package,pdfmode} + \from{l3backend-color.dtx} {package,pdfmode} + \from{l3backend-box.dtx} {package,pdfmode} + \from{l3backend-draw.dtx} {package,pdfmode} + \from{l3backend-graphics.dtx}{package,pdfmode} + \from{l3backend-pdf.dtx} {package,pdfmode} + } + } +\generate + { + \file{l3backend-xdvipdfmx.def} + { + \from{l3backend-basics.dtx} {package,xdvipdfmx} + \from{l3backend-color.dtx} {package,xdvipdfmx} + \from{l3backend-box.dtx} {package,xdvipdfmx} + \from{l3backend-draw.dtx} {package,xdvipdfmx} + \from{l3backend-graphics.dtx}{package,xdvipdfmx} + \from{l3backend-pdf.dtx} {package,xdvipdfmx} + } + } + +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/l3backend/l3backend-dvipdfmx.def b/Master/texmf-dist/tex/latex/l3backend/l3backend-dvipdfmx.def new file mode 100644 index 00000000000..3614e4f9437 --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3backend/l3backend-dvipdfmx.def @@ -0,0 +1,648 @@ +%% +%% This is file `l3backend-dvipdfmx.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3backend-basics.dtx (with options: `package,dvipdfmx') +%% l3backend-color.dtx (with options: `package,dvipdfmx') +%% l3backend-box.dtx (with options: `package,dvipdfmx') +%% l3backend-draw.dtx (with options: `package,dvipdfmx') +%% l3backend-graphics.dtx (with options: `package,dvipdfmx') +%% l3backend-pdf.dtx (with options: `package,dvipdfmx') +%% +%% 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 +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3backend bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: l3backend-basics.dtx +\ProvidesExplFile + {l3backend-dvipdfmx.def}{2019-04-06}{} + {L3 Experimental backend support: dvipdfmx} +\cs_new_eq:NN \__kernel_backend_literal:e \tex_special:D +\cs_new_protected:Npn \__kernel_backend_literal:n #1 + { \__kernel_backend_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \__kernel_backend_literal:n { x } +\cs_new_protected:Npn \__kernel_backend_literal_pdf:n #1 + { \__kernel_backend_literal:n { pdf:literal~ #1 } } +\cs_generate_variant:Nn \__kernel_backend_literal_pdf:n { x } +\cs_new_protected:Npn \__kernel_backend_literal_page:n #1 + { \__kernel_backend_literal:n { pdf:literal~direct~ #1 } } +\cs_new_protected:Npn \__kernel_backend_scope_begin: + { \__kernel_backend_literal:n { x:gsave } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal:n { x:grestore } } +%% File: l3backend-color.dtx +\cs_new_protected:Npn \__color_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \__color_backend_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_backend_pickup:w + { \current@color } \q_stop #1 + } + } + \cs_new_protected:Npn \__color_backend_pickup:w #1 ~ #2 \q_stop #3 + { \tl_set:Nn #3 { #1 ~ #2 } } + } + { } + } +\cs_new_protected:Npn \__color_backend_cmyk:nnnn #1#2#3#4 + { + \__color_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__color_backend_gray:n #1 + { \__color_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \__color_backend_rgb:nnn #1#2#3 + { + \__color_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \__color_backend_spot:nn #1#2 + { \__color_backend_select:n { #1 } } +\cs_new_protected:Npn \__color_backend_select:n #1 + { + \__kernel_backend_literal:n { color~push~ #1 } + \group_insert_after:N \__color_backend_reset: + } +\cs_generate_variant:Nn \__color_backend_select:n { x } +\cs_new_protected:Npn \__color_backend_reset: + { \__kernel_backend_literal:n { color~pop } } +%% File: l3backend-box.dtx +\cs_new_protected:Npn \__box_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_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 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +\cs_new_protected:Npn \__box_backend_rotate:Nn #1#2 + { \exp_args:NNf \__box_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \__box_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( #2 , 5 ) } } + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +\cs_new_protected:Npn \__box_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +%% File: l3backend-draw.dtx +\cs_new_eq:NN \__draw_backend_literal:n \__kernel_backend_literal_pdf:n +\cs_generate_variant:Nn \__draw_backend_literal:n { x } +\cs_new_protected:Npn \__draw_backend_begin: + { \__draw_backend_scope_begin: } +\cs_new_protected:Npn \__draw_backend_end: + { \__draw_backend_scope_end: } +\cs_new_eq:NN \__draw_backend_scope_begin: \__kernel_backend_scope_begin: +\cs_new_eq:NN \__draw_backend_scope_end: \__kernel_backend_scope_end: +\cs_new_protected:Npn \__draw_backend_moveto:nn #1#2 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } + } +\cs_new_protected:Npn \__draw_backend_lineto:nn #1#2 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } + } +\cs_new_protected:Npn \__draw_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \__draw_backend_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 \__draw_backend_rectangle:nnnn #1#2#3#4 + { + \__draw_backend_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 \__draw_backend_evenodd_rule: + { \bool_gset_true:N \g__draw_draw_eor_bool } +\cs_new_protected:Npn \__draw_backend_nonzero_rule: + { \bool_gset_false:N \g__draw_draw_eor_bool } +\bool_new:N \g__draw_draw_eor_bool +\cs_new_protected:Npn \__draw_backend_closepath: + { \__draw_backend_literal:n { h } } +\cs_new_protected:Npn \__draw_backend_stroke: + { \__draw_backend_literal:n { S } } +\cs_new_protected:Npn \__draw_backend_closestroke: + { \__draw_backend_literal:n { s } } +\cs_new_protected:Npn \__draw_backend_fill: + { + \__draw_backend_literal:x + { f \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_fillstroke: + { + \__draw_backend_literal:x + { B \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_clip: + { + \__draw_backend_literal:x + { W \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_discardpath: + { \__draw_backend_literal:n { n } } +\cs_new_protected:Npn \__draw_backend_dash_pattern:nn #1#2 + { + \__draw_backend_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \__draw_backend_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ d + } + } +\cs_new:Npn \__draw_backend_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \__draw_backend_linewidth:n #1 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ w } + } +\cs_new_protected:Npn \__draw_backend_miterlimit:n #1 + { \__draw_backend_literal:x { \fp_eval:n {#1} ~ M } } +\cs_new_protected:Npn \__draw_backend_cap_butt: + { \__draw_backend_literal:n { 0 ~ J } } +\cs_new_protected:Npn \__draw_backend_cap_round: + { \__draw_backend_literal:n { 1 ~ J } } +\cs_new_protected:Npn \__draw_backend_cap_rectangle: + { \__draw_backend_literal:n { 2 ~ J } } +\cs_new_protected:Npn \__draw_backend_join_miter: + { \__draw_backend_literal:n { 0 ~ j } } +\cs_new_protected:Npn \__draw_backend_join_round: + { \__draw_backend_literal:n { 1 ~ j } } +\cs_new_protected:Npn \__draw_backend_join_bevel: + { \__draw_backend_literal:n { 2 ~ j } } +\cs_new_protected:Npn \__draw_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \__draw_backend_color_fill_gray:n #1 + { \__draw_backend_color_select:x { \fp_eval:n {#1} ~ g } } +\cs_new_protected:Npn \__draw_backend_color_stroke_gray:n #1 + { \__draw_backend_color_select:x { \fp_eval:n {#1} ~ G } } +\cs_new_protected:Npn \__draw_backend_color_fill_rgb:nnn #1#2#3 + { + \__draw_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_rgb:nnn #1#2#3 + { + \__draw_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } + } +\cs_new_eq:NN \__draw_backend_color_select:n \__kernel_backend_literal_pdf:n +\cs_generate_variant:Nn \__draw_backend_color_select:n { x } +\cs_new_protected:Npn \__draw_backend_cm:nnnn #1#2#3#4 + { + \__draw_backend_cm_decompose:nnnnN {#1} {#2} {#3} {#4} + \__draw_backend_cm_aux:nnnn + } +\cs_new_protected:Npn \__draw_backend_cm_aux:nnnn #1#2#3#4 + { + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#1} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#1 , 5 ) } } + } + \__kernel_backend_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#4} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#4 , 5 ) } } + } + } +\cs_new_protected:Npn \__draw_backend_cm_decompose:nnnnN #1#2#3#4#5 + { + \use:x + { + \__draw_backend_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_backend_cm_decompose_auxi:nnnnN #1#2#3#4#5 + { + \use:x + { + \__draw_backend_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_backend_cm_decompose_auxii:nnnnN #1#2#3#4#5 + { + \use:x + { + \__draw_backend_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_backend_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} } + } +\cs_new_protected:Npn \__draw_backend_box_use:Nnnnn #1#2#3#4#5 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + pdf:btrans~matrix~ + \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ + \fp_eval:n {#4} ~ \fp_eval:n {#5} ~ + 0 ~ 0 + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_literal:n { pdf:etrans } + \__kernel_backend_scope_end: + } +%% File: l3backend-graphics.dtx +\AtBeginDocument + { \cs_new_eq:NN \__graphics_backend_getbb_eps:n \graphics_read_bb:n } +\cs_new_protected:Npn \__graphics_backend_getbb_jpg:n #1 + { + \int_zero:N \l_graphics_page_int + \tl_clear:N \l_graphics_pagebox_tl + \graphics_extract_bb:n {#1} + } +\cs_new_eq:NN \__graphics_backend_getbb_png:n \__graphics_backend_getbb_jpg:n +\cs_new_protected:Npn \__graphics_backend_getbb_pdf:n #1 + { + \tl_clear:N \l_graphics_decodearray_tl + \bool_set_false:N \l_graphics_interpolate_bool + \graphics_extract_bb:n {#1} + } +\int_new:N \g__graphics_track_int +\cs_new_protected:Npn \__graphics_backend_include_eps:n #1 + { + \__kernel_backend_literal:x + { + PSfile = #1 \c_space_tl + llx = \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + lly = \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + urx = \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + ury = \dim_to_decimal_in_bp:n \l_graphics_ury_dim + } + } +\cs_new_protected:Npn \__graphics_backend_include_jpg:n #1 + { \__graphics_backend_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \__graphics_backend_include_png:n \__graphics_backend_include_jpg:n +\cs_new_protected:Npn \__graphics_backend_include_pdf:n #1 + { \__graphics_backend_include_auxi:nn {#1} { epdf } } +\cs_new_protected:Npn \__graphics_backend_include_auxi:nn #1#2 + { + \__graphics_backend_include_auxii:xnn + { + \tl_if_empty:NF \l_graphics_pagebox_tl + { : \l_graphics_pagebox_tl } + \int_compare:nNnT \l_graphics_page_int > 1 + { :P \int_use:N \l_graphics_page_int } + \tl_if_empty:NF \l_graphics_decodearray_tl + { :D \l_graphics_decodearray_tl } + \bool_if:NT \l_graphics_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \__graphics_backend_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c__graphics_graphics_ #2#1 _int } + { + \__kernel_backend_literal:x + { pdf:usexobj~@graphic \int_use:c { c__graphics_graphics_ #2#1 _int } } + } + { \__graphics_backend_include_auxiii:nnn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \__graphics_backend_include_auxii:nnn { x } +\cs_new_protected:Npn \__graphics_backend_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g__graphics_track_int + \int_const:cn { c__graphics_graphics_ #1#2 _int } { \g__graphics_track_int } + \__kernel_backend_literal:x + { + pdf:#3~ + @graphic \int_use:c { c__graphics_graphics_ #1#2 _int } ~ + \int_compare:nNnT \l_graphics_page_int > 1 + { page ~ \int_use:N \l_graphics_page_int \c_space_tl } + \tl_if_empty:NF \l_graphics_pagebox_tl + { + pagebox ~ \l_graphics_pagebox_tl \c_space_tl + bbox ~ + \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_ury_dim \c_space_tl + } + (#1) + \bool_lazy_or:nnT + { \l_graphics_interpolate_bool } + { ! \tl_if_empty_p:N \l_graphics_decodearray_tl } + { + << + \tl_if_empty:NF \l_graphics_decodearray_tl + { /Decode~[ \l_graphics_decodearray_tl ] } + \bool_if:NT \l_graphics_interpolate_bool + { /Interpolate~true> } + >> + } + } + } +%% File: l3backend-pdf.dtx +\box_new:N \l__pdf_internal_box +\cs_new_protected:Npx \__pdf_backend:n #1 + { \__kernel_backend_literal:n { pdf: #1 } } +\cs_generate_variant:Nn \__pdf_backend:n { x } +\cs_new_protected:Npn \__pdf_backend_catalog_gput:nn #1#2 + { \__pdf_backend:n { put ~ @catalog << /#1 ~ #2 >> } } +\cs_new_protected:Npn \__pdf_backend_info_gput:nn #1#2 + { \__pdf_backend:n { docinfo << /#1 ~ #2 >> } } +\int_new:N \g__pdf_backend_object_int +\prop_new:N \g__pdf_backend_object_prop +\cs_new_protected:Npn \__pdf_backend_object_new:nn #1#2 + { + \int_gincr:N \g__pdf_backend_object_int + \int_const:cn + { c__pdf_backend_object_ \tl_to_str:n {#1} _int } + { \g__pdf_backend_object_int } + \prop_gput:Nnn \g__pdf_backend_object_prop {#1} {#2} + } +\cs_new:Npn \__pdf_backend_object_ref:n #1 + { @pdf.obj \int_use:c { g__pdf_backend_object_ \tl_to_str:n {#1} _int } } +\cs_new_protected:Npn \__pdf_backend_object_write:nn #1#2 + { + \exp_args:Nx \__pdf_backend_object_write:nnn + { \prop_item:Nn \g__pdf_backend_object_prop {#1} } {#1} {#2} + } +\cs_generate_variant:Nn \__pdf_backend_object_write:nn { nx } +\cs_new_protected:Npn \__pdf_backend_object_write:nnn #1#2#3 + { + \use:c { __pdf_backend_object_write_ #1 :nn } + { \__pdf_backend_object_ref:n {#2} } {#3} + } +\cs_new_protected:Npn \__pdf_backend_object_write_array:nn #1#2 + { + \__pdf_backend:x + { obj ~ #1 ~ [ ~ \exp_not:n {#2} ~ ] } + } +\cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2 + { + \__pdf_backend:x + { obj ~ #1 ~ << ~ \exp_not:n {#2} ~ >> } + } +\cs_new_protected:Npn \__pdf_backend_object_write_fstream:nn #1#2 + { \__pdf_backend_object_write_stream:nnnn { f } {#1} #2 } +\cs_new_protected:Npn \__pdf_backend_object_write_stream:nn #1#2 + { \__pdf_backend_object_write_stream:nnnn { } {#1} #2 } +\cs_new_protected:Npn \__pdf_backend_object_write_stream:nnnn #1#2#3#4 + { + \__pdf_backend:x + { + #1 stream ~ #2 ~ + ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> + } + } +\cs_new_protected:Npn \__pdf_backend_object_now:nn #1#2 + { + \int_gincr:N \g__pdf_backend_object_int + \exp_args:Nnx \use:c { __pdf_backend_object_write_ #1 :nn } + { @pdf.obj \int_use:N \g__pdf_backend_object_int } + {#2} + } +\cs_generate_variant:Nn \__pdf_backend_object_now:nn { nx } +\cs_new:Npn \__pdf_backend_object_last: + { @pdf.obj \int_use:N \g__pdf_backend_object_int } +\bool_new:N \g__pdf_landscape_bool +\AtBeginDocument + { + \cs_if_exist:NT \landscape + { + \tl_put_right:Nn \landscape + { \bool_gset_true:N \g__pdf_landscape_bool } + \tl_put_left:Nn \endlandscape + { \bool_gset_false:N \g__pdf_landscape_bool } + } + } +\int_new:N \g__pdf_backend_annotation_int +\cs_new_protected:Npn \__pdf_backend_annotation:nnnn #1#2#3#4 + { + \bool_if:NTF \g__pdf_landscape_bool + { + \box_move_up:nn {#2} + { + \vbox:n + { + \__pdf_backend_annotation_aux:nnnn + { #2 + #3 } {#1} { 0pt } {#4} + } + } + } + { \__pdf_backend_annotation_aux:nnnn {#1} {#2} {#3} {#4} } + } +\cs_new_protected:Npn \__pdf_backend_annotation_aux:nnnn #1#2#3#4 + { + \int_gincr:N \g__pdf_backend_object_int + \int_gset_eq:NN \g__pdf_backend_annotation_int \g__pdf_backend_object_int + \__pdf_backend:x + { + ann ~ @pdf.obj \int_use:N \g__pdf_backend_object_int \c_space_tl + width ~ \dim_eval:n {#1} ~ + height ~ \dim_eval:n {#2} ~ + depth ~ \dim_eval:n {#3} ~ + << #4 >> + } + } +\cs_new:Npn \__pdf_backend_annotation_last: + { @pdf.obj \int_use:N \g__pdf_backend_annotation_int } +\cs_new_protected:Npn \__pdf_backend_link_begin_goto:nnw #1#2 + { \__pdf_backend_link_begin:n { #1 /Subtype /Link /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \__pdf_backend_link_begin_user:nnw #1#2 + { \__pdf_backend_link_begin:n {#1#2} } +\cs_new_protected:Npn \__pdf_backend_link_begin:n #1 + { + \__pdf_backend:n + { + bann + << + /Type /Annot + #1 + >> + } + } +\cs_new_protected:Npn \__pdf_backend_link_end: + { \__pdf_backend:n { eann } } +\cs_new:Npn \__pdf_backend_link_last: { } +\cs_new_protected:Npn \__pdf_backend_link_margin:n #1 + { \__kernel_backend_literal:x { dvipdfmx:config~g~ \dim_eval:n {#1} } } +\cs_new_protected:Npn \__pdf_backend_destination:nn #1#2 + { + \__pdf_backend:x + { + dest ~ ( \exp_not:n {#1} ) + [ + @thispage + \str_case:nnF {#2} + { + { xyz } { /XYZ ~ @xpos ~ @ypos ~ null } + { fit } { /Fit } + { fitb } { /FitB } + { fitbh } { /FitBH } + { fitbv } { /FitBV ~ @xpos } + { fith } { /FitH ~ @ypos } + { fitv } { /FitV ~ @xpos } + } + { /XYZ ~ @xpos ~ @ypos ~ \fp_eval:n { (#2) / 100 } } + ] + } + } +\cs_new_protected:Npn \__pdf_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l__pdf_internal_box {#2} + \box_move_down:nn { \box_dp:N \l__pdf_internal_box } + { + \hbox:n + { + \__pdf_backend:n { obj ~ @pdf_ #1 _llx ~ @xpos } + \__pdf_backend:n { obj ~ @pdf_ #1 _lly ~ @ypos } + } + } + \box_use:N \l__pdf_internal_box + \box_move_up:nn { \box_ht:N \l__pdf_internal_box } + { + \hbox:n + { + \__pdf_backend:n + { + dest ~ (#1) + [ + @thispage + /FitR ~ + @pdf_ #1 _llx ~ @pdf_ #1 _lly ~ + @xpos ~ @ypos + ] + } + } + } + \group_end: + } +\cs_new_protected:Npn \__pdf_backend_compresslevel:n #1 + { \__kernel_backend_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } +\cs_new_protected:Npn \__pdf_backend_compress_objects:n #1 + { + \bool_if:nF {#1} + { \__kernel_backend_literal:n { dvipdfmx:config~C~0x40 } } + } +\cs_new_protected:Npn \__pdf_backend_version_major:n #1 + { + \cs_gset:Npx \__pdf_backend_version_major: { \int_eval:n {#1} } + \__kernel_backend_literal:x { pdf:majorversion \__pdf_backend_version_major: } + } +\cs_new_protected:Npn \__pdf_backend_version_minor:n #1 + { + \cs_gset:Npx \__pdf_backend_version_minor: { \int_eval:n {#1} } + \__kernel_backend_literal:x { pdf:minorversion \__pdf_backend_version_minor: } + } +\cs_new:Npn \__pdf_backend_version_major: { 1 } +\cs_new:Npn \__pdf_backend_version_minor: { 5 } +\cs_new_protected:Npn \__pdf_backend_bdc:nn #1#2 + { \__kernel_backend_literal_page:n { /#1 ~ #2 ~ BDC } } +\cs_new_protected:Npn \__pdf_backend_emc: + { \__kernel_backend_literal_page:n { EMC } } +%% +%% +%% End of file `l3backend-dvipdfmx.def'. diff --git a/Master/texmf-dist/tex/latex/l3backend/l3backend-dvips.def b/Master/texmf-dist/tex/latex/l3backend/l3backend-dvips.def new file mode 100644 index 00000000000..d259a884fe8 --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3backend/l3backend-dvips.def @@ -0,0 +1,1197 @@ +%% +%% This is file `l3backend-dvips.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3backend-basics.dtx (with options: `package,dvips') +%% l3backend-color.dtx (with options: `package,dvips') +%% l3backend-box.dtx (with options: `package,dvips') +%% l3backend-draw.dtx (with options: `package,dvips') +%% l3backend-graphics.dtx (with options: `package,dvips') +%% l3backend-pdf.dtx (with options: `package,dvips') +%% +%% 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 +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3backend bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: l3backend-basics.dtx +\ProvidesExplFile + {l3backend-dvips.def}{2019-04-06}{} + {L3 Experimental backend support: dvips} +\cs_new_eq:NN \__kernel_backend_literal:e \tex_special:D +\cs_new_protected:Npn \__kernel_backend_literal:n #1 + { \__kernel_backend_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \__kernel_backend_literal:n { x } +\cs_new_protected:Npn \__kernel_backend_literal_postscript:n #1 + { \__kernel_backend_literal:n { ps:: #1 } } +\cs_generate_variant:Nn \__kernel_backend_literal_postscript:n { x } +\cs_new_protected:Npn \__kernel_backend_postscript:n #1 + { \__kernel_backend_literal:n { ps: SDict ~ begin ~ #1 ~ end } } +\cs_generate_variant:Nn \__kernel_backend_postscript:n { x } +\cs_new_protected:Npx \__kernel_backend_postscript_header:n #1 + { + \cs_if_exist:NTF \AtBeginDvi + { \exp_not:N \AtBeginDvi } + { \use:n } + { \__kernel_backend_literal:n { ! #1 } } + } +\cs_new_protected:Npn \__kernel_backend_align_begin: + { + \__kernel_backend_literal:n { ps::[begin] } + \__kernel_backend_literal_postscript:n { currentpoint } + \__kernel_backend_literal_postscript:n { currentpoint~translate } + } +\cs_new_protected:Npn \__kernel_backend_align_end: + { + \__kernel_backend_literal_postscript:n { neg~exch~neg~exch~translate } + \__kernel_backend_literal:n { ps::[end] } + } +\cs_new_protected:Npn \__kernel_backend_scope_begin: + { \__kernel_backend_literal:n { ps:gsave } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal:n { ps:grestore } } +%% File: l3backend-color.dtx +\cs_new_protected:Npn \__color_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \__color_backend_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_backend_pickup:w + { \current@color } \q_stop #1 + } + } + \cs_new_protected:Npn \__color_backend_pickup:w #1 ~ #2 \q_stop #3 + { \tl_set:Nn #3 { #1 ~ #2 } } + } + { } + } +\cs_new_protected:Npn \__color_backend_cmyk:nnnn #1#2#3#4 + { + \__color_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__color_backend_gray:n #1 + { \__color_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \__color_backend_rgb:nnn #1#2#3 + { + \__color_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \__color_backend_spot:nn #1#2 + { \__color_backend_select:n { #1 } } +\cs_new_protected:Npn \__color_backend_select:n #1 + { + \__kernel_backend_literal:n { color~push~ #1 } + \__kernel_backend_postscript:n { /color.fc~{ }~def } + \group_insert_after:N \__color_backend_reset: + } +\cs_generate_variant:Nn \__color_backend_select:n { x } +\cs_new_protected:Npn \__color_backend_reset: + { \__kernel_backend_literal:n { color~pop } } +%% File: l3backend-box.dtx +\cs_new_protected:Npn \__box_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_align_begin: + \__kernel_backend_literal_postscript:n { matrix~currentmatrix } + \__kernel_backend_literal_postscript:n + { Resolution~72~div~VResolution~72~div~scale } + \__kernel_backend_literal_postscript:n { DVImag~dup~scale } + \__kernel_backend_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 + } + \__kernel_backend_literal_postscript:n { setmatrix } + \__kernel_backend_align_end: + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +\cs_new_protected:Npn \__box_backend_rotate:Nn #1#2 + { \exp_args:NNf \__box_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \__box_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \__kernel_backend_align_begin: + \__kernel_backend_literal_postscript:x + { + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -(#2) , 5 ) } } ~ + rotate + } + \__kernel_backend_align_end: + \box_use:N #1 + \__kernel_backend_scope_end: + } +\cs_new_protected:Npn \__box_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_align_begin: + \__kernel_backend_literal_postscript:x + { + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } ~ + scale + } + \__kernel_backend_align_end: + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +%% File: l3backend-draw.dtx +\cs_new_eq:NN \__draw_backend_literal:n \__kernel_backend_literal_postscript:n +\cs_generate_variant:Nn \__draw_backend_literal:n { x } +\cs_new_protected:Npn \__draw_backend_begin: + { + \__kernel_backend_literal:n { ps::[begin] } + \__draw_backend_literal:n { @beginspecial } + \__draw_backend_literal:n { SDict ~ begin ~ /color.fc ~ { } ~ def ~ end } + } +\cs_new_protected:Npn \__draw_backend_end: + { + \__draw_backend_literal:n { @endspecial } + \__kernel_backend_literal:n { ps::[end] } + } +\cs_new_protected:Npn \__draw_backend_scope_begin: + { \__draw_backend_literal:n { save } } +\cs_new_protected:Npn \__draw_backend_scope_end: + { \__draw_backend_literal:n { restore } } +\cs_new_protected:Npn \__draw_backend_moveto:nn #1#2 + { + \__draw_backend_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ + \dim_to_decimal_in_bp:n {#2} ~ moveto + } + } +\cs_new_protected:Npn \__draw_backend_lineto:nn #1#2 + { + \__draw_backend_literal:x + { + \dim_to_decimal_in_bp:n {#1} ~ + \dim_to_decimal_in_bp:n {#2} ~ lineto + } + } +\cs_new_protected:Npn \__draw_backend_rectangle:nnnn #1#2#3#4 + { + \__draw_backend_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 \__draw_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \__draw_backend_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 + } + } +\cs_new_protected:Npn \__draw_backend_evenodd_rule: + { \bool_gset_true:N \g__draw_draw_eor_bool } +\cs_new_protected:Npn \__draw_backend_nonzero_rule: + { \bool_gset_false:N \g__draw_draw_eor_bool } +\bool_new:N \g__draw_draw_eor_bool +\cs_new_protected:Npn \__draw_backend_closepath: + { \__draw_backend_literal:n { closepath } } +\cs_new_protected:Npn \__draw_backend_stroke: + { + \__draw_backend_literal:n { stroke } + \bool_if:NT \g__draw_draw_clip_bool + { + \__draw_backend_literal:x + { + \bool_if:NT \g__draw_draw_eor_bool { eo } + clip + } + } + \__draw_backend_literal:n { newpath } + \bool_gset_false:N \g__draw_draw_clip_bool + } +\cs_new_protected:Npn \__draw_backend_closestroke: + { + \__draw_backend_closepath: + \__draw_backend_stroke: + } +\cs_new_protected:Npn \__draw_backend_fill: + { + \__draw_backend_literal:n { gsave } + \__draw_backend_literal:n { color.fc } + \__draw_backend_literal:x + { + \bool_if:NT \g__draw_draw_eor_bool { eo } + fill + } + \__draw_backend_literal:n { grestore } + \bool_if:NT \g__draw_draw_clip_bool + { + \__draw_backend_literal:x + { + \bool_if:NT \g__draw_draw_eor_bool { eo } + clip + } + } + \__draw_backend_literal:n { newpath } + \bool_gset_false:N \g__draw_draw_clip_bool + } +\cs_new_protected:Npn \__draw_backend_fillstroke: + { + \__draw_backend_literal:n { gsave } + \__draw_backend_literal:n { color.fc } + \__draw_backend_literal:x + { + \bool_if:NT \g__draw_draw_eor_bool { eo } + fill + } + \__draw_backend_literal:n { grestore } + \__draw_backend_literal:n { stroke } + \bool_if:NT \g__draw_draw_clip_bool + { + \__draw_backend_literal:x + { + \bool_if:NT \g__draw_draw_eor_bool { eo } + clip + } + } + \__draw_backend_literal:n { newpath } + \bool_gset_false:N \g__draw_draw_clip_bool + } +\cs_new_protected:Npn \__draw_backend_clip: + { \bool_gset_true:N \g__draw_draw_clip_bool } +\bool_new:N \g__draw_draw_clip_bool +\cs_new_protected:Npn \__draw_backend_discardpath: + { + \bool_if:NT \g__draw_draw_clip_bool + { + \__draw_backend_literal:x + { + \bool_if:NT \g__draw_draw_eor_bool { eo } + clip + } + } + \__draw_backend_literal:n { newpath } + \bool_gset_false:N \g__draw_draw_clip_bool + } +\cs_new_protected:Npn \__draw_backend_dash_pattern:nn #1#2 + { + \__draw_backend_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \__draw_backend_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ setdash + } + } +\cs_new:Npn \__draw_backend_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \__draw_backend_linewidth:n #1 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ setlinewidth } + } +\cs_new_protected:Npn \__draw_backend_miterlimit:n #1 + { \__draw_backend_literal:x { \fp_eval:n {#1} ~ setmiterlimit } } +\cs_new_protected:Npn \__draw_backend_cap_butt: + { \__draw_backend_literal:n { 0 ~ setlinecap } } +\cs_new_protected:Npn \__draw_backend_cap_round: + { \__draw_backend_literal:n { 1 ~ setlinecap } } +\cs_new_protected:Npn \__draw_backend_cap_rectangle: + { \__draw_backend_literal:n { 2 ~ setlinecap } } +\cs_new_protected:Npn \__draw_backend_join_miter: + { \__draw_backend_literal:n { 0 ~ setlinejoin } } +\cs_new_protected:Npn \__draw_backend_join_round: + { \__draw_backend_literal:n { 1 ~ setlinejoin } } +\cs_new_protected:Npn \__draw_backend_join_bevel: + { \__draw_backend_literal:n { 2 ~ setlinejoin } } +\cs_new_protected:Npn \__draw_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_fill:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + setcmykcolor + } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_stroke:x + { + cmyk ~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__draw_backend_color_fill_gray:n #1 + { \__draw_backend_color_fill:x { \fp_eval:n {#1} ~ setgray } } +\cs_new_protected:Npn \__draw_backend_color_stroke_gray:n #1 + { \__draw_backend_color_stroke:x { gray ~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \__draw_backend_color_fill_rgb:nnn #1#2#3 + { + \__draw_backend_color_fill:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ setrgbcolor } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_rgb:nnn #1#2#3 + { + \__draw_backend_color_stroke:x + { rgb ~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \__draw_backend_color_fill:n #1 + { + \__kernel_backend_postscript:n + { SDict ~ begin ~ /color.fc ~ { #1 } ~ def ~ end } + } +\cs_generate_variant:Nn \__draw_backend_color_fill:n { x } +\cs_new_protected:Npn \__draw_backend_color_stroke:n #1 + { + \__kernel_backend_literal:n { color~push~#1 } + \group_insert_after:N \__draw_color_reset: + } +\cs_generate_variant:Nn \__draw_backend_color_stroke:n { x } +\cs_new_protected:Npn \__draw_backend_cm:nnnn #1#2#3#4 + { + \__draw_backend_literal:n + { + [ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + 0 ~ 0 + ] ~ + concat + } + } +\cs_new_protected:Npn \__draw_backend_box_use:Nnnnn #1#2#3#4#5 + { + \__draw_backend_literal:n { @endspecial } + \__draw_backend_literal:n { [end] } + \__draw_backend_literal:n { [begin] } + \__draw_backend_literal:n { save } + \__draw_backend_literal:n { currentpoint } + \__draw_backend_literal:n { currentpoint~translate } + \__draw_backend_cm:nnnn { 1 } { 0 } { 0 } { -1 } + \__draw_backend_cm:nnnn {#2} {#3} {#4} {#5} + \__draw_backend_cm:nnnn { 1 } { 0 } { 0 } { -1 } + \__draw_backend_literal:n { neg~exch~neg~exch~translate } + \__draw_backend_literal:n { [end] } + \hbox_overlap_right:n { \box_use:N #1 } + \__draw_backend_literal:n { [begin] } + \__draw_backend_literal:n { restore } + \__draw_backend_literal:n { [end] } + \__draw_backend_literal:n { [begin] } + \__draw_backend_literal:n { @beginspecial } + } +%% File: l3backend-graphics.dtx +\AtBeginDocument + { \cs_new_eq:NN \__graphics_backend_getbb_eps:n \graphics_read_bb:n } +\cs_new_protected:Npn \__graphics_backend_include_eps:n #1 + { + \__kernel_backend_literal:x + { + PSfile = #1 \c_space_tl + llx = \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + lly = \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + urx = \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + ury = \dim_to_decimal_in_bp:n \l_graphics_ury_dim + } + } +%% File: l3backend-pdf.dtx +\box_new:N \l__pdf_internal_box +\cs_new_protected:Npn \__pdf_backend_pdfmark:n #1 + { \__kernel_backend_postscript:n { mark #1 ~ pdfmark } } +\cs_generate_variant:Nn \__pdf_backend_pdfmark:n { x } +\cs_new_protected:Npn \__pdf_backend_catalog_gput:nn #1#2 + { \__pdf_backend_pdfmark:n { { Catalog } << /#1 ~ #2 >> /PUT } } +\cs_new_protected:Npn \__pdf_backend_info_gput:nn #1#2 + { \__pdf_backend_pdfmark:n { /#1 ~ #2 /DOCINFO } } +\int_new:N \g__pdf_backend_object_int +\prop_new:N \g__pdf_backend_object_prop +\cs_new_protected:Npn \__pdf_backend_object_new:nn #1#2 + { + \int_gincr:N \g__pdf_backend_object_int + \int_const:cn + { c__pdf_backend_object_ \tl_to_str:n {#1} _int } + { \g__pdf_backend_object_int } + \prop_gput:Nnn \g__pdf_backend_object_prop {#1} {#2} + } +\cs_new:Npn \__pdf_backend_object_ref:n #1 + { { pdf.obj \int_use:c { c__pdf_backend_object_ \tl_to_str:n {#1} _int } } } +\cs_new_protected:Npn \__pdf_backend_object_write:nn #1#2 + { + \__pdf_backend_pdfmark:x + { + /_objdef ~ \__pdf_backend_object_ref:n {#1} + /type + \str_case_e:nn + { \prop_item:Nn \g__pdf_backend_object_prop {#1} } + { + { array } { /array } + { dict } { /dict } + { fstream } { /stream } + { stream } { /stream } + } + /OBJ + } + \use:c + { __pdf_backend_object_write_ \prop_item:Nn \g__pdf_backend_object_prop {#1} :nn } + { \__pdf_backend_object_ref:n {#1} } {#2} + } +\cs_generate_variant:Nn \__pdf_backend_object_write:nn { nx } +\cs_new_protected:Npn \__pdf_backend_object_write_array:nn #1#2 + { + \__pdf_backend_pdfmark:x + { #1 [ ~ \exp_not:n {#2} ~ ] ~ /PUTINTERVAL } + } +\cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2 + { + \__pdf_backend_pdfmark:x + { #1 << \exp_not:n {#2} >> /PUT } + } +\cs_new_protected:Npn \__pdf_backend_object_write_stream:nn #1#2 + { + \exp_args:Nx + \__pdf_backend_object_write_stream:nnn {#1} #2 + } +\cs_new_protected:Npn \__pdf_backend_object_write_stream:nnn #1#2#3 + { + \__pdf_postscript:n + { + [nobreak] + mark ~ #1 ~ ( #3 ) /PUT ~ pdfmark ~ + mark ~ #1 ~ << #2 >> /PUT ~ pdfmark + } + } +\cs_new_protected:Npn \__pdf_backend_object_now:nn #1#2 + { + \int_gincr:N \g__pdf_backend_object_int + \__pdf_backend_pdfmark:x + { + /_objdef ~ { pdf.obj \int_use:N \g__pdf_backend_object_int } + /type + \str_case:nn + {#1} + { + { array } { /array } + { dict } { /dict } + { fstream } { /stream } + { stream } { /stream } + } + /OBJ + } + \exp_args:Nnx \use:c { __pdf_backend_object_write_ #1 :nn } + { { pdf.obj \int_use:N \g__pdf_backend_object_int } } {#2} + } +\cs_generate_variant:Nn \__pdf_backend_object_now:nn { nx } +\cs_new:Npn \__pdf_backend_object_last: + { { pdf.obj \int_use:N \g__pdf_backend_object_int } } +\__kernel_backend_postscript_header:n + { + true ~ setglobal ~ + /pdf.globaldict ~ 4 ~ dict ~ def ~ + false ~ setglobal + } +\__kernel_backend_postscript_header:n + { + /pdf.cvs { 65534 ~ string ~ cvs } def + /pdf.dvi.pt { 72.27 ~ mul ~ Resolution ~ div } def + /pdf.pt.dvi { 72.27 ~ div ~ Resolution ~ mul } def + /pdf.rect.ht { dup ~ 1 ~ get ~ neg ~ exch ~ 3 ~ get ~ add } def + } +\__kernel_backend_postscript_header:n + { + /pdf.linkmargin { 1 ~ pdf.pt.dvi } def + /pdf.linkdp.pad { 0 } def + /pdf.linkht.pad { 0 } def + } +\__kernel_backend_postscript_header:n + { + /pdf.rect + { /Rect [ pdf.llx ~ pdf.lly ~ pdf.urx ~ pdf.ury ] } def + /pdf.save.ll + { + currentpoint + /pdf.lly ~ exch ~ def + /pdf.llx ~ exch ~ def + } + def + /pdf.save.ur + { + currentpoint + /pdf.ury ~ exch ~ def + /pdf.urx ~ exch ~ def + } + def + /pdf.save.linkll + { + currentpoint ~ + pdf.linkmargin ~ add ~ + pdf.linkdp.pad ~ add + /pdf.lly ~ exch ~ def ~ + pdf.linkmargin ~ sub + /pdf.llx ~ exch ~ def + } + def + /pdf.save.linkur + { + currentpoint ~ + pdf.linkmargin ~ sub ~ + pdf.linkht.pad ~ sub + /pdf.ury ~ exch ~ def ~ + pdf.linkmargin ~ add + /pdf.urx ~ exch ~ def + } + def + } +\__kernel_backend_postscript_header:n + { + /pdf.dest.anchor + { + currentpoint ~ exch ~ + pdf.dvi.pt ~ 72 ~ add ~ + /pdf.dest.x ~ exch ~ def ~ + pdf.dvi.pt ~ + vsize ~ 72 ~ sub ~ exch ~ sub ~ + /pdf.dest.y ~ exch ~ def + } + def + /pdf.dest.point + { pdf.dest.x ~ pdf.dest.y } def + /pdf.dest2device + { + /pdf.dest.y ~ exch ~ def + /pdf.dest.x ~ exch ~ def ~ + matrix ~ currentmatrix ~ + matrix ~ defaultmatrix ~ + matrix ~ invertmatrix ~ + matrix ~ concatmatrix ~ + cvx ~ exec + /pdf.dev.y ~ exch ~ def + /pdf.dev.x ~ exch ~ def + /pdf.tmpd ~ exch ~ def + /pdf.tmpc ~ exch ~ def + /pdf.tmpb ~ exch ~ def + /pdf.tmpa ~ exch ~ def ~ + pdf.dest.x ~ pdf.tmpa ~ mul ~ + pdf.dest.y ~ pdf.tmpc ~ mul ~ add ~ + pdf.dev.x ~ add ~ + pdf.dest.x ~ pdf.tmpb ~ mul ~ + pdf.dest.y ~ pdf.tmpd ~ mul ~ add ~ + pdf.dev.y ~ add + } + def + } +\__kernel_backend_postscript_header:n + { + /pdf.bordertracking ~ false ~ def + /pdf.bordertracking.begin + { + SDict ~ /pdf.bordertracking ~ true ~ put ~ + SDict ~ /pdf.leftboundary ~ undef ~ + SDict ~ /pdf.rightboundary ~ undef ~ + /a ~ where + { + /a + { + currentpoint ~ pop ~ + SDict /pdf.rightboundary ~ known ~ dup + { + SDict /pdf.rightboundary ~ get ~ 2 ~ index ~ lt + { not } + if + } + if + { pop } + { SDict ~ exch /pdf.rightboundary ~ exch ~ put } + ifelse ~ + moveto ~ + currentpoint ~ pop ~ + SDict /pdf.leftboundary ~ known ~ dup + { + SDict /pdf.leftboundary ~ get ~ 2 ~ index ~ gt + { not } + if + } + if + { pop } + { SDict ~ exch /pdf.leftboundary ~ exch ~ put } + ifelse + } + put + } + if + } + def + /pdf.bordertracking.end + { + /a ~ where { /a { moveto } put } if + /x ~ where { /x { 0 ~ exch ~ rmoveto } put } if ~ + SDict /pdf.leftboundary ~ known + { pdf.outerbox ~ 0 ~ pdf.leftboundary ~ put } + if ~ + SDict /pdf.rightboundary ~ known + { pdf.outerbox ~ 2 ~ pdf.rightboundary ~ put } + if ~ + SDict /pdf.bordertracking ~ false ~ put + } + def + /pdf.bordertracking.endpage + { + pdf.bordertracking + { + pdf.bordertracking.end ~ + true ~ setglobal ~ + pdf.globaldict + /pdf.brokenlink.rect [ pdf.outerbox ~ aload ~ pop ] put ~ + pdf.globaldict + /pdf.brokenlink.skip ~ pdf.baselineskip ~ put ~ + pdf.globaldict + /pdf.brokenlink.dict ~ + pdf.link.dict ~ pdf.cvs ~ put ~ + false ~ setglobal ~ + mark ~ pdf.link.dict ~ cvx ~ exec ~ /Rect + [ + pdf.llx ~ + pdf.lly ~ + pdf.outerbox ~ 2 ~ get ~ pdf.linkmargin ~ add ~ + currentpoint ~ exch ~ pop ~ + pdf.outerbox ~ pdf.rect.ht ~ sub ~ pdf.linkmargin ~ sub + ] + /ANN ~ pdf.pdfmark + } + if + } + def + /pdf.bordertracking.continue + { + /pdf.link.dict ~ pdf.globaldict + /pdf.brokenlink.dict ~ get ~ def + /pdf.outerbox ~ pdf.globaldict + /pdf.brokenlink.rect ~ get ~ def + /pdf.baselineskip ~ pdf.globaldict + /pdf.brokenlink.skip ~ get ~ def ~ + pdf.globaldict ~ dup ~ dup + /pdf.brokenlink.dict ~ undef + /pdf.brokenlink.skip ~ undef + /pdf.brokenlink.rect ~ undef ~ + currentpoint + /pdf.originy ~ exch ~ def + /pdf.originx ~ exch ~ def + /a ~ where + { + /a + { + moveto ~ + SDict ~ + begin ~ + currentpoint ~ pdf.originy ~ ne ~ exch ~ + pdf.originx ~ ne ~ or + { + pdf.save.linkll + /pdf.lly ~ + pdf.lly ~ pdf.outerbox ~ 1 ~ get ~ sub ~ def ~ + pdf.bordertracking.begin + } + if ~ + end + } + put + } + if + /x ~ where + { + /x + { + 0 ~ exch ~ rmoveto ~ + SDict~ + begin ~ + currentpoint ~ + pdf.originy ~ ne ~ exch ~ pdf.originx ~ ne ~ or + { + pdf.save.linkll + /pdf.lly ~ + pdf.lly ~ pdf.outerbox ~ 1 ~ get ~ sub ~ def ~ + pdf.bordertracking.begin + } + if ~ + end + } + put + } + if + } + def + } +\__kernel_backend_postscript_header:n + { + /pdf.breaklink + { + pop ~ + counttomark ~ 2 ~ mod ~ 0 ~ eq + { + counttomark /pdf.count ~ exch ~ def + { + pdf.count ~ 0 ~ eq { exit } if ~ + counttomark ~ 2 ~ roll ~ + 1 ~ index ~ /Rect ~ eq + { + dup ~ 4 ~ array ~ copy ~ + dup ~ dup ~ + 1 ~ get ~ + pdf.outerbox ~ pdf.rect.ht ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ sub ~ + 3 ~ exch ~ put ~ + dup ~ + pdf.outerbox ~ 2 ~ get ~ + pdf.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + pdf.outerbox ~ pdf.rect.ht ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ add ~ + 1 ~ exch ~ put + /pdf.currentrect ~ exch ~ def ~ + pdf.breaklink.write + { + pdf.currentrect ~ + dup ~ + pdf.outerbox ~ 0 ~ get ~ + pdf.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ + pdf.outerbox ~ 2 ~ get ~ + pdf.linkmargin ~ add ~ + 2 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + pdf.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + pdf.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + /pdf.currentrect ~ exch ~ def ~ + pdf.breaklink.write + } + 1 ~ index ~ 3 ~ get ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ + pdf.outerbox ~ pdf.rect.ht ~ add ~ + 2 ~ index ~ 1 ~ get ~ sub ~ + pdf.baselineskip ~ div ~ round ~ cvi ~ 1 ~ sub ~ + exch ~ + repeat ~ + pdf.currentrect ~ + dup ~ + pdf.outerbox ~ 0 ~ get ~ + pdf.linkmargin ~ sub ~ + 0 ~ exch ~ put ~ + dup ~ dup ~ + 1 ~ get ~ + pdf.baselineskip ~ add ~ + 1 ~ exch ~ put ~ + dup ~ dup ~ + 3 ~ get ~ + pdf.baselineskip ~ add ~ + 3 ~ exch ~ put ~ + dup ~ 2 ~ index ~ 2 ~ get ~ 2 ~ exch ~ put + /pdf.currentrect ~ exch ~ def ~ + pdf.breaklink.write ~ + SDict /pdf.pdfmark.good ~ false ~ put ~ + exit + } + { pdf.count ~ 2 ~ sub /pdf.count ~ exch ~ def } + ifelse + } + loop + } + if + /ANN + } + def + /pdf.breaklink.write + { + counttomark ~ 1 ~ sub ~ + index /_objdef ~ eq + { + counttomark ~ -2 ~ roll ~ + dup ~ wcheck ~ + { + readonly ~ + counttomark ~ 2 ~ roll + } + { pop ~ pop } + ifelse + } + if ~ + counttomark ~ 1 ~ add ~ copy ~ + pop ~ pdf.currentrect + /ANN ~ pdfmark + } + def + } +\__kernel_backend_postscript_header:n + { + /pdf.pdfmark + { + SDict /pdf.pdfmark.good ~ true ~ put ~ + dup /ANN ~ eq + { + pdf.pdfmark.store ~ + pdf.pdfmark.dict ~ + begin ~ + Subtype /Link ~ eq ~ + currentdict /Rect ~ known ~ and ~ + SDict /pdf.outerbox ~ known ~ and ~ + SDict /pdf.baselineskip ~ known ~ and ~ + { + Rect ~ 3 ~ get ~ + pdf.linkmargin ~ 2 ~ mul ~ add ~ + pdf.outerbox ~ pdf.rect.ht ~ add ~ + Rect ~ 1 ~ get ~ sub ~ + pdf.baselineskip ~ div ~ round ~ cvi ~ 0 ~ gt + { pdf.breaklink } + if + } + if ~ + end ~ + SDict /pdf.outerbox ~ undef ~ + SDict /pdf.baselineskip ~ undef ~ + currentdict /pdf.pdfmark.dict ~ undef ~ + } + if ~ + pdf.pdfmark.good + { pdfmark } + { cleartomark } + ifelse + } + def + /pdf.pdfmark.store + { + /pdf.pdfmark.dict ~ 65534 ~ dict ~ def ~ + counttomark ~ 1 ~ add ~ copy ~ + pop + { + dup ~ mark ~ eq + { + pop ~ + exit + } + { + pdf.pdfmark.dict ~ + begin ~ def ~ end + } + ifelse + } + loop + } + def + } +\box_new:N \l__pdf_backend_content_box +\box_new:N \l__pdf_backend_model_box +\int_new:N \g__pdf_backend_annotation_int +\cs_new_protected:Npn \__pdf_backend_annotation:nnnn #1#2#3#4 + { + \__pdf_backend_annotation_aux:nnnn {#1} {#2} {#3} {#4} + \int_gincr:N \g__pdf_backend_object_int + \int_gset_eq:NN \g__pdf_backend_annotation_int \g__pdf_backend_object_int + \__pdf_backend_pdfmark:x + { + + /_objdef { pdf.obj \int_use:N \g__pdf_backend_object_int } + pdf.rect ~ + #4 ~ + /ANN + } + } +\cs_new_protected:Npn \__pdf_backend_annotation_aux:nnnn #1#2#3#4 + { + \box_move_down:nn {#3} + { \hbox:n { \__pdf_postscript:n { pdf.save.ll } } } + \hbox:n {#4} + \box_move_up:nn {#2} + { + \hbox:n + { + \tex_kern:D \dim_eval:n {#1} \scan_stop: + \__pdf_postscript:n { pdf.save.ur } + } + } + \int_gincr:N \g__pdf_backend_object_int + \int_gset_eq:NN \g__pdf_backend_annotation_int \g__pdf_backend_object_int + \__pdf_backend_pdfmark:x + { + /_objdef { pdf.obj \int_use:N \g__pdf_backend_object_int } + pdf.rect + /ANN + } + } +\cs_new:Npn \__pdf_backend_annotation_last: + { { pdf.obj \int_use:N \g__pdf_backend_annotation_int } } +\int_new:N \g__pdf_backend_link_int +\tl_new:N \g__pdf_backend_link_dict_tl +\int_new:N \g__pdf_backend_link_sf_int +\bool_new:N \g__pdf_backend_link_math_bool +\bool_new:N \g__pdf_backend_link_bool +\tl_new:N \l__pdf_breaklink_pdfmark_tl +\tl_set:Nn \l__pdf_breaklink_pdfmark_tl { pdfmark } +\cs_new_protected:Npn \__pdf_breaklink_postscript:n #1 { } +\cs_new_eq:NN \__pdf_breaklink_usebox:N \box_use:N +\cs_new_protected:Npn \__pdf_backend_link_begin_goto:nnw #1#2 + { \__pdf_backend_link_begin:nw { #1 /Subtype /Link /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \__pdf_backend_link_begin_user:nnw #1#2 + { \__pdf_backend_link_begin:nw {#1#2} } +\cs_new_protected:Npn \__pdf_backend_link_begin:nw #1 + { + \bool_if:NF \g__pdf_backend_link_bool + { \__pdf_backend_link_begin_aux:nw {#1} } + } +\cs_new_protected:Npn \__pdf_backend_link_begin_aux:nw #1 + { + \bool_gset_true:N \g__pdf_backend_link_bool + \__pdf_postscript:n + { /pdf.link.dict ( #1 ) def } + \tl_gset:Nn \g__pdf_backend_link_dict_tl {#1} + \__pdf_backend_link_sf_save: + \mode_if_math:TF + { \bool_gset_true:N \g__pdf_backend_link_math_bool } + { \bool_gset_false:N \g__pdf_backend_link_math_bool } + \hbox_set:Nw \l__pdf_backend_content_box + \__pdf_backend_link_sf_restore: + \bool_if:NT \g__pdf_backend_link_math_bool + { \c_math_toggle_token } + } +\cs_new_protected:Npn \__pdf_backend_link_end: + { + \bool_if:NT \g__pdf_backend_link_bool + { \__pdf_backend_link_end_aux: } + } +\cs_new_protected:Npn \__pdf_backend_link_end_aux: + { + \bool_if:NT \g__pdf_backend_link_math_bool + { \c_math_toggle_token } + \__pdf_backend_link_sf_save: + \hbox_set_end: + \__pdf_backend_link_minima: + \hbox_set:Nn \l__pdf_backend_model_box { Gg } + \exp_args:Nx \__pdf_backend_link_outerbox:n + { + \int_if_odd:nTF { \value { page } } + { \oddsidemargin } + { \evensidemargin } + } + \box_move_down:nn { \box_dp:N \l__pdf_backend_content_box } + { \hbox:n { \__pdf_postscript:n { pdf.save.linkll } } } + \__pdf_breaklink_postscript:n { pdf.bordertracking.begin } + \__pdf_breaklink_usebox:N \l__pdf_backend_content_box + \__pdf_breaklink_postscript:n { pdf.bordertracking.end } + \box_move_up:nn { \box_ht:N \l__pdf_backend_content_box } + { + \hbox:n + { \__pdf_postscript:n { pdf.save.linkur } } + } + \int_gincr:N \g__pdf_backend_object_int + \int_gset_eq:NN \g__pdf_backend_link_int \g__pdf_backend_object_int + \__pdf_postscript:x + { + mark + /_objdef { pdf.obj \int_use:N \g__pdf_backend_link_int } + \g__pdf_backend_link_dict_tl \c_space_tl + pdf.rect + /ANN ~ \l__pdf_breaklink_pdfmark_tl + } + \__pdf_backend_link_sf_restore: + \bool_gset_false:N \g__pdf_backend_link_bool + } +\cs_new_protected:Npn \__pdf_backend_link_minima: + { + \hbox_set:Nn \l__pdf_backend_model_box { Gg } + \__pdf_postscript:x + { + /pdf.linkdp.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_dp:N \l__pdf_backend_model_box + - \box_dp:N \l__pdf_backend_content_box + } + { 0pt } + } ~ + pdf.pt.dvi ~ def + /pdf.linkht.pad ~ + \dim_to_decimal:n + { + \dim_max:nn + { + \box_ht:N \l__pdf_backend_model_box + - \box_ht:N \l__pdf_backend_content_box + } + { 0pt } + } ~ + pdf.pt.dvi ~ def + } + } +\cs_new_protected:Npn \__pdf_backend_link_outerbox:n #1 + { + \__pdf_postscript:x + { + /pdf.outerbox + [ + \dim_to_decimal:n {#1} ~ + \dim_to_decimal:n { -\box_dp:N \l__pdf_backend_model_box } ~ + \dim_to_decimal:n { #1 + \textwidth } ~ + \dim_to_decimal:n { \box_ht:N \l__pdf_backend_model_box } + ] + [ exch { pdf.pt.dvi } forall ] def + /pdf.baselineskip ~ + \dim_to_decimal:n { \tex_baselineskip:D } ~ dup ~ 0 ~ gt + { pdf.pt.dvi ~ def } + { pop ~ pop } + ifelse + } + } +\cs_new_protected:Npn \__pdf_backend_link_sf_save: + { + \int_gset:Nn \g__pdf_backend_link_sf_int + { + \mode_if_horizontal:TF + { \tex_spacefactor:D } + { 0 } + } + } +\cs_new_protected:Npn \__pdf_backend_link_sf_restore: + { + \mode_if_horizontal:T + { + \int_compare:nNnT \g__pdf_backend_link_sf_int > { 0 } + { \int_set_eq:NN \tex_spacefactor:D \g__pdf_backend_link_sf_int } + } + } +\use_none:n + { + \cs_if_exist:NT \@makecol@hook + { + \tl_put_right:Nn \@makecol@hook + { + \box_if_empty:NF \@cclv + { + \vbox_set:Nn \@cclv + { + \__pdf_postscript:n + { + pdf.globaldict /pdf.brokenlink.rect ~ known + { pdf.bordertracking.continue } + if + } + \vbox_unpack_drop:N \@cclv + \__pdf_postscript:n + { pdf.bordertracking.endpage } + } + } + } + \tl_set:Nn \l__pdf_breaklink_pdfmark_tl { pdf.pdfmark } + \cs_set_eq:NN \__pdf_breaklink_postscript:n \__pdf_postscript:n + \cs_set_eq:NN \__pdf_breaklink_usebox:N \hbox_unpack:N + } + } +\cs_new:Npn \__pdf_backend_link_last: + { { pdf.obj \int_use:N \g__pdf_backend_link_int } } +\cs_new_protected:Npn \__pdf_backend_link_margin:n #1 + { + \__pdf_postscript:x + { + /pdf.linkmargin { \dim_to_decimal:n {#1} ~ pdf.pt.dvi } def + } + } +\cs_new_protected:Npn \__pdf_backend_destination:nn #1#2 + { + \__pdf_postscript:n { pdf.dest.anchor } + \__pdf_backend_pdfmark:x + { + /View + [ + \str_case:nnF {#2} + { + { xyz } { /XYZ ~ pdf.dest.point ~ null } + { fit } { /Fit } + { fitb } { /FitB } + { fitbh } { /FitBH ~ pdf.dest.y } + { fitbv } { /FitBV ~ pdf.dest.x } + { fith } { /FitH ~ pdf.dest.y } + { fitv } { /FitV ~ pdf.dest.x } + } + { + /XYZ ~ pdf.dest.point ~ \fp_eval:n { (#2) / 100 } + } + ] + /Dest ( \exp_not:n {#1} ) cvn + /DEST + } + } +\cs_new_protected:Npn \__pdf_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l__pdf_internal_box {#2} + \box_move_down:nn + { \box_dp:N \l__pdf_internal_box } + { \hbox:n { \__pdf_postscript:n { pdf.save.ll } } } + \box_use:N \l__pdf_internal_box + \box_move_up:nn + { \box_ht:N \l__pdf_internal_box } + { \hbox:n { \__pdf_postscript:n { pdf.save.ur } } } + \__pdf_backend_pdfmark:n + { + /View + [ + /FitR ~ + pdf.llx ~ pdf.lly ~ pdf.dest2device ~ + pdf.urx ~ pdf.ury ~ pdf.dest2device + ] + /Dest ( #1 ) cvn + /DEST + } + \group_end: + } +\cs_new_protected:Npn \__pdf_backend_compresslevel:n #1 { } +\cs_new_protected:Npn \__pdf_backend_compress_objects:n #1 { } +\cs_new_protected:Npn \__pdf_backend_version_major_gset:n #1 { } +\cs_new_protected:Npn \__pdf_backend_version_minor_gset:n #1 { } +\cs_new:Npn \__pdf_backend_version_major: { -1 } +\cs_new:Npn \__pdf_backend_version_minor: { -1 } +\cs_new_protected:Npn \__pdf_backend_bdc:nn #1#2 + { \__pdf_backend_pdfmark:n { /#1 ~ #2 /BDC } } +\cs_new_protected:Npn \__pdf_backend_emc: + { \__pdf_backend_pdfmark:n { /EMC } } +%% +%% +%% End of file `l3backend-dvips.def'. diff --git a/Master/texmf-dist/tex/latex/l3backend/l3backend-dvisvgm.def b/Master/texmf-dist/tex/latex/l3backend/l3backend-dvisvgm.def new file mode 100644 index 00000000000..254169a1c6d --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3backend/l3backend-dvisvgm.def @@ -0,0 +1,504 @@ +%% +%% This is file `l3backend-dvisvgm.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3backend-basics.dtx (with options: `package,dvisvgm') +%% l3backend-color.dtx (with options: `package,dvisvgm') +%% l3backend-box.dtx (with options: `package,dvisvgm') +%% l3backend-draw.dtx (with options: `package,dvisvgm') +%% l3backend-graphics.dtx (with options: `package,dvisvgm') +%% l3backend-pdf.dtx (with options: `package,dvisvgm') +%% +%% 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 +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3backend bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: l3backend-basics.dtx +\ProvidesExplFile + {l3backend-dvisvgm.def}{2019-04-06}{} + {L3 Experimental backend support: dvisvgm} +\cs_new_eq:NN \__kernel_backend_literal:e \tex_special:D +\cs_new_protected:Npn \__kernel_backend_literal:n #1 + { \__kernel_backend_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \__kernel_backend_literal:n { x } +\cs_new_protected:Npn \__kernel_backend_literal_svg:n #1 + { \__kernel_backend_literal:n { dvisvgm:raw~ #1 { ?nl } } } +\cs_generate_variant:Nn \__kernel_backend_literal_svg:n { x } +\cs_new_protected:Npn \__kernel_backend_scope_begin: + { \__kernel_backend_literal_svg:n { <g> } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal_svg:n { </g> } } +\cs_new_protected:Npn \__kernel_backend_scope_begin:n #1 + { \__kernel_backend_literal_svg:n { <g~ #1 > } } +\cs_generate_variant:Nn \__kernel_backend_scope_begin:n { x } +%% File: l3backend-color.dtx +\cs_new_protected:Npn \__color_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \__color_backend_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_backend_pickup:w + { \current@color } \q_stop #1 + } + } + \cs_new_protected:Npn \__color_backend_pickup:w #1 ~ #2 \q_stop #3 + { \tl_set:Nn #3 { #1 ~ #2 } } + } + { } + } +\cs_new_protected:Npn \__color_backend_cmyk:nnnn #1#2#3#4 + { + \__color_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__color_backend_gray:n #1 + { \__color_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \__color_backend_rgb:nnn #1#2#3 + { + \__color_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \__color_backend_spot:nn #1#2 + { \__color_backend_select:n { #1 } } +\cs_new_protected:Npn \__color_backend_select:n #1 + { + \__kernel_backend_literal:n { color~push~ #1 } + \group_insert_after:N \__color_backend_reset: + } +\cs_generate_variant:Nn \__color_backend_select:n { x } +\cs_new_protected:Npn \__color_backend_reset: + { \__kernel_backend_literal:n { color~pop } } +%% File: l3backend-box.dtx +\cs_new_protected:Npn \__box_backend_clip:N #1 + { + \int_gincr:N \g__box_clip_path_int + \__kernel_backend_literal_svg:x + { < clipPath~id = " l3cp \int_use:N \g__box_clip_path_int " > } + \__kernel_backend_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 + " + /> + } + \__kernel_backend_literal_svg:n + { < /clipPath > } + \__kernel_backend_scope_begin:n + { + transform = + " + translate ( { ?x } , { ?y } ) ~ + scale ( 1 , -1 ) + " + } + \__kernel_backend_scope_begin:x + { + clip-path = + "url ( \c_hash_str l3cp \int_use:N \g__box_clip_path_int ) " + } + \__kernel_backend_scope_begin:n + { + transform = + " + scale ( -1 , 1 ) ~ + translate ( { ?x } , { ?y } ) ~ + scale ( -1 , -1 ) + " + } + \box_use:N #1 + \__kernel_backend_scope_end: + \__kernel_backend_scope_end: + \__kernel_backend_scope_end: + } +\int_new:N \g__box_clip_path_int +\cs_new_protected:Npn \__box_backend_rotate:Nn #1#2 + { + \__kernel_backend_scope_begin:x + { + transform = + " + rotate + ( \fp_eval:n { round ( -(#2) , 5 ) } , ~ { ?x } , ~ { ?y } ) + " + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +\cs_new_protected:Npn \__box_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_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 } + \__kernel_backend_scope_end: + } +%% File: l3backend-draw.dtx +\cs_new_eq:NN \__draw_backend_literal:n \__kernel_backend_literal_svg:n +\cs_generate_variant:Nn \__draw_backend_literal:n { x } +\cs_new_protected:Npn \__draw_backend_begin: + { + \__draw_backend_scope_begin: + \__draw_backend_scope:n { transform="translate({?x},{?y})~scale(1,-1)" } + } +\cs_new_protected:Npn \__draw_backend_end: + { \__draw_backend_scope_end: } +\cs_new_protected:Npn \__draw_backend_scope_begin: + { + \int_set_eq:NN + \l__draw_draw_scope_int + \g__draw_draw_scope_int + \group_begin: + \int_gzero:N \g__draw_draw_scope_int + } +\cs_new_protected:Npn \__draw_backend_scope_end: + { + \prg_replicate:nn + { \g__draw_draw_scope_int } + { \__draw_backend_literal:n { </g> } } + \group_end: + \int_gset_eq:NN + \g__draw_draw_scope_int + \l__draw_draw_scope_int + } +\cs_new_protected:Npn \__draw_backend_scope:n #1 + { + \__draw_backend_literal:n { <g~ #1 > } + \int_gincr:N \g__draw_draw_scope_int + } +\cs_generate_variant:Nn \__draw_backend_scope:n { x } +\int_new:N \g__draw_draw_scope_int +\int_new:N \l__draw_draw_scope_int +\cs_new_protected:Npn \__draw_backend_moveto:nn #1#2 + { + \__draw_backend_add_to_path:n + { M ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } + } +\cs_new_protected:Npn \__draw_backend_lineto:nn #1#2 + { + \__draw_backend_add_to_path:n + { L ~ \dim_to_decimal:n {#1} ~ \dim_to_decimal:n {#2} } + } +\cs_new_protected:Npn \__draw_backend_rectangle:nnnn #1#2#3#4 + { + \__draw_backend_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 \__draw_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \__draw_backend_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_backend_add_to_path:n #1 + { + \tl_gset:Nx \g__draw_draw_path_tl + { + \g__draw_draw_path_tl + \tl_if_empty:NF \g__draw_draw_path_tl { \c_space_tl } + #1 + } + } +\tl_new:N \g__draw_draw_path_tl +\cs_new_protected:Npn \__draw_backend_evenodd_rule: + { \__draw_backend_scope:n { fill-rule="evenodd" } } +\cs_new_protected:Npn \__draw_backend_nonzero_rule: + { \__draw_backend_scope:n { fill-rule="nonzero" } } +\cs_new_protected:Npn \__draw_backend_closepath: + { \__draw_backend_add_to_path:n { Z } } +\cs_new_protected:Npn \__draw_backend_path:n #1 + { + \bool_if:NTF \g__draw_draw_clip_bool + { + \int_gincr:N \g__draw_clip_path_int + \__draw_backend_literal:x + { + < clipPath~id = " l3cp \int_use:N \g__draw_clip_path_int " > + { ?nl } + <path~d=" \g__draw_draw_path_tl "/> { ?nl } + < /clipPath > { ? nl } + < + use~xlink:href = + "\c_hash_str l3path \int_use:N \g__draw_path_int " ~ + #1 + /> + } + \__draw_backend_scope:x + { + clip-path = + "url( \c_hash_str l3cp \int_use:N \g__draw_clip_path_int)" + } + } + { + \__draw_backend_literal:x + { <path ~ d=" \g__draw_draw_path_tl " ~ #1 /> } + } + \tl_gclear:N \g__draw_draw_path_tl + \bool_gset_false:N \g__draw_draw_clip_bool + } +\int_new:N \g__draw_path_int +\cs_new_protected:Npn \__draw_backend_stroke: + { \__draw_backend_path:n { style="fill:none" } } +\cs_new_protected:Npn \__draw_backend_closestroke: + { + \__draw_backend_closepath: + \__draw_backend_stroke: + } +\cs_new_protected:Npn \__draw_backend_fill: + { \__draw_backend_path:n { style="stroke:none" } } +\cs_new_protected:Npn \__draw_backend_fillstroke: + { \__draw_backend_path:n { } } +\cs_new_protected:Npn \__draw_backend_clip: + { \bool_gset_true:N \g__draw_draw_clip_bool } +\bool_new:N \g__draw_draw_clip_bool +\cs_new_protected:Npn \__draw_backend_discardpath: + { + \bool_if:NT \g__draw_draw_clip_bool + { + \int_gincr:N \g__draw_clip_path_int + \__draw_backend_literal:x + { + < clipPath~id = " l3cp \int_use:N \g__draw_clip_path_int " > + { ?nl } + <path~d=" \g__draw_draw_path_tl "/> { ?nl } + < /clipPath > + } + \__draw_backend_scope:x + { + clip-path = + "url( \c_hash_str l3cp \int_use:N \g__draw_clip_path_int)" + } + } + \tl_gclear:N \g__draw_draw_path_tl + \bool_gset_false:N \g__draw_draw_clip_bool + } +\cs_new_protected:Npn \__draw_backend_dash_pattern:nn #1#2 + { + \use:x + { + \__draw_backend_dash_aux:nn + { \clist_map_function:nn {#1} \__draw_backend_dash:n } + { \dim_to_decimal:n {#2} } + } + } +\cs_new:Npn \__draw_backend_dash:n #1 + { , \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \__draw_backend_dash_aux:nn #1#2 + { + \__draw_backend_scope:x + { + stroke-dasharray = + " + \tl_if_empty:oTF { \use_none:n #1 } + { none } + { \use_none:n #1 } + " ~ + stroke-offset=" #2 " + } + } +\cs_new_protected:Npn \__draw_backend_linewidth:n #1 + { \__draw_backend_scope:x { stroke-width=" \dim_to_decimal:n {#1} " } } +\cs_new_protected:Npn \__draw_backend_miterlimit:n #1 + { \__draw_backend_scope:x { stroke-miterlimit=" \fp_eval:n {#1} " } } +\cs_new_protected:Npn \__draw_backend_cap_butt: + { \__draw_backend_scope:n { stroke-linecap="butt" } } +\cs_new_protected:Npn \__draw_backend_cap_round: + { \__draw_backend_scope:n { stroke-linecap="round" } } +\cs_new_protected:Npn \__draw_backend_cap_rectangle: + { \__draw_backend_scope:n { stroke-linecap="square" } } +\cs_new_protected:Npn \__draw_backend_join_miter: + { \__draw_backend_scope:n { stroke-linejoin="miter" } } +\cs_new_protected:Npn \__draw_backend_join_round: + { \__draw_backend_scope:n { stroke-linejoin="round" } } +\cs_new_protected:Npn \__draw_backend_join_bevel: + { \__draw_backend_scope:n { stroke-linejoin="bevel" } } +\cs_new_protected:Npn \__draw_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \use:x + { + \__draw_backend_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_protected:Npn \__draw_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__draw_backend_color_fill_gray:n #1 + { + \use:x + { + \__draw_backend_color_gray_aux:n + { \fp_eval:n { 100 * (#1) } } + } + } +\cs_new_protected:Npn \__draw_backend_color_gray_aux:n #1 + { \__draw_backend_color_fill:nnn {#1} {#1} {#1} } +\cs_new_protected:Npn \__draw_backend_color_stroke_gray:n #1 + { \__draw_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \__draw_backend_color_fill_rgb:nnn #1#2#3 + { + \use:x + { + \__draw_backend_color_fill:nnn + { \fp_eval:n { 100 * (#1) } } + { \fp_eval:n { 100 * (#2) } } + { \fp_eval:n { 100 * (#3) } } + } + } +\cs_new_protected:Npn \__draw_backend_color_fill:nnn #1#2#3 + { + \__draw_backend_scope:x + { + fill = + " + rgb + ( + #1 \c_percent_str , + #2 \c_percent_str , + #3 \c_percent_str + ) + " + } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_rgb:nnn #1#2#3 + { + \__draw_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \__draw_backend_cm:nnnn #1#2#3#4 + { + \__draw_backend_scope:n + { + transform = + " + matrix + ( + \fp_eval:n {#1} , \fp_eval:n {#2} , + \fp_eval:n {#3} , \fp_eval:n {#4} , + 0pt , 0pt + ) + " + } + } +\cs_new_protected:Npn \__draw_backend_box_use:Nnnnn #1#2#3#4#5#6#7 + { + \__kernel_backend_scope_begin: + \__draw_backend_cm:nnnn {#2} {#3} {#4} {#5} + \__kernel_backend_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 + \__kernel_backend_literal_svg:n { </g> } + \__kernel_backend_scope_end: + } +%% File: l3backend-graphics.dtx +\AtBeginDocument + { + \cs_new_eq:NN \__graphics_backend_getbb_png:n \graphics_extract_bb:n + \cs_new_eq:NN \__graphics_backend_getbb_jpg:n \graphics_extract_bb:n + } +\cs_new_protected:Npn \__graphics_backend_include_png:n #1 + { + \__kernel_backend_literal:x + { + dvisvgm:img~ + \dim_to_decimal:n { \l_graphics_ury_dim } ~ + \dim_to_decimal:n { \l_graphics_ury_dim } ~ + \__graphics_backend_include_bitmap_quote:w #1 " #1 " \q_stop + } + } +\cs_new_eq:NN \__graphics_backend_include_jpg:n \__graphics_backend_include_png:n +\cs_new:Npn \__graphics_backend_include_bitmap_quote:w #1 " #2 " #3 \q_stop + { " #2 " } +%% File: l3backend-pdf.dtx +\box_new:N \l__pdf_internal_box +\cs_new_protected:Npn \__pdf_backend_catalog_gput:nn #1#2 { } +\cs_new_protected:Npn \__pdf_backend_info_gput:nn #1#2 { } +\cs_new_protected:Npn \__pdf_backend_object_new:nn #1#2 { } +\cs_new:Npn \__pdf_backend_object_ref:n #1 { } +\cs_new_protected:Npn \__pdf_backend_object_write:nn #1#2 { } +\cs_new_protected:Npn \__pdf_backend_object_write:nx #1#2 { } +\cs_new_protected:Npn \__pdf_backend_object_now:nn #1#2 { } +\cs_new_protected:Npn \__pdf_backend_object_now:nx #1#2 { } +\cs_new:Npn \__pdf_backend_object_last: { } +\cs_new_protected:Npn \__pdf_backend_compresslevel:n #1 { } +\cs_new_protected:Npn \__pdf_backend_compress_objects:n #1 { } +\cs_new_protected:Npn \__pdf_backend_version_major_gset:n #1 { } +\cs_new_protected:Npn \__pdf_backend_version_minor_gset:n #1 { } +\cs_new:Npn \__pdf_backend_version_major: { -1 } +\cs_new:Npn \__pdf_backend_version_minor: { -1 } +\cs_new_protected:Npn \__pdf_backend_bdc:nn #1#2 { } +\cs_new_protected:Npn \__pdf_backend_emc: { } +%% +%% +%% End of file `l3backend-dvisvgm.def'. diff --git a/Master/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def b/Master/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def new file mode 100644 index 00000000000..111678846c4 --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def @@ -0,0 +1,752 @@ +%% +%% This is file `l3backend-pdfmode.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3backend-basics.dtx (with options: `package,pdfmode') +%% l3backend-color.dtx (with options: `package,pdfmode') +%% l3backend-box.dtx (with options: `package,pdfmode') +%% l3backend-draw.dtx (with options: `package,pdfmode') +%% l3backend-graphics.dtx (with options: `package,pdfmode') +%% l3backend-pdf.dtx (with options: `package,pdfmode') +%% +%% 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 +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3backend bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: l3backend-basics.dtx +\ProvidesExplFile + {l3backend-pdfmode.def}{2019-04-06}{} + {L3 Experimental backend support: PDF mode} +\cs_new_eq:NN \__kernel_backend_literal:e \tex_special:D +\cs_new_protected:Npn \__kernel_backend_literal:n #1 + { \__kernel_backend_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \__kernel_backend_literal:n { x } +\cs_new_protected:Npx \__kernel_backend_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 \__kernel_backend_literal_pdf:n { x } +\cs_new_protected:Npx \__kernel_backend_literal_page:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D literal ~ } + { \tex_pdfliteral:D } + page + { \exp_not:N \exp_not:n {#1} } + } +\cs_new_protected:Npx \__kernel_backend_scope_begin: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D save \scan_stop: } + { \tex_pdfsave:D } + } +\cs_new_protected:Npx \__kernel_backend_scope_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D restore \scan_stop: } + { \tex_pdfrestore:D } + } +\cs_new_protected:Npx \__kernel_backend_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 \__kernel_backend_matrix:n { x } +%% File: l3backend-color.dtx +\cs_new_protected:Npn \__color_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \__color_backend_pickup:N #1 + { + \exp_last_unbraced:Nx \__color_backend_pickup:w + { \current@color } ~ 0 ~ 0 ~ 0 \q_stop #1 + } + \cs_new_protected:Npn \__color_backend_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 } + } + } + } + } + } + } + { } + } +\int_new:N \l__kernel_color_stack_int +\cs_new_protected:Npn \__color_backend_cmyk:nnnn #1#2#3#4 + { + \use:x + { + \__color_backend_cmyk_aux:nnnn + { \fp_eval:n {#1} } + { \fp_eval:n {#2} } + { \fp_eval:n {#3} } + { \fp_eval:n {#4} } + } + } +\cs_new_protected:Npn \__color_backend_cmyk_aux:nnnn #1#2#3#4 + { + \__color_backend_select:n + { #1 ~ #2 ~ #3 ~ #4 ~ k ~ #1 ~ #2 ~ #3 ~ #4 ~ K } + } +\cs_new_protected:Npn \__color_backend_gray:n #1 + { \exp_args:Nx \__color_backend_gray_aux:n { \fp_eval:n {#1} } } +\cs_new_protected:Npn \__color_backend_gray_aux:n #1 + { \__color_backend_select:n { #1 ~ g ~ #1 ~ G } } +\cs_new_protected:Npn \__color_backend_rgb:nnn #1#2#3 + { + \use:x + { + \__color_backend_rgb_aux:nnn + { \fp_eval:n {#1} } + { \fp_eval:n {#2} } + { \fp_eval:n {#3} } + } + } +\cs_new_protected:Npn \__color_backend_rgb_aux:nnn #1#2#3 + { \__color_backend_select:n { #1 ~ #2 ~ #3 ~ rg ~ #1 ~ #2 ~ #3 ~ RG } } +\cs_new_protected:Npn \__color_backend_spot:nn #1#2 + { \__color_backend_select:n { /#1 ~ cs ~ /#1 ~ CS ~ #2 ~ sc ~ #2 ~ SC } } +\cs_new_protected:Npx \__color_backend_select:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int push {#1} + \group_insert_after:N \exp_not:N \__color_backend_reset: + } +\cs_generate_variant:Nn \__color_backend_select:n { x } +\cs_new_protected:Npx \__color_backend_reset: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int pop \scan_stop: + } +%% File: l3backend-box.dtx +\cs_new_protected:Npn \__box_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_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 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +\cs_new_protected:Npn \__box_backend_rotate:Nn #1#2 + { \exp_args:NNf \__box_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \__box_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \box_set_wd:Nn #1 { 0pt } + \fp_set:Nn \l__box_backend_cos_fp { round ( cosd ( #2 ) , 5 ) } + \fp_compare:nNnT \l__box_backend_cos_fp = \c_zero_fp + { \fp_zero:N \l__box_backend_cos_fp } + \fp_set:Nn \l__box_backend_sin_fp { round ( sind ( #2 ) , 5 ) } + \__kernel_backend_matrix:x + { + \fp_use:N \l__box_backend_cos_fp \c_space_tl + \fp_compare:nNnTF \l__box_backend_sin_fp = \c_zero_fp + { 0~0 } + { + \fp_use:N \l__box_backend_sin_fp + \c_space_tl + \fp_eval:n { -\l__box_backend_sin_fp } + } + \c_space_tl + \fp_use:N \l__box_backend_cos_fp + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +\fp_new:N \l__box_backend_cos_fp +\fp_new:N \l__box_backend_sin_fp +\cs_new_protected:Npn \__box_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_matrix:x + { + \fp_eval:n { round ( #2 , 5 ) } ~ + 0~0~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +%% File: l3backend-draw.dtx +\cs_new_eq:NN \__draw_backend_literal:n \__kernel_backend_literal_pdf:n +\cs_generate_variant:Nn \__draw_backend_literal:n { x } +\cs_new_protected:Npn \__draw_backend_begin: + { \__draw_backend_scope_begin: } +\cs_new_protected:Npn \__draw_backend_end: + { \__draw_backend_scope_end: } +\cs_new_eq:NN \__draw_backend_scope_begin: \__kernel_backend_scope_begin: +\cs_new_eq:NN \__draw_backend_scope_end: \__kernel_backend_scope_end: +\cs_new_protected:Npn \__draw_backend_moveto:nn #1#2 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } + } +\cs_new_protected:Npn \__draw_backend_lineto:nn #1#2 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } + } +\cs_new_protected:Npn \__draw_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \__draw_backend_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 \__draw_backend_rectangle:nnnn #1#2#3#4 + { + \__draw_backend_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 \__draw_backend_evenodd_rule: + { \bool_gset_true:N \g__draw_draw_eor_bool } +\cs_new_protected:Npn \__draw_backend_nonzero_rule: + { \bool_gset_false:N \g__draw_draw_eor_bool } +\bool_new:N \g__draw_draw_eor_bool +\cs_new_protected:Npn \__draw_backend_closepath: + { \__draw_backend_literal:n { h } } +\cs_new_protected:Npn \__draw_backend_stroke: + { \__draw_backend_literal:n { S } } +\cs_new_protected:Npn \__draw_backend_closestroke: + { \__draw_backend_literal:n { s } } +\cs_new_protected:Npn \__draw_backend_fill: + { + \__draw_backend_literal:x + { f \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_fillstroke: + { + \__draw_backend_literal:x + { B \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_clip: + { + \__draw_backend_literal:x + { W \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_discardpath: + { \__draw_backend_literal:n { n } } +\cs_new_protected:Npn \__draw_backend_dash_pattern:nn #1#2 + { + \__draw_backend_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \__draw_backend_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ d + } + } +\cs_new:Npn \__draw_backend_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \__draw_backend_linewidth:n #1 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ w } + } +\cs_new_protected:Npn \__draw_backend_miterlimit:n #1 + { \__draw_backend_literal:x { \fp_eval:n {#1} ~ M } } +\cs_new_protected:Npn \__draw_backend_cap_butt: + { \__draw_backend_literal:n { 0 ~ J } } +\cs_new_protected:Npn \__draw_backend_cap_round: + { \__draw_backend_literal:n { 1 ~ J } } +\cs_new_protected:Npn \__draw_backend_cap_rectangle: + { \__draw_backend_literal:n { 2 ~ J } } +\cs_new_protected:Npn \__draw_backend_join_miter: + { \__draw_backend_literal:n { 0 ~ j } } +\cs_new_protected:Npn \__draw_backend_join_round: + { \__draw_backend_literal:n { 1 ~ j } } +\cs_new_protected:Npn \__draw_backend_join_bevel: + { \__draw_backend_literal:n { 2 ~ j } } +\cs_new_protected:Npn \__draw_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \__draw_backend_color_fill_gray:n #1 + { \__draw_backend_color_select:x { \fp_eval:n {#1} ~ g } } +\cs_new_protected:Npn \__draw_backend_color_stroke_gray:n #1 + { \__draw_backend_color_select:x { \fp_eval:n {#1} ~ G } } +\cs_new_protected:Npn \__draw_backend_color_fill_rgb:nnn #1#2#3 + { + \__draw_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_rgb:nnn #1#2#3 + { + \__draw_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } + } +\cs_new_protected:Npx \__draw_backend_color_select:n #1 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int push {#1} + \group_insert_after:N \exp_not:N \__draw_backend_color_reset: + } +\cs_new_protected:Npx \__draw_backend_color_reset: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D colorstack } + { \tex_pdfcolorstack:D } + \exp_not:N \l__kernel_color_stack_int pop \scan_stop: + } +\cs_generate_variant:Nn \__draw_backend_color_select:n { x } +\cs_new_protected:Npn \__draw_backend_cm:nnnn #1#2#3#4 + { + \__kernel_backend_matrix:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__draw_backend_box_use:Nnnnn #1#2#3#4#5 + { + \__kernel_backend_scope_begin: + \__draw_backend_cm:nnnn {#2} {#3} {#4} {#5} + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +%% File: l3backend-graphics.dtx +\tl_new:N \l__graphics_graphics_attr_tl +\cs_new_protected:Npn \__graphics_backend_getbb_jpg:n #1 + { + \int_zero:N \l_graphics_page_int + \tl_clear:N \l_graphics_pagebox_tl + \tl_set:Nx \l__graphics_graphics_attr_tl + { + \tl_if_empty:NF \l_graphics_decodearray_tl + { :D \l_graphics_decodearray_tl } + \bool_if:NT \l_graphics_interpolate_bool + { :I } + } + \tl_clear:N \l__graphics_graphics_attr_tl + \__graphics_backend_getbb_auxi:n {#1} + } +\cs_new_eq:NN \__graphics_backend_getbb_png:n \__graphics_backend_getbb_jpg:n +\cs_new_protected:Npn \__graphics_backend_getbb_pdf:n #1 + { + \tl_clear:N \l_graphics_decodearray_tl + \bool_set_false:N \l_graphics_interpolate_bool + \tl_set:Nx \l__graphics_graphics_attr_tl + { + : \l_graphics_pagebox_tl + \int_compare:nNnT \l_graphics_page_int > 1 + { :P \int_use:N \l_graphics_page_int } + } + \__graphics_backend_getbb_auxi:n {#1} + } +\cs_new_protected:Npn \__graphics_backend_getbb_auxi:n #1 + { + \graphics_bb_restore:xF { #1 \l__graphics_graphics_attr_tl } + { \__graphics_backend_getbb_auxii:n {#1} } + } +\cs_new_protected:Npn \__graphics_backend_getbb_auxii:n #1 + { + \tex_immediate:D \tex_pdfximage:D + \bool_lazy_or:nnT + { \l_graphics_interpolate_bool } + { ! \tl_if_empty_p:N \l_graphics_decodearray_tl } + { + attr ~ + { + \tl_if_empty:NF \l_graphics_decodearray_tl + { /Decode~[ \l_graphics_decodearray_tl ] } + \bool_if:NT \l_graphics_interpolate_bool + { /Interpolate~true } + } + } + \int_compare:nNnT \l_graphics_page_int > 0 + { page ~ \int_use:N \l_graphics_page_int } + \tl_if_empty:NF \l_graphics_pagebox_tl + { \l_graphics_pagebox_tl } + {#1} + \hbox_set:Nn \l__graphics_internal_box + { \tex_pdfrefximage:D \tex_pdflastximage:D } + \dim_set:Nn \l_graphics_urx_dim { \box_wd:N \l__graphics_internal_box } + \dim_set:Nn \l_graphics_ury_dim { \box_ht:N \l__graphics_internal_box } + \int_const:cn { c__graphics_graphics_ #1 \l__graphics_graphics_attr_tl _int } + { \tex_the:D \tex_pdflastximage:D } + \graphics_bb_save:x { #1 \l__graphics_graphics_attr_tl } + } +\cs_new_protected:Npn \__graphics_backend_include_jpg:n #1 + { + \tex_pdfrefximage:D + \int_use:c { c__graphics_graphics_ #1 \l__graphics_graphics_attr_tl _int } + } +\cs_new_eq:NN \__graphics_backend_include_pdf:n \__graphics_backend_include_jpg:n +\cs_new_eq:NN \__graphics_backend_include_png:n \__graphics_backend_include_jpg:n +\sys_if_shell:T + { + \str_new:N \l__graphics_backend_dir_str + \str_new:N \l__graphics_backend_name_str + \str_new:N \l__graphics_backend_ext_str + \cs_new_protected:Npn \__graphics_backend_getbb_eps:n #1 + { + \file_parse_full_name:nNNN {#1} + \l__graphics_backend_dir_str + \l__graphics_backend_name_str + \l__graphics_backend_ext_str + \exp_args:Nx \__graphics_backend_getbb_eps:nn + { + \l__graphics_backend_name_str - \str_tail:N \l__graphics_backend_ext_str + -converted-to.pdf + } + {#1} + } + \cs_new_protected:Npn \__graphics_backend_getbb_eps:nn #1#2 + { + \file_compare_timestamp:nNnT {#2} > {#1} + { + \sys_shell_now:n + { repstopdf ~ #2 ~ #1 } + } + \tl_set:Nn \l_graphics_name_tl {#1} + \__graphics_backend_getbb_pdf:n {#1} + } + \cs_new_protected:Npn \__graphics_backend_include_eps:n #1 + { + \file_parse_full_name:nNNN {#1} + \l__graphics_backend_dir_str \l__graphics_backend_name_str \l__graphics_backend_ext_str + \exp_args:Nx \__graphics_backend_include_pdf:n + { + \l__graphics_backend_name_str - \str_tail:N \l__graphics_backend_ext_str + -converted-to.pdf + } + } + } +%% File: l3backend-pdf.dtx +\box_new:N \l__pdf_internal_box +\cs_new_protected:Npx \__pdf_backend_annotation:nnnn #1#2#3#4 + { + \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 \__pdf_backend_annotation_last: + { + \exp_not:N \int_value:w + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastannot ~ } + { \exp_not:N \tex_pdflastannot:D } + \c_space_tl 0 ~ R + } +\cs_new_protected:Npn \__pdf_backend_link_begin_goto:nnw #1#2 + { \__pdf_backend_link_begin:nnnw {#1} { goto~name } {#2} } +\cs_new_protected:Npn \__pdf_backend_link_begin_user:nnw #1#2 + { \__pdf_backend_link_begin:nnnw {#1} { user } {#2} } +\cs_new_protected:Npx \__pdf_backend_link_begin:nnnw #1#2#3 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D startlink ~ } + { \tex_pdfstartlink:D } + attr {#1} + #2 {#3} + } +\cs_new_protected:Npx \__pdf_backend_link_end: + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D endlink \scan_stop: } + { \tex_pdfendlink:D } + } +\cs_new:Npx \__pdf_backend_link_last: + { + \exp_not:N \int_value:w + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastlink ~ } + { \exp_not:N \tex_pdflastlink:D } + \c_space_tl 0 ~ R + } +\cs_new_protected:Npx \__pdf_backend_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: + } +\cs_new_protected:Npx \__pdf_backend_destination:nn #1#2 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \exp_not:N \tex_pdfextension:D dest ~ } + { \exp_not:N \tex_pdfdest:D } + name {#1} + \exp_not:N \str_case:nnF {#2} + { + { xyz } { xyz } + { fit } { fit } + { fitb } { fitb } + { fitbh } { fitbh } + { fitbv } { fitbv } + { fith } { fith } + { fitv } { fitv } + } + { xyz ~ zoom \exp_not:N \fp_eval:n { #2 * 10 } } + \scan_stop: + } +\cs_new_protected:Npx \__pdf_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l__pdf_internal_box {#2} + \cs_if_exist:NTF \tex_pdfextension:D + { \exp_not:N \tex_pdfextension:D dest ~ } + { \exp_not:N \tex_pdfdest:D } + name {#1} + fitr ~ + width \exp_not:N \box_wd:N \l__pdf_internal_box + height \exp_not:N \box_ht:N \l__pdf_internal_box + depth \exp_not:N \box_dp:N \l__pdf_internal_box + \box_use:N \l__pdf_internal_box + \group_end: + } +\cs_new_protected:Npx \__pdf_backend_catalog_gput:nn #1#2 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D catalog } + { \tex_pdfcatalog:D } + { / #1 ~ #2 } + } +\cs_new_protected:Npx \__pdf_backend_info_gput:nn #1#2 + { + \cs_if_exist:NTF \tex_pdfextension:D + { \tex_pdfextension:D info } + { \tex_pdfinfo:D } + { / #1 ~ #2 } + } +\prop_new:N \g__pdf_backend_object_prop +\group_begin: + \cs_set_protected:Npn \__pdf_tmp:w #1#2 + { + \cs_new_protected:Npx \__pdf_backend_object_new:nn ##1##2 + { + #1 reserveobjnum ~ + \int_const:cn + { c__pdf_backend_object_ \exp_not:N \tl_to_str:n {##1} _int } + {#2} + \prop_gput:Nnn \exp_not:N \g__pdf_backend_object_prop {##1} {##2} + } + } + \cs_if_exist:NTF \tex_pdfextension:D + { + \__pdf_tmp:w + { \tex_pdfextension:D obj ~ } + { \exp_not:N \tex_pdffeedback:D lastobj } + } + { \__pdf_tmp:w { \tex_pdfobj:D } { \tex_pdflastobj:D } } +\group_end: +\cs_new:Npn \__pdf_backend_object_ref:n #1 + { \int_use:c { c__pdf_backend_object_ \tl_to_str:n {#1} _int } ~ 0 ~ R } +\group_begin: + \cs_set_protected:Npn \__pdf_tmp:w #1 + { + \cs_new_protected:Npn \__pdf_backend_object_write:nn ##1##2 + { + \tex_immediate:D #1 useobjnum ~ + \int_use:c + { c__pdf_backend_object_ \tl_to_str:n {##1} _int } + \str_case_e:nn + { \prop_item:Nn \g__pdf_backend_object_prop {##1} } + { + { array } { { [ ~ \exp_not:n {##2} ~ ] } } + { dict } { { << ~ \exp_not:n {##2} ~ >> } } + { fstream } + { + stream ~ attr ~ { \__pdf_exp_not_i:nn ##2 } ~ + file ~ { \__pdf_exp_not_ii:nn ##2 } + } + { stream } + { + stream ~ attr ~ { \__pdf_exp_not_i:nn ##2 } ~ + { \__pdf_exp_not_ii:nn ##2 } + } + } + } + } + \cs_if_exist:NTF \tex_pdfextension:D + { \__pdf_tmp:w { \tex_pdfextension:D obj ~ } } + { \__pdf_tmp:w { \tex_pdfobj:D } } +\group_end: +\cs_generate_variant:Nn \__pdf_backend_object_write:nn { nx } +\cs_new:Npn \__pdf_exp_not_i:nn #1#2 { \exp_not:n {#1} } +\cs_new:Npn \__pdf_exp_not_ii:nn #1#2 { \exp_not:n {#2} } +\group_begin: + \cs_set_protected:Npn \__pdf_tmp:w #1 + { + \cs_new_protected:Npn \__pdf_backend_object_now:nn ##1##2 + { + \tex_immediate:D #1 + \str_case:nn + {##1} + { + { array } { { [ ~ \exp_not:n {##2} ~ ] } } + { dict } { { << ~ \exp_not:n {##2} ~ >> } } + { fstream } + { + stream ~ attr ~ { \__pdf_exp_not_i:nn ##2 } ~ + file ~ { \__pdf_exp_not_ii:nn ##2 } + } + { stream } + { + stream ~ attr ~ { \__pdf_exp_not_i:nn ##2 } ~ + { \__pdf_exp_not_ii:nn ##2 } + } + } + } + } + \cs_if_exist:NTF \tex_pdfextension:D + { \__pdf_tmp:w { \tex_pdfextension:D obj ~ } } + { \__pdf_tmp:w { \tex_pdfobj:D } } +\group_end: +\cs_generate_variant:Nn \__pdf_backend_object_now:nn { nx } +\cs_new:Npx \__pdf_backend_object_last: + { + \exp_not:N \int_value:w + \cs_if_exist:NTF \tex_pdffeedback:D + { \exp_not:N \tex_pdffeedback:D lastobj ~ } + { \exp_not:N \tex_pdflastobj:D } + \c_space_tl 0 ~ R + } +\cs_new_protected:Npx \__pdf_backend_compresslevel:n #1 + { + \exp_not:N \tex_global:D + \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 \__pdf_backend_compress_objects:n #1 + { + \bool_if:nTF {#1} + { \__pdf_backend_objcompresslevel:n { 2 } } + { \__pdf_backend_objcompresslevel:n { 0 } } + } +\cs_new_protected:Npx \__pdf_backend_objcompresslevel:n #1 + { + \exp_not:N \tex_global:D + \cs_if_exist:NTF \tex_pdfobjcompresslevel:D + { \tex_pdfobjcompresslevel:D } + { \tex_pdfvariable:D objcompresslevel } + #1 \scan_stop: + } +\cs_new_protected:Npx \__pdf_backend_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 \__pdf_backend_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: + } +\cs_new:Npx \__pdf_backend_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 \__pdf_backend_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 } + } +\cs_new_protected:Npn \__pdf_backend_bdc:nn #1#2 + { \__kernel_backend_literal_page:n { /#1 ~ #2 ~ BDC } } +\cs_new_protected:Npn \__pdf_backend_emc: + { \__kernel_backend_literal_page:n { EMC } } +%% +%% +%% End of file `l3backend-pdfmode.def'. diff --git a/Master/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def b/Master/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def new file mode 100644 index 00000000000..2a4fee00222 --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def @@ -0,0 +1,694 @@ +%% +%% This is file `l3backend-xdvipdfmx.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3backend-basics.dtx (with options: `package,xdvipdfmx') +%% l3backend-color.dtx (with options: `package,xdvipdfmx') +%% l3backend-box.dtx (with options: `package,xdvipdfmx') +%% l3backend-draw.dtx (with options: `package,xdvipdfmx') +%% l3backend-graphics.dtx (with options: `package,xdvipdfmx') +%% l3backend-pdf.dtx (with options: `package,xdvipdfmx') +%% +%% 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 +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3backend bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: l3backend-basics.dtx +\ProvidesExplFile + {l3backend-xdvipdfmx.def}{2019-04-06}{} + {L3 Experimental backend support: xdvipdfmx} +\cs_new_eq:NN \__kernel_backend_literal:e \tex_special:D +\cs_new_protected:Npn \__kernel_backend_literal:n #1 + { \__kernel_backend_literal:e { \exp_not:n {#1} } } +\cs_generate_variant:Nn \__kernel_backend_literal:n { x } +\cs_new_protected:Npn \__kernel_backend_literal_pdf:n #1 + { \__kernel_backend_literal:n { pdf:literal~ #1 } } +\cs_generate_variant:Nn \__kernel_backend_literal_pdf:n { x } +\cs_new_protected:Npn \__kernel_backend_literal_page:n #1 + { \__kernel_backend_literal:n { pdf:literal~direct~ #1 } } +\cs_new_protected:Npn \__kernel_backend_scope_begin: + { \__kernel_backend_literal:n { x:gsave } } +\cs_new_protected:Npn \__kernel_backend_scope_end: + { \__kernel_backend_literal:n { x:grestore } } +%% File: l3backend-color.dtx +\cs_new_protected:Npn \__color_backend_pickup:N #1 { } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \__color_backend_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_backend_pickup:w + { \current@color } \q_stop #1 + } + } + \cs_new_protected:Npn \__color_backend_pickup:w #1 ~ #2 \q_stop #3 + { \tl_set:Nn #3 { #1 ~ #2 } } + } + { } + } +\cs_new_protected:Npn \__color_backend_cmyk:nnnn #1#2#3#4 + { + \__color_backend_select:x + { + cmyk~ + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} + } + } +\cs_new_protected:Npn \__color_backend_gray:n #1 + { \__color_backend_select:x { gray~ \fp_eval:n {#1} } } +\cs_new_protected:Npn \__color_backend_rgb:nnn #1#2#3 + { + \__color_backend_select:x + { rgb~ \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} } + } +\cs_new_protected:Npn \__color_backend_spot:nn #1#2 + { \__color_backend_select:n { #1 } } +\cs_new_protected:Npn \__color_backend_select:n #1 + { + \__kernel_backend_literal:n { color~push~ #1 } + \group_insert_after:N \__color_backend_reset: + } +\cs_generate_variant:Nn \__color_backend_select:n { x } +\cs_new_protected:Npn \__color_backend_reset: + { \__kernel_backend_literal:n { color~pop } } +%% File: l3backend-box.dtx +\cs_new_protected:Npn \__box_backend_clip:N #1 + { + \__kernel_backend_scope_begin: + \__kernel_backend_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 } + \__kernel_backend_scope_end: + \skip_horizontal:n { \box_wd:N #1 } + } +\cs_new_protected:Npn \__box_backend_rotate:Nn #1#2 + { \exp_args:NNf \__box_backend_rotate_aux:Nn #1 { \fp_eval:n {#2} } } +\cs_new_protected:Npn \__box_backend_rotate_aux:Nn #1#2 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( #2 , 5 ) } } + } + \box_use:N #1 + \__kernel_backend_scope_end: + } +\cs_new_protected:Npn \__box_backend_scale:Nnn #1#2#3 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_scope_end: + } +%% File: l3backend-draw.dtx +\cs_new_eq:NN \__draw_backend_literal:n \__kernel_backend_literal_pdf:n +\cs_generate_variant:Nn \__draw_backend_literal:n { x } +\cs_new_protected:Npn \__draw_backend_begin: + { \__draw_backend_scope_begin: } +\cs_new_protected:Npn \__draw_backend_end: + { \__draw_backend_scope_end: } +\cs_new_eq:NN \__draw_backend_scope_begin: \__kernel_backend_scope_begin: +\cs_new_eq:NN \__draw_backend_scope_end: \__kernel_backend_scope_end: +\cs_new_protected:Npn \__draw_backend_moveto:nn #1#2 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ m } + } +\cs_new_protected:Npn \__draw_backend_lineto:nn #1#2 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ \dim_to_decimal_in_bp:n {#2} ~ l } + } +\cs_new_protected:Npn \__draw_backend_curveto:nnnnnn #1#2#3#4#5#6 + { + \__draw_backend_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 \__draw_backend_rectangle:nnnn #1#2#3#4 + { + \__draw_backend_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 \__draw_backend_evenodd_rule: + { \bool_gset_true:N \g__draw_draw_eor_bool } +\cs_new_protected:Npn \__draw_backend_nonzero_rule: + { \bool_gset_false:N \g__draw_draw_eor_bool } +\bool_new:N \g__draw_draw_eor_bool +\cs_new_protected:Npn \__draw_backend_closepath: + { \__draw_backend_literal:n { h } } +\cs_new_protected:Npn \__draw_backend_stroke: + { \__draw_backend_literal:n { S } } +\cs_new_protected:Npn \__draw_backend_closestroke: + { \__draw_backend_literal:n { s } } +\cs_new_protected:Npn \__draw_backend_fill: + { + \__draw_backend_literal:x + { f \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_fillstroke: + { + \__draw_backend_literal:x + { B \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_clip: + { + \__draw_backend_literal:x + { W \bool_if:NT \g__draw_draw_eor_bool * } + } +\cs_new_protected:Npn \__draw_backend_discardpath: + { \__draw_backend_literal:n { n } } +\cs_new_protected:Npn \__draw_backend_dash_pattern:nn #1#2 + { + \__draw_backend_literal:x + { + [ + \exp_args:Nf \use:n + { \clist_map_function:nN {#1} \__draw_backend_dash:n } + ] ~ + \dim_to_decimal_in_bp:n {#2} ~ d + } + } +\cs_new:Npn \__draw_backend_dash:n #1 + { ~ \dim_to_decimal_in_bp:n {#1} } +\cs_new_protected:Npn \__draw_backend_linewidth:n #1 + { + \__draw_backend_literal:x + { \dim_to_decimal_in_bp:n {#1} ~ w } + } +\cs_new_protected:Npn \__draw_backend_miterlimit:n #1 + { \__draw_backend_literal:x { \fp_eval:n {#1} ~ M } } +\cs_new_protected:Npn \__draw_backend_cap_butt: + { \__draw_backend_literal:n { 0 ~ J } } +\cs_new_protected:Npn \__draw_backend_cap_round: + { \__draw_backend_literal:n { 1 ~ J } } +\cs_new_protected:Npn \__draw_backend_cap_rectangle: + { \__draw_backend_literal:n { 2 ~ J } } +\cs_new_protected:Npn \__draw_backend_join_miter: + { \__draw_backend_literal:n { 0 ~ j } } +\cs_new_protected:Npn \__draw_backend_join_round: + { \__draw_backend_literal:n { 1 ~ j } } +\cs_new_protected:Npn \__draw_backend_join_bevel: + { \__draw_backend_literal:n { 2 ~ j } } +\cs_new_protected:Npn \__draw_backend_color_fill_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_cmyk:nnnn #1#2#3#4 + { + \__draw_backend_color_select:x + { + \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ + \fp_eval:n {#3} ~ \fp_eval:n {#4} ~ + k + } + } +\cs_new_protected:Npn \__draw_backend_color_fill_gray:n #1 + { \__draw_backend_color_select:x { \fp_eval:n {#1} ~ g } } +\cs_new_protected:Npn \__draw_backend_color_stroke_gray:n #1 + { \__draw_backend_color_select:x { \fp_eval:n {#1} ~ G } } +\cs_new_protected:Npn \__draw_backend_color_fill_rgb:nnn #1#2#3 + { + \__draw_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ rg } + } +\cs_new_protected:Npn \__draw_backend_color_stroke_rgb:nnn #1#2#3 + { + \__draw_backend_color_select:x + { \fp_eval:n {#1} ~ \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ RG } + } +\cs_new_eq:NN \__draw_backend_color_select:n \__kernel_backend_literal_pdf:n +\cs_generate_variant:Nn \__draw_backend_color_select:n { x } +\cs_new_protected:Npn \__draw_backend_cm:nnnn #1#2#3#4 + { + \__draw_backend_cm_decompose:nnnnN {#1} {#2} {#3} {#4} + \__draw_backend_cm_aux:nnnn + } +\cs_new_protected:Npn \__draw_backend_cm_aux:nnnn #1#2#3#4 + { + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#1} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#1 , 5 ) } } + } + \__kernel_backend_literal:x + { + x:scale~ + \fp_eval:n { round ( #2 , 5 ) } ~ + \fp_eval:n { round ( #3 , 5 ) } + } + \__kernel_backend_literal:x + { + x:rotate~ + \fp_compare:nNnTF {#4} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( -#4 , 5 ) } } + } + } +\cs_new_protected:Npn \__draw_backend_cm_decompose:nnnnN #1#2#3#4#5 + { + \use:x + { + \__draw_backend_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_backend_cm_decompose_auxi:nnnnN #1#2#3#4#5 + { + \use:x + { + \__draw_backend_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_backend_cm_decompose_auxii:nnnnN #1#2#3#4#5 + { + \use:x + { + \__draw_backend_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_backend_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} } + } +\cs_new_protected:Npn \__draw_backend_box_use:Nnnnn #1#2#3#4#5 + { + \__kernel_backend_scope_begin: + \__kernel_backend_literal:x + { + pdf:btrans~matrix~ + \fp_eval:n {#2} ~ \fp_eval:n {#3} ~ + \fp_eval:n {#4} ~ \fp_eval:n {#5} ~ + 0 ~ 0 + } + \hbox_overlap_right:n { \box_use:N #1 } + \__kernel_backend_literal:n { pdf:etrans } + \__kernel_backend_scope_end: + } +%% File: l3backend-graphics.dtx +\AtBeginDocument + { \cs_new_eq:NN \__graphics_backend_getbb_eps:n \graphics_read_bb:n } +\int_new:N \g__graphics_track_int +\cs_new_protected:Npn \__graphics_backend_include_eps:n #1 + { + \__kernel_backend_literal:x + { + PSfile = #1 \c_space_tl + llx = \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + lly = \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + urx = \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + ury = \dim_to_decimal_in_bp:n \l_graphics_ury_dim + } + } +\cs_new_protected:Npn \__graphics_backend_include_jpg:n #1 + { \__graphics_backend_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \__graphics_backend_include_png:n \__graphics_backend_include_jpg:n +\cs_new_protected:Npn \__graphics_backend_include_auxi:nn #1#2 + { + \__graphics_backend_include_auxii:xnn + { + \tl_if_empty:NF \l_graphics_pagebox_tl + { : \l_graphics_pagebox_tl } + \int_compare:nNnT \l_graphics_page_int > 1 + { :P \int_use:N \l_graphics_page_int } + \tl_if_empty:NF \l_graphics_decodearray_tl + { :D \l_graphics_decodearray_tl } + \bool_if:NT \l_graphics_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \__graphics_backend_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c__graphics_graphics_ #2#1 _int } + { + \__kernel_backend_literal:x + { pdf:usexobj~@graphic \int_use:c { c__graphics_graphics_ #2#1 _int } } + } + { \__graphics_backend_include_auxiii:nnn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \__graphics_backend_include_auxii:nnn { x } +\cs_new_protected:Npn \__graphics_backend_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g__graphics_track_int + \int_const:cn { c__graphics_graphics_ #1#2 _int } { \g__graphics_track_int } + \__kernel_backend_literal:x + { + pdf:#3~ + @graphic \int_use:c { c__graphics_graphics_ #1#2 _int } ~ + \int_compare:nNnT \l_graphics_page_int > 1 + { page ~ \int_use:N \l_graphics_page_int \c_space_tl } + \tl_if_empty:NF \l_graphics_pagebox_tl + { + pagebox ~ \l_graphics_pagebox_tl \c_space_tl + bbox ~ + \dim_to_decimal_in_bp:n \l_graphics_llx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_lly_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_urx_dim \c_space_tl + \dim_to_decimal_in_bp:n \l_graphics_ury_dim \c_space_tl + } + (#1) + \bool_lazy_or:nnT + { \l_graphics_interpolate_bool } + { ! \tl_if_empty_p:N \l_graphics_decodearray_tl } + { + << + \tl_if_empty:NF \l_graphics_decodearray_tl + { /Decode~[ \l_graphics_decodearray_tl ] } + \bool_if:NT \l_graphics_interpolate_bool + { /Interpolate~true> } + >> + } + } + } +\cs_new_protected:Npn \__graphics_backend_getbb_jpg:n #1 + { + \int_zero:N \l_graphics_page_int + \tl_clear:N \l_graphics_pagebox_tl + \__graphics_backend_getbb_auxi:nN {#1} \tex_XeTeXpicfile:D + } +\cs_new_eq:NN \__graphics_backend_getbb_png:n \__graphics_backend_getbb_jpg:n +\cs_new_protected:Npn \__graphics_backend_getbb_pdf:n #1 + { + \tl_clear:N \l_graphics_decodearray_tl + \bool_set_false:N \l_graphics_interpolate_bool + \__graphics_backend_getbb_auxi:nN {#1} \tex_XeTeXpdffile:D + } +\cs_new_protected:Npn \__graphics_backend_getbb_auxi:nN #1#2 + { + \int_compare:nNnTF \l_graphics_page_int > 1 + { \__graphics_backend_getbb_auxii:VnN \l_graphics_page_int {#1} #2 } + { \__graphics_backend_getbb_auxiii:nNnn {#1} #2 { :P 1 } { page 1 } } + } +\cs_new_protected:Npn \__graphics_backend_getbb_auxii:nnN #1#2#3 + { \__graphics_backend_getbb_auxiii:nNnn {#2} #3 { :P #1 } { page #1 } } +\cs_generate_variant:Nn \__graphics_backend_getbb_auxii:nnN { V } +\cs_new_protected:Npn \__graphics_backend_getbb_auxiii:nNnn #1#2#3#4 + { + \tl_if_empty:NTF \l_graphics_pagebox_tl + { \__graphics_backend_getbb_auxiv:VnNnn \l_graphics_pagebox_tl } + { \__graphics_backend_getbb_auxv:nNnn } + {#1} #2 {#3} {#4} + } +\cs_new_protected:Npn \__graphics_backend_getbb_auxiv:nnNnn #1#2#3#4#5 + { + \use:x + { + \__graphics_backend_getbb_auxv:nNnn {#2} #3 { : #1 #4 } + { #5 ~ \__graphics_backend_getbb_pagebox:w #1 } + } + } +\cs_generate_variant:Nn \__graphics_backend_getbb_auxiv:nnNnn { V } +\cs_new_protected:Npn \__graphics_backend_getbb_auxv:nNnn #1#2#3#4 + { + \graphics_bb_restore:nF {#1#3} + { \__graphics_backend_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } + } +\cs_new_protected:Npn \__graphics_backend_getbb_auxvi:nNnn #1#2#3#4 + { + \hbox_set:Nn \l__graphics_internal_box { #2 #1 ~ #4 } + \dim_set:Nn \l_graphics_urx_dim { \box_wd:N \l__graphics_internal_box } + \dim_set:Nn \l_graphics_ury_dim { \box_ht:N \l__graphics_internal_box } + \graphics_bb_save:n {#1#3} + } +\cs_new:Npn \__graphics_backend_getbb_pagebox:w #1 box {#1} +\cs_new_protected:Npn \__graphics_backend_include_pdf:n #1 + { + \tex_XeTeXpdffile:D + \__graphics_backend_include_pdf_quote:w #1 "#1" \q_stop \c_space_tl + \int_compare:nNnT \l_graphics_page_int > 0 + { page ~ \int_use:N \l_graphics_page_int \c_space_tl } + \exp_after:wN \__graphics_backend_getbb_pagebox:w \l_graphics_pagebox_tl + } +\cs_new:Npn \__graphics_backend_include_pdf_quote:w #1 " #2 " #3 \q_stop + { " #2 " } +%% File: l3backend-pdf.dtx +\box_new:N \l__pdf_internal_box +\cs_new_protected:Npx \__pdf_backend:n #1 + { \__kernel_backend_literal:n { pdf: #1 } } +\cs_generate_variant:Nn \__pdf_backend:n { x } +\cs_new_protected:Npn \__pdf_backend_catalog_gput:nn #1#2 + { \__pdf_backend:n { put ~ @catalog << /#1 ~ #2 >> } } +\cs_new_protected:Npn \__pdf_backend_info_gput:nn #1#2 + { \__pdf_backend:n { docinfo << /#1 ~ #2 >> } } +\int_new:N \g__pdf_backend_object_int +\prop_new:N \g__pdf_backend_object_prop +\cs_new_protected:Npn \__pdf_backend_object_new:nn #1#2 + { + \int_gincr:N \g__pdf_backend_object_int + \int_const:cn + { c__pdf_backend_object_ \tl_to_str:n {#1} _int } + { \g__pdf_backend_object_int } + \prop_gput:Nnn \g__pdf_backend_object_prop {#1} {#2} + } +\cs_new:Npn \__pdf_backend_object_ref:n #1 + { @pdf.obj \int_use:c { g__pdf_backend_object_ \tl_to_str:n {#1} _int } } +\cs_new_protected:Npn \__pdf_backend_object_write:nn #1#2 + { + \exp_args:Nx \__pdf_backend_object_write:nnn + { \prop_item:Nn \g__pdf_backend_object_prop {#1} } {#1} {#2} + } +\cs_generate_variant:Nn \__pdf_backend_object_write:nn { nx } +\cs_new_protected:Npn \__pdf_backend_object_write:nnn #1#2#3 + { + \use:c { __pdf_backend_object_write_ #1 :nn } + { \__pdf_backend_object_ref:n {#2} } {#3} + } +\cs_new_protected:Npn \__pdf_backend_object_write_array:nn #1#2 + { + \__pdf_backend:x + { obj ~ #1 ~ [ ~ \exp_not:n {#2} ~ ] } + } +\cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2 + { + \__pdf_backend:x + { obj ~ #1 ~ << ~ \exp_not:n {#2} ~ >> } + } +\cs_new_protected:Npn \__pdf_backend_object_write_fstream:nn #1#2 + { \__pdf_backend_object_write_stream:nnnn { f } {#1} #2 } +\cs_new_protected:Npn \__pdf_backend_object_write_stream:nn #1#2 + { \__pdf_backend_object_write_stream:nnnn { } {#1} #2 } +\cs_new_protected:Npn \__pdf_backend_object_write_stream:nnnn #1#2#3#4 + { + \__pdf_backend:x + { + #1 stream ~ #2 ~ + ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >> + } + } +\cs_new_protected:Npn \__pdf_backend_object_now:nn #1#2 + { + \int_gincr:N \g__pdf_backend_object_int + \exp_args:Nnx \use:c { __pdf_backend_object_write_ #1 :nn } + { @pdf.obj \int_use:N \g__pdf_backend_object_int } + {#2} + } +\cs_generate_variant:Nn \__pdf_backend_object_now:nn { nx } +\cs_new:Npn \__pdf_backend_object_last: + { @pdf.obj \int_use:N \g__pdf_backend_object_int } +\bool_new:N \g__pdf_landscape_bool +\AtBeginDocument + { + \cs_if_exist:NT \landscape + { + \tl_put_right:Nn \landscape + { \bool_gset_true:N \g__pdf_landscape_bool } + \tl_put_left:Nn \endlandscape + { \bool_gset_false:N \g__pdf_landscape_bool } + } + } +\int_new:N \g__pdf_backend_annotation_int +\cs_new_protected:Npn \__pdf_backend_annotation:nnnn #1#2#3#4 + { + \bool_if:NTF \g__pdf_landscape_bool + { + \box_move_up:nn {#2} + { + \vbox:n + { + \__pdf_backend_annotation_aux:nnnn + { #2 + #3 } {#1} { 0pt } {#4} + } + } + } + { \__pdf_backend_annotation_aux:nnnn {#1} {#2} {#3} {#4} } + } +\cs_new_protected:Npn \__pdf_backend_annotation_aux:nnnn #1#2#3#4 + { + \int_gincr:N \g__pdf_backend_object_int + \int_gset_eq:NN \g__pdf_backend_annotation_int \g__pdf_backend_object_int + \__pdf_backend:x + { + ann ~ @pdf.obj \int_use:N \g__pdf_backend_object_int \c_space_tl + width ~ \dim_eval:n {#1} ~ + height ~ \dim_eval:n {#2} ~ + depth ~ \dim_eval:n {#3} ~ + << #4 >> + } + } +\cs_new:Npn \__pdf_backend_annotation_last: + { @pdf.obj \int_use:N \g__pdf_backend_annotation_int } +\cs_new_protected:Npn \__pdf_backend_link_begin_goto:nnw #1#2 + { \__pdf_backend_link_begin:n { #1 /Subtype /Link /A << /S /GoTo /D ( #2 ) >> } } +\cs_new_protected:Npn \__pdf_backend_link_begin_user:nnw #1#2 + { \__pdf_backend_link_begin:n {#1#2} } +\cs_new_protected:Npn \__pdf_backend_link_begin:n #1 + { + \__pdf_backend:n + { + bann + << + /Type /Annot + #1 + >> + } + } +\cs_new_protected:Npn \__pdf_backend_link_end: + { \__pdf_backend:n { eann } } +\cs_new:Npn \__pdf_backend_link_last: { } +\cs_new_protected:Npn \__pdf_backend_link_margin:n #1 + { \__kernel_backend_literal:x { dvipdfmx:config~g~ \dim_eval:n {#1} } } +\cs_new_protected:Npn \__pdf_backend_destination:nn #1#2 + { + \__pdf_backend:x + { + dest ~ ( \exp_not:n {#1} ) + [ + @thispage + \str_case:nnF {#2} + { + { xyz } { /XYZ ~ @xpos ~ @ypos ~ null } + { fit } { /Fit } + { fitb } { /FitB } + { fitbh } { /FitBH } + { fitbv } { /FitBV ~ @xpos } + { fith } { /FitH ~ @ypos } + { fitv } { /FitV ~ @xpos } + } + { /XYZ ~ @xpos ~ @ypos ~ \fp_eval:n { (#2) / 100 } } + ] + } + } +\cs_new_protected:Npn \__pdf_backend_destination_rectangle:nn #1#2 + { + \group_begin: + \hbox_set:Nn \l__pdf_internal_box {#2} + \box_move_down:nn { \box_dp:N \l__pdf_internal_box } + { + \hbox:n + { + \__pdf_backend:n { obj ~ @pdf_ #1 _llx ~ @xpos } + \__pdf_backend:n { obj ~ @pdf_ #1 _lly ~ @ypos } + } + } + \box_use:N \l__pdf_internal_box + \box_move_up:nn { \box_ht:N \l__pdf_internal_box } + { + \hbox:n + { + \__pdf_backend:n + { + dest ~ (#1) + [ + @thispage + /FitR ~ + @pdf_ #1 _llx ~ @pdf_ #1 _lly ~ + @xpos ~ @ypos + ] + } + } + } + \group_end: + } +\cs_new_protected:Npn \__pdf_backend_compresslevel:n #1 + { \__kernel_backend_literal:x { dvipdfmx:config~z~ \int_eval:n {#1} } } +\cs_new_protected:Npn \__pdf_backend_compress_objects:n #1 + { + \bool_if:nF {#1} + { \__kernel_backend_literal:n { dvipdfmx:config~C~0x40 } } + } +\cs_new_protected:Npn \__pdf_backend_version_major:n #1 + { + \cs_gset:Npx \__pdf_backend_version_major: { \int_eval:n {#1} } + \__kernel_backend_literal:x { pdf:majorversion \__pdf_backend_version_major: } + } +\cs_new_protected:Npn \__pdf_backend_version_minor:n #1 + { + \cs_gset:Npx \__pdf_backend_version_minor: { \int_eval:n {#1} } + \__kernel_backend_literal:x { pdf:minorversion \__pdf_backend_version_minor: } + } +\cs_new:Npn \__pdf_backend_version_major: { 1 } +\cs_new:Npn \__pdf_backend_version_minor: { 5 } +\cs_new_protected:Npn \__pdf_backend_bdc:nn #1#2 + { \__kernel_backend_literal_page:n { /#1 ~ #2 ~ BDC } } +\cs_new_protected:Npn \__pdf_backend_emc: + { \__kernel_backend_literal_page:n { EMC } } +%% +%% +%% End of file `l3backend-xdvipdfmx.def'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index ebbc6fa4794..cab7ffaaf20 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -382,7 +382,7 @@ my @TLP_working = qw( kpfonts ksfh_nat ksp-thesis ktv-texdata ku-template kurdishlipsum kurier kvmap l2picfaq l2tabu l2tabu-english l2tabu-french l2tabu-italian l2tabu-spanish - l3build l3kernel l3packages l3experimental + l3backend l3build l3kernel l3packages l3experimental labbook labels labels4easylist labelschanged labyrinth ladder lambda-lists langcode langsci lapdf lastpackage lastpage diff --git a/Master/tlpkg/tlpsrc/collection-latexrecommended.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexrecommended.tlpsrc index c2dcf133a53..305251aa02f 100644 --- a/Master/tlpkg/tlpsrc/collection-latexrecommended.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexrecommended.tlpsrc @@ -33,6 +33,7 @@ depend index depend jknapltx depend koma-script depend latexbug +depend l3backend depend l3experimental depend l3kernel depend l3packages diff --git a/Master/tlpkg/tlpsrc/l3backend.tlpsrc b/Master/tlpkg/tlpsrc/l3backend.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/l3backend.tlpsrc |