summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-01-23 21:25:14 +0000
committerKarl Berry <karl@freefriends.org>2019-01-23 21:25:14 +0000
commit962fafc31aa04f3ce45d9f90e89f18fcb7c373f4 (patch)
tree939498ad6f0dc73a8d9212f5022e94a25653d884 /Master/texmf-dist/tex
parented60ba6a1ec160e6ce7abe75fa93a3127c7dc422 (diff)
animate (23jan19)
git-svn-id: svn://tug.org/texlive/trunk@49800 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/animate/animate.sty301
1 files changed, 191 insertions, 110 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty
index e72ae9635cd..058c363d5e2 100644
--- a/Master/texmf-dist/tex/latex/animate/animate.sty
+++ b/Master/texmf-dist/tex/latex/animate/animate.sty
@@ -13,7 +13,7 @@
\NeedsTeXFormat{LaTeX2e}
-\def\@anim@version{2018/12/19}
+\def\@anim@version{2019/01/23}
\ProvidesPackage{animate}
[\@anim@version\space PDF & SVG animations from files and inline graphics]
@@ -51,13 +51,6 @@
\PassOptionsToPackage{xetex}{pdfbase}
}
\DeclareOptionX{dvisvgm}{%
- \@ifclassloaded{standalone}{
- \PackageError{animate}{%
- Option `dvisvgm' and the `standalone' document\MessageBreak%
- class are not compatible.\MessageBreak%
- Use another document class, such as `article'%
- }{}%
- }{}%
\setboolean{@anim@dvisvgm}{true}
\setboolean{@anim@dvips}{false}
\PassOptionsToPackage{dvisvgm}{graphics}
@@ -88,36 +81,133 @@
\RequirePackage{graphics}%\scalebox, \resizebox, \rotatebox
\RequirePackage{zref-abspage}
+% get number of pages in file given as #1 (file basename); #2 extension;
+% store result into macro given as #3
+\ifpdf %pdflatex/lualatex
+ \def\@anim@getpagecount#1#2#3{%
+ \pdfximage page 1 {#1.#2}\xdef#3{\the\pdflastximagepages}%
+ }
+\else
+ \if@anim@xetex
+ \def\@anim@getpagecount#1#2#3{%
+ \xdef#3{\the\numexpr\XeTeXpdfpagecount "#1.#2"\relax}%
+ }
+ \else
+ \if@anim@dvips
+ \def\@anim@getpagecount#1#2#3{\gdef#3{1}}%
+ \else %dvipdfmx, dvisvgm
+ \def\@anim@getpagecount#1#2#3{{%
+ \global\let#3\@undefined%
+ \def\%##1: ##2:{%
+ \expandafter\edef\csname ##1\endcsname{##2}%
+ \global\let#3\Pages%
+ }%
+ \endlinechar`\:% `:' appended to every line read
+ \IfFileExists{#1.xbb}{%
+ %read from xbb file
+ {\catcode`\%=0\sbox0{\input{#1.xbb}}}%
+ \ifdefined#3\else%
+ \PackageError{animate}{%
+ Cannot read number of pages from file\MessageBreak%
+ -------------------------------------\MessageBreak%
+ #1.xbb\MessageBreak%
+ -------------------------------------\MessageBreak%
+ This file seems to be invalid and should be deleted%
+ }{}%
+ \fi%
+ }{%
+ %read from command pipe (`extractbb')
+ %firstly, check whether reading from pipe is allowed
+ \immediate\closein\@inputcheck%
+ \immediate\openin\@inputcheck="|extractbb -h"%
+ \let\@anim@foo\@anim@bar% <-- needed for some reason to make
+ \ifeof\@inputcheck% <-- this test work correctly
+ \immediate\closein\@inputcheck%
+ \PackageError{animate}{%
+ Cannot determine number of pages in file\MessageBreak%
+ ----------------------------------------\MessageBreak%
+ #1.#2\MessageBreak%
+ ----------------------------------------\MessageBreak%
+ Try --shell-escape option (--enable-pipes in MikTeX),%
+ \MessageBreak or run\MessageBreak%
+ \space\space extractbb #1.#2\MessageBreak%
+ on the command line to provide a valid `xbb' file%
+ }{}%
+ \else%
+ \immediate\closein\@inputcheck%
+ {\catcode`\%=0\sbox0{\@@input "|extractbb -O #1.#2"}}%
+ \fi%
+ }%
+ }}
+ \fi
+ \fi
+\fi
+
\if@anim@dvisvgm
\setboolean{@anim@export}{false}
\AtBeginDocument{%
- %bring back PS file inclusion
- \ifdefined\Ginclude@eps\else%
- \def\Gin@extensions{.svg,.eps,.png,.jpg,.jpeg}%
- \def\Ginclude@eps#1{%
- \message{<#1>}%
- \bgroup
- \def\@tempa{!}%
- \dimen@\Gin@req@width
- \dimen@ii.1bp%
- \divide\dimen@\dimen@ii
- \@tempdima\Gin@req@height
- \divide\@tempdima\dimen@ii
- \special{PSfile="#1"\GPT@space
- llx=\Gin@llx\GPT@space
- lly=\Gin@lly\GPT@space
- urx=\Gin@urx\GPT@space
- ury=\Gin@ury\GPT@space
- \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\GPT@space\fi
- \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\GPT@space\fi
- \ifGin@clip clip\fi}%
- \egroup}%
- \@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}%
- \@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}%
- \@namedef{Gin@rule@.mps}#1{{eps}{.mps}{#1}}%
- \fi%
- %restore PS scaling and rotation
+ % Add PS and PDF file inclusion (PDF files as of dvisvgm-2.4) to and
+ % fix scaling/rotation/transformation in dvisvgm graphics driver
+ \xdef\Gin@extensions{.eps,.pdf,\Gin@extensions}%
+ \def\Ginclude@pdf#1{\@anim@include@psorpdf{#1}{pdffile}}%
+ \def\Ginclude@eps#1{\let\Gin@page\@empty\@anim@include@psorpdf{#1}{PSfile}}%
+ \def\@anim@include@psorpdf#1#2{% code taken from dvips.def
+ \message{<#1>}%
+ \bgroup%
+ \def\@tempa{!}%
+ \dimen@\Gin@req@width%
+ \dimen@ii.1bp%
+ \divide\dimen@\dimen@ii%
+ \@tempdima\Gin@req@height%
+ \divide\@tempdima\dimen@ii%
+ \special{#2="#1"\GPT@space%
+ \ifx\Gin@page\@empty\else page=\Gin@page\GPT@space\fi%
+ llx=\Gin@llx\GPT@space%
+ lly=\Gin@lly\GPT@space%
+ urx=\Gin@urx\GPT@space%
+ ury=\Gin@ury\GPT@space%
+ \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\GPT@space\fi%
+ \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\GPT@space\fi%
+ \ifGin@clip clip\fi}%
+ \egroup}%
+ \@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}%
+ \@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}%
+ \@namedef{Gin@rule@.mps}#1{{eps}{.mps}{#1}}%
+ \@namedef{Gin@rule@.pdf}#1{{pdf}{.xbb}{#1}}%
+ % BoundingBox determination (from dvipdfmx.def)
+ \def\Gread@pdf#1{%
+ \Gread@generic{#1}\Gread@extractbb@aux%
+ }%
+ \def\Gread@extractbb@aux#1{%
+ \ifeof\@inputcheck%
+ \immediate\openin\@inputcheck=%
+ "|extractbb %
+ \ifx\Gin@page\@empty\else -p \Gin@page\GPT@space\fi
+ \ifx\Gin@pagebox\@empty\else -B \Gin@pagebox\GPT@space\fi
+ -O \Gin@base\Gin@ext"%
+ \fi%
+ \Gread@true%
+ \let\@tempb\Gread@false%
+ \ifeof\@inputcheck%
+ \@latex@error%
+ {Cannot run pipe command. Try --shell-escape^^J%
+ (--enable-pipes in MikTeX) option}%
+ {}%
+ \else%
+ \loop%
+ \read\@inputcheck to\@tempa%
+ \ifeof\@inputcheck%
+ \Gread@false%
+ \else%
+ \expandafter\Gread@find@bb\@tempa:.\\%
+ \fi%
+ \ifGread@%
+ \repeat%
+ \immediate\closein\@inputcheck%
+ \fi%
+ }%
+ % PS scaling and rotation (from dvips.def)
\def\Grot@start{%
\special{ps: gsave currentpoint
currentpoint translate \Grot@angle\GPT@space neg
@@ -384,19 +474,20 @@
\def\@anim@xformnatdp#1{\expandafter\@anim@thirdofthree#1}
%helper macro that typesets graphics file into savebox
-\def\@anim@filebox#1#2{% dvips, dvisvgm: no multi-page support
- \edef\@anim@curfile{[clip\@anim@gropts]{#1}}%
- \global\setbox\@anim@box=\hbox{%
- \expandafter\includegraphics\@anim@curfile}%
-}
-\if@anim@dvips\else\if@anim@dvisvgm\else
- %pdfTeX, LuaTeX, dvipdfmx, xetex (multi-page)
+\if@anim@dvips
+ \def\@anim@filebox#1#2{% dvips: no multi-page support
+ \edef\@anim@curfile{[clip\@anim@gropts]{#1}}%
+ \global\setbox\@anim@box=\hbox{%
+ \expandafter\includegraphics\@anim@curfile}%
+ }
+\else
+ %pdfTeX, LuaTeX, dvipdfmx, xetex, dvisvgm
\def\@anim@filebox#1#2{%
\edef\@anim@curfile{[clip\@anim@gropts,page=#2]{#1}}%
\global\setbox\@anim@box=\hbox{%
\expandafter\includegraphics\@anim@curfile}%
}
-\fi\fi
+\fi
\def\@anim@checkboxsize#1#2{% #1: box number, #2: file
\ifdim\wd#1=\z@%
@@ -419,7 +510,7 @@
%create Form XObject from graphics file
\def\@anim@ximage#1#2#3#4{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename,
- % #4: page number of multipage file
+ % #4: page number of multipage file
\if@anim@dvisvgm%
% with dvisvgm, final animation dims must be passed to includegraphics;
% otherwise, final bbox of the document may be wrong, in particular in the
@@ -1338,7 +1429,9 @@
\if@anim@dvisvgm
\def\@anim@getpath#1#2{%
\ifx\@empty#2\@empty%
- \gdef\@anim@ext{.eps}% we start with `eps'
+ \gdef\@anim@ext{.pdf}% we start with `pdf'
+ \IfFileExists{#1\@anim@ext}{}{%
+ \gdef\@anim@ext{.eps}%
\IfFileExists{#1\@anim@ext}{}{%
\gdef\@anim@ext{.ps}%
\IfFileExists{#1\@anim@ext}{}{%
@@ -1354,6 +1447,7 @@
\IfFileExists{#1\@anim@ext}{}{%
\PackageError{animate}{%
None of the files\MessageBreak%
+ `#1.pdf',\MessageBreak%
`#1.eps',\MessageBreak%
`#1.ps',\MessageBreak%
`#1.mps',\MessageBreak%
@@ -1364,7 +1458,7 @@
could be found.\MessageBreak%
Wrong file type? Mis-spelled file name?%
}{}%
- }}}}}}}%
+ }}}}}}}}%
\else%
\gdef\@anim@ext{.#2}%
\IfFileExists{#1\@anim@ext}{}{%
@@ -1459,23 +1553,27 @@
\endgroup%
}
-\ifpdf
- %detects multipage PDF and corrects user supplied page range
+%detects multipage PDF and corrects user supplied page range
+\def\@anim@checkmultipage#1#2{% no multi-page support in dvips
+ \setboolean{@anim@multipage}{false}}%
+\if@anim@dvips\else
\def\@anim@checkmultipage#1#2{% #1: file base name, #2 user provided file ext
\ifx\@empty#2\@empty%
\IfFileExists{#1.pdf}{%
\setboolean{@anim@multipage}{true}%
\gdef\@anim@ext{.pdf}%
}{%
- \IfFileExists{#1.jbig2}{%
- \setboolean{@anim@multipage}{true}%
- \gdef\@anim@ext{.jbig2}%
- }{%
- \IfFileExists{#1.jb2}{%
+ \ifpdf% some extra file formats for pdftex/luatex
+ \IfFileExists{#1.jbig2}{%
\setboolean{@anim@multipage}{true}%
- \gdef\@anim@ext{.jb2}%
- }{}%
- }%
+ \gdef\@anim@ext{.jbig2}%
+ }{%
+ \IfFileExists{#1.jb2}{%
+ \setboolean{@anim@multipage}{true}%
+ \gdef\@anim@ext{.jb2}%
+ }{}%
+ }%
+ \fi%
}%
\else%
\IfFileExists{#1.#2}{%
@@ -1485,10 +1583,12 @@
\fi%
\if@anim@multipage%
\xdef\@anim@pathtofile{\expandafter\zap@finalspace\@filef@und\@nil}%
- \pdfximage page 1 {\@anim@pathtofile}%
- \@anim@curframe=\pdflastximagepages%
- \advance\@anim@curframe by -\@ne%since \pdfximagepages is 1-based
- \edef\@anim@lastpage{\the\@anim@curframe}%
+ \filename@parse{\@anim@pathtofile}%
+ \@anim@getpagecount{\filename@area\filename@base}{\filename@ext}{%
+ \@anim@lastpage%
+ }%
+ %we need it zero-based
+ \edef\@anim@lastpage{\the\numexpr\@anim@lastpage-\@ne\relax}%
\ifx\@anim@first\@empty%
\gdef\@anim@first{0}%
\else%
@@ -1513,56 +1613,7 @@
\xdef\@anim@last{\the\@anim@curframe}%
\fi%
}%
-\else
- \if@anim@xetex
- \def\@anim@checkmultipage#1#2{%
- \ifx\@empty#2\@empty%
- \IfFileExists{#1.pdf}{%
- \setboolean{@anim@multipage}{true}%
- \gdef\@anim@ext{.pdf}%
- }{}%
- \else%
- \IfFileExists{#1.#2}{%
- \setboolean{@anim@multipage}{true}%
- \gdef\@anim@ext{.#2}%
- }{}%
- \fi%
- \if@anim@multipage%
- \xdef\@anim@pathtofile{\expandafter\zap@finalspace\@filef@und\@nil}%
- \@anim@curframe=\XeTeXpdfpagecount "\@anim@pathtofile"%
- \advance\@anim@curframe by -\@ne%since XeTeXpdfpagecount is 1-based
- \edef\@anim@lastpage{\the\@anim@curframe}%
- \ifx\@anim@first\@empty%
- \gdef\@anim@first{0}%
- \else%
- \ifnum\@anim@first<\z@\relax\gdef\@anim@first{0}\fi%
- \ifnum\@anim@first>\@anim@lastpage\relax%
- \global\let\@anim@first\@anim@lastpage%
- \fi%
- \fi%
- \ifx\@anim@last\@empty%
- \global\let\@anim@last\@anim@lastpage%
- \else%
- \ifnum\@anim@last<\z@\relax\gdef\@anim@last{0}\fi%
- \ifnum\@anim@last>\@anim@lastpage\relax%
- \global\let\@anim@last\@anim@lastpage%
- \fi%
- \fi%
- \@anim@curframe=\@anim@first%
- \advance\@anim@curframe by \@ne%
- \xdef\@anim@first{\the\@anim@curframe}%
- \@anim@curframe=\@anim@last%
- \advance\@anim@curframe by \@ne%
- \xdef\@anim@last{\the\@anim@curframe}%
- \fi%
- }%
- \else
- %no multi-page support in dvips & dvisvgm;
- %although dvipdfmx actually has multi-page support, it lacks a way to
- %determine the total page count which is needed here
- \def\@anim@checkmultipage#1#2{\setboolean{@anim@multipage}{false}}%
- \fi
-\fi
+\fi%
%environment for setting LTR typesetting direction
\def\@anim@beginLTR{%
@@ -1625,6 +1676,10 @@
\ifnum\@anim@resizeflags=7\relax% height+totalheight+width->totalheight+width
\global\@anim@resizeflags=5%
\fi%
+ \if@anim@hiresbb\xdef\@anim@gropts{\@anim@gropts,hiresbb}\fi%
+ \if@anim@interpolate\xdef\@anim@gropts{\@anim@gropts,interpolate}\fi%
+ \ifx\@anim@pagebox\@empty\else%
+ \xdef\@anim@gropts{\@anim@gropts,pagebox=\@anim@pagebox}\fi%
\ifthenelse{\boolean{@anim@autoplay}\OR\boolean{@anim@autoresume}}{%
\setboolean{@anim@autoplayorresume}{true}%
}{}%
@@ -2032,7 +2087,7 @@
\@anim@annot{\@anim@btnsize}{\@anim@btnsize}{\z@}{%
cursor='pointer' onmousedown='\@anim@btnJS{#1}{\@anim@arg}'%
}%
- \@anim@updatebbox{\@anim@btnsize}{\@anim@btnsize}{}%
+ \@anim@updatebbox{\@anim@btnsize}{\@anim@btnsize}{\z@}%
\hbox to \@anim@btnsize {%
\vrule width \z@ height \@anim@btnsize depth \z@%
\hss%
@@ -2872,6 +2927,17 @@
\define@key{anim@user}{keepaspectratio}[true]{%
\setboolean{@anim@iso}{#1}%
}
+\newboolean{@anim@hiresbb}
+\define@key{anim@user}{hiresbb}[true]{%
+ \setboolean{@anim@hiresbb}{#1}%
+}
+\newboolean{@anim@interpolate}
+\define@key{anim@user}{interpolate}[true]{%
+ \setboolean{@anim@interpolate}{#1}%
+}
+\define@key{anim@user}{pagebox}{%
+ \gdef\@anim@pagebox{#1}%
+}
\define@key{anim@user}{scale}{%
\gdef\@anim@boxscale{#1}%
}
@@ -3138,6 +3204,9 @@
\setboolean{@anim@doscaling}{true}%
\global\let\@anim@boxscale\@anim@@boxscale%
\global\let\if@anim@iso=\if@anim@@iso%
+ \global\let\if@anim@hiresbb=\if@anim@@hiresbb%
+ \global\let\if@anim@interpolate=\if@anim@@interpolate%
+ \global\let\@anim@pagebox\@anim@@pagebox%
\global\@anim@resizeflags\@anim@@resizeflags%
\global\let\@anim@widtharg\@anim@@widtharg%
\global\let\@anim@heightarg\@anim@@heightarg%
@@ -3331,6 +3400,18 @@
\define@key{anim@pkg}{keepaspectratio}[true]{%
\setboolean{@anim@@iso}{#1}%
}
+\newboolean{@anim@@hiresbb}
+\define@key{anim@pkg}{hiresbb}[true]{%
+ \setboolean{@anim@@hiresbb}{#1}%
+}
+\newboolean{@anim@@interpolate}
+\define@key{anim@pkg}{interpolate}[true]{%
+ \setboolean{@anim@@interpolate}{#1}%
+}
+\def\@anim@@pagebox{}
+\define@key{anim@pkg}{pagebox}{%
+ \def\@anim@@pagebox{#1}%
+}
\def\@anim@@boxscale{1}%
\define@key{anim@pkg}{scale}{%
\def\@anim@@boxscale{#1}%