diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-03 03:01:14 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-03 03:01:14 +0000 |
commit | fc732340b62b41cedbe82bcb3675a86c65343a21 (patch) | |
tree | c490d1d57d300b1024517118f6e494d68eae5bcd /macros/latex/contrib/l3backend/l3backend-pdf.dtx | |
parent | 66aedee32b96d68acc7b854602552c75ef261973 (diff) |
CTAN sync 202009030301
Diffstat (limited to 'macros/latex/contrib/l3backend/l3backend-pdf.dtx')
-rw-r--r-- | macros/latex/contrib/l3backend/l3backend-pdf.dtx | 419 |
1 files changed, 230 insertions, 189 deletions
diff --git a/macros/latex/contrib/l3backend/l3backend-pdf.dtx b/macros/latex/contrib/l3backend/l3backend-pdf.dtx index fb569f2c24..f0f20e1b9a 100644 --- a/macros/latex/contrib/l3backend/l3backend-pdf.dtx +++ b/macros/latex/contrib/l3backend/l3backend-pdf.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-08-07} +% \date{Released 2020-09-01} % % \maketitle % @@ -744,10 +744,10 @@ %</dvips> % \end{macrocode} % -% \subsection{\texttt{pdfmode} backend} +% \subsection{\LuaTeX{} and \pdfTeX{} backend} % % \begin{macrocode} -%<*pdfmode> +%<*luatex|pdftex> % \end{macrocode} % % \subsubsection{Annotations} @@ -755,28 +755,35 @@ % \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_new_protected:Npn \@@_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} ~ +%<*luatex> + \tex_pdfextension:D annot ~ +%</luatex> +%<*pdftex> + \tex_pdfannot:D +%</pdftex> + width ~ \dim_eval:n {#1} ~ + height ~ \dim_eval:n {#2} ~ + depth ~ \dim_eval:n {#3} ~ {#4} } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_backend_annotation_last:} -% A tiny amount of extra data gets added here. +% A tiny amount of extra data gets added here; we use \texttt{x}-type +% expansion to get the space in the right place and form. % \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 } +%<*luatex> + \exp_not:N \tex_pdffeedback:D lastannot +%</luatex> +%<*pdftex> + \exp_not:N \tex_pdfannot:D +%</pdftex> \c_space_tl 0 ~ R } % \end{macrocode} @@ -792,19 +799,25 @@ { \@@_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_new_protected:Npn \@@_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} +%<*luatex> + \tex_pdfextension:D startlink ~ +%</luatex> +%<*pdftex> + \tex_pdfstartlink:D +%</pdftex> + attr {#1} + #2 {#3} } -\cs_new_protected:Npx \@@_backend_link_end: +\cs_new_protected:Npn \@@_backend_link_end: { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D endlink \scan_stop: } - { \tex_pdfendlink:D } +%<*luatex> + \tex_pdfextension:D endlink \scan_stop: +%</luatex> +%<*pdftex> + \tex_pdfendlink:D +%</pdftex> } % \end{macrocode} % \end{macro} @@ -817,9 +830,12 @@ \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 } +%<*luatex> + \exp_not:N \tex_pdffeedback:D lastlink +%</luatex> +%<*pdftex> + \exp_not:N \tex_pdflastlink:D +%</pdftex> \c_space_tl 0 ~ R } % \end{macrocode} @@ -828,12 +844,15 @@ % \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_new_protected:Npn \@@_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: +%<*luatex> + \tex_pdfvariable:D linkmargin +%</luatex> +%<*pdftex> + \tex_pdflinkmargin:D +%</pdftex> + \dim_eval:n {#1} \scan_stop: } % \end{macrocode} % \end{macro} @@ -844,13 +863,16 @@ % 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_new_protected:Npn \@@_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 } +%<*luatex> + \tex_pdfextension:D dest ~ +%</luatex> +%<*pdftex> + \tex_pdfdest:D +%</pdftex> name {#1} - \exp_not:N \str_case:nnF {#2} + \str_case:nnF {#2} { { xyz } { xyz } { fit } { fit } @@ -860,21 +882,24 @@ { fith } { fith } { fitv } { fitv } } - { xyz ~ zoom \exp_not:N \fp_eval:n { #2 * 10 } } + { xyz ~ zoom \fp_eval:n { #2 * 10 } } \scan_stop: } -\cs_new_protected:Npx \@@_backend_destination_box:nn #1#2 +\cs_new_protected:Npn \@@_backend_destination_box: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 } +%<*luatex> + \tex_pdfextension:D dest ~ +%</luatex> +%<*pdftex> + \tex_pdfdest:D +%</pdftex> 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 + width \box_wd:N \l_@@_internal_box + height \box_ht:N \l_@@_internal_box + depth \box_dp:N \l_@@_internal_box \box_use:N \l_@@_internal_box \group_end: } @@ -885,19 +910,25 @@ % % \begin{macro}{\@@_backend_catalog_gput:nn, \@@_backend_info_gput:nn} % \begin{macrocode} -\cs_new_protected:Npx \@@_backend_catalog_gput:nn #1#2 +\cs_new_protected:Npn \@@_backend_catalog_gput:nn #1#2 { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D catalog } - { \tex_pdfcatalog:D } - { / #1 ~ #2 } +%<*luatex> + \tex_pdfextension:D catalog +%</luatex> +%<*pdftex> + \tex_pdfcatalog:D +%</pdftex> + { / #1 ~ #2 } } -\cs_new_protected:Npx \@@_backend_info_gput:nn #1#2 +\cs_new_protected:Npn \@@_backend_info_gput:nn #1#2 { - \cs_if_exist:NTF \tex_pdfextension:D - { \tex_pdfextension:D info } - { \tex_pdfinfo:D } - { / #1 ~ #2 } +%<*luatex> + \tex_pdfextension:D info +%</luatex> +%<*pdftex> + \tex_pdfinfo:D +%</pdftex> + { / #1 ~ #2 } } % \end{macrocode} % \end{macro} @@ -916,26 +947,25 @@ % 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_protected:Npn \@@_backend_object_new:nn #1#2 + { +%<*luatex> + \tex_pdfextension:D obj ~ +%</luatex> +%<*pdftex> + \tex_pdfobj:D +%</pdftex> + reserveobjnum ~ + \int_const:cn + { c_@@_backend_object_ \tl_to_str:n {#1} _int } +%<*luatex> + { \tex_pdffeedback:D lastobj } +%</luatex> +%<*pdftex> + { \tex_pdflastobj:D } +%</pdftex> + \prop_gput:Nnn \exp_not:N \g_@@_backend_object_prop {#1} {#2} + } \cs_new:Npn \@@_backend_object_ref:n #1 { \int_use:c { c_@@_backend_object_ \tl_to_str:n {#1} _int } ~ 0 ~ R } % \end{macrocode} @@ -947,36 +977,34 @@ % 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 +\cs_new_protected:Npn \@@_backend_object_write:nn #1#2 + { +%<*luatex> + \tex_immediate:D \tex_pdfextension:D obj ~ +%</luatex> +%<*pdftex> + \tex_immediate:D \tex_pdfobj:D +%</pdftex> + 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} } { - \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 } - } - } + { 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} } @@ -987,34 +1015,31 @@ % \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 +\cs_new_protected:Npn \@@_backend_object_now:nn #1#2 + { +%<*luatex> + \tex_immediate:D \tex_pdfextension:D obj ~ +%</luatex> +%<*pdftex> + \tex_immediate:D \tex_pdfobj:D +%</pdftex> + \str_case:nn + {#1} { - \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 } - } - } + { 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} @@ -1025,23 +1050,29 @@ \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 } +%<*luatex> + \exp_not:N \tex_pdffeedback:D lastobj ~ +%</luatex> +%<*pdftex> + \exp_not:N \tex_pdflastobj:D +%</pdftex> \c_space_tl 0 ~ R } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_backend_pageobject_ref:n} -% The usual wrapper situation. +% The usual wrapper situation; the three spaces here are essential. % \begin{macrocode} \cs_new:Npx \@@_backend_pageobject_ref:n #1 { \exp_not:N \int_value:w - \cs_if_exist:NTF \tex_pdffeedback:D - { \exp_not:N \tex_pdffeedback:D pageref } - { \exp_not:N \tex_pdfpageref:D } +%<*luatex> + \exp_not:N \tex_pdffeedback:D pageref +%</luatex> +%<*pdftex> + \exp_not:N \tex_pdfpageref:D +%</pdftex> \c_space_tl #1 \c_space_tl \c_space_tl \c_space_tl 0 ~ R } % \end{macrocode} @@ -1054,13 +1085,16 @@ % \begin{macro}{\@@_backend_objcompresslevel:n} % Simply pass data to the engine. % \begin{macrocode} -\cs_new_protected:Npx \@@_backend_compresslevel:n #1 +\cs_new_protected:Npn \@@_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: + \tex_global:D +%<*luatex> + \tex_pdfvariable:D compresslevel +%</luatex> +%<*pdftex> + \tex_pdfcompresslevel:D +%</pdftex> + \int_value:w \int_eval:n {#1} \scan_stop: } \cs_new_protected:Npn \@@_backend_compress_objects:n #1 { @@ -1068,13 +1102,16 @@ { \@@_backend_objcompresslevel:n { 2 } } { \@@_backend_objcompresslevel:n { 0 } } } -\cs_new_protected:Npx \@@_backend_objcompresslevel:n #1 +\cs_new_protected:Npn \@@_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: + \tex_global:D +%<*luatex> + \tex_pdfvariable:D objcompresslevel +%</luatex> +%<*pdftex> + \tex_pdfobjcompresslevel:D +%</pdftex> + #1 \scan_stop: } % \end{macrocode} % \end{macro} @@ -1083,61 +1120,65 @@ % % \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 +% The availability of the primitive is not universal, so we have to test +% at load time. % \begin{macrocode} \cs_new_protected:Npx \@@_backend_version_major_gset:n #1 { - \cs_if_exist:NTF \tex_pdfvariable:D +%<*luatex> + \int_compare:nNnT \tex_luatexversion:D > { 106 } { - \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: - } + \exp_not:N \tex_global:D \tex_pdfvariable:D majorversion + \exp_not:N \int_eval:n {#1} \scan_stop: } +%</luatex> +%<*pdftex> + \cs_if_exist:NT \tex_pdfmajorversion:D { - \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: - } + \exp_not:N \tex_global:D \tex_pdfmajorversion:D + \exp_not:N \int_eval:n {#1} \scan_stop: } +%</pdftex> } -\cs_new_protected:Npx \@@_backend_version_minor_gset:n #1 +\cs_new_protected:Npn \@@_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: + \tex_global:D +%<*luatex> + \tex_pdfvariable:D minorversion +%</luatex> +%<*pdftex> + \tex_pdfminorversion:D +%</pdftex> + \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! +% As above. % \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 } - } +%<*luatex> + \int_compare:nNnTF \tex_luatexversion:D > { 106 } + { \exp_not:N \tex_the:D \tex_pdfvariable:D majorversion } + { 1 } +%</luatex> +%<*pdftex> + \cs_if_exist:NTF \tex_pdfmajorversion:D + { \exp_not:N \tex_the:D \tex_pdfmajorversion:D } + { 1 } +%</pdftex> } -\cs_new:Npx \@@_backend_version_minor: +\cs_new:Npn \@@_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 } + \tex_the:D +%<*luatex> + \tex_pdfvariable:D minorversion +%</luatex> +%<*pdftex> + \tex_pdfminorversion:D +%</pdftex> } % \end{macrocode} % \end{macro} @@ -1158,13 +1199,13 @@ % \end{macro} % % \begin{macrocode} -%</pdfmode> +%</luatex|pdftex> % \end{macrocode} % % \subsection{\texttt{dvipdfmx} backend} % % \begin{macrocode} -%<*dvipdfmx|xdvipdfmx> +%<*dvipdfmx|xetex> % \end{macrocode} % % \begin{macro}{\@@_backend:n, \@@_backend:x} @@ -1290,7 +1331,7 @@ % \end{macro} % % \begin{macro}[EXP]{\@@_backend_pageobject_ref:n} -% Page references are easy in \texttt{(x)dvipdfmx}. +% Page references are easy in \texttt{dvipdfmx}/\XeTeX{}. % \begin{macrocode} \cs_new:Npn \@@_backend_pageobject_ref:n #1 { @page #1 } @@ -1300,7 +1341,7 @@ % \subsubsection{Annotations} % % \begin{variable}{\g_@@_landscape_bool} -% There is a bug in \texttt{(x)dvipdfmx} which means annotations do +% There is a bug in \texttt{dvipdfmx}/\XeTeX{} which means annotations do % not rotate. As such, we need to know if landscape is active. % \begin{macrocode} \bool_new:N \g_@@_landscape_bool @@ -1524,7 +1565,7 @@ % \end{macro} % % \begin{macrocode} -%</dvipdfmx|xdvipdfmx> +%</dvipdfmx|xetex> % \end{macrocode} % % \subsection{\texttt{dvisvgm} backend} |