diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2015-05-13 15:59:22 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2015-05-13 15:59:22 +0000 |
commit | b9f79c6fd42e181a176153fe8a1e325e48901fc6 (patch) | |
tree | d505f783bfbb6104267fd1ed6698b99a059042a6 /Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def | |
parent | 6f242ead5f2313c1d4ec42cdcaab6a1cf54737bd (diff) |
pgf: compatibility patch for the latest ConTeXt version
git-svn-id: svn://tug.org/texlive/trunk@37375 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def | 321 |
1 files changed, 157 insertions, 164 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def index 22c2a291417..ebc04d012e9 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfutil-context.def @@ -6,16 +6,18 @@ % 2. under the GNU Public License. % % See the file doc/generic/pgf/licenses/LICENSE for more details. - +% +% Adapted for colors and pdf resources by Hans Hagen. There can be a few more +% optimizations but they are not critital. \pgfutil@format@is@contexttrue % The aux files, needed for reading back coordinates -\def\pgfutil@aux@read@hook{ +\def\pgfutil@aux@read@hook{% \pgfutil@IfFileExists{\jobname.pgf}{\input \jobname.pgf\relax}{} \csname newwrite\endcsname\pgfutil@auxout - \csname openout\endcsname\pgfutil@auxout\jobname.pgf + \csname openout\endcsname\pgfutil@auxout\jobname.pgf\relax } \def\pgfutil@writetoaux#1{\write\pgfutil@auxout{#1}} @@ -26,19 +28,21 @@ \def\pgfutil@emu@rgb#1#2,#3,#4\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#3,#4}}} \def\pgfutil@emu@gray#1#2\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#2,#2}}} -\pgfutil@definecolor{white}{gray}{1} -\pgfutil@definecolor{black}{gray}{0} -\pgfutil@definecolor{gray}{gray}{0.5} -\pgfutil@definecolor{red}{rgb}{1,0,0} -\pgfutil@definecolor{green}{rgb}{0,1,0} -\pgfutil@definecolor{blue}{rgb}{0,0,1} -\pgfutil@definecolor{cyan}{rgb}{0,1,1} -\pgfutil@definecolor{magenta}{rgb}{1,0,1} -\pgfutil@definecolor{yellow}{rgb}{1,1,0} -\pgfutil@definecolor{orange}{rgb}{1,0.5,0} -\pgfutil@definecolor{violet}{rgb}{0.5,0,0.5} -\pgfutil@definecolor{purple}{rgb}{0.75,0,0.25} -\pgfutil@definecolor{brown}{rgb}{0.75,0.5,0.25} + +% no need for x colors (users can load it if needed) +%\pgfutil@definecolor{white}{gray}{1} +%\pgfutil@definecolor{black}{gray}{0} +%\pgfutil@definecolor{gray}{gray}{0.5} +%\pgfutil@definecolor{red}{rgb}{1,0,0} +%\pgfutil@definecolor{green}{rgb}{0,1,0} +%\pgfutil@definecolor{blue}{rgb}{0,0,1} +%\pgfutil@definecolor{cyan}{rgb}{0,1,1} +%\pgfutil@definecolor{magenta}{rgb}{1,0,1} +%\pgfutil@definecolor{yellow}{rgb}{1,1,0} +%\pgfutil@definecolor{orange}{rgb}{1,0.5,0} +%\pgfutil@definecolor{violet}{rgb}{0.5,0,0.5} +%\pgfutil@definecolor{purple}{rgb}{0.75,0,0.25} +%\pgfutil@definecolor{brown}{rgb}{0.75,0.5,0.25} \def\pgfutil@color#1{% \pgfutil@colorlet{.}{#1}% @@ -61,7 +65,6 @@ \edef#3{\expandafter\expandafter\expandafter\pgfutil@emu@select\csname\string\color@#1\endcsname}% } - \def\pgfutil@doifcolorelse#1#2#3{% \expandafter\ifx\csname\string\color@#1\endcsname\relax% \doifcolorelse{#1}{\let\pgf@next=\pgfutil@firstoftwo}{\let\pgf@next=\pgfutil@secondoftwo}% @@ -71,7 +74,6 @@ \pgf@next{#2}{#3}% } - \def\pgfutil@reset@color{% \pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp% {% @@ -82,6 +84,7 @@ }% \pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp% } + \expandafter\def\csname\string\color@.\endcsname{\xcolor@{}{}{rgb}{0,0,0}} \def\pgfutil@colorlet#1#2{% @@ -104,12 +107,13 @@ \pgf@marshal% \fi% } + \def\pgfutil@emu@mix#1!#2!#3!#4\@nil{% \expandafter\ifx\csname\string\color@#1\endcsname\relax% - \pgfutil@registercolor{#1}% + \pgfutil@registerrgb{#1}% \fi% \expandafter\ifx\csname\string\color@#3\endcsname\relax% - \pgfutil@registercolor{#3}% + \pgfutil@registerrgb{#3}% \fi% \expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#1\endcsname% \pgf@ya=\pgf@xa% @@ -129,9 +133,11 @@ \advance\pgf@xc by\c@pgf@counta\pgf@yc% \divide\pgf@xc by 100\relax% } + \def\pgfutil@emu@unpack#1#2#3#4#5{% \pgfutil@emu@@unpack#5\@nil% } + \def\pgfutil@emu@@unpack#1,#2,#3\@nil{% \pgf@xa=#1pt% \pgf@xb=#2pt% @@ -140,136 +146,56 @@ \def\pgfutil@emu@select#1#2#3#4#5{#5} -% The cmyk part is from Joseph Wright. -% See tex.stackexchange.com/questions/27952/cmyk-context-colors-in-tikz -\def\pgfutil@registercolor#1{% - \edef\pgf@temp{\PDFcolor{#1}}% - \edef\pgf@marshal{\noexpand\pgfutil@in@{rg}{\pgf@temp}}% - \pgf@marshal - \ifpgfutil@in@ - \expandafter\pgfutil@context@parse@rgb\pgf@temp\pgf@stop{#1}% - \else - \edef\pgf@marshal{\noexpand\pgfutil@in@{g}{\pgf@temp}}% - \pgf@marshal - \ifpgfutil@in@ - \expandafter\pgfutil@context@parse@gray\pgf@temp\pgf@stop{#1}% - \else - \edef\pgf@marshal{\noexpand\pgfutil@in@{k}{\pgf@temp}}% - \pgf@marshal - \ifpgfutil@in@ - \expandafter\pgfutil@context@parse@cmyk\pgf@temp\pgf@stop{#1}% - \else - \pgferror{Color #1 has an unsupported color model.}% - \pgfutil@definecolor{#1}{gray}{0}% - \fi - \fi - \fi -} - -\def\pgfutil@context@parse@gray#1 g#2\pgf@stop#3{% - \pgfutil@definecolor{#3}{gray}{#1} -} +% goody -\def\pgfutil@context@parse@rgb#1 #2 #3 rg#4\pgf@stop#5{% - \pgfutil@definecolor{#5}{rgb}{#1,#2,#3} -} - -\def\pgfutil@context@parse@cmyk#1 #2 #3 #4k#5\pgf@stop #6{% - \pgfutil@definecolor{#6}{cmyk}{#1,#2,#3,#4}% -} +\let\colorlet=\pgfutil@colorlet -\def\pgfutil@emu@cmyk#1#2,#3,#4,#5\@nil{% - \expandafter\def\csname\string\color@#1\endcsname - {\xcolor@{}{}{cmyk}{#2,#3,#4,#5}}% -} +% latex stuff -% Make this command available in general: -\let\colorlet=\pgfutil@colorlet +\newskip\pgfutil@flushglue +\pgfutil@flushglue=0pt plus 1fil % pgfutil@minipage \def\pgfutil@minipage[#1]#2{% - \hbox to#2\bgroup% - \hsize=#2\relax% - \vbox\bgroup\leavevmode% + \hbox to#2\bgroup + \hsize=#2\relax + \vbox\bgroup\leavevmode } -\def\pgfutil@endminipage{\egroup\egroup} - - - -% Driver detector (how should we do this in ConTeXt?) : - -\ifx\pdfoutput\@undefined\newcount\pdfoutput\fi -\ifx\pdfoutput\relax\newcount\pdfoutput\fi - -\def\pgfutil@guessdriver{ - \ifx\XeTeXversion\@undefined - \ifx\preloadedspecials\@undefined% - \ifcase\pdfoutput% - \def\pgfsysdriver{pgfsys-dvips.def}% - \else% - \def\pgfsysdriver{pgfsys-pdftex.def}% pdfTeX & LuaTeX - \fi% - \else% - \pgfutil@driver@if@in{postscript}{pgfsys-dvips.def} - \pgfutil@driver@if@in{tpd}{pgfsys-pdftex.def} - \pgfutil@driver@if@in{dpm}{pgfsys-dvipdfm.def} - \pgfutil@driver@if@in{dpx}{pgfsys-dvipdfmx.def} - \pgfutil@driver@if@in{xetex}{pgfsys-xetex.def} - \ifx\pgfsysdriver\relax% - \PackageWarning{pgf}{I was not able to discern the driver, the - preloaded specials were \preloadedspecials. I am going to use - pgfsys-dvips.def}% - \def\pgfsysdriver{pgfsys-dvips.def} - \fi% - \fi - \else - \def\pgfsysdriver{pgfsys-xetex.def}% should be right - \fi -} -\def\pgfutil@driver@if@in#1#2{% - \edef\pgf@marshal{\noexpand\pgfutil@in@{#1}{\preloadedspecials}} - \pgf@marshal - \ifpgfutil@in@% - \def\pgfsysdriver{#2}% - \fi% -} - - -% Global colors -\let\pgfutil@globalcolorsfalse=\relax -\let\pgfutil@globalcolorstrue=\relax +\def\pgfutil@endminipage{% + \egroup + \egroup +} +% global colors +\let\pgfutil@globalcolorsfalse\relax +\let\pgfutil@globalcolorstrue \relax -% Font stuff +% font stuff -\def\pgfutil@font@tiny{\tfxx} -\def\pgfutil@font@scriptsize{\tfxx} +\def\pgfutil@font@tiny {\tfxx} +\def\pgfutil@font@scriptsize {\tfxx} \def\pgfutil@font@footnotesize{\tfx} -\def\pgfutil@font@small{\tfx} -\def\pgfutil@font@normalsize{\tf} -\def\pgfutil@font@large{\tfa} -\def\pgfutil@font@Large{\tfb} -\def\pgfutil@font@huge{\tfc} -\def\pgfutil@font@Huge{\tfc} - -\def\pgfutil@font@itshape{\it} -\def\pgfutil@font@bfseries{\bf} - -\let\pgfutil@font@normalfont=\tf - -\let\pgfutil@selectfont=\tf - - -% Extra counters, registers, boxes +\def\pgfutil@font@small {\tfx} +\def\pgfutil@font@normalsize {\tf} +\def\pgfutil@font@large {\tfa} +\def\pgfutil@font@Large {\tfb} +\def\pgfutil@font@huge {\tfc} +\def\pgfutil@font@Huge {\tfc} +\def\pgfutil@font@itshape {\it} +\def\pgfutil@font@bfseries {\bf} +\def\pgfutil@font@normalfont {\tf} +\def\pgfutil@selectfont {\tf} + +% registers \newcount\pgfutil@tempcnta \newcount\pgfutil@tempcntb -\newbox\pgfutil@tempboxa +\newbox \pgfutil@tempboxa \newbox \pgfutil@voidb@x \newtoks \pgfutil@toks@ @@ -279,15 +205,11 @@ \let\pgfmath@tempcnta\pgfutil@tempcnta \let\pgfmath@tempcntb\pgfutil@tempcntb -% From LaTeX -\newskip\pgfutil@flushglue -\pgfutil@flushglue=0pt plus 1fil - -% Module stuff +% module stuff \def\pgfutil@usemodule#1{\usemodule[#1]} -% % % % begin patches by HH % % % % +% more adaptions \let\pgfutil@insertatbegincurrentpagefrombox\flushatshipout \let\pgfutil@insertatbegincurrentpage \flushatshipout @@ -297,6 +219,16 @@ \doifmodeelse {mkiv} { + \def\pgfsysdriver{pgfsys-pdftex.def} + + \def\pgfutil@driver@if@in#1#2{% + \edef\pgf@marshal{\noexpand\pgfutil@in@{#1}{\preloadedspecials}}% + \pgf@marshal + \ifpgfutil@in@ + \def\pgfsysdriver{#2}% + \fi + } + \def\pgf@sys@pdf@pdfbackendset@one#1#2% {\normalexpanded{\noexpand\pgf@sys@pdf@pdfbackendset@two\noexpand#1#2\relax}} @@ -309,34 +241,103 @@ \def\pgf@sys@pdf@possible@resources {\pdfbackendcurrentresources} \def\pgf@sys@pdf@check@resources {} -} { + \let\pgfutil@registercolor\pgf@context@registercolor + \let\pgfutil@registerrgb \pgf@context@registerrgb + \let\pgfutil@registercmyk \pgf@context@registercmyk + \let\pgfutil@registergray \pgf@context@registergray +} { \def\pgf@sys@pdf@addtopageresource@extgstate {\appendtoPDFdocumentextgstates } \def\pgf@sys@pdf@addtopageresource@colorspace {\appendtoPDFdocumentcolorspaces} \def\pgf@sys@pdf@addtopageresource@pattern {\appendtoPDFdocumentpatterns } \def\pgf@sys@pdf@possible@resources {\currentPDFresources} \def\pgf@sys@pdf@check@resources {} - % this code is now in the mkii driver so this code can go away - - \ifx\appendtoPDFdocumentpatterns\undefined - \let\docuPDFpatterns\empty - - \def\checkPDFpatterns - {\ifx\docuPDFpatterns\empty \else - \ifnum\realpageno=\lastpage\relax - \doPDFdictionaryobject{FDF}{docupatterns}{\docuPDFpatterns}% - \fi - \doPDFgetobjectreference{FDF}{docupatterns}\PDFobjectreference - \doPDFpageresource{/Pattern \PDFobjectreference}% - \fi} - - \appendtoksonce \checkPDFpatterns \to \everyshipout + \ifx\pdfoutput\undefined\newcount\pdfoutput\fi + \ifx\pdfoutput\relax \newcount\pdfoutput\fi + + \def\pgfutil@guessdriver{ + \ifx\XeTeXversion\@undefined + \ifx\preloadedspecials\@undefined% + \ifcase\pdfoutput% + \def\pgfsysdriver{pgfsys-dvips.def}% + \else% + \def\pgfsysdriver{pgfsys-pdftex.def}% pdfTeX & LuaTeX + \fi% + \else% + \pgfutil@driver@if@in{postscript}{pgfsys-dvips.def} + \pgfutil@driver@if@in{tpd}{pgfsys-pdftex.def} + \pgfutil@driver@if@in{dpm}{pgfsys-dvipdfm.def} + \pgfutil@driver@if@in{dpx}{pgfsys-dvipdfmx.def} + \pgfutil@driver@if@in{xetex}{pgfsys-xetex.def} + \ifx\pgfsysdriver\relax% + \PackageWarning{pgf}{I was not able to discern the driver, the + preloaded specials were \preloadedspecials. I am going to use + pgfsys-dvips.def}% + \def\pgfsysdriver{pgfsys-dvips.def} + \fi% + \fi + \else + \def\pgfsysdriver{pgfsys-xetex.def}% should be right + \fi + } - \def\appendtoPDFdocumentpatterns#1{\xdef\docuPDFpatterns{\docuPDFpatterns\space#1}} + \def\pgfutil@driver@if@in#1#2{% + \edef\pgf@marshal{\noexpand\pgfutil@in@{#1}{\preloadedspecials}}% + \pgf@marshal + \ifpgfutil@in@ + \def\pgfsysdriver{#2}% + \fi + } + + % The cmyk part is from Joseph Wright. + % See tex.stackexchange.com/questions/27952/cmyk-context-colors-in-tikz + \def\pgfutil@registercolor#1{% + \edef\pgf@temp{\PDFcolor{#1}}% + \edef\pgf@marshal{\noexpand\pgfutil@in@{rg}{\pgf@temp}}% + \pgf@marshal + \ifpgfutil@in@ + \expandafter\pgfutil@context@parse@rgb\pgf@temp\pgf@stop{#1}% + \else + \edef\pgf@marshal{\noexpand\pgfutil@in@{g}{\pgf@temp}}% + \pgf@marshal + \ifpgfutil@in@ + \expandafter\pgfutil@context@parse@gray\pgf@temp\pgf@stop{#1}% + \else + \edef\pgf@marshal{\noexpand\pgfutil@in@{k}{\pgf@temp}}% + \pgf@marshal + \ifpgfutil@in@ + \expandafter\pgfutil@context@parse@cmyk\pgf@temp\pgf@stop{#1}% + \else + \pgferror{Color #1 has an unsupported color model.}% + \pgfutil@definecolor{#1}{gray}{0}% + \fi + \fi + \fi + } + + \def\pgfutil@context@parse@gray#1 g#2\pgf@stop#3{% + \pgfutil@definecolor{#3}{gray}{#1} + } + + \def\pgfutil@context@parse@rgb#1 #2 #3 rg#4\pgf@stop#5{% + \pgfutil@definecolor{#5}{rgb}{#1,#2,#3} + } + + \def\pgfutil@context@parse@cmyk#1 #2 #3 #4k#5\pgf@stop #6{% + \pgfutil@definecolor{#6}{cmyk}{#1,#2,#3,#4}% + } + + \def\pgfutil@emu@cmyk#1#2,#3,#4,#5\@nil{% + \expandafter\def\csname\string\color@#1\endcsname + {\xcolor@{}{}{cmyk}{#2,#3,#4,#5}}% + } + + \let\pgfutil@registerrgb \pgfutil@registercolor + \let\pgfutil@registercmyk \pgfutil@registercolor + \let\pgfutil@registergray \pgfutil@registercolor - \fi } @@ -347,18 +348,10 @@ \pgf@sys@addpdfresource@colorspaces@plain{/pgfprgb [/Pattern /DeviceRGB]} -% % % % end patches by HH % % % % - -% Do something at the end of a job +% do something at the end of a job \appendtoks \the\pgfutil@everybye \to \everybye -% The following is still messy and needs to be cleanup up (everything -% prefixed by pgfutil@): - -%\def\PackageInfo#1#2{} -%\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% -%\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% \long\def\AtBeginDocument#1{#1}% \endinput |