[latex3-commits] [git/LaTeX3-latex3-latex3] main: Support transparency in Distiller (f3cf89187)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jul 12 14:35:58 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/f3cf89187dc1dd2d5bbc3183e9ecc94349cbe2e3

>---------------------------------------------------------------

commit f3cf89187dc1dd2d5bbc3183e9ecc94349cbe2e3
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Jul 12 13:35:58 2021 +0100

    Support transparency in Distiller
    
    We may need to move the GhostScript test to the
    header if it's needed more widely.


>---------------------------------------------------------------

f3cf89187dc1dd2d5bbc3183e9ecc94349cbe2e3
 l3backend/CHANGELOG.md          |  1 +
 l3backend/l3backend-opacity.dtx | 56 +++++++++++++++++++++++++++++------------
 2 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/l3backend/CHANGELOG.md b/l3backend/CHANGELOG.md
index 75f9d0555..26f633cf5 100644
--- a/l3backend/CHANGELOG.md
+++ b/l3backend/CHANGELOG.md
@@ -8,6 +8,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Fixed
 - GoTo link formation for Distiller-based workflows (issue #957)
+- Support transparency with Distiller
 
 ## [2021-05-07]
 
diff --git a/l3backend/l3backend-opacity.dtx b/l3backend/l3backend-opacity.dtx
index a600defcc..add340588 100644
--- a/l3backend/l3backend-opacity.dtx
+++ b/l3backend/l3backend-opacity.dtx
@@ -72,7 +72,13 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\@@_backend_select:n,\@@_backend_select_aux:n}
-%   No stack so set values directly.
+% \begin{macro}{\@@_backend_fill:n, \@@_backend_stroke:n}
+% \begin{macro}{\@@_backend:nnn, \@@_backend:xnn}
+%   No stack so set values directly. The need to deal with Distiller and
+%   Ghostscript separately means we use a common auxiliary: the two
+%   systems require different PostScript for transparency. This is
+%   of course not quite as efficient as doing one test for setting all
+%   transparency, but it keeps things clearer here.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_backend_select:n #1
   {
@@ -81,29 +87,47 @@
   }
 \cs_new_protected:Npn \@@_backend_select_aux:n #1
   {
-    \__kernel_backend_postscript:n
-      { #1 ~ .setfillconstantalpha ~ #1 ~ .setstrokeconstantalpha }
+    \@@_backend:nnn {#1} { fill }   { ca }
+    \@@_backend:nnn {#1} { stroke } { CA }
   }
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_backend_fill:n, \@@_backend_stroke:n}
-% \begin{macro}{\@@_backend:nn, \@@_backend:xn}
-%   Similar to the above but with no stack and only adding to one or other of
-%   the entries.
-%    \begin{macrocode}
 \cs_new_protected:Npn \@@_backend_fill:n #1
-  { \@@_backend:xn { \fp_eval:n { min(max(0,#1),1) } } { fill } }
+  {
+    \@@_backend:xnn
+      { \fp_eval:n { min(max(0,#1),1) } }
+      { fill }
+      { ca }
+  }
 \cs_new_protected:Npn \@@_backend_stroke:n #1
-  { \@@_backend:xn { \fp_eval:n { min(max(0,#1),1) } } { stroke } }
-\cs_new_protected:Npn \@@_backend:nn #1#2
   {
-    \__kernel_backend_postscript:n { #1 ~ .set #2 constantalpha  }
+    \@@_backend:xnn
+      { \fp_eval:n { min(max(0,#1),1) } }
+      { stroke }
+      { CA }
   }
-\cs_generate_variant:Nn \@@_backend:nn { x }
+\cs_new_protected:Npn \@@_backend:nnn #1#2#3
+  {
+    \__kernel_backend_postscript:n
+      {
+        product ~ (Ghostscript) ~ search
+          {
+            pop ~ pop ~ pop ~
+            #1 ~ .set #2 constantalpha
+          }
+          {
+            pop ~
+            mark ~
+            /#3 ~ #1
+            /SetTransparency ~
+            pdfmark
+          }
+        ifelse
+      }
+  }
+\cs_generate_variant:Nn \@@_backend:nnn { x }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 %    \begin{macrocode}
 %</dvips>





More information about the latex3-commits mailing list.