[latex3-commits] [git/LaTeX3-latex3-pdfresources] reworking-annot: reorganize patch code (f9593f0)
Ulrike Fischer
fischer at troubleshooting-tex.de
Wed Feb 10 16:14:56 CET 2021
Repository : https://github.com/latex3/pdfresources
On branch : reworking-annot
Link : https://github.com/latex3/pdfresources/commit/f9593f0e17b1aa5ccc4733126a74d35bce1c2277
>---------------------------------------------------------------
commit f9593f0e17b1aa5ccc4733126a74d35bce1c2277
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed Feb 10 16:14:56 2021 +0100
reorganize patch code
>---------------------------------------------------------------
f9593f0e17b1aa5ccc4733126a74d35bce1c2277
build.lua | 3 +-
ltdocinit.dtx | 5 +-
newpackages/transparent-ltx.sty | 26 +++++
...ement-patches.dtx => pdfmanagement-firstaid.dtx | 126 ++++++++++-----------
pdfmanagement.dtx | 15 +--
pdfmanagement.ins | 4 +-
6 files changed, 98 insertions(+), 81 deletions(-)
diff --git a/build.lua b/build.lua
index fa32596..2fa0837 100644
--- a/build.lua
+++ b/build.lua
@@ -13,8 +13,7 @@ sourcefiles = {"*.dtx","*.ins",
"xcolor-patches-tmp.sty",
"pdfmanagement-regressiontest.sty",
"hgeneric-experimental.def",
- "newpackages/new-transparent.sty",
- "newpackages/new-transparent2.sty",
+ "newpackages/transparent-ltx.sty",
"newpackages/new-bookmark.sty",
"newpackages/bkm-generic.def",
"newpackages/new-attachfile.sty",
diff --git a/ltdocinit.dtx b/ltdocinit.dtx
index 11343fd..cd52b79 100644
--- a/ltdocinit.dtx
+++ b/ltdocinit.dtx
@@ -142,6 +142,7 @@
\str_remove_all:cn {opt at hyperref.sty}{customdriver=hgeneric-experimental}
}
}
+ \RequirePackage{pdfmanagement-firstaid}
}
}
@@ -167,6 +168,7 @@
\prop_show:N \g_@@_documentmetadata_prop
}
+\clist_new:N \g_@@_firstaidoff_clist
\keys_define:nn { pdf / setup }
{
backend .code:n =
@@ -207,8 +209,9 @@
{
\msg_warning:nnn{pdf}{unknown-standard}{#1}
}
- ,pdfmanagement .bool_gset:N = \g__pdfmanagement_active_bool
+ ,pdfmanagement .bool_gset:N = \g_@@_active_bool
,pdfmanagement .initial:n = {true}
+ ,firstaidoff .clist_gset:N = \g_@@_firstaidoff_clist
}
% \end{macrocode}
% \end{function}
diff --git a/newpackages/transparent-ltx.sty b/newpackages/transparent-ltx.sty
new file mode 100644
index 0000000..eefebc6
--- /dev/null
+++ b/newpackages/transparent-ltx.sty
@@ -0,0 +1,26 @@
+%%
+%% This is file `transparent-ltx.sty',
+%% a replacement for transparent sty from Heiko Oberdiek
+%%
+\NeedsTeXFormat{LaTeX2e}[2020/10/01]
+\ProvidesExplPackage{transparent-ltx}%
+ {2021-02-10}{v1}{Transparency with color stacks (replacement for transparent.sty from Heiko Oberdiek)}%
+
+\RequirePackage{l3opacity}
+
+\NewDocumentCommand{\transparent} { m }
+ {
+ \opacity_select:n{\fp_eval:n{ min(max(0,#1),1) } }
+ }
+
+\NewDocumentCommand{\texttransparent}{m m}
+ {
+ \mode_leave_vertical:
+ \group_begin:
+ \transparent{#1}
+ #2
+ \group_end:
+ }
+
+
+\endinput
diff --git a/pdfmanagement-patches.dtx b/pdfmanagement-firstaid.dtx
similarity index 74%
copy from pdfmanagement-patches.dtx
copy to pdfmanagement-firstaid.dtx
index 4b1cb86..adc5bd4 100644
--- a/pdfmanagement-patches.dtx
+++ b/pdfmanagement-firstaid.dtx
@@ -1,8 +1,8 @@
% \iffalse meta-comment
%
-%% File: pdfmanagement-patches.dtx
+%% File: pdfmanagement-firstaid.dtx
%
-% Copyright (C) 2018-2020 The LaTeX3 Project
+% Copyright (C) 2018-2021 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
@@ -30,7 +30,7 @@
%</driver>
% \fi
% \title{^^A
-% The \pkg{pdfmanagement-patches} package -- temporarly patches ^^A
+% The \pkg{pdfmanagement-firstaid} package -- temporarly patches and package replacements ^^A
% }
%
% \author{^^A
@@ -47,11 +47,36 @@
% \maketitle
% \begin{documentation}
%
-% \section{\pkg{pdfmanagement-patches} documentation}
-% This code is temporary! It tries to patch commands of other packages which
-% fills pdfmanagement too, to remove clashes and test if everything works as expected.
+% \section{\pkg{pdfmanagement-firstaid} documentation}
+% This code is temporary! It tries to patch commands of other packages or even
+% replace package which are incompatible with the pdfmanagement,
+% to remove clashes and test if everything works as expected.
% This code should disappear when packages adapt to the central interfaces.
%
+% The package contains an number of sections for various packages. Every
+% section can be disabled in (the first) \cs{DeclareDocumentMetadata} with
+% |firstaidoff={name1,name2,...}|.
+% \begin{macrocode}
+%<*package>
+\ProvidesExplPackage {pdfmanagement-firstaid} {2021-02-10} {0.8}
+ {experimental pdf-resource management / firstaid}
+
+%<@@=pdfmanagement>
+\clist_map_inline:nn {pgf,transparent}
+ {
+ \bool_new:c { g_@@_firstaid_#1_bool }
+ \bool_gset_true:c { g_@@_firstaid_#1_bool }
+ }
+\clist_map_inline:Nn \g_@@_firstaidoff_clist
+ {
+ \bool_if_exist:cT { g_@@_firstaid_#1_bool }
+ {
+ \bool_gset_false:c { g_@@_firstaid_#1_bool }
+ }
+ }
+\msg_new:nnn { pdfmanagement } { firstaid }
+ { loading~pdfmanagement~firstaid~code~for~#1 }
+% \end{macrocode}
% \subsection{\pkg{pgf}}
%
% In \pkg{pgf}, resource management is set up in the file |pgfutil-common.tex|.
@@ -74,24 +99,28 @@
% For the pdfmanagement 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).
+% The actual patch is in a file hook guarded by the boolean,
+% the rest of the code is always defined.
% \begin{macrocode}
-%<@@=pdf>
-%<*package>
-\ProvidesExplPackage {pdfmanagement-patches} {2020-07-13} {0.7}
- {experimental pdf-resource management / patches}
-% 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}
-%
+
+\bool_if:NT \g_@@_firstaid_pgf_bool
+ {
+ \msg_info:nnn{pdfmanagement }{firstaid}{pgf}
+ \AddToHook{file/after/pgfrcs.sty}
+ {
+ \cs_set_eq:NN \@@_pgfori_pgfutil at setuppdfresources\pgfutil at setuppdfresources
+ \def\pgfutil at setuppdfresources
+ {
+ \pdfmanagement_if_active:TF
+ {
+ \@@_pgf_sys_setuppdfresources_plain:
+ }
+ {
+ \@@_pgfori_pgfutil at setuppdfresources
+ }
+ }
+ }
+ }
%\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}}
@@ -127,20 +156,6 @@
\@@_patch_pgfcolorspaces:w ##1\q_stop
}
}
-\cs_set_eq:NN \@@_pgfori_pgfutil at setuppdfresources\pgfutil at setuppdfresources
-\def\pgfutil at setuppdfresources
- {
- \pdfmanagement_if_active:TF
- {
- \@@_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
@@ -150,48 +165,29 @@
\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>>}
+ \exp_args:Nne \__pdf_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}
+ \exp_args:Nnxx \__pdf_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]}
+ \__pdf_backend_PageResources_gput:nnn {ColorSpace}{\tl_trim_spaces:n{#2}}{[#3]}
}
-%</package>
+
% \end{macrocode}
% \subsection{\pkg{transparent}}
-% transparent, we assume that pdfmanagement is loaded first.
-% the code does nothing is with new-transparent ...
+% We simply replace by the new version.
% \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}
- }
- }
- }
+\bool_if:NT \g_@@_firstaid_transparent_bool
+ {
+ \declare at file@substitution{transparent.sty}{transparent-ltx.sty}
+ }
%</package>
% \end{macrocode}
% \subsection{\pkg{colorspace}}
diff --git a/pdfmanagement.dtx b/pdfmanagement.dtx
index 847491e..d1842b3 100644
--- a/pdfmanagement.dtx
+++ b/pdfmanagement.dtx
@@ -318,18 +318,11 @@
{
\msg_redirect_module:nnn { pdf } { none } { warning }
}
-\DeclareOption { patches }{\AtEndOfPackage{\RequirePackage{pdfmanagement-patches}}}
+\DeclareOption { patches }
+ {
+ %nothing
+ }
\ProcessOptions\relax
-%</package>
-% \end{macrocode}
-% \section{messages}
-% \begin{macrocode}
-%<*package>
-\msg_new:nnn { pdf } { patches }
- { loading~patch~code }
-\msg_new:nnn { pdf } { pgf-too-late }
- { pgf~is~already~loaded.~Patching~not~possible.}
-
%</package>
% \end{macrocode}
% \section{Loading the core files.}
diff --git a/pdfmanagement.ins b/pdfmanagement.ins
index adef567..69c850c 100644
--- a/pdfmanagement.ins
+++ b/pdfmanagement.ins
@@ -93,9 +93,9 @@ and all files in that bundle must be distributed together.
\generate
{%
- \file{pdfmanagement-patches.sty}
+ \file{pdfmanagement-firstaid.sty}
{%
- \from{pdfmanagement-patches.dtx}{package}
+ \from{pdfmanagement-firstaid.dtx}{package}
}%
}
More information about the latex3-commits
mailing list.