diff options
author | Karl Berry <karl@freefriends.org> | 2014-01-07 23:06:03 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-01-07 23:06:03 +0000 |
commit | ea751c100642b9b81c97ad32b1b492c917d5a93c (patch) | |
tree | 8b3554859f8f067f8ca942d08dad6a0792a3a803 /Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx | |
parent | 79b68a754e61b4825c185082d15b0e334440fbde (diff) |
l3kernel (7jan14)
git-svn-id: svn://tug.org/texlive/trunk@32599 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx | 156 |
1 files changed, 81 insertions, 75 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx index 5eb91ddc2cb..778038661c1 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3drivers.dtx Copyright(C) 2011-2013 The LaTeX3 Project +%% File: l3drivers.dtx Copyright(C) 2011-2014 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 @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3drivers.dtx 4632 2013-12-31 17:09:37Z joseph $ +\GetIdInfo$Id: l3drivers.dtx 4641 2014-01-04 17:05:41Z joseph $ {L3 Experimental drivers} %</driver|package> %<*driver> @@ -219,7 +219,10 @@ % \begin{macro}{\@@_state_save:, \@@_state_restore:} % All of the drivers have a stack for saving the graphic state. These % have slightly different interfaces. For both \texttt{dvips} and -% \texttt{(x)dvipdfmx} this is done using an appropriate special. +% \texttt{(x)dvipdfmx} this is done using an appropriate special. Note +% that here and later, the \texttt{dvipdfmx} documentation does not cover +% the |literal| key word but that this appears to behave in the same way as +% \pdfTeX{}'s \tn{pdfliteral} (making life easier all-round). % \begin{macrocode} %<*!pdfmode> \cs_new_protected_nopar:Npn \@@_state_save: @@ -227,14 +230,14 @@ { \tex_special:D { ps:gsave } } %</dvips> %<*dvipdfmx|xdvipdfmx> - { \tex_special:D { pdf:bcontent } } + { \tex_special:D { pdf:literal~q } } %</dvipdfmx|xdvipdfmx> \cs_new_protected_nopar:Npn \@@_state_restore: %<*dvips> { \tex_special:D { ps:grestore } } %</dvips> %<*dvipdfmx|xdvipdfmx> - { \tex_special:D { pdf:econtent } } + { \tex_special:D { pdf:literal~Q } } %</dvipdfmx|xdvipdfmx> %</!pdfmode> % \end{macrocode} @@ -263,14 +266,31 @@ % the underlying binary. The exact command is driver-dependent but the % concept is general enough to use a single function. However, it is % important to remember this is a convenient shortcut: the arguments will -% be driver-specific. +% be driver-specific. Note that these functions set the transformation matrix +% to the current position: contrast with \cs{\@@_literal_direct:n}. % \begin{macrocode} \cs_new_protected:Npn \@@_literal:n #1 %<*dvipdfmx|xdvipdfmx> { \tex_special:D { pdf:literal~ #1 } } %</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% 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} %<*dvips> - { \tex_special:D { ps: #1 } } + { + \tex_special:D + { + ps: + currentpoint~ + currentpoint~translate~ + #1 ~ + neg~exch~neg~exch~translate + } + } %</dvips> %<*pdfmode> { \pdftex_pdfliteral:D {#1} } @@ -278,6 +298,44 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\@@_literal_direct:n} +% Even \enquote{lower level} than \cs{\@@_literal:n}, these commands do +% not set the transformation matrix but simply dump the driver code directly +% into the output. In the \texttt{(x)dvipdfmx} case this two-part keyword +% is documented (\emph{cf.}~|literal| alone). +% \begin{macrocode} +\cs_new_protected:Npn \@@_literal_direct:n #1 +%<*dvipdfmx|xdvipdfmx> + { \tex_special:D { pdf:literal~direct~ #1 } } +%</dvipdfmx|xdvipdfmx> +%<*dvips> + { \tex_special:D { ps:: #1 } } +%</dvips> +%<*pdfmode> + { \pdftex_pdfliteral:D direct {#1} } +%</pdfmode> +% \end{macrocode} +% \end{macro} +% +% \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 |normalscale| from \texttt{special.pro}. +% \begin{macrocode} +%<*dvips> +\cs_new:Npn \@@_absolute_lengths:n #1 + { + /savedmatrix~matrix~currentmatrix~def~ + Resolution~72~div~VResolution~72~div~scale~ + DVImag~dup~scale~ + #1 ~ + savedmatrix~setmatrix + } +%</dvips> +% \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 a new enough \pdfTeX{} (version~1.40.0 or later) @@ -299,7 +357,7 @@ %</pdfmode> %<*dvipdfmx|xdvipdfmx> \cs_new_protected:Npn \@@_matrix:n #1 - { \@@_literal:n { direct~ #1 \c_space_tl 0~0~cm } } + { \@@_literal:n { #1 \c_space_tl 0~0~cm } } %</dvipdfmx|xdvipdfmx> % \end{macrocode} % \end{macro} @@ -318,43 +376,23 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_box_use_clip:N #1 { -%<*dvips> \@@_state_save: +%<*dvips> \@@_literal:n { - /savedmatrix~matrix~currentmatrix~def~ - currentpoint~translate~ - Resolution~72~div~VResolution~72~div~scale - } - \@@_literal:n - { - 0~ - \__dim_strip_bp:n { \box_dp:N #1 } ~ - \__dim_strip_bp:n { \box_wd:N #1 } ~ - \__dim_strip_bp:n { - \box_ht:N #1 - \box_dp:N #1 } ~ - rectclip + \@@_absolute_lengths:n + { + 0~ + \__dim_strip_bp:n { \box_dp:N #1 } ~ + \__dim_strip_bp:n { \box_wd:N #1 } ~ + \__dim_strip_bp:n { - \box_ht:N #1 - \box_dp:N #1 } ~ + rectclip + } } - \@@_literal:n { savedmatrix~setmatrix } %</dvips> -% \end{macrocode} -% The PDF box is easier to define as it is automatically in big points and -% as the driver deals with the relationship between the \TeX{} and graphics -% locations automatically. The only slight issue is the need to handle -% \texttt{(x)dvipdfmx}'s requirements for mixing PostScript and PDF code: -% using the standard save/restore stack here fails. -% \begin{macrocode} -%<*dvipdfmx|xdvipdfmx> - \@@_literal:n { q } -%</dvipdfmx|xdvipdfmx> -%<*pdfmode> - \@@_state_save: -%</pdfmode> %<*dvipdfmx|pdfmode|xdvipdfmx> \@@_literal:n { -%<*dvipdfmx|xdvipdfmx> - direct~ -%</dvipdfmx|xdvipdfmx> 0~ \__dim_strip_bp:n { - \box_dp:N #1 } ~ \__dim_strip_bp:n { \box_wd:N #1 } ~ @@ -363,36 +401,11 @@ } %</dvipdfmx|pdfmode|xdvipdfmx> % \end{macrocode} -% For \texttt{(x)dvipdfmx} the is a bit more to do yet. Using -% \texttt{pdf:bcontent}/\texttt{pdf:econtent} for scoping seems the easiest -% approach, but only works reliably when all of the specials used are -% \texttt{pdf:\ldots} ones. As (some) PostScript specials can also be used -% with \texttt{(x)dvipdfmx}, that is not safe and can give unexpected output. -% To get everything in the right place, what is required is that the -% insertion point for the clip and the \TeX{} box material are the same. That -% is done by flipping the axes twice with an additional scope level in -% between. The scoping level moves to the \enquote{current point}, which -% due to the axis inversion is the \emph{start} of the clip. The second -% inversion puts things back to normal, the \TeX{} material is inserted and -% then the extra scope is closed (below). -% \begin{macrocode} -%<*dvipdfmx|xdvipdfmx> - \@@_matrix:n { -1~0~0~-1 } - \@@_literal:n { q } - \@@_matrix:n { -1~0~0~-1 } -%</dvipdfmx|xdvipdfmx> -% \end{macrocode} % Insert the material in a box of no width, restore the graphic state % and then insert the necessary width. % \begin{macrocode} \hbox_overlap_right:n { \box_use:N #1 } -%<*dvipdfmx|xdvipdfmx> - \@@_literal:n { Q } - \@@_literal:n { Q } -%</dvipdfmx|xdvipdfmx> -%<*dvips|pdfmode> \@@_state_restore: -%</dvips|pdfmode> \skip_horizontal:n { \box_wd:N #1 } } % \end{macrocode} @@ -403,11 +416,8 @@ % \begin{macro}{\@@_box_rotate_begin:, \@@_box_rotate_end:} % The driver for \texttt{dvips} works with a simple rotation angle. % In PDF mode, an affine matrix is used instead. The transformation for -% \texttt{(x)dvipdfmx} can be done either way: to have some code sharing, -% the choice here is to use an affine approach (at least some code is -% shared in this way). For the \texttt{dvips}, that odd-looking -% |currentpoint| at the beginning is used to put this data onto the -% stack for |neg exch neg exch translate| to pick up. +% \texttt{(x)dvipdfmx} can be done either way: the affine approach is +% chosen here as where possible we pick the PDF-style route. % % In both cases, some rounding code is included to limit the floating % point values to five decimal places. There is no point using any more @@ -446,13 +456,11 @@ \fp_set:Nn \l__box_angle_fp { round ( \l__box_angle_fp , 5 ) } \@@_literal:n { - currentpoint~ - currentpoint~translate~ \fp_compare:nNnTF \l__box_angle_fp = \c_zero_fp { 0 } { \fp_eval:n { - \l__box_angle_fp } } - \c_space_tl rotate~ - neg~exch~neg~exch~translate + \c_space_tl + rotate } %</dvips> } @@ -476,11 +484,9 @@ %<*dvips> \@@_literal:n { - currentpoint~ - currentpoint~translate~ \fp_use:N \l__box_scale_x_fp \c_space_tl - \fp_use:N \l__box_scale_y_fp \c_space_tl scale~ - neg~exch~neg~exch~translate + \fp_use:N \l__box_scale_y_fp \c_space_tl + scale } %</dvips> %<*dvipdfmx|pdfmode|xdvipdfmx> |