diff options
author | Norbert Preining <norbert@preining.info> | 2022-12-21 03:02:22 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-12-21 03:02:22 +0000 |
commit | 90958e75f9ca64e2362424209dd3c0de08c32049 (patch) | |
tree | dd0c23ec5bdb3467098accf8c2b33e7fde5475d7 /macros | |
parent | b1e1420cbf53db6acb48b1a88e8b16904f238db2 (diff) |
CTAN sync 202212210302
Diffstat (limited to 'macros')
-rw-r--r-- | macros/latex/contrib/graphicscache/LICENSE | 2 | ||||
-rw-r--r-- | macros/latex/contrib/graphicscache/graphicscache.dtx | 167 | ||||
-rw-r--r-- | macros/latex/contrib/graphicscache/graphicscache.pdf | bin | 242162 -> 176773 bytes |
3 files changed, 110 insertions, 59 deletions
diff --git a/macros/latex/contrib/graphicscache/LICENSE b/macros/latex/contrib/graphicscache/LICENSE index 189aad77d3..ccd1c677f1 100644 --- a/macros/latex/contrib/graphicscache/LICENSE +++ b/macros/latex/contrib/graphicscache/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2018, Max Schwarz +Copyright (c) 2018-2021, Max Schwarz All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/macros/latex/contrib/graphicscache/graphicscache.dtx b/macros/latex/contrib/graphicscache/graphicscache.dtx index 50215f8796..141c97f6bf 100644 --- a/macros/latex/contrib/graphicscache/graphicscache.dtx +++ b/macros/latex/contrib/graphicscache/graphicscache.dtx @@ -19,7 +19,7 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{graphicscache} %<*package> - [2021/08/02 v0.3 Cache includegraphics calls] + [2022/12/20 v0.4 Windows support and special character escaping] %</package> % %<*driver> @@ -60,6 +60,7 @@ % \changes{v0.1}{2018/10/03}{Initial version} % \changes{v0.2}{2021/04/08}{Better compatibility with different graphicx versions} % \changes{v0.3}{2021/08/02}{Added cachedir option} +% \changes{v0.4}{2022/12/20}{Windows support and special character escaping} % % \DoNotIndex{\newcommand,\newenvironment} % @@ -213,6 +214,7 @@ \RequirePackage{filemod} \RequirePackage{letltxmacro} \RequirePackage{pgfopts} +\RequirePackage{pgffor} \RequirePackage{ifplatform} \RequirePackage{pdftexcmds} \RequirePackage{ltxcmds} @@ -220,6 +222,7 @@ \newif\ifgraphicscache@compress \newif\ifgraphicscache@listing \newif\ifgraphicscache@hashshortnames +\newif\ifgraphicscache@gsnotavailable\graphicscache@gsnotavailablefalse \def\graphicscache@graphicsargs{} \newlength\graphicscache@tmplen \newcommand{\graphicscache@addarg}[1]{% @@ -309,25 +312,115 @@ \newwrite\graphicscache@listout \immediate\openout\graphicscache@listout=\jobname.graphicscache \fi +% +% shellesc has a bug on Ubuntu 16.04 (\ShellEscape is not immediate). +% So we simply define our own shellescape macro. +\ifx\lastsavedimageresourcepages\@undefined + \protected\def\graphicscache@ShellEscape{\immediate\write18 } +\else + \protected\def\graphicscache@ShellEscape#1{% + \directlua{os.execute("\luaescapestring{#1}")}} +\fi % \end{macrocode} % +% \begin{macro}{\graphicscache@callgswithname} +% This macro calls ghostscript using the name specified in the first argument. +% \begin{macrocode} +\newcommand{\graphicscache@callgswithname}[1]{% + \ifwindows + \graphicscache@ShellEscape{#1 + -sOutputFile=\graphicscache@output\space + -sDEVICE=pdfwrite + -dCompatibilityLevel=1.4 + -dPDFSETTINGS=/prepress + -dNOPAUSE -dQUIET -dBATCH + -c "<< + /AutoFilterColorImages false + /EncodeColorImages true + /ColorImageFilter /\graphicscache@compress@mode\space + /ColorImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> + /ColorImageResolution \graphicscache@dpi\space + /AutoFilterGrayImages false + /EncodeGrayImages true + /GrayImageFilter /\graphicscache@compress@mode\space + /GrayImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> + /GrayImageResolution \graphicscache@dpi\space + >> setdistillerparams" + -f \graphicscache@cachedir\string\graphicscacheout.pdf + }% + \else + \graphicscache@ShellEscape{#1 + -sOutputFile=\graphicscache@output\space + -sDEVICE=pdfwrite + -dCompatibilityLevel=1.4 + -dPDFSETTINGS=/prepress + -dNOPAUSE -dQUIET -dBATCH + -c '<< + /AutoFilterColorImages false + /EncodeColorImages true + /ColorImageFilter /\graphicscache@compress@mode\space + /ColorImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> + /ColorImageResolution \graphicscache@dpi\space + /AutoFilterGrayImages false + /EncodeGrayImages true + /GrayImageFilter /\graphicscache@compress@mode\space + /GrayImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> + /GrayImageResolution \graphicscache@dpi\space + >> setdistillerparams' + -f \graphicscache@cachedir/graphicscacheout.pdf \string|\string| rm \graphicscache@output + }% + \fi +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\graphicscache@callgs} +% This macro finds the correct ghostscript executable to call. +% \begin{macrocode} +\newcommand{\graphicscache@callgs}{% +% \end{macrocode} +% If we previously established gs is not available, do nothing. +% \begin{macrocode} + \ifgraphicscache@gsnotavailable + \else + \@ifundefined{graphicscache@gscommand}{% + \foreach \cmd in {rungs,gs,mgs} {% + \PackageInfo{graphicscache}{Trying \cmd\space to call ghostscript...^^J}% + \graphicscache@callgswithname{\cmd}% + \IfFileExists{\graphicscache@output}{% + \PackageInfo{graphicscache}{Found a working ghostscript called '\cmd'.}% + \global\edef\graphicscache@gscommand{\cmd}% + \breakforeach + }{}% + }% + \@ifundefined{graphicscache@gscommand}{% + \PackageWarning{graphicscache}{Could not find a working ghostscript executable. I will not compress any images.}{}% + \graphicscache@gsnotavailabletrue + }{}% + }{% + \PackageInfo{graphicscache}{Calling gs with name '\graphicscache@gscommand'^^J} + \graphicscache@callgswithname{\graphicscache@gscommand} + }% + \fi +} +% \end{macrocode} +% \end{macro} % \begin{macro}{\graphicscache@dorender} % Here, we actually perform the rendering. Sadly, this is quite complex due % to cross-platform support. % \begin{macrocode} \newcommand{\graphicscache@dorender}{% - \message{Rendering \graphicscache@outputhash: \graphicscache@fname\space with args: \graphicscache@graphicsargs\space (master file)}% + \PackageInfo{graphicscache}{Rendering \graphicscache@outputhash: \graphicscache@fname\space with args: \graphicscache@graphicsargs\space (master file)}% \ifwindows - \immediate\write18{md "\graphicscache@cachedir" 2>NUL}% + \graphicscache@ShellEscape{md "\graphicscache@cachedir" 2>NUL}% \else - \immediate\write18{mkdir -p "\graphicscache@cachedir"}% + \graphicscache@ShellEscape{mkdir -p "\graphicscache@cachedir"}% \fi % \end{macrocode} % First, render the graphics. % \begin{macrocode} \ifwindows - \immediate\write18{del /q \graphicscache@cachedir\string\graphicscacheout.pdf} - \immediate\write18{pdflatex + \graphicscache@ShellEscape{del /q \graphicscache@cachedir\string\graphicscacheout.pdf} + \graphicscache@ShellEscape{pdflatex -jobname graphicscacheout -interaction nonstopmode -output-directory "\graphicscache@cachedir" @@ -337,11 +430,11 @@ \string\begin{document}\string\includegraphics[\graphicscache@graphicsargs]{\graphicscache@fname}\string\end{document}" }% \IfFileExists{\graphicscache@cachedir/graphicscacheout.pdf}{}{% - \PackageError{graphicscache}{External pdflatex call failed (see above)}{}% + \PackageWarning{graphicscache}{External pdflatex call failed (see above)}% \def\graphicscache@output{}% } \else - \immediate\write18{pdflatex + \graphicscache@ShellEscape{pdflatex -jobname graphicscacheout -interaction nonstopmode -output-directory "\graphicscache@cachedir" @@ -349,7 +442,7 @@ \string\usepackage{graphicx} \string\usepackage[export]{adjustbox} \string\begin{document}\string\includegraphics[\graphicscache@graphicsargs]{\graphicscache@fname}\string\end{document}' - > /dev/null || rm "\graphicscache@cachedir/graphicscacheout.pdf" + > /dev/null \string|\string| rm "\graphicscache@cachedir/graphicscacheout.pdf" }% \fi % \end{macrocode} @@ -357,58 +450,16 @@ % file. % \begin{macrocode} \ifgraphicscache@compress - \message{With compression: \graphicscache@compress@mode}% - \ifwindows - \immediate\write18{mgs - -sOutputFile=\graphicscache@output\space - -sDEVICE=pdfwrite - -dCompatibilityLevel=1.4 - -dPDFSETTINGS=/prepress - -dNOPAUSE -dQUIET -dBATCH - -c ".setpdfwrite << - /AutoFilterColorImages false - /EncodeColorImages true - /ColorImageFilter /\graphicscache@compress@mode\space - /ColorImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> - /ColorImageResolution \graphicscache@dpi\space - /AutoFilterGrayImages false - /EncodeGrayImages true - /GrayImageFilter /\graphicscache@compress@mode\space - /GrayImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> - /GrayImageResolution \graphicscache@dpi\space - >> setdistillerparams" - -f \graphicscache@cachedir\string\graphicscacheout.pdf - }% - \else - \immediate\write18{gs - -sOutputFile=\graphicscache@output\space - -sDEVICE=pdfwrite - -dCompatibilityLevel=1.4 - -dPDFSETTINGS=/prepress - -dNOPAUSE -dQUIET -dBATCH - -c '.setpdfwrite << - /AutoFilterColorImages false - /EncodeColorImages true - /ColorImageFilter /\graphicscache@compress@mode\space - /ColorImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> - /ColorImageResolution \graphicscache@dpi\space - /AutoFilterGrayImages false - /EncodeGrayImages true - /GrayImageFilter /\graphicscache@compress@mode\space - /GrayImageDict << /ColorTransform 1 /QFactor \graphicscache@qfactor\space /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> - /GrayImageResolution \graphicscache@dpi\space - >> setdistillerparams' - -f \graphicscache@cachedir/graphicscacheout.pdf || rm \graphicscache@output - }% - \fi + \PackageInfo{graphicscache}{With compression: \graphicscache@compress@mode}% + \graphicscache@callgs \else - \message{Direct}% + \PackageInfo{graphicscache}{Direct}% \ifwindows - \immediate\write18{ + \graphicscache@ShellEscape{ copy \graphicscache@cachedir\string\graphicscacheout.pdf \graphicscache@output }% \else - \immediate\write18{ + \graphicscache@ShellEscape{ cp \graphicscache@cachedir/graphicscacheout.pdf \graphicscache@output }% \fi @@ -437,7 +488,7 @@ \filemodcmp{\graphicscache@fname}{\graphicscache@output}{% input is newer \graphicscache@dorender% }{% Output is newer - \message{Already have \graphicscache@outputhash: \graphicscache@fname}% + \PackageInfo{graphicscache}{Already have \graphicscache@outputhash: \graphicscache@fname}% }% % \end{macrocode} % If it still does not exist, we are likely in a strange environment @@ -560,7 +611,7 @@ \edef\graphicscache@outputhash{\pdf@mdfivesum{\graphicscache@options\graphicscache@graphicsargs\graphicscache@hashedname}}% \edef\graphicscache@output{\graphicscache@cachedir/\graphicscache@outputhash.pdf}% \ifgraphicscache@listing - \message{graphicscache: includegraphics\{#2\} => \graphicscache@output}% + \PackageInfo{graphicscache}{graphicscache: includegraphics\{#2\} => \graphicscache@output}% \immediate\write\graphicscache@listout{#2 \graphicscache@fname\space \graphicscache@output}% \fi \graphicscache@work diff --git a/macros/latex/contrib/graphicscache/graphicscache.pdf b/macros/latex/contrib/graphicscache/graphicscache.pdf Binary files differindex 27682695fe..fbbc069887 100644 --- a/macros/latex/contrib/graphicscache/graphicscache.pdf +++ b/macros/latex/contrib/graphicscache/graphicscache.pdf |