diff options
author | Karl Berry <karl@freefriends.org> | 2021-07-22 20:40:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-07-22 20:40:06 +0000 |
commit | 1533ab903c9333f75c242d2a5927036e4ce14739 (patch) | |
tree | 4ccd9360dd898abcefcc5faa1effdb18e3cb9c96 /Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx | |
parent | 5d6aa3bb897112068aa9d0576df5330ef881f8e3 (diff) |
pdfmanagement-testphase (22jul21)
git-svn-id: svn://tug.org/texlive/trunk@60016 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx | 205 |
1 files changed, 159 insertions, 46 deletions
diff --git a/Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx b/Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx index b877ce86fc1..7b4aad8fe6b 100644 --- a/Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx +++ b/Master/texmf-dist/source/latex/pdfmanagement-testphase/l3backend-testphase.dtx @@ -45,7 +45,7 @@ % }^^A % } % -% \date{Version 0.95f, released 2021-06-29} +% \date{Version 0.95g, released 2021-07-21} % % \maketitle % @@ -56,27 +56,27 @@ % \begin{macrocode} %<drivers>\ProvidesExplFile %<*dvipdfmx> - {l3backend-testphase-dvipdfmx.def}{2021-06-29}{} + {l3backend-testphase-dvipdfmx.def}{2021-07-21}{} {LaTeX~PDF~management~testphase~bundle~backend~support: dvipdfmx} %</dvipdfmx> %<*dvips> - {l3backend-testphase-dvips.def}{2021-06-29}{} + {l3backend-testphase-dvips.def}{2021-07-21}{} {LaTeX~PDF~management~testphase~bundle~backend~support: dvips} %</dvips> %<*dvisvgm> - {l3backend-testphase-dvisvgm.def}{2021-06-29}{} + {l3backend-testphase-dvisvgm.def}{2021-07-21}{} {LaTeX~PDF~management~testphase~bundle~backend~support: dvisvgm} %</dvisvgm> %<*luatex> - {l3backend-testphase-luatex.def}{2021-06-29}{} + {l3backend-testphase-luatex.def}{2021-07-21}{} {LaTeX~PDF~management~testphase~bundle~backend~support: PDF output (LuaTeX)} %</luatex> %<*pdftex> - {l3backend-testphase-pdftex.def}{2021-06-29}{} + {l3backend-testphase-pdftex.def}{2021-07-21}{} {LaTeX~PDF~management~testphase~bundle~backend~support: PDF output (pdfTeX)} %</pdftex> %<*xdvipdfmx> - {l3backend-testphase-xetex.def}{2021-06-29}{} + {l3backend-testphase-xetex.def}{2021-07-21}{} {LaTeX~PDF~management~testphase~bundle~backend~support: XeTeX} %</xdvipdfmx> % \end{macrocode} @@ -106,11 +106,10 @@ \cs_generate_variant:Nn \@@_backend_ref_value:nn {en} %</drivers> % \end{macrocode} +% avoid that destinations names are optimized with xelatex/dvipdfmx +% see https://tug.org/pipermail/dvipdfmx/2019-May/000002.html % \begin{macrocode} %<*dvipdfmx|xdvipdfmx> -% avoid that destinations names are optimized. -% is this still needed?? -% see https://tug.org/pipermail/dvipdfmx/2019-May/000002.html \__kernel_backend_literal:x { dvipdfmx:config~C~ 0x0010 } %</dvipdfmx|xdvipdfmx> % \end{macrocode} @@ -121,6 +120,7 @@ \prop_new:N \g_@@_tmpa_prop \tl_new:N \l_@@_tmpa_tl \box_new:N \l_@@_backend_tmpa_box +\box_new:N \l_@@_backend_tmpb_box %</drivers> % \end{macrocode} % \end{variable} @@ -201,20 +201,12 @@ { \g__kernel_pdfmanagement_thispage_shipout_code_tl } - \tl_gput_left:Nn\@kernel@after@shipout@lastpage - { - \g__kernel_pdfmanagement_lastpage_shipout_code_tl - } } { \hook_gput_code:nnn{shipout/background}{pdf} { \g__kernel_pdfmanagement_thispage_shipout_code_tl } - \hook_gput_code:nnn {shipout/lastpage} {pdf} - { - \g__kernel_pdfmanagement_lastpage_shipout_code_tl - } } %</drivers> @@ -561,21 +553,10 @@ % \subsection{\enquote{Page/Resources}: ExtGState, ColorSpace, Shading, Pattern} % Path: Page/Resources/ExtGState etc. The actual output of the resources is handled % together with the bdc/Properties. Here is only special code. -% \begin{macro}{\@@_backend_PageResources_gput:nnn} -% stores values for the page resources. -% \begin{arguments} -% \item name of the resource (ExtGState, ColorSpace, Shading, Pattern) -% \item a pdf name without slash -% \item value -% \end{arguments} -% \begin{macro}{\@@_backend_PageResources_obj_gpush:} -% This pushes out the objects. It is a no-op with xdvipdfmx and dvips. -% \begin{macrocode} -% backend commands the command to fill the register -% and to push the values. -% +% \begin{macro}{\c_@@_backend_PageResources_clist} % The names are quite often needed % a similar list is now in l3pdfmanagement. Perhaps it should be merged. +% \begin{macrocode} %<*drivers> \clist_const:Nn \c_@@_backend_PageResources_clist { @@ -585,9 +566,25 @@ Shading, } %</drivers> -% pdftex and luatex +% \end{macrocode} +% \end{macro} +% +% Now the backend commands the command to fill the register +% and to push the values. +% +% \begin{macro}{\@@_backend_PageResources_gput:nnn} +% stores values for the page resources. +% \begin{arguments} +% \item name of the resource (ExtGState, ColorSpace, Shading, Pattern) +% \item a pdf name without slash +% \item value +% \end{arguments} +% \begin{macro}{\@@_backend_PageResources_obj_gpush:} +% This pushes out the objects. It should be a no-op with xdvipdfmx and dvips +% as it currently issued in the end-of-run hook! +% create the backend objects: +% \begin{macrocode} %<*pdftex|luatex> - %create the backend objects: \clist_map_inline:Nn \c_@@_backend_PageResources_clist { \@@_backend_object_new:nn {@@/Page/Resources/#1} {dict} @@ -602,12 +599,14 @@ } } %</pdftex|luatex> +% \end{macrocode} +% values are only stored in a prop and will be output at end document. +% luatex must also trigger the lua side +% \begin{macrocode} %<*luatex> -%values are only stored in a prop and will be output at end document. \cs_new_protected:Npn \@@_backend_PageResources_gput:nnn #1 #2 #3 { \pdfdict_gput:nnn {g_@@_Core/Page/Resources/#1} { #2 }{ #3 } - % luatex must also trigger the lua side \tex_latelua:D{ltx.@@.Page.Resources.#1=true} \tex_latelua:D { @@ -621,8 +620,10 @@ \pdfdict_gput:nnn {g_@@_Core/Page/Resources/#1} { #2 }{ #3 } } %</pdftex> +% \end{macrocode} +% code for end of document code +% \begin{macrocode} %<*pdftex|luatex> -%code for end of document code \cs_new_protected:Npn \@@_backend_PageResources_obj_gpush: { \clist_map_inline:Nn \c_@@_backend_PageResources_clist @@ -637,15 +638,19 @@ } } %</pdftex|luatex> +% \end{macrocode} % xdvipdfmx % \special{pdf:pageresources<<#1>>} doesn't work correctly with object names ... % https://tug.org/pipermail/dvipdfmx/2019-August/000021.html, % so we use \special{pdf:put @resources} % this must be issued on every page! -%<*dvipdfmx|xdvipdfmx> -%objects should not only be created but also "initialized" +% objects should not only be created but also "initialized" % initialization should be done before anyone tries to write % so we add rules for the backend. +% The push command should not be used as it is +% in the wrong end document hook. If needed a new command must be added. +% \begin{macrocode} +%<*dvipdfmx|xdvipdfmx> %<xdvipdfmx>\hook_gset_rule:nnnn{shipout/firstpage}{l3backend-xetex}{after}{pdf} %<dvipdfmx>\hook_gset_rule:nnnn{shipout/firstpage}{l3backend-dvipdfmx}{after}{pdf} % @@ -673,8 +678,11 @@ \cs_new_protected:Npn \@@_backend_PageResources_obj_gpush: {} %</dvipdfmx|xdvipdfmx> +% \end{macrocode} +% dvips unneeded, or no-op. The push command should not be used as it is +% in the wrong end document hook. If needed a new command must be added. +% \begin{macrocode} %<*dvips> -% dvips unneeded, or no-op \cs_new_protected:Npn \@@_backend_PageResources:n #1 {} \cs_new_protected:Npn \@@_backend_PageResources_gput:nnn #1 #2 #3 { %only for the show command TEST!! @@ -682,8 +690,10 @@ } \cs_new_protected:Npn \@@_backend_PageResources_obj_gpush: {} %</dvips> +% \end{macrocode} +% dvipsvgm unneeded, or no-op +% \begin{macrocode} %<*dvisvgm> -% dvips unneeded, or no-op \cs_new_protected:Npn \@@_backend_PageResources:n #1 {} \cs_new_protected:Npn \@@_backend_PageResources_gput:nnn #1 #2 #3 { %only for the show command TEST!! @@ -725,23 +735,23 @@ % \cs_set_protected:Npn \@@_backend_bdc:nn #1 #2 % #1 eg. Span, #2: dict_content { - \__pdf_backend_pdfmark:x{/#1~<<#2>>~/BDC} + \@@_backend_pdfmark:x{/#1~<<#2>>~/BDC} } \cs_set_protected:Npn \@@_backend_bdcobject:nn #1 #2 % #1 eg. Span, #2: object name { - \__pdf_backend_pdfmark:x{/#1~\@@_backend_object_ref:n{#2}~/BDC} + \@@_backend_pdfmark:x{/#1~\@@_backend_object_ref:n{#2}~/BDC} } \cs_set_protected:Npn \@@_backend_bdcobject:n #1 % #1 eg. Span, { - \__pdf_backend_pdfmark:x{/#1~\@@_backend_object_last:~/BDC} + \@@_backend_pdfmark:x{/#1~\@@_backend_object_last:~/BDC} } \cs_set_protected:Npn \@@_backend_emc: { - \__pdf_backend_pdfmark:n{/EMC} % + \@@_backend_pdfmark:n{/EMC} % } \cs_set_protected:Npn \@@_backend_bmc:n #1 { - \__pdf_backend_pdfmark:n{/#1~/BMC} % + \@@_backend_pdfmark:n{/#1~/BMC} % } \cs_new_protected:Npn \@@_backend_PageResources_gpush:n #1 {} @@ -1099,7 +1109,7 @@ { \pdf_object_unnamed_write:nn {dict} { /Names [#1] } %n or x? - \__pdf_backend:x {put~@names~<</EmbeddedFiles~\pdf_object_ref_last: >>} + \@@_backend:x {put~@names~<</EmbeddedFiles~\pdf_object_ref_last: >>} } %</dvipdfmx|xdvipdfmx> @@ -1472,6 +1482,109 @@ \cs_new_protected:Npn \@@_backend_xform_use:n #1 {} \cs_new:Npn \@@_backend_xform_ref:n {} %</dvisvgm> +% \end{macrocode} +% The xform code for dvips is based on code from the attachfile2 package +% (in atfi-dvips), along with some ideas from pdfbase and has been corrected +% with the help of Alexander Grahn. +% Details like clipping and landscape will probably be corrected in the future. +% \begin{macrocode} +%<*dvips> +\cs_new_protected:Npn\@@_backend_xform_new:nnnn #1 #2 #3 #4 % #1 name, #2 attribute, #4 content + { + \int_gincr:N \g_@@_backend_object_int + \int_const:cn + { c_@@_backend_xform_ \tl_to_str:n {#1} _int } + { \g_@@_backend_object_int } + + \hbox_set:Nn \l_@@_backend_tmpa_box + { + \bool_set_true:N \l_@@_backend_xform_bool + \prop_gclear:c {\__kernel_pdfdict_name:n { g_@@_Core/Xform/Resources/Properties }} + #4 + } + %store the dimensions + \tl_const:cx + { c_@@_backend_xform_wd_ \tl_to_str:n {#1} _tl } + { \tex_the:D \box_wd:N \l_@@_backend_tmpa_box } + \tl_const:cx + { c_@@_backend_xform_ht_ \tl_to_str:n {#1} _tl } + { \tex_the:D \box_ht:N \l_@@_backend_tmpa_box } + \tl_const:cx + { c_@@_backend_xform_dp_ \tl_to_str:n {#1} _tl } + { \tex_the:D \box_dp:N \l_@@_backend_tmpa_box } + %mirror the box + \box_scale:Nnn \l_@@_backend_tmpa_box {1} {-1} + \hbox_set:Nn\l_@@_backend_tmpb_box + { + \__kernel_backend_postscript:x + { + gsave~currentpoint~translate~ + mark~ + /_objdef~{ pdf.obj \int_use:N\g_@@_backend_object_int }\c_space_tl~ + /BBox[ + currentpoint~\dim_to_decimal:n{\box_dp:N \l_@@_backend_tmpa_box}~72.27~div~VResolution~mul~add~ + currentpoint~ + exch~\dim_to_decimal:n{\box_wd:N \l_@@_backend_tmpa_box}~72.27~div~Resolution~mul~add~ + exch~\dim_to_decimal:n{\box_ht:N \l_@@_backend_tmpa_box}~72.27~div~VResolution~mul~sub~ + ] + \str_if_eq:eeF{#1}{} + { + product~(Distiller)~search~{pop~pop~pop~#2}{pop}ifelse~ + } + /BP~pdfmark~grestore~ + } + \box_use_drop:N\l_@@_backend_tmpa_box + \__kernel_backend_postscript:n + { + mark ~ /EP~pdfmark + } + \str_if_eq:eeF{#1}{} + { + \__kernel_backend_postscript:x + { + product~(Ghostscript)~search~ + { + pop~pop~pop~ + mark~ + { pdf.obj \int_use:c{c_@@_backend_xform_ \tl_to_str:n {#1} _int} } + ~<<#2>>~/PUT~pdfmark + }{pop}ifelse + } + } + } + \box_set_dp:Nn \l_@@_backend_tmpb_box { \c_zero_dim } + \box_set_ht:Nn \l_@@_backend_tmpb_box { \c_zero_dim } + \box_set_wd:Nn \l_@@_backend_tmpb_box { \c_zero_dim } + \hook_gput_code:nnn {begindocument/end}{pdfxform} + { + \mode_leave_vertical: + \box_use:N\l_@@_backend_tmpb_box + } + } + + +\cs_new_protected:Npn \@@_backend_xform_use:n #1 + { + \hbox_set:Nn \l_@@_backend_tmpa_box + { + \__kernel_backend_postscript:x + { + gsave~currentpoint~translate~1~-1~scale~ + mark~{ pdf.obj \int_use:c{c__pdf_backend_xform_ \tl_to_str:n {#1} _int }}~ + /SP~pdfmark ~ grestore + } + } + \box_set_wd:Nn \l_@@_backend_tmpa_box { \pdfxform_wd:n { #1 } } + \box_set_ht:Nn \l_@@_backend_tmpa_box { \pdfxform_ht:n { #1 } } + \box_set_dp:Nn \l_@@_backend_tmpa_box { \pdfxform_dp:n { #1 } } + \box_use_drop:N \l_@@_backend_tmpa_box + } +\cs_new:Npn \@@_backend_xform_ref:n #1 + { + { pdf.obj \int_use:c{c_@@_backend_xform_ \tl_to_str:n {#1} _int} } + } + +%</dvips> %<*drivers> %% all \prg_new_conditional:Npnn \@@_backend_xform_if_exist:n #1 { p , T , F , TF } |