summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-04-19 22:15:45 +0000
committerKarl Berry <karl@freefriends.org>2020-04-19 22:15:45 +0000
commite906e55ded93f3190924425ff26574acbd701732 (patch)
tree792902e02e525888a7cb2f10bef2e0720f33a0ea /Master/texmf-dist/tex/latex
parent9d2bfa4b61a536743b393ace444b2ca1b2e47ce9 (diff)
bxpdfver (20apr20)
git-svn-id: svn://tug.org/texlive/trunk@54802 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty227
1 files changed, 157 insertions, 70 deletions
diff --git a/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty b/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty
index 213871f7bfb..ad472da1b4f 100644
--- a/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty
+++ b/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty
@@ -1,8 +1,16 @@
-% bxpdfver.sty
+%%
+%% This is file 'bxpdfver.sty'.
+%%
+%% Copyright (c) 2014-2020 Takayuki YATO (aka. "ZR")
+%% GitHub: https://github.com/zr-tex8r
+%% Twitter: @zr_tex8r
+%%
+%% This package is distributed under the MIT License.
+%%
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bxpdfver}[2017/02/11 v0.4]
+\ProvidesPackage{bxpdfver}[2020/04/19 v0.5]
\def\bxpv@pkgname{bxpdfver}
%% preparations
@@ -20,26 +28,17 @@
\let\bxpv@compress=t % use compression?
\let\bxpv@obj@compress=t % use object stream?
\chardef\bxpv@infolevel=2 % info-log level
+\let\bxpv@new@dvipdfmx=f % assume new dvipdfmx?
+
+%% \bxpv@valid@versions
+\def\bxpv@valid@versions{1.4,1.5,1.6,1.7,2.0}
%% options
% (PDF version)
-\DeclareOption{1.4}{%
- \edef\bxpv@version{\CurrentOption}%
-}
-\DeclareOption{1.5}{%
- \edef\bxpv@version{\CurrentOption}%
-}
-\DeclareOption{1.6}{%
- \edef\bxpv@version{\CurrentOption}%
-}
-\DeclareOption{1.7}{%
- \edef\bxpv@version{\CurrentOption}%
-}
-\DeclareOption{1.8}{%
- \edef\bxpv@version{\CurrentOption}%
-}
-\DeclareOption{1.9}{%
- \edef\bxpv@version{\CurrentOption}%
+\@for\bxpv@tmpa:=\bxpv@valid@versions\do{%
+ \DeclareOption{\bxpv@tmpa}{%
+ \edef\bxpv@version{\CurrentOption}%
+ }%
}
% (compression)
\DeclareOption{nocompress}{%
@@ -83,6 +82,11 @@
\let\bxpv@drv@type=0%
\def\bxpv@drv@name{nodvidriver}%
}
+\DeclareOption{new-dvipdfmx}{%
+ \let\bxpv@drv@type=d%
+ \let\bxpv@new@dvipdfmx=t%
+ \def\bxpv@drv@name{dvipdfmx}%
+}
% (other)
\DeclareOption{lenient}{%
\chardef\bxpv@infolevel=1
@@ -130,6 +134,12 @@
the engine/driver does not support the feature}%
}
+%% \ifbxpv@defined
+\let\ifbxpv@defined\ifdefined
+\ifx\ifbxpv@defined\@undefined \expandafter\@firstofone
+\else \expandafter\@gobble
+\fi{\let\ifbxpv@defined\iffalse}
+
%--------------------------------------- internal dispatchers
%% \bxpv@suppress@compress
@@ -142,6 +152,9 @@
\def\bxpv@suppress@obj@compress{%
\bxpv@fail@nafea{Cannot suppress object compression}%
}
+%% \bxpv@check@version
+\@onlypreamble\bxpv@check@version
+\let\bxpv@check@version\bxpv@okfalse
%% \bxpv@set@version
\@onlypreamble\bxpv@set@version
\def\bxpv@set@version{%
@@ -206,30 +219,59 @@
\global\let\bxpv@@minorversion\pdfminorversion
\global\let\bxpv@@decimaldigits\pdfdecimaldigits
\global\let\bxpv@@pkresolution\pdfpkresolution
+ \global\let\bxpv@@majorversion\pdfmajorversion
\bxpv@check@prim\pdfvariable{%
\protected\xdef\bxpv@@compresslevel{\pdfvariable compresslevel}%
\protected\xdef\bxpv@@objcompresslevel{\pdfvariable objcompresslevel}%
\protected\xdef\bxpv@@minorversion{\pdfvariable minorversion}%
\protected\xdef\bxpv@@decimaldigits{\pdfvariable decimaldigits}%
\protected\xdef\bxpv@@pkresolution{\pdfvariable pkresolution}%
+ \ifnum 0\directlua{%
+ if pdf.getmajorversion then tex.write('1') end}>\z@
+ \protected\xdef\bxpv@@majorversion{\pdfvariable majorversion}%
+ \fi
}%
% If \pdfcompresslevel is available, use it.
- \ifx\bxpv@@compresslevel\@undefined\else
+ \ifbxpv@defined\bxpv@@compresslevel
\gdef\bxpv@suppress@compress{%
\global\bxpv@@compresslevel\z@
}%
\fi
% If \pdfobjcompresslevel is available, use it.
- \ifx\bxpv@@objcompresslevel\@undefined\else
+ \ifbxpv@defined\bxpv@@objcompresslevel
\global\chardef\bxpv@org@objcompresslevel\bxpv@@objcompresslevel
\gdef\bxpv@suppress@obj@compress{%
\global\bxpv@@objcompresslevel\z@
}%
\global\let\bxpv@cancel@obj@compress\bxpv@suppress@obj@compress
\fi
- % If \pdfminorversion is available, use it.
- \ifx\bxpv@@minorversion\@undefined\else
+ % If \pdfmajorversion/\pdfminorversion is available, use it.
+ \ifbxpv@defined\bxpv@@majorversion
\global\chardef\bxpv@org@minorversion\bxpv@@minorversion
+ \global\chardef\bxpv@org@majorversion\bxpv@@majorversion
+ \global\let\bxpv@check@version\bxpv@oktrue
+ \gdef\bxpv@set@version{%
+ \ifx\bxpdfverMinorVersion\relax
+ \global\bxpv@@minorversion\bxpv@org@minorversion
+ \global\bxpv@@majorversion\bxpv@org@majorversion
+ \else
+ \global\bxpv@@minorversion\bxpdfverMinorVersion
+ \global\bxpv@@majorversion\bxpdfverMajorVersion
+ \fi
+ }%
+ \g@addto@macro\bxpv@begin@document@hook{%
+ \ifnum\bxpv@@majorversion<2 \ifnum\bxpv@@minorversion<5
+ \bxpv@cancel@obj@compress
+ \fi\fi
+ }%
+ \else\ifbxpv@defined\bxpv@@minorversion
+ \global\chardef\bxpv@org@minorversion\bxpv@@minorversion
+ \gdef\bxpv@check@version{%
+ \bxpv@oktrue
+ \ifx\bxpdfverMajorVersion\tw@
+ \bxpv@okfalse % cannot set major version 2
+ \fi
+ }
\gdef\bxpv@set@version{%
\ifx\bxpdfverMinorVersion\relax
\global\bxpv@@minorversion\bxpv@org@minorversion
@@ -242,9 +284,9 @@
\bxpv@cancel@obj@compress
\fi
}%
- \fi
+ \fi\fi
% If \pdfdecimaldigits is available, use it.
- \ifx\bxpv@@decimaldigits\@undefined\else
+ \ifbxpv@defined\bxpv@@decimaldigits
\global\chardef\bxpv@org@decimaldigits\bxpv@@decimaldigits
\gdef\bxpv@set@decimaldigits{%
\ifx\bxpdfverDecimalDigits\relax
@@ -255,7 +297,7 @@
}%
\fi
% If \pdfpkresolution is available, use it.
- \ifx\bxpv@@pkresolution\@undefined\else
+ \ifbxpv@defined\bxpv@@pkresolution
\global\mathchardef\bxpv@org@pkresolution\bxpv@@pkresolution
\gdef\bxpv@set@pkresolution{%
\ifx\bxpdfverPkResolution\relax
@@ -285,6 +327,7 @@
\else\if d\bxpv@drv@type % 'dvipdfmx'
\global\let\bxpv@suppress@compress\relax
\global\let\bxpv@suppress@obj@compress\relax
+ \global\let\bxpv@check@version\relax
\global\let\bxpv@set@version\relax
\global\let\bxpv@set@decimaldigits\relax
%\global\let\bxpv@set@pkresolution\relax
@@ -324,8 +367,13 @@
\@onlypreamble\setpdfversion
\newcommand*\setpdfversion[1]{%
\edef\bxpv@version{#1}%
- \bxpv@get@mversion
- \bxpv@set@version
+ \bxpv@set@version@values
+ \bxpv@check@version
+ \ifbxpv@ok
+ \bxpv@set@version
+ \else
+ \bxpv@fail@nafea{Cannot set PDF version to '\bxpv@version'}%
+ \fi
}
%%<*> \setpdfdecimaldigits{<number>}
@@ -362,6 +410,13 @@
\let\bxpdfverMinorVersion\relax
}
+%%<+> \bxpdfverMajorVersion
+% The PDF major version (eg. '1' for 1.4) that this package
+% will impose. It is a number constant, or \relax.
+\@ifdefinable{\bxpdfverMajorVersion}{%
+ \let\bxpdfverMajorVersion\relax
+}
+
%%<+> \bxpdfverDecimalDigits
% The PDF decimal-digits value that this package
% will impose. It is a number constant, or \relax.
@@ -418,90 +473,100 @@
%% variables
\let\bxpv@mversion\relax % minor version (temporary)
-%% \bxpv@get@mversion
-% Sets \bxpdfverMinorVersion.
-\@onlypreamble\bxpv@get@mversion
-\def\bxpv@get@mversion{%
+%% \bxpv@set@version@values
+% Sets \bxpdfverMinorVersion/\bxpdfverMajorVersion.
+\@onlypreamble\bxpv@set@version@values
+\def\bxpv@set@version@values{%
\edef\bxpv@version{\bxpv@version}%
+ \let\bxpv@tmpc\bxpv@version
\ifx\bxpv@version\@empty
\global\let\bxpdfverMinorVersion\relax % unset
+ \global\let\bxpdfverMajorVersion\relax % unset
\else
- \let\bxpv@mversion\relax
- \@tfor\bxpv@x:=456789\do{%
- \edef\bxpv@tmpa{1.\bxpv@x}%
+ \bxpv@okfalse
+ \@for\bxpv@tmpa:=\bxpv@valid@versions\do{%
\ifx\bxpv@version\bxpv@tmpa
- \chardef\bxpv@mversion=\bxpv@x\relax
+ \bxpv@oktrue
\fi
}%
- \ifx\bxpv@mversion\relax
- \bxpv@file@mversion
+ \ifbxpv@ok\else
+ \bxpv@check@file@version
+ \ifx\bxpv@version\relax
+ \bxpv@okfalse
+ \else
+ \bxpv@oktrue
+ \PackageInfo\bxpv@pkgname
+ {Output PDF version is set to \bxpv@version\MessageBreak}%
+ \fi
\fi
- \ifx\bxpv@mversion\relax
+ \ifbxpv@ok
+ \expandafter\bxpv@set@version@values@a\bxpv@version\relax
+ \else
\PackageError\bxpv@pkgname
{Invalid value given for PDF version\MessageBreak
- (value=\bxpv@version)}{%
- PDF version must be either 1.4, 1.5, ..., 1.9, or\MessageBreak
+ (value=\bxpv@tmpc)}{%
+ PDF version must be either one of the following:\MessageBreak
+ \@spaces \bxpv@valid@versions;\MessageBreak
or the name of a PDF file from which the version is pulled.%
\MessageBreak\@ehc}%
- \else
- \PackageInfo\bxpv@pkgname
- {Output PDF version is set to 1.\the\bxpv@mversion
- \MessageBreak}%
- \global\let\bxpdfverMinorVersion\bxpv@mversion
\fi
\fi
}
+\def\bxpv@set@version@values@a#1.#2\relax{%
+ \global\chardef\bxpdfverMinorVersion=#2\relax
+ \global\chardef\bxpdfverMajorVersion=#1\relax
+}
-%% \bxpv@file@mversion
-\@onlypreamble\bxpv@file@mversion
-\def\bxpv@file@mversion{%
- \let\bxpv@mversion\relax
- \expandafter\bxpv@file@mversion@a\bxpv@version\bxpv@end
+%% \bxpv@check@file@version
+\@onlypreamble\bxpv@check@file@version
+\def\bxpv@check@file@version{%
+ \expandafter\bxpv@check@file@version@a\bxpv@version\bxpv@end
}
-\@onlypreamble\bxpv@file@mversion@a
-\def\bxpv@file@mversion@a#1\bxpv@end{%
+\@onlypreamble\bxpv@check@file@version@a
+\def\bxpv@check@file@version@a#1\bxpv@end{%
\filename@parse{#1}%
\edef\bxpv@next{%
\lowercase{\def\noexpand\filename@ext{\filename@ext}}%
}\bxpv@next
\def\bxpv@tmpb{pdf}%
+ \let\bxpv@version\relax
\ifx\filename@ext\bxpv@tmpb
\global\let\bxpv@gtmpa\relax
\bxpv@read@file{#1}{%
- \bxpv@file@mversion@xa{##1 }%
+ \bxpv@check@file@version@xa{##1 }%
\bxpv@read@file@finish
}%
\ifbxpv@read@file@ok\else
\PackageWarning\bxpv@pkgname
{File '#1' not found}%
\fi
- \@tfor\bxpv@x:=456789\do{%
- \ifx\bxpv@x\bxpv@gtmpa
- \chardef\bxpv@mversion=\bxpv@x\relax
+ \@for\bxpv@tmpa:=\bxpv@valid@versions\do{%
+ \ifx\bxpv@gtmpa\bxpv@tmpa
+ \let\bxpv@version\bxpv@tmpa
\fi
}%
\fi
}
% some more subprocedures
-\@onlypreamble\bxpv@file@mversion@xa
-\@onlypreamble\bxpv@file@mversion@xb
-\@onlypreamble\bxpv@file@mversion@xc
+\@onlypreamble\bxpv@check@file@version@xa
+\@onlypreamble\bxpv@check@file@version@xb
+\@onlypreamble\bxpv@check@file@version@xc
\begingroup
\escapechar\m@ne
\def\bxpv@tmpa#1\bxpv@end{%
- \gdef\bxpv@file@mversion@xa##1{%
- \bxpv@file@mversion@xb##1#1\bxpv@end
+ \gdef\bxpv@check@file@version@xa##1{%
+ \bxpv@check@file@version@xb##1#1\bxpv@end
}%
- \gdef\bxpv@file@mversion@xb##1#1##2\bxpv@end{%
+ \gdef\bxpv@check@file@version@xb##1#1##2\bxpv@end{%
\ifx\bxpv@mt##1\bxpv@mt
- \bxpv@file@mversion@xc##2\bxpv@end
+ \bxpv@check@file@version@xc##2\bxpv@end
\fi
}%
- \gdef\bxpv@file@mversion@xc##1 ##2\bxpv@end{%
+ \gdef\bxpv@check@file@version@xc##1 ##2\bxpv@end{%
\gdef\bxpv@gtmpa{##1}%
}%
}
- \edef\bxpv@tmpb{{\expandafter\string\csname\string\%PDF-1.\endcsname}}%
+ \edef\bxpv@tmpb{{\expandafter\string\csname\string\%PDF-\endcsname}}%
\expandafter\bxpv@tmpa\bxpv@tmpb\bxpv@end
\endgroup
@@ -531,10 +596,26 @@
\@onlypreamble\bxpv@begin@document@dvipdfmx
\def\bxpv@begin@document@dvipdfmx{%
% PDF version
- \ifx\bxpdfverMinorVersion\relax\else
- \g@addto@macro\bxpv@page@specials{%
- \special{pdf:minorversion \the\bxpdfverMinorVersion}%
- }%
+ \ifx\bxpdfverMajorVersion\tw@
+ \bxpv@check@dvipdfmx@version{20180217}%
+ {Cannot set PDF major version}%
+ \else
+ \bxpv@oktrue
+ \fi
+ \ifbxpv@ok
+ \ifx\bxpdfverMinorVersion\relax\else
+ \g@addto@macro\bxpv@page@specials{%
+ \special{pdf:minorversion \the\bxpdfverMinorVersion}%
+ }%
+ \fi
+ \ifx\bxpdfverMinorVersion\relax\else
+ \bxpv@cache@fetch{dvipdfmxver}%
+ \ifnum\bxpv@cache@@dvipdfmxver<20180217 \else
+ \g@addto@macro\bxpv@page@specials{%
+ \special{pdf:majorversion \the\bxpdfverMajorVersion}%
+ }%
+ \fi
+ \fi
\fi
% compression
\ifbxpdfverCompressionSuppressed
@@ -806,6 +887,7 @@
\chardef\bxpv@rf@cont\@ne
\bxpv@read@file@b
\fi
+ \closein\@inputcheck
\endgroup
}
\@onlypreamble\bxpv@read@file@b
@@ -888,11 +970,13 @@
\def\next#1{\expandafter\meaning\csname if#1\endcsname}%
\typeout{**bxpdfver-----------%
^^JMinorVersion=\meaning\bxpdfverMinorVersion
+ ^^JMajorVersion=\meaning\bxpdfverMajorVersion
^^JCompressionSuppressed=\next{bxpdfverCompressionSuppressed}%
^^JObjCompressionSuppressed=\next{bxpdfverObjCompressionSuppressed}%
^^JDecimalDigits=\meaning\bxpdfverDecimalDigits
^^JPkResolution=\meaning\bxpdfverPkResolution
\do minorversion=\bxpv@@minorversion
+ \do majorversion=\bxpv@@majorversion
\do compresslevel=\bxpv@@compresslevel
\do objcompresslevel=\bxpv@@objcompresslevel
\do decimaldigits=\bxpv@@decimaldigits
@@ -912,6 +996,9 @@
\if t\bxpv@obj@compress\else
\suppresspdfobjcompression
\fi
+\if t\bxpv@new@dvipdfmx
+ \bxpv@cache@store{dvipdfmxver}{99999999}
+\fi
%--------------------------------------- all done
\endinput