diff options
author | Karl Berry <karl@freefriends.org> | 2017-06-05 23:17:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-06-05 23:17:08 +0000 |
commit | 683004f8a1d94fc432fd8104903a431e27bfba93 (patch) | |
tree | 2450b41f4c918810556cbaec853ec48ddc2b949a /Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx | |
parent | c684ba451bf548bdb24c40ed54caa9f11ac21422 (diff) |
latex3 (30may17)
git-svn-id: svn://tug.org/texlive/trunk@44483 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 | 343 |
1 files changed, 313 insertions, 30 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx index 9584a9aa624..68bb90ec8cc 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx @@ -45,7 +45,7 @@ % }^^A % } % -% \date{Released 2017/05/13} +% \date{Released 2017/05/29} % % \maketitle % @@ -640,17 +640,17 @@ % % \subsubsection{Color} % -% \begin{variable}{\l_@@_current_color_tl} +% \begin{variable}{\l_@@_color_current_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 } +\tl_new:N \l_@@_color_current_tl +\tl_set:Nn \l_@@_color_current_tl { 0~g~0~G } %<*package> \AtBeginDocument { \@ifpackageloaded { color } - { \tl_set:Nn \l_@@_current_color_tl { \current@color } } + { \tl_set:Nn \l_@@_color_current_tl { \current@color } } { } } %</package> @@ -676,7 +676,7 @@ { \luatex_pdfextension:D colorstack } { \pdftex_pdfcolorstack:D } \exp_not:N \l_@@_color_stack_int push - { \exp_not:N \l_@@_current_color_tl } + { \exp_not:N \l_@@_color_current_tl } \group_insert_after:N \exp_not:N \@@_color_reset: } \cs_new_protected:Npx \@@_color_reset: @@ -690,6 +690,108 @@ % \end{macro} % \end{macro} % +% \subsection{Images} +% +% \begin{variable}{\l_@@_image_attr_tl} +% In PDF mode, additional attributes of an image (such as page number) are +% needed both to obtain the bounding box and when inserting the image: this +% occurs as the image dictionary approach means they are read as part of +% the bounding box operation. As such, it is easier to track additional +% attributes using a dedicated |tl| rather than build up the same data +% twice. +% \begin{macrocode} +\tl_new:N \l_@@_image_attr_tl +% \end{macrocode} +% \end{variable} +% +% \begin{macro}[int] +% {\@@_image_getbb_jpg:n, \@@_image_getbb_pdf:n, \@@_image_getbb_png:n} +% \begin{macro}[aux] +% {\@@_image_getbb_auxi:n, \@@_image_getbb_auxii:n} +% Getting the bounding box here requires us to box up the image and +% measure it. To deal with the difference in feature support in bitmap +% and vector images but keeping the common parts, there is a little work +% to do in terms of auxiliaries. The key here is to notice that we need +% two forms of the attributes: a \enquote{short} set to allow us to +% track for caching, and the full form to pass to the primitive. Note that +% in |pdftex.def| the short reference is stored to be used in the inclusion +% stage: may be required when there are more aspects to track. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 + { + \int_zero:N \l__image_page_int + \tl_set:Nx \l_@@_image_attr_tl + { + \bool_if:NT \l__image_interpolate_bool + { :I } + } + \@@_image_getbb_auxi:n {#1} + } +\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n +\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 + { + \bool_set_false:N \l__image_interpolate_bool + \tl_set:Nx \l_@@_image_attr_tl + { + \int_compare:nNnT \l__image_page_int > 0 + { :P \int_use:N \l__image_page_int } + } + \@@_image_getbb_auxi:n {#1} + } +\cs_new_protected:Npn \@@_image_getbb_auxi:n #1 + { + \dim_if_exist:cTF { c__image_ #1 \l_@@_image_attr_tl _ht_dim } + { + \dim_set_eq:Nc \l__image_ht_dim + { c__image_ #1 \l_@@_image_attr_tl _ht_dim } + \dim_set_eq:Nc \l__image_wd_dim + { c__image_ #1 \l_@@_image_attr_tl _wd_dim } + } + { \@@_image_getbb_auxii:n {#1} } + } +% \begin{macrocode} +% Measuring the image is done by boxing up: for PDF images we could +% use |\pdftex_pdfximagebbox:D|, but if doesn't work for other types. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_getbb_auxii:n #1 + { + \tex_immediate:D \pdftex_pdfximage:D + \bool_if:NT \l__image_interpolate_bool + { attr ~ { /Interpolate~true } } + \int_compare:nNnT \l__image_page_int > 0 + { page ~ \int_use:N \l__image_page_int } + {#1} + \hbox_set:Nn \l__image_tmp_box + { \pdftex_pdfrefximage:D \pdftex_pdflastximage:D } + \dim_set:Nn \l__image_ht_dim { \box_ht:N \l__image_tmp_box } + \dim_set:Nn \l__image_wd_dim { \box_wd:N \l__image_tmp_box } + \int_const:cn { c__image_ #1 \l_@@_image_attr_tl _int } + { \tex_the:D \pdftex_pdflastximage:D } + \dim_const:cn { c__image_ #1 \l_@@_image_attr_tl _ht_dim } + { \l__image_ht_dim } + \dim_const:cn { c__image_ #1 \l_@@_image_attr_tl _wd_dim } + { \l__image_wd_dim } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[int] +% {\@@_image_include_jpg:n, \@@_image_include_pdf:n, \@@_image_include_png:n} +% Images are already loaded for the measurement part of the code, so +% inclusion is straight-forward, with only any attributes to worry about. The +% latter carry through from determination of the bounding box. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_jpg:n #1 + { + \pdftex_pdfrefximage:D + \int_use:c { c__image_ #1 \l_@@_image_attr_tl _int } + } +\cs_new_eq:NN \@@_image_include_pdf:n \@@_image_include_jpg:n +\cs_new_eq:NN \@@_image_include_png:n \@@_image_include_jpg:n +% \end{macrocode} +% \end{macro} +% % \begin{macrocode} %</pdfmode> % \end{macrocode} @@ -799,16 +901,16 @@ % % \subsubsection{Color} % -% \begin{variable}{\l_@@_current_color_tl} +% \begin{variable}{\l_@@_color_current_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 ] } +\tl_new:N \l_@@_color_current_tl +\tl_set:Nn \l_@@_color_current_tl { [ 0 ] } %<*package> \AtBeginDocument { \@ifpackageloaded { color } - { \tl_set:Nn \l_@@_current_color_tl { \current@color } } + { \tl_set:Nn \l_@@_color_current_tl { \current@color } } { } } %</package> @@ -821,7 +923,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_color_ensure_current: { - \tex_special:D { pdf:bcolor~\l_@@_current_color_tl } + \tex_special:D { pdf:bcolor~\l_@@_color_current_tl } \group_insert_after:N \@@_color_reset: } \cs_new_protected:Npn \@@_color_reset: @@ -830,6 +932,107 @@ % \end{macro} % \end{macro} % +% \subsection{Images} +% +% \begin{macro}[int] +% { +% \@@_image_getbb_eps:n, \@@_image_getbb_jpg:n, +% \@@_image_getbb_pdf:n, \@@_image_getbb_png:n +% } +% Simply use the generic functions: only for \texttt{dvipdfmx} in the +% extraction cases. +% \begin{macrocode} +\cs_new_eq:NN \@@_image_getbb_eps:n \__image_read_bb:n +%<*dvipdfmx> +\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 + { + \int_zero:N \l__image_page_int + \__image_extract_bb:n {#1} + } +\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n +\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 + { + \bool_set_false:N \l__image_interpolate_tl + \__image_extract_bb:n {#1} + } +%</dvipdfmx> +% \end{macrocode} +% \end{macro} +% +% \begin{variable}[aux]{\g_@@_image_int} +% Used to track the object number associated with each image. +% \begin{macrocode} +\int_new:N \g_@@_image_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}[int] +% { +% \@@_image_include_eps:n, \@@_image_include_jpg:n, +% \@@_image_include_pdf:n, \@@_image_include_png:n +% } +% \begin{macro}[aux]{\@@_image_include_auxi:nn} +% \begin{macro}[aux]{\@@_image_include_auxii:nnn, \@@_image_include_auxii:xnn} +% \begin{macro}[aux]{\@@_image_include_auxiii:nn} +% The special syntax depends on the file type. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_eps:n #1 + { + \tex_special:D { PSfile = #1 } + } +\cs_new_protected:Npn \@@_image_include_jpg:n #1 + { \@@_image_include_auxi:nn {#1} { image } } +\cs_new_eq:NN \@@_image_include_png:n \@@_image_include_png:n +\cs_new_protected:Npn \@@_image_include_pdf:n #1 + { \@@_image_include_auxi:nn {#1} { epdf } } +% \end{macrocode} +% Image inclusion is set up to use the fact that each image is stored in +% the PDF as an XObject. This means that we can include repeated images +% only once and refer to them. To allow that, track the nature of each +% image: much the same as for the direct PDF mode case. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_auxi:nn #1#2 + { + \@@_image_include_auxii:xnn + { + \int_compare:nNnT \l__image_page_int > 0 + { :P \int_use:N \l__image_page_int } + \bool_if:NT \l__image_interpolate_bool + { :I } + } + {#1} {#2} + } +\cs_new_protected:Npn \@@_image_include_auxii:nnn #1#2#3 + { + \int_if_exist:cTF { c__image_ #2#1 _int } + { + \tex_special:D + { pdf:usexobj~@image \int_use:c { c__image_ #2#1 _int } } + } + { \@@_image_include_auxiii:nn {#2} {#1} {#3} } + } +\cs_generate_variant:Nn \@@_image_include_auxii:nnn { x } +\cs_new_protected:Npn \@@_image_include_auxiii:nnn #1#2#3 + { + \int_gincr:N \g_@@_image_int + \int_const:cn { c__image_ #1#2 _int } { \g_@@_image_int } + \tex_special:D + { + pdf:#3~ + @image \int_use:c { c__image_ #1#2 _int } + \int_compare:nNnT \l__image_page_int > 0 + { page ~ \int_use:N \l__image_page_int \c_space_tl } + (#1) + \bool_if:NT \l__image_interpolate_bool + { <</Interpolate~true>> } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macrocode} %</dvipdfmx|xdvipdfmx> % \end{macrocode} @@ -844,21 +1047,29 @@ % % \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. +% Older \LaTeXe{} drivers uses \texttt{dvips}-like specials so there has to +% be a change of set up if \pkg{color} is loaded and if the current color +% doesn't match the pattern expected for |dvipdfmx|. % \begin{macrocode} %<*package> \AtBeginDocument { \@ifpackageloaded { color } { - \cs_set_protected:Npn \@@_color_ensure_current: + \cs_set_protected:Npn \@@_tmp:w #1 [ #2 ] #3 \q_stop { - \tex_special:D { color~push~\l_@@_current_color_tl } - \group_insert_after:N \@@_color_reset: + \tl_if_empty:nT {#2} + { + \cs_set_protected:Npn \@@_color_ensure_current: + { + \tex_special:D { color~push~\l_@@_color_current_tl } + \group_insert_after:N \@@_color_reset: + } + \cs_set_protected:Npn \@@_color_reset: + { \tex_special:D { color~pop } } + } } - \cs_set_protected:Npn \@@_color_reset: - { \tex_special:D { color~pop } } + \exp_after:wN \@@_tmp:w \current@color [ ] \q_stop } { } } @@ -867,6 +1078,58 @@ % \end{macro} % \end{macro} % +% \subsection{Images} +% +% \begin{macro}[int] +% {\@@_image_getbb_jpg:n, \@@_image_getbb_pdf:n, \@@_image_getbb_png:n} +% \begin{macro}[aux]{\@@_image_getbb_auxi:nN} +% \begin{macro}[aux]{\@@_image_getbb_auxii:nnN, \@@_image_getbb_auxii:VnN} +% \begin{macro}[aux]{\@@_image_getbb_auxiii:nNnn} +% For \texttt{xdvipdfmx}, there are two primitives that allow us to obtain +% the bounding box without needing \texttt{extractbb}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_getbb_jpg:n #1 + { + \int_zero:N \l__image_page_int + \@@_image_getbb_auxi:nN {#1} \xetex_picfile:D + } +\cs_new_eq:NN \@@_image_getbb_png:n \@@_image_getbb_jpg:n +\cs_new_protected:Npn \@@_image_getbb_pdf:n #1 + { \@@_image_getbb_auxi:nN {#1} \xetex_pdffile:D } +\cs_new_protected:Npn \@@_image_getbb_auxi:nN #1#2 + { + \int_compare:nNnTF \l__image_page_int > 0 + { \@@_image_getbb_auxii:VnN \l__image_page_int {#1} #2 } + { \@@_image_getbb_auxiii:nNnn {#1} #2 } + } +\cs_new_protected:Npn \@@_image_getbb_auxii:nnN #1#2#3 + { \@@_image_getbb_auxiii:nNnn {#2} #3 { :P #1 } { page #1 } } +\cs_generate_variant:Nn \@@_image_getbb_auxii:nnN { V } +\cs_new_protected:Npn \@@_image_getbb_auxiii:nNnn #1#2#3#4 + { + \dim_if_exist:cTF { c__image_ #1#3 _ht_dim } + { + \dim_set_eq:Nc \l__image_ht_dim { c__image_ #1#3 _ht_dim } + \dim_set_eq:Nc \l__image_wd_dim { c__image_ #1#3 _wd_dim } + } + { \@@_image_getbb_auxvi:nNnn {#1} #2 {#3} {#4} } + } +\cs_new_protected:Npn \@@_image_getbb_auxvi:nNnn #1#2#3#4 + { + \hbox_set:Nn \l__image_tmp_box { #2 #1 ~ #4 } + \dim_set:Nn \l__image_ht_dim { \box_ht:N \l__image_tmp_box } + \dim_set:Nn \l__image_wd_dim { \box_wd:N \l__image_tmp_box } + \dim_const:cn { c__image_ #1#3 _ht_dim } + { \l__image_ht_dim } + \dim_const:cn { c__image_ #1#3 _wd_dim } + { \l__image_wd_dim } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macrocode} %</xdvipdfmx> % \end{macrocode} @@ -874,7 +1137,7 @@ % \subsection{Drawing commands: \texttt{pdfmode} and \texttt{(x)dvipdfmx}} % % Both \texttt{pdfmode} and \texttt{(x)dvipdfmx} directly produce PDF output -% and undertand a shared set of specials for drawing commands. +% and understand a shared set of specials for drawing commands. % % \begin{macrocode} %<*dvipdfmx|pdfmode|xdvipdfmx> @@ -954,7 +1217,7 @@ % \end{macro} % % \begin{macro}[int]{\@@_draw_evenodd_rule:, \@@_draw_nonzero_rule:} -% \begin{variable}[aux]{\g_@@_draw_eor_bool} +% \begin{variable}[int]{\g_@@_draw_eor_bool} % The even-odd rule here can be implemented as a simply switch. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_evenodd_rule: @@ -1341,16 +1604,16 @@ % % \subsubsection{Color} % -% \begin{variable}{\l_@@_current_color_tl} +% \begin{variable}{\l_@@_color_current_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 } +\tl_new:N \l_@@_color_current_tl +\tl_set:Nn \l_@@_color_current_tl { gray~0 } %<*package> \AtBeginDocument { \@ifpackageloaded { color } - { \tl_set:Nn \l_@@_current_color_tl { \current@color } } + { \tl_set:Nn \l_@@_color_current_tl { \current@color } } { } } %</package> @@ -1363,7 +1626,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_color_ensure_current: { - \tex_special:D { color~push~\l_@@_current_color_tl } + \tex_special:D { color~push~\l_@@_color_current_tl } \group_insert_after:N \@@_color_reset: } \cs_new_protected:Npn \@@_color_reset: @@ -1372,6 +1635,26 @@ % \end{macro} % \end{macro} % +% \subsection{Images} +% +% \begin{macro}[int]{\@@_image_getbb_eps:n} +% Simply use the generic function. +% \begin{macrocode} +\cs_new_eq:NN \@@_image_getbb_eps:n \__image_read_bb:n +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\@@_image_include_eps:n} +% The special syntax is relatively clear here: remember we need PostScript +% sizes here. +% \begin{macrocode} +\cs_new_protected:Npn \@@_image_include_eps:n #1 + { + \tex_special:D { PSfile = #1 } + } +% \end{macrocode} +% \end{macro} +% % \subsection{Drawing} % % \begin{macro}[aux]{\@@_draw_literal:n, \@@_draw_literal:x} @@ -1972,17 +2255,17 @@ % % \subsubsection{Color} % -% \begin{variable}{\l_@@_current_color_tl} +% \begin{variable}{\l_@@_color_current_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 } +\tl_new:N \l_@@_color_current_tl +\tl_set:Nn \l_@@_color_current_tl { gray~0 } %<*package> \AtBeginDocument { \@ifpackageloaded { color } - { \tl_set:Nn \l_@@_current_color_tl { \current@color } } + { \tl_set:Nn \l_@@_color_current_tl { \current@color } } { } } %</package> @@ -1995,7 +2278,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_color_ensure_current: { - \tex_special:D { color~push~\l_@@_current_color_tl } + \tex_special:D { color~push~\l_@@_color_current_tl } \group_insert_after:N \@@_color_reset: } \cs_new_protected:Npn \@@_color_reset: |