From 7b7fe1bdeb83f129ceff31a7907db12d8e9340cd Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 26 Feb 2021 22:22:51 +0000
Subject: graphics-def (26feb21)

git-svn-id: svn://tug.org/texlive/trunk@57951 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/graphics-def/dvipdfmx.def | 65 ++++++++++++++++++++++
 1 file changed, 65 insertions(+)

(limited to 'Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def')

diff --git a/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def b/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def
index 0944ae0d884..30599167977 100644
--- a/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def
+++ b/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def
@@ -336,3 +336,68 @@
 }
 \fi
 \fi
+% Updates for newer dvipdfmx versions
+% Loaded last as we can then bail-out if not required
+\begingroup
+  \ifcsname\detokenize{c__kernel_sys_dvipdfmx_version_int}\endcsname
+    \edef\extractbbversion{%
+      \number\csname\detokenize{c__kernel_sys_dvipdfmx_version_int}\endcsname}%
+  \else
+    \immediate\openin 0 = |"extractbb --version"
+    \ifeof0 %
+      \def\extractbbversion{0}%
+    \else
+      \read0 to \extractbbversion % \par
+      \ifeof0 %
+        \def\extractbbversion{0}%
+      \else
+        \read0 to \extractbbversion
+          \long\def\getextractbbversion#1Version #2 #3\stop{%
+            \def\extractbbversion{#2}}%
+          \expandafter\getextractbbversion\extractbbversion Version 0 \stop
+      \fi
+    \fi
+  \fi
+\ifnum\extractbbversion<20201111 %
+  \endgroup
+  \expandafter\endinput
+\else
+  \endgroup
+\fi
+% Conversion functions so the internal representation stays unchanged
+\let\init@current@color\current@color
+\def\convert@color#1{%
+  \ifx#1\init@current@color
+    \expandafter\convert@color@init
+  \else
+    \expandafter\convert@@color
+  \fi
+    #1%
+}
+\def\convert@color@init#1{0 g 0 G}
+\def\convert@@color#1{%
+  \expandafter\expandafter\expandafter\convert@@@color#1\stop
+}
+\def\convert@@@color#1 #2\stop{%
+  \csname convert@color@#1\endcsname{#2}%
+}
+\def\convert@color@cmyk#1{#1 k #1 K}
+\def\convert@color@gray#1{#1 g #1 G}
+\def\convert@color@rgb#1{#1 rg #1 RG}
+% Change the specials to use the stack
+\chardef\main@pdfcolorstack=1 %
+\ifx\AtBeginDvi\undefined
+  \long\def\@firstofone#1{#1}%
+  \expandafter\@firstofone
+\else
+  \expandafter\AtBeginDvi
+\fi
+  {\special{pdfcolorstackinit \the\main@pdfcolorstack\space page direct (0 g 0 G)}}
+\def\@pdfcolorstack{\the\main@pdfcolorstack\space}
+\def\set@color{%
+  \special{pdfcolorstack \@pdfcolorstack push (\convert@color\current@color)}%
+  \aftergroup \reset@color
+}
+\def\reset@color{%
+  \special{pdfcolorstack \@pdfcolorstack pop}%
+}
-- 
cgit v1.2.3

