[latex3-commits] [git/LaTeX3-latex3-pdfresources] splitting: working on load order (cc2dfed)
Ulrike Fischer
fischer at troubleshooting-tex.de
Mon Jul 13 20:03:38 CEST 2020
Repository : https://github.com/latex3/pdfresources
On branch : splitting
Link : https://github.com/latex3/pdfresources/commit/cc2dfed7539a16bff1643fc8f05a6f2d3a48862f
>---------------------------------------------------------------
commit cc2dfed7539a16bff1643fc8f05a6f2d3a48862f
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Mon Jul 13 20:03:38 2020 +0200
working on load order
>---------------------------------------------------------------
cc2dfed7539a16bff1643fc8f05a6f2d3a48862f
l3pdfmeta.dtx | 7 +-
pdfresources-patches.dtx | 244 +++++++++++++++++++++++++++++++++++++++++++++++
pdfresources.dtx | 209 +---------------------------------------
pdfresources.ins | 8 ++
4 files changed, 260 insertions(+), 208 deletions(-)
diff --git a/l3pdfmeta.dtx b/l3pdfmeta.dtx
index addd3bb..4660fd6 100644
--- a/l3pdfmeta.dtx
+++ b/l3pdfmeta.dtx
@@ -23,7 +23,6 @@
% for those people who are interested.
%
%<*driver>
-\RequirePackage{expl3}
\documentclass[full]{l3doc}
\begin{document}
\DocInput{\jobname.dtx}
@@ -82,7 +81,6 @@
%<*package>
\ProvidesExplPackage {l3pdfmeta} {2020-05-17} {0.2}
{XMP-Metadata}
-\RequirePackage{lthooks}
% \end{macrocode}
% \section{Document metadata}
% We plan a \cs{DeclareDocumentMetaData} so let's start with it.
@@ -111,7 +109,10 @@
{ \msg_error:nn { pdf }{ setup-after-documentclass } }
{
\keys_set_groups:nnn { pdf / setup} {init}{ #1 }
- \RequirePackage{pdfresources}
+ \RequirePackage{l3pdf}
+ \RequirePackage{lthooks} %
+ % %load backend driver
+ %\file_input:n {l3\g__sys_backend_tl-pdf.def}
\bool_gset_true:N \g_@@_Core_active_bool
\keys_set_filter:nnn { pdf / setup } { init } { #1 }
}
diff --git a/pdfresources-patches.dtx b/pdfresources-patches.dtx
new file mode 100644
index 0000000..d5a1414
--- /dev/null
+++ b/pdfresources-patches.dtx
@@ -0,0 +1,244 @@
+% \iffalse meta-comment
+%
+%% File: pdfresources-patches.dtx
+%
+% Copyright (C) 2018-2020 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 "(experimental) pdfresources bundle" (The Work in LPPL)
+% and all files in that bundle must be distributed together.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+% https://github.com/latex3/pdfresources
+%
+% for those people who are interested.
+%
+%<*driver>
+\documentclass[full]{l3doc}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+% \title{^^A
+% The \pkg{pdfresources-patches} package -- temporarly patches ^^A
+% }
+%
+% \author{^^A
+% The \LaTeX3 Project\thanks
+% {^^A
+% E-mail:
+% \href{mailto:latex-team at latex-project.org}
+% {latex-team at latex-project.org}^^A
+% }^^A
+% }
+%
+% \date{Released XXXX-XX-XX}
+%
+% \maketitle
+% \begin{documentation}
+%
+% \section{\pkg{pdfresources-patches} documentation}
+% This code is temporary! It tries to patch commands of other packages which
+% fills pdfresources too, to remove clashes and test if everything works as expected.
+% This code should disappear when packages adapt to the central interfaces.
+%
+% \subsection{\pkg{pgf}}
+%
+% In \pkg{pgf}, resource management is set up in the file |pgfutil-common.tex|.
+% This then provides three functions for adding to the resources, all of which
+% are objects:
+% \begin{itemize}
+% \item \cs{pgfutil at addpdfresource@extgs}: Extended graphics state
+% \item \cs{pgfutil at addpdfresource@colorspaces}: Color spaces
+% \item \cs{pgfutil at addpdfresource@patterns}: Patterns
+% \end{itemize}
+%
+% These resource dictionaries are used by adding entries in a cumulative sense;
+% the macro layer deals with ensuring that each entry is only given once. Note
+% that the objects themselves must be given only once for each page.
+%
+% To support these functions, there are a series of set-up macros which install
+% these resources. That has to take place for every page: the exact route
+% therefore depends on the driver.
+%
+% For the pdfresources project we need to avoid that pgf interferes in ExtGState,
+% ColorSpace and Pattern (Shadings are added to the xform resources and so probably
+% unproblematic for now).
+% \begin{macrocode}
+%<*package>
+% patches for xetex/dvips doesn't make much sense for colorspace and
+% transparent. But pgf should be tested sometimes.
+\RequirePackage{etoolbox}
+\@ifpackageloaded{pgfrcs}
+ {
+ \msg_warning:nn{pdf}{pgf-too-late}
+ \file_input_stop:
+ }
+ {
+ \msg_info:nn{pdf}{patches}
+ }
+\RequirePackage{pgfrcs}
+%
+%\def\pgfutil at addpdfresource@extgs#1{\pgf at sys@addpdfresource at extgs@plain{#1}}
+%\def\pgfutil at addpdfresource@colorspaces#1{\pgf at sys@addpdfresource at colorspaces@plain{#1}}
+%\def\pgfutil at addpdfresource@patterns#1{\pgf at sys@addpdfresource at patterns@plain{#1}}
+%\def\pgfutil at setuppdfresources{\pgf at sys@setuppdfresources at plain}
+% \pgf at sys@pdf at possible@resources %used in xform
+%Trying to patch pgf ..
+\cs_new_protected:Npn \@@_pgf_sys_setuppdfresources_plain:
+ {
+ %objects are already created ...
+ \def\pgf at sys@pdf at possible@resources
+ {
+ /ColorSpace~\pdf_object_ref:n {Page/Resources/ColorSpace}
+ /Pattern ~\pdf_object_ref:n {Page/Resources/Pattern}
+ /ExtGState ~\pdf_object_ref:n {Page/Resources/ExtGState}
+ }
+ \let\pgf at sys@pdf at check@resources=\relax%
+ %not sure if needed, but perhaps the lists are used somewhere else ...
+ \let\pgf at sys@pgf at resource@list at extgs=\pgfutil at empty%
+ \let\pgf at sys@pgf at resource@list at patterns=\pgfutil at empty%
+ \let\pgf at sys@pgf at resource@list at colorspaces=\pgfutil at empty%
+ % the commands to add page resources
+ \def\pgf at sys@addpdfresource at extgs@plain##1
+ {
+ \exp_after:wN %for transparent which passes a command
+ \@@_patch_pgfextgs:w ##1\q_stop
+ }
+ \def\pgf at sys@addpdfresource at patterns@plain##1
+ {
+ \@@_patch_pgfpatterns:w ##1\q_stop
+ }
+ \def\pgf at sys@addpdfresource at colorspaces@plain##1
+ {
+ \@@_patch_pgfcolorspaces:w ##1\q_stop
+ }
+ }
+\cs_set_eq:NN \@@_pgfori_pgfutil at setuppdfresources\pgfutil at setuppdfresources
+\def\pgfutil at setuppdfresources
+ {
+ \bool_if:NTF \g_@@_Core_active_bool
+ {
+ \@@_pgf_sys_setuppdfresources_plain:
+ }
+ {
+ \@@_pgfori_pgfutil at setuppdfresources
+ }
+ }
+
+% Why on earth do I explicitly call the command? Doesn't pgf do it?
+%\hook_gput_code:nnn {begindocument/end} {pdf} { \pgfutil at setuppdfresources }
+
+%\AtEndPreamble{\pgfutil at setuppdfresources}
+% helper commands as pgf doesn't pass resources as two arguments
+% code to add to the resources existing stuff in the format "/name value":
+\cs_new:Npn \@@_split_dict_entry_aux:NNw #1 #2 /#3~#4\q_stop
+ {
+ \tl_set:Nn #1 {#3}
+ \tl_set:Nn #2 {#4}
+ }
+\tl_new:N \l_@@_name_tmp_tl
+\tl_new:N \l_@@_value_tmp_tl
+
+\cs_new:Npn \@@_patch_pgfextgs:w #1/#2<<#3>>#4\q_stop
+ {
+ \exp_args:Nne \@@_backend_PageResources_gput:nnn {ExtGState}{\tl_trim_spaces:n{#2}}{<<#3>>}
+ }
+\cs_new:Npn \@@_patch_pgfpatterns:w #1/#2\space#3\q_stop
+ {
+ \exp_args:Nnxx \@@_backend_PageResources_gput:nnn {Pattern}{\tl_trim_spaces:n{#2}}{#3}
+ }
+\cs_new:Npn \@@_patch_pgfcolorspaces:w #1/#2[#3]#4\q_stop
+ {
+ \exp_args:Nne
+ \@@_backend_PageResources_gput:nnn {ColorSpace}{\tl_trim_spaces:n{#2}}{[#3]}
+ }
+%</package>
+% \end{macrocode}
+% \subsection{\pkg{transparent}}
+% transparent, we assume that pdfresources is loaded first.
+% the code does nothing is with new-transparent ...
+% \begin{macrocode}
+%<*package>
+%label??
+\hook_gput_code:nnn {begindocument/end} {pdf}
+ {
+ \def\TRP at addresource
+ {
+ \@@_backend_PageResources_gput:nnn{ExtGState}{TRP1}{<</ca~1/CA~1>>}
+ }
+ \def\transparent at use#1
+ {
+ \tl_if_exist:cF{TRP#1}
+ {
+ \@@_backend_PageResources_gput:nnn
+ {ExtGState}
+ {TRP#1}
+ {<</ca~#1/CA~#1>>}
+ \tl_const:cn{TRP#1}{/TRP#1~gs}
+ }
+ }
+ }
+%</package>
+% \end{macrocode}
+% \subsection{\pkg{colorspace}}
+% This is rather difficult as no real places to inject patches
+% at first a try to avoid that its ExtGState is missing:
+% it can not be avoided to recreate the objects (and so to get duplicates)
+% as colorspace uses temporary macros whose contents is lost.
+% \begin{macrocode}
+%<*package>
+% this must be earlier, to avoid problems with luatex which has two pageresources
+% lua/tex
+\hook_gput_code:nnn {begindocument} {pdf}
+ {
+ \tl_if_exist:NT \spc at op
+ {
+ \def\spc at Pageresources#1{}
+ }
+
+ }
+
+\hook_gput_code:nnn {begindocument/end} {pdf}
+ {
+ \tl_if_exist:NT \spc at op
+ {
+ \@@_backend_object_new:nn {__spc_extgstate_op_false}{dict}
+ \@@_backend_object_write:nn
+ {__spc_extgstate_op_false}
+ {/Type /ExtGState~/op~false~/OP~false}
+ \pdfcoredict_gput:nnn
+ {Page/Resources/ExtGState}
+ {SPCko}
+ {\@@_backend_object_ref:n {__spc_extgstate_op_false}}
+ \@@_backend_object_new:nn {__spc_extgstate_op_true0}{dict}
+ \@@_backend_object_write:nn
+ {__spc_extgstate_op_true0}
+ {/Type /ExtGState~/op~true~/OP~true~/OPM~0}%
+ \pdfcoredict_gput:nnn
+ {Page/Resources/ExtGState}
+ {SPCmz}
+ {\@@_backend_object_ref:n {__spc_extgstate_op_true0}}
+ \@@_backend_object_new:nn {__spc_extgstate_op_true1}{dict}
+ \@@_backend_object_write:nn
+ {__spc_extgstate_op_true1}
+ {/Type /ExtGState~/op~true~/OP~true~/OPM~1}%
+ \pdfcoredict_gput:nnn
+ {Page/Resources/ExtGState}
+ {SPCop}
+ {\@@_backend_object_ref:n {__spc_extgstate_op_true1}}
+ }
+ }
+%</package>
+% \end{macrocode}%
+% \PrintIndex
diff --git a/pdfresources.dtx b/pdfresources.dtx
index fdce5d2..df13233 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -36,16 +36,14 @@
% \begin{macrocode}
%<@@=pdf>
%<*package>
-\RequirePackage{xparse,l3pdf}
-\RequirePackage{lthooks,zref-base,bitset}
-\ProvidesExplPackage {pdfresources} {2020-06-15} {0.6}
+\ProvidesExplPackage {pdfresources} {2020-07-13} {0.7}
{experimental pdf-resource management}
+\RequirePackage{zref-base,bitset}
\DeclareOption { debug }
{
\msg_redirect_module:nnn { pdf } { none } { warning }
}
-\bool_new:N\g_@@_patches_bool
-\DeclareOption { patches }{\bool_gset_true:N\g_@@_patches_bool}
+\DeclareOption { patches }{\AtEndOfPackage{\RequirePackage{pdfresources-patches}}}
\ProcessOptions\relax
%</package>
% \end{macrocode}
@@ -104,8 +102,6 @@
\RequirePackage{l3pdfdict}
\RequirePackage{l3pdftools}
\RequirePackage{l3pdfcoredict}
-% %load backend driver
-\file_input:n {l3\g__sys_backend_tl-pdf.def}
%</package>
% \end{macrocode}
%
@@ -925,203 +921,6 @@
% The code has been moved to \pkg{l3pdfmeta}.
%
% \section{Patches}
-% This code is temporary! It tries to patch commands of other packages which
-% fills pdfresources too, to remove clashes and test if everything works as expected.
-% This code should disappear when packages adapt to the central interfaces.
-%
-% \subsection{\pkg{pgf}}
-%
-% In \pkg{pgf}, resource management is set up in the file |pgfutil-common.tex|.
-% This then provides three functions for adding to the resources, all of which
-% are objects:
-% \begin{itemize}
-% \item \cs{pgfutil at addpdfresource@extgs}: Extended graphics state
-% \item \cs{pgfutil at addpdfresource@colorspaces}: Color spaces
-% \item \cs{pgfutil at addpdfresource@patterns}: Patterns
-% \end{itemize}
-%
-% These resource dictionaries are used by adding entries in a cumulative sense;
-% the macro layer deals with ensuring that each entry is only given once. Note
-% that the objects themselves must be given only once for each page.
-%
-% To support these functions, there are a series of set-up macros which install
-% these resources. That has to take place for every page: the exact route
-% therefore depends on the driver.
-%
-% For the pageresources project we need to avoid that pgf interferes in ExtGState,
-% ColorSpace and Pattern (Shadings are added to the xform resources and so probably
-% unproblematic for now).
-% \begin{macrocode}
-%<*package>
-% patches for xetex/dvips doesn't make much sense for colorspace and
-% transparent. But pgf should be tested sometimes.
-% currently only pdftex/luatex is handled here.
-\bool_if:nT { !\g_@@_patches_bool || \sys_if_output_dvi_p: }
- {
- \file_input_stop:
- }
-\RequirePackage{etoolbox}
-\@ifpackageloaded{pgfrcs}
- {
- \msg_warning:nn{pdf}{pgf-too-late}
- \file_input_stop:
- }
- {
- \msg_info:nn{pdf}{patches}
- }
-\RequirePackage{pgfrcs}
-%
-%\def\pgfutil at addpdfresource@extgs#1{\pgf at sys@addpdfresource at extgs@plain{#1}}
-%\def\pgfutil at addpdfresource@colorspaces#1{\pgf at sys@addpdfresource at colorspaces@plain{#1}}
-%\def\pgfutil at addpdfresource@patterns#1{\pgf at sys@addpdfresource at patterns@plain{#1}}
-%\def\pgfutil at setuppdfresources{\pgf at sys@setuppdfresources at plain}
-% \pgf at sys@pdf at possible@resources %used in xform
-%Trying to patch pgf ..
-\cs_new_protected:Npn \@@_pgf_sys_setuppdfresources_plain:
- {
- %objects are already created ...
- \def\pgf at sys@pdf at possible@resources
- {
- /ColorSpace~\pdf_object_ref:n {Page/Resources/ColorSpace}
- /Pattern ~\pdf_object_ref:n {Page/Resources/Pattern}
- /ExtGState ~\pdf_object_ref:n {Page/Resources/ExtGState}
- }
- \let\pgf at sys@pdf at check@resources=\relax%
- %not sure if needed, but perhaps the lists are used somewhere else ...
- \let\pgf at sys@pgf at resource@list at extgs=\pgfutil at empty%
- \let\pgf at sys@pgf at resource@list at patterns=\pgfutil at empty%
- \let\pgf at sys@pgf at resource@list at colorspaces=\pgfutil at empty%
- % the commands to add page resources
- \def\pgf at sys@addpdfresource at extgs@plain##1
- {
- \exp_after:wN %for transparent which passes a command
- \@@_patch_pgfextgs:w ##1\q_stop
- }
- \def\pgf at sys@addpdfresource at patterns@plain##1
- {
- \@@_patch_pgfpatterns:w ##1\q_stop
- }
- \def\pgf at sys@addpdfresource at colorspaces@plain##1
- {
- \@@_patch_pgfcolorspaces:w ##1\q_stop
- }
- }
-\cs_set_eq:NN \@@_pgfori_pgfutil at setuppdfresources\pgfutil at setuppdfresources
-\def\pgfutil at setuppdfresources
- {
- \bool_if:NTF \g_@@_Core_active_bool
- {
- \@@_pgf_sys_setuppdfresources_plain:
- }
- {
- \@@_pgfori_pgfutil at setuppdfresources
- }
- }
-
-% Why on earth do I explicitly call the command? Doesn't pgf do it?
-%\hook_gput_code:nnn {begindocument/end} {pdf} { \pgfutil at setuppdfresources }
-
-%\AtEndPreamble{\pgfutil at setuppdfresources}
-% helper commands as pgf doesn't pass resources as two arguments
-% code to add to the resources existing stuff in the format "/name value":
-\cs_new:Npn \@@_split_dict_entry_aux:NNw #1 #2 /#3~#4\q_stop
- {
- \tl_set:Nn #1 {#3}
- \tl_set:Nn #2 {#4}
- }
-\tl_new:N \l_@@_name_tmp_tl
-\tl_new:N \l_@@_value_tmp_tl
-
-\cs_new:Npn \@@_patch_pgfextgs:w #1/#2<<#3>>#4\q_stop
- {
- \exp_args:Nne \@@_backend_PageResources_gput:nnn {ExtGState}{\tl_trim_spaces:n{#2}}{<<#3>>}
- }
-\cs_new:Npn \@@_patch_pgfpatterns:w #1/#2\space#3\q_stop
- {
- \exp_args:Nnxx \@@_backend_PageResources_gput:nnn {Pattern}{\tl_trim_spaces:n{#2}}{#3}
- }
-\cs_new:Npn \@@_patch_pgfcolorspaces:w #1/#2[#3]#4\q_stop
- {
- \exp_args:Nne
- \@@_backend_PageResources_gput:nnn {ColorSpace}{\tl_trim_spaces:n{#2}}{[#3]}
- }
-%</package>
-% \end{macrocode}
-% \subsection{\pkg{transparent}}
-% transparent, we assume that pdfresource is loaded first.
-% the code does nothing is with new-transparent ...
-% \begin{macrocode}
-%<*package>
-%label??
-\hook_gput_code:nnn {begindocument/end} {pdf}
- {
- \def\TRP at addresource
- {
- \@@_backend_PageResources_gput:nnn{ExtGState}{TRP1}{<</ca~1/CA~1>>}
- }
- \def\transparent at use#1
- {
- \tl_if_exist:cF{TRP#1}
- {
- \@@_backend_PageResources_gput:nnn
- {ExtGState}
- {TRP#1}
- {<</ca~#1/CA~#1>>}
- \tl_const:cn{TRP#1}{/TRP#1~gs}
- }
- }
- }
-%</package>
-% \end{macrocode}
-% \subsection{\pkg{colorspace}}
-% This is rather difficult as no real places to inject patches
-% at first a try to avoid that its ExtGState is missing:
-% it can not be avoided to recreate the objects (and so to get duplicates)
-% as colorspace uses temporary macros whose contents is lost.
-% \begin{macrocode}
-%<*package>
-% this must be earlier, to avoid problems with luatex which has two pageresources
-% lua/tex
-\hook_gput_code:nnn {begindocument} {pdf}
- {
- \tl_if_exist:NT \spc at op
- {
- \def\spc at Pageresources#1{}
- }
-
- }
-
-\hook_gput_code:nnn {begindocument/end} {pdf}
- {
- \tl_if_exist:NT \spc at op
- {
- \@@_backend_object_new:nn {__spc_extgstate_op_false}{dict}
- \@@_backend_object_write:nn
- {__spc_extgstate_op_false}
- {/Type /ExtGState~/op~false~/OP~false}
- \pdfcoredict_gput:nnn
- {Page/Resources/ExtGState}
- {SPCko}
- {\@@_backend_object_ref:n {__spc_extgstate_op_false}}
- \@@_backend_object_new:nn {__spc_extgstate_op_true0}{dict}
- \@@_backend_object_write:nn
- {__spc_extgstate_op_true0}
- {/Type /ExtGState~/op~true~/OP~true~/OPM~0}%
- \pdfcoredict_gput:nnn
- {Page/Resources/ExtGState}
- {SPCmz}
- {\@@_backend_object_ref:n {__spc_extgstate_op_true0}}
- \@@_backend_object_new:nn {__spc_extgstate_op_true1}{dict}
- \@@_backend_object_write:nn
- {__spc_extgstate_op_true1}
- {/Type /ExtGState~/op~true~/OP~true~/OPM~1}%
- \pdfcoredict_gput:nnn
- {Page/Resources/ExtGState}
- {SPCop}
- {\@@_backend_object_ref:n {__spc_extgstate_op_true1}}
- }
- }
-%</package>
-% \end{macrocode}
+% The code has been moved to pageresources-patches.dtx
% \newpage
% \PrintIndex
diff --git a/pdfresources.ins b/pdfresources.ins
index 6c98f74..70af9b2 100644
--- a/pdfresources.ins
+++ b/pdfresources.ins
@@ -63,6 +63,14 @@ and all files in that bundle must be distributed together.
}
\generate
+ {%
+ \file{pdfresources-patches.sty}
+ {%
+ \from{pdfresources-patches.dtx}{package}
+ }%
+ }
+
+\generate
{
\file{l3dvipdfmx-pdf.def}
{
More information about the latex3-commits
mailing list.