% \iffalse meta-comment % %% File: l3drivers.dtx Copyright(C) 2011-2016 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 %% %% http://www.latex-project.org/lppl.txt %% %% This file is part of the "l3kernel bundle" (The Work in LPPL) %% and all files in that bundle must be distributed together. %% %% The released version of this bundle is available from CTAN. %% %% ----------------------------------------------------------------------- %% %% The development version of the bundle can be found at %% %% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% %%%%%%%%%%% %% NOTE: %% %%%%%%%%%%% %% %% Snapshots taken from the repository represent work in progress and may %% not work or may contain conflicting material! We therefore ask %% people _not_ to put them into distributions, archives, etc. without %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- %% % %<*driver> \documentclass[full]{l3doc} % %<*driver|package> \GetIdInfo$Id: l3drivers.dtx 6494 2016-05-14 21:10:56Z joseph $ {L3 Experimental drivers} % %<*driver> \begin{document} \DocInput{\jobname.dtx} \end{document} % % \fi % % \title{^^A % The \textsf{l3drivers} package\\ Drivers^^A % \thanks{This file describes v\ExplFileVersion, % last revised \ExplFileDate.}^^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 \ExplFileDate} % % \maketitle % % \begin{documentation} % % \TeX{} relies on drivers in order to carry out a number of tasks, such % as using color, including graphics and setting up hyper-links. The nature % of the code required depends on the exact driver in use. Currently, % \LaTeX3 is aware of the following drivers: % \begin{itemize} % \item \texttt{pdfmode}: The \enquote{driver} for direct PDF output by % \emph{both} \pdfTeX{} and \LuaTeX{} (no separate driver is used in this % case: the engine deals with PDF creation itself). % \item \texttt{dvips}: The \texttt{dvips} program, which works in % conjugation with \pdfTeX{} or \LuaTeX{} in DVI mode. % \item \texttt{dvipdfmx}: The \texttt{dvipdfmx} program, which works in % conjugation with \pdfTeX{} or \LuaTeX{} in DVI mode. % \item \texttt{dvisvgm}: The \texttt{dvisvgm} program, which works in % conjugation with \pdfTeX{} or \LuaTeX{} in DVI mode to create SVG % output. % \item \texttt{xdvipdfmx}: The driver used by \XeTeX{}. % \end{itemize} % % The code here is all very low-level, and should not in general be used % outside of the kernel. It is also important to note that many of the % functions here are closely tied to the immediate level \enquote{up}, % and they must be used in the correct contexts.d % % \section{Box clipping} % % \begin{function}[added = 2011-11-11]{\__driver_box_use_clip:N} % \begin{syntax} % \cs{__driver_box_use_clip:N} \meta{box} % \end{syntax} % Inserts the content of the \meta{box} at the current insertion point % such that any material outside of the bounding box will not be displayed % by the driver. The material in the \meta{box} is still placed in the % output stream: the clipping takes place at a driver level. % % This function should only be used within a surrounding horizontal % box construct. % \end{function} % % \section{Box rotation and scaling} % % \begin{function}[added = 2016-05-12]{\__driver_box_use_rotate:Nn} % \begin{syntax} % \cs{__driver_box_use_rotate:Nn} \meta{box} \Arg{angle} % \end{syntax} % Inserts the content of the \meta{box} at the current insertion point % rotated by the \meta{angle} (expressed in degrees). The material is % inserted with no apparent height or width, and is rotated such the % the \TeX{} reference point of the box is the center of rotation and % remains the reference point after rotation. It is the responsibly of % the code using this function to adjust the apparent size of the box to % be correct at the \TeX{} side. % % This function should only be used within a surrounding horizontal % box construct. % \end{function} % % \begin{function}[added = 2016-05-12]{\__driver_box_use_scale:Nnn} % \begin{syntax} % \cs{__driver_box_use_scale:Nnn} \meta{box} \Arg{x-scale} \Arg{y-scale} % \end{syntax} % Inserts the content of the \meta{box} at the current insertion point % scale by the \meta{x-scale} and \meta{y-scale}. The material is % inserted with no apparent height or width. It is the responsibly of % the code using this function to adjust the apparent size of the box to % be correct at the \TeX{} side. % % This function should only be used within a surrounding horizontal % box construct. % \end{function} % % \section{Color support} % % \begin{function}[added = 2011-09-03, updated = 2012-05-18] % {\__driver_color_ensure_current:} % \begin{syntax} % \cs{__driver_color_ensure_current:} % \end{syntax} % Ensures that the color used to typeset material is that which was % set when the material was placed in a box. This function is therefore % required inside any \enquote{color safe} box to ensure that the box may % be inserted in a location where the foreground color has been altered, % while preserving the color used in the box. % \end{function} % % \end{documentation} % % \begin{implementation} % % \section{\pkg{l3drivers} Implementation} % % \begin{macrocode} %<*initex|package> %<@@=driver> % \end{macrocode} % % Whilst there is a reasonable amount of code overlap between drivers, % it is much clearer to have the blocks more-or-less separated than run % in together and DocStripped out in parts. As such, most of the following % is set up on a per-driver basis, though there is some common code (again % given in blocks not interspersed with other material). % % All the file identifiers are up-front so that they come out in the right % place in the files. % \begin{macrocode} %<*package> \ProvidesExplFile %<*dvipdfmx> {l3dvidpfmx.def}{\ExplFileDate}{\ExplFileVersion} {L3 Experimental driver: dvipdfmx} % %<*dvips> {l3dvips.def}{\ExplFileDate}{\ExplFileVersion} {L3 Experimental driver: dvips} % %<*dvisvgm> {l3dvisvgm.def}{\ExplFileDate}{\ExplFileVersion} {L3 Experimental driver: dvisvgm} % %<*pdfmode> {l3pdfmode.def}{\ExplFileDate}{\ExplFileVersion} {L3 Experimental driver: PDF mode} % %<*xdvipdfmx> {l3xdvidpfmx.def}{\ExplFileDate}{\ExplFileVersion} {L3 Experimental driver: xdvipdfmx} % % % \end{macrocode} % % \subsection{\texttt{pdfmode} driver} % % \begin{macrocode} %<*pdfmode> % \end{macrocode} % % The direct PDF driver covers both \pdfTeX{} and \LuaTeX{}. The latter % renames/restructures the driver primitives but this can be handled % at one level of abstraction. As such, we avoid using two separate drivers % for this material at the cost of some \texttt{x}-type definitions to get % everything expanded up-front. % % \subsubsection{Basics} % % \begin{macro}[int]{\@@_literal:n} % This is equivalent to \verb|\special{pdf:}| but the engine can % track it. Without the \texttt{direct} keyword everything is kept in % sync: the transformation matrix is set to the current point automatically. % Note that this is still inside the text (\texttt{BT} \dots \texttt{ET} % block). % \begin{macrocode} \cs_new_protected:Npx \@@_literal:n #1 { \cs_if_exist:NTF \luatex_pdfextension:D { \luatex_pdfextension:D literal } { \pdftex_pdfliteral:D } {#1} } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\@@_scope_begin:, \@@_scope_end:} % Higher-level interfaces for saving and restoring the graphic state. % \begin{macrocode} \cs_new_protected_nopar:Npx \@@_scope_begin: { \cs_if_exist:NTF \luatex_pdfextension:D { \luatex_pdfextension:D save \scan_stop: } { \pdftex_pdfsave:D } } \cs_new_protected_nopar:Npx \@@_scope_end: { \cs_if_exist:NTF \luatex_pdfextension:D { \luatex_pdfextension:D restore \scan_stop: } { \pdftex_pdfrestore:D } } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\@@_matrix:n} % Here the appropriate function is set up to insert an affine matrix % into the PDF. With \pdfTeX{} and \LuaTeX{} in direct PDF output mode there % is a primitive for this, which only needs the rotation/scaling/skew part. % \begin{macrocode} \cs_new_protected:Npx \@@_matrix:n #1 { \cs_if_exist:NTF \luatex_pdfextension:D { \luatex_pdfextension:D setmatrix } { \pdftex_pdfsetmatrix:D } {#1} } % \end{macrocode} % \end{macro} % % \subsubsection{Color} % % \begin{variable}{\l_@@_current_color_tl} % The current color in driver-dependent format: pick up the package-mode % data if available. % \begin{macrocode} \tl_new:N \l_@@_current_color_tl \tl_set:Nn \l_@@_current_color_tl { 0~g~0~G } %<*package> \AtBeginDocument { \@ifpackageloaded { color } { \tl_set:Nn \l_@@_current_color_tl { \current@color } } { } } % % \end{macrocode} % \end{variable} % % \begin{variable}{\l_@@_color_stack_int} % \pdfTeX{} and \LuaTeX{} have multiple stacks available, and to track % which one is in use a variable is required. % \begin{macrocode} \int_new:N \l_@@_color_stack_int % \end{macrocode} % \end{variable} % % \begin{macro}[int]{\@@_color_ensure_current:} % \begin{macro}[aux]{\@@_color_reset:} % There is a dedicated primitive/primitive interface for setting colors. % As with scoping, this approach is not suitable for cached operations. % \begin{macrocode} \cs_new_protected_nopar:Npx \@@_color_ensure_current: { \cs_if_exist:NTF \luatex_pdfextension:D { \luatex_pdfextension:D colorstack } { \pdftex_pdfcolorstack:D } \exp_not:N \l_@@_color_stack_int push { \exp_not:N \l_@@_current_color_tl } \group_insert_after:N \exp_not:N \@@_color_reset: } \cs_new_protected_nopar:Npx \@@_color_reset: { \cs_if_exist:NTF \luatex_pdfextension:D { \luatex_pdfextension:D colorstack } { \pdftex_pdfcolorstack:D } \exp_not:N \l_@@_color_stack_int pop \scan_stop: } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \subsection{\texttt{dvipdfmx} driver} % % \begin{macrocode} %<*dvipdfmx|xdvipdfmx> % \end{macrocode} % % The \texttt{dvipdfmx} shares code with the PDF mode one (using the common % section to this file) but also with \texttt{xdvipdfmx}. The latter is close % to identical to \texttt{dvipdfmx} and so all of the code here is extracted % for both drivers, with some \texttt{clean up} for \texttt{xdvipdfmx} as % required. % % \subsubsection{Basics} % % \begin{macro}[int]{\@@_literal:n} % Equivalent to \texttt{pdf:content} but favoured as the link to % the \pdfTeX{} primitive approach is clearer. % \begin{macrocode} \cs_new_protected:Npn \@@_literal:n #1 { \tex_special:D { pdf:literal~ #1 } } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\@@_scope_begin:, \@@_scope_end:} % Scoping is done using direct PDF operations here. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_scope_begin: { \@@_literal:n { q } } \cs_new_protected_nopar:Npn \@@_scope_end: { \@@_literal:n { Q } } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\@@_matrix:n} % With \texttt{(x)dvipdfmx} the matrix has to include a translation % part: that is always zero and so is built in here so that the same % internal interface works for all PDF-related drivers. % \begin{macrocode} \cs_new_protected:Npn \@@_matrix:n #1 { \@@_literal:n { #1 \c_space_tl 0~0~cm } } % \end{macrocode} % \end{macro} % % \subsubsection{Color} % % \begin{variable}{\l_@@_current_color_tl} % The current color in driver-dependent format. % \begin{macrocode} \tl_new:N \l_@@_current_color_tl \tl_set:Nn \l_@@_current_color_tl { [ 0 ] } %<*package> \AtBeginDocument { \@ifpackageloaded { color } { \tl_set:Nn \l_@@_current_color_tl { \current@color } } { } } % % \end{macrocode} % \end{variable} % % \begin{macro}[int]{\@@_color_ensure_current:} % \begin{macro}[aux]{\@@_color_reset:} % Directly set the color using the specials with optimisation support. % \begin{macrocode} \cs_new_protected_nopar:Npx \@@_color_ensure_current: { \tex_special:D { pdf:bcolor~\l_@@_current_color_tl } \group_insert_after:N \exp_not:N \@@_color_reset: } \cs_new_protected_nopar:Npx \@@_color_reset: { \tex_special:D { pdf:ecolor } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \subsection{\texttt{xdvipdfmx} driver} % % \begin{macrocode} %<*xdvipdfmx> % \end{macrocode} % % \subsubsection{Color} % % \begin{macro}[int]{\@@_color_ensure_current:} % \begin{macro}[aux]{\@@_color_reset:} % The \LaTeXe{} driver uses \texttt{dvips}-like specials so there has to % be a change of set up if \pkg{color} is loaded. % \begin{macrocode} %<*package> \AtBeginDocument { \@ifpackageloaded { color } { \cs_set_protected_nopar:Npn \@@_color_ensure_current: { \tex_special:D { color~push~\l_@@_current_color_tl } \group_insert_after:N \exp_not:N \@@_color_reset: } \cs_set_protected_nopar:Npn \@@_color_reset: { \tex_special:D { color~pop } } } { } } % % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \subsection{Common code for PDF production} % % As all of the drivers which understand PDF-targeted specials act in much % the same way there is a lot of shared code. Rather than try to DocStrip it % interspersed with the above, we collect all of it here. % % \begin{macrocode} %<*dvipdfmx|pdfmode|xdvipdfmx> % \end{macrocode} % % \subsubsection{Box operations} % % \begin{macro}{\@@_box_use_clip:N} % The general method is to save the current location, define a clipping path % equivalent to the bounding box, then insert the content at the current % position and in a zero width box. The \enquote{real} width is then made up % using a horizontal skip before tidying up. There are other approaches that % can be taken (for example using XForm objects), but the logic here shares % as much code as possible and uses the same conversions (and so same % rounding errors) in all cases. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_clip:N #1 { \@@_scope_begin: \@@_literal:n { 0~ \dim_to_decimal_in_bp:n { -\box_dp:N #1 } ~ \dim_to_decimal_in_bp:n { \box_wd:N #1 } ~ \dim_to_decimal_in_bp:n { \box_ht:N #1 + \box_dp:N #1 } ~ re~W~n } \hbox_overlap_right:n { \box_use:N #1 } \@@_scope_end: \skip_horizontal:n { \box_wd:N #1 } } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\@@_box_use_rotate:Nn} % \begin{variable}{\l_@@_cos_fp, \l_@@_sin_fp} % Rotations are set using an affine transformation matrix which therefore % requires sine/cosine values not the angle itself. We store the rounded % values to avoid rounding twice. There are also a couple of comparisons to % ensure that |-0| is not written to the output, as this avoids any issues % with problematic display programs. Note that numbers are compared to~$0$ % after rounding. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 { \@@_scope_begin: \box_set_wd:Nn #1 \c_zero_dim \fp_set:Nn \l_@@_cos_fp { round ( cosd ( #2 ) , 5 ) } \fp_compare:nNnT \l_@@_cos_fp = \c_zero_fp { \fp_zero:N \l_@@_cos_fp } \fp_set:Nn \l_@@_sin_fp { round ( sind ( #2 ) , 5 ) } \@@_matrix:n { \fp_use:N \l_@@_cos_fp \c_space_tl \fp_compare:nNnTF \l_@@_sin_fp = \c_zero_fp { 0~0 } { \fp_use:N \l_@@_sin_fp \c_space_tl \fp_eval:n { -\l_@@_sin_fp } } \c_space_tl \fp_use:N \l_@@_cos_fp } \box_use:N #1 \@@_scope_end: } \fp_new:N \l_@@_cos_fp \fp_new:N \l_@@_sin_fp % \end{macrocode} % \end{variable} % \end{macro} % % \begin{macro}{\@@_box_use_scale:Nnn} % The same idea as for rotation but without the complexity of signs and % cosines. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_scale:Nnn #1#2#3 { \@@_scope_begin: \@@_matrix:n { \fp_eval:n { round ( #2 , 5 ) } ~ 0~0~ \fp_eval:n { round ( #3 , 5 ) } } \hbox_overlap_right:n { \box_use:N #1 } \@@_scope_end: } % \end{macrocode} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \subsection{\texttt{dvips} driver} % % \begin{macrocode} %<*dvips> % \end{macrocode} % % \subsubsection{Basics} % % \begin{macro}[int]{\@@_literal:n} % In the case of \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. % \begin{macrocode} \cs_new_protected:Npx \@@_literal:n #1 { \tex_special:D { ps: currentpoint~ currentpoint~translate~ #1 ~ neg~exch~neg~exch~translate } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_scope_begin:, \@@_scope_end:} % Scope saving/restoring is done directly with no need to worry about the % transformation matrix. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_scope_begin: { \tex_special:D { ps:gsave } } \cs_new_protected_nopar:Npn \@@_scope_end: { \tex_special:D { ps:grestore } } % \end{macrocode} % \end{macro} % % \subsection{Driver-specific auxiliaries} % % \begin{macro}[int, EXP]{\@@_absolute_lengths:n} % The \texttt{dvips} driver scales all absolute dimensions based % on the output resolution selected and any \TeX{} magnification. Thus % for any operation involving absolute lengths there is a correction to % make. This is based on \texttt{normalscale} from \texttt{special.pro} % but using the stack rather than a definition to save the current matrix. % \begin{macrocode} \cs_new:Npn \@@_absolute_lengths:n #1 { matrix~currentmatrix~ Resolution~72~div~VResolution~72~div~scale~ DVImag~dup~scale~ #1 ~ setmatrix } % \end{macrocode} % \end{macro} % % \subsubsection{Box operations} % % \begin{macro}{\@@_box_use_clip:N} % Much the same idea as for the PDF mode version but with a slightly % different syntax for creating the clip path. To avoid any scaling % issues we need the absolute length auxiliary here. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_clip:N #1 { \@@_scope_begin: \@@_literal:n { \@@_absolute_lengths:n { 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 } } \hbox_overlap_right:n { \box_use:N #1 } \@@_scope_end: \skip_horizontal:n { \box_wd:N #1 } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_box_use_rotate:Nn} % Rotating using \texttt{dvips} does not require that the box dimensions % are altered and has a very convenient built-in operation. Zero rotation % must be written as |0| not |-0| so there is a quick test. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 { \@@_scope_begin: \@@_literal:n { \fp_compare:nNnTF {#2} = \c_zero_fp { 0 } { \fp_eval:n { round ( -#2 , 5 ) } } ~ rotate } \box_use:N #1 \@@_scope_end: } % \end{macro} % % \begin{macro}{\@@_box_use_scale:Nnn} % The \texttt{dvips} driver once again has a dedicated operation we can % use here. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_scale:Nnn #1#2#3 { \@@_scope_begin: \@@_literal:n { \fp_eval:n { round ( #2 , 5 ) } ~ \fp_eval:n { round ( #3 , 5 ) } ~ scale } \hbox_overlap_right:n { \box_use:N #1 } \@@_scope_end: } % \end{macrocode} % \end{macro} % % \subsubsection{Color} % % \begin{variable}{\l_@@_current_color_tl} % The current color in driver-dependent format. % \begin{macrocode} \tl_new:N \l_@@_current_color_tl \tl_set:Nn \l_@@_current_color_tl { gray~0 } %<*package> \AtBeginDocument { \@ifpackageloaded { color } { \tl_set:Nn \l_@@_current_color_tl { \current@color } } { } } % % \end{macrocode} % \end{variable} % % \begin{macro}[int]{\@@_color_ensure_current:} % \begin{macro}[aux]{\@@_color_reset:} % Directly set the color using the specials: no optimisation here. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_color_ensure_current: { \tex_special:D { color~push~\l_@@_current_color_tl } \group_insert_after:N \@@_color_reset: } \cs_new_protected_nopar:Npn \@@_color_reset: { \tex_special:D { color~pop } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \subsection{\texttt{dvisvgm} driver} % % \begin{macrocode} %<*dvisvgm> % \end{macrocode} % % \subsubsection{Basics} % % \begin{macro}[int]{\@@_literal:n} % Unlike the other drivers, the requirements for making SVG files mean % that we can't conveniently transform all operations to the current point. % That makes life a bit more tricky later as that needs to be accounted for. % A new line is added after each call to help to keep the output readable % for debugging. % \begin{macrocode} \cs_new_protected:Npn \@@_literal:n #1 { \tex_special:D { dvisvgm:raw~ #1 { ?nl } } } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\@@_scope_begin:, \@@_scope_end:} % A scope in SVG terms is slightly different to the other drivers as % operations have to be \enquote{tied} to these not simply inside them. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_scope_begin: { \@@_literal:n { } } \cs_new_protected_nopar:Npn \@@_scope_end: { \@@_literal:n { } } % \end{macrocode} % \end{macro} % % \subsection{Driver-specific auxiliaries} % % \begin{macro}[int]{\@@_scope_begin:n} % 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 that % \cs{@@_scope_begin:} as a result. No assumptions are made about the nature % of the scoped operation(s). % \begin{macrocode} \cs_new_protected:Npn \@@_scope_begin:n #1 { \@@_literal:n { } } % \end{macrocode} % \end{macro} % % \subsubsection{Box operations} % % \begin{macro}[int]{\@@_box_use_clip:N} % \begin{variable}[aux]{\g_@@_clip_path_int} % Clipping in SVG is more involved than with other drivers. The first issue % is that the clipping path must be defined separately from where it is used, % so we need to track how many paths have applied. The naming here uses % \texttt{l3cp} as the namespace with a number following. Rather than use % a rectangular operation, we define the path manually as this allows it to % have a depth: easier than the alternative approach of shifting content % up and down using scopes to allow for the depth of the \TeX{} box and % keep the reference point the same! % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_clip:N #1 { \int_gincr:N \g_@@_clip_path_int \@@_literal:n { < clipPath~id = " l3cp \int_use:N \g_@@_clip_path_int " > } \@@_literal:n { < path ~ d = " M ~ 0 ~ \dim_to_decimal:n { -\box_dp:N #1 } ~ L ~ \dim_to_decimal:n { \box_wd:N #1 } ~ \dim_to_decimal:n { -\box_dp:N #1 } ~ L ~ \dim_to_decimal:n { \box_wd:N #1 } ~ \dim_to_decimal:n { \box_ht:N #1 + \box_dp:N #1 } ~ L ~ 0 ~ \dim_to_decimal:n { \box_ht:N #1 + \box_dp:N #1 } ~ Z " /> } \@@_literal:n { < /clipPath > } % \end{macrocode} % In general the SVG set up does not try to transform coordinates to the % current point. For clipping we need to do that, so have a transformation % here to get us to the right place, and a matching one just before the % \TeX{} box is inserted to get things back on track. The clip path needs to % come between those two such that if lines up with the current point, as % does the \TeX{} box. % \begin{macrocode} \@@_scope_begin:n { transform = " translate ( { ?x } , { ?y } ) ~ scale ( 1 , -1 ) " } \@@_scope_begin:n { clip-path = "url ( \c_hash_str l3cp \int_use:N \g_@@_clip_path_int ) " } \@@_scope_begin:n { transform = " scale ( -1 , 1 ) ~ translate ( { ?x } , { ?y } ) ~ scale ( -1 , -1 ) " } \box_use:N #1 \@@_scope_end: \@@_scope_end: \@@_scope_end: % \skip_horizontal:n { \box_wd:N #1 } } \int_new:N \g_@@_clip_path_int % \end{macrocode} % \end{variable} % \end{macro} % % \begin{macro}[int]{\@@_box_use_rotate:Nn} % Rotation has a dedicated operation which includes a centre-of-rotation % optional pair. That can be picked up from the driver syntax, so there is % no need to worry about the transformation matrix. % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_rotate:Nn #1#2 { \@@_scope_begin:n { transform = " rotate ( \fp_eval:n { round ( -#2 , 5 ) } , ~ { ?x } , ~ { ?y } ) " } \box_use:N #1 \@@_scope_end: } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_box_use_scale:Nnn} % In contrast to rotation, we have to account for the current position in this % case. That is done using a couple of translations in addition to the scaling % (which is therefore done backward with a flip). % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_scale:Nnn #1#2#3 { \@@_scope_begin:n { transform = " translate ( { ?x } , { ?y } ) ~ scale ( \fp_eval:n { round ( -#2 , 5 ) } , \fp_eval:n { round ( -#3 , 5 ) } ) ~ translate ( { ?x } , { ?y } ) ~ scale ( -1 ) " } \hbox_overlap_right:n { \box_use:N #1 } \@@_scope_end: } % \end{macrocode} % \end{macro} % % \subsubsection{Color} % % \begin{variable}{\l_@@_current_color_tl} % The current color in driver-dependent format: the same as for % \texttt{dvips}. % \begin{macrocode} \tl_new:N \l_@@_current_color_tl \tl_set:Nn \l_@@_current_color_tl { gray~0 } %<*package> \AtBeginDocument { \@ifpackageloaded { color } { \tl_set:Nn \l_@@_current_color_tl { \current@color } } { } } % % \end{macrocode} % \end{variable} % % \begin{macro}[int]{\@@_color_ensure_current:} % \begin{macro}[aux]{\@@_color_reset:} % Directly set the color: same as \texttt{dvips}. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_color_ensure_current: { \tex_special:D { color~push~\l_@@_current_color_tl } \group_insert_after:N \exp_not:N \@@_color_reset: } \cs_new_protected_nopar:Npn \@@_color_reset: { \tex_special:D { color~pop } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \begin{macrocode} % % \end{macrocode} % % \end{implementation} % % \PrintIndex