summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-08-11 21:42:45 +0000
committerKarl Berry <karl@freefriends.org>2016-08-11 21:42:45 +0000
commit08ddf2612db3c8882d81fa31045b11c4daba10b1 (patch)
tree145054aa3aab4d0cacde0a9a7a82e576ac22a187
parentcbf866cb27098913d37293178005d01dcc91dc03 (diff)
bxpdfver (11aug16)
git-svn-id: svn://tug.org/texlive/trunk@41837 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/bxpdfver/README-ja.md (renamed from Master/texmf-dist/doc/latex/bxpdfver/README-ja)21
-rw-r--r--Master/texmf-dist/doc/latex/bxpdfver/README.md (renamed from Master/texmf-dist/doc/latex/bxpdfver/README)24
-rw-r--r--Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty648
3 files changed, 545 insertions, 148 deletions
diff --git a/Master/texmf-dist/doc/latex/bxpdfver/README-ja b/Master/texmf-dist/doc/latex/bxpdfver/README-ja.md
index 7b51dda9669..368811e072b 100644
--- a/Master/texmf-dist/doc/latex/bxpdfver/README-ja
+++ b/Master/texmf-dist/doc/latex/bxpdfver/README-ja.md
@@ -46,6 +46,7 @@ bxpdfver パッケージ
のでドライバオプションは不要である。
+ `dvipdfmx`: dvipdfmx 用のドライバを指定する。
+ `disabled`: 全ての機能を無効化する。
+ * `lenient`: サポートしない機能に対するエラーを警告に格下げする。
`compress`、`objcompress` はこのパッケージによる抑止を行わないという意味
であり、既に抑止されている場合にそれを再び有効化するものではない。
@@ -53,7 +54,16 @@ bxpdfver パッケージ
### ドライバ指定
* pdfTeX および LuaTeX では全ての機能が使用可能。
- * XeTeX および dvipdfmx では PDF バージョン指定のみ使用可能。
+ * XeTeX および dvipdfmx の場合:
+ - 「PDF バージョン指定」は無条件に使用可能。
+ - 「オブジェクト圧縮抑止」および「オブジェクトストリーム抑止」の
+ 機能を使用するためには、(x)dvipdfmx のバージョンが 20160307 以上
+ である必要がある。またバージョン判定のために外部プログラムの
+ 起動を利用するため、シェルエスケープが制限付許可または完全許可
+ されている必要がある。
+ - dvipdfmx のバージョン情報は補助ファイル(.aux)中にキャッシュ
+ される。このため、何か状況が変わった場合は、一旦補助ファイルを
+ 削除する必要が生じる。
* 使用不可能な機能を使おうと試みるとエラーが発生する。
* `dvips` 等の“全く対応していない”若干のドライバオプションを認識
する。この場合、全ての機能の呼出でエラーが発生する。
@@ -77,9 +87,14 @@ bxpdfver パッケージ
更新履歴
--------
- * Version 0.2a [2015/08/05]
+ * Version 0.3 ‹2016/08/11›
+ - dvipdfmx/XeTeX でも全ての機能がサポートされる。
+ * Version 0.2b ‹2016/08/10›
+ - `lenient` オプションを追加。
+ - 新しい LuaTeX エンジンのサポート。
+ * Version 0.2a ‹2015/08/05›
- 細かい修正。
- * Version 0.2 [2014/07/04]
+ * Version 0.2 ‹2014/07/04›
- 最初の公開版。
--------------------
diff --git a/Master/texmf-dist/doc/latex/bxpdfver/README b/Master/texmf-dist/doc/latex/bxpdfver/README.md
index c5af09b52be..2149826e3e0 100644
--- a/Master/texmf-dist/doc/latex/bxpdfver/README
+++ b/Master/texmf-dist/doc/latex/bxpdfver/README.md
@@ -37,7 +37,7 @@ The available options are:
* `1.4`, `1.5`, `1.6`, or `1.7`: Sets PDF version.
* `nocompress`: Suppresses stream compression.
- * `compress` (defalt): Does not suppress stream compression.
+ * `compress` (default): Does not suppress stream compression.
* `noobjcompress`: Suppresses use of object streams.
* `objcompress` (default): Does not suppress use of object streams.
* Driver options: As below:
@@ -45,15 +45,22 @@ The available options are:
since the appropriate one is auto-detected.
+ `dvipdfmx`: Uses dvipdfmx driver.
+ `disabled`: Disables all functions of the package.
+ * `lenient`: Turns the errors for unsupported features into warnings.
Note that the options `compress` and `objcompress` mean that this
-package *does not suppress* a feature. They do not active a feature
+package *does not suppress* a feature. They do not activate a feature
when it is already suppressed by other means.
### NOTE ON DRIVERS
* pdfTeX and LuaTeX support all features.
- * XeTeX and dvipdfmx support only PDF version setting.
+ * When using XeTeX and dvipdfmx:
+ - PDF version setting is always available.
+ - Suppression of compression and suppression of object streams
+ are available only when the version of (x)dvipdfmx is 20160307
+ or later. Also shell escape must be accepted (with or without
+ restriction), because external programs (such as kpsewhich)
+ are invoked in order to detect the dvipdfmx version.
* If you try to use unavailable features, an error will occur.
* The package recognizes some “unsupported” driver options such as
`dvips`; when such drivers are used, use of any feature will cause
@@ -68,15 +75,20 @@ when it is already suppressed by other means.
+ `1.4`, `1.5`, `1.6`, or `1.7`; the version itself.
+ the name of a PDF file; the version is set equal to that of
the given file.
- * `\suppresspdfcompression`: Suppresses use of object streams.
+ * `\suppresspdfcompression`: Suppresses stream compression.
* `\suppresspdfobjcompression`: Suppresses use of object streams.
REVISION HISTORY
----------------
- * Version 0.2a [2015/08/05]
+ * Version 0.3 ‹2016/08/11›
+ - Supported all features on dvipdfmx/XeTeX.
+ * Version 0.2b ‹2016/08/10›
+ - Added the `lenient` option.
+ - Supported the newer version of LuaTeX.
+ * Version 0.2a ‹2015/08/05›
- Minor fix.
- * Version 0.2 [2014/07/04]
+ * Version 0.2 ‹2014/07/04›
- First public version.
--------------------
diff --git a/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty b/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty
index 046f558a3c7..0c3afab1a70 100644
--- a/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty
+++ b/Master/texmf-dist/tex/latex/bxpdfver/bxpdfver.sty
@@ -2,23 +2,26 @@
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bxpdfver}[2015/08/05 v0.2a]
+\ProvidesPackage{bxpdfver}[2016/08/11 v0.3]
+\def\bxpv@pkgname{bxpdfver}
%% preparations
-\def\bxpv@pkgname{bxpdfver}
-\def\bxpv@error{\PackageError\bxpv@pkgname}
-\def\bxpv@info{\PackageInfo\bxpv@pkgname}
+\RequirePackage{ifthen}[]% for \newboolean
+\newif\ifbxpv@ok
+\providecommand\bxDebug[1]{}
+
+%--------------------------------------- package options
%% variables
-\newif\ifbxpv@ok
-\let\bxpv@drv@type\relax
-\let\bxpv@drv@name\relax
-\let\bxpv@version\relax
-\let\bxpv@mversion\relax
-\let\bxpv@compress=t
-\let\bxpv@obj@compress=t
-
-%% process options
+\let\bxpv@drv@type\relax % driver type
+ % p=pdfmode,d=dvipdfmx,0=disabled,x=unsupported
+\let\bxpv@drv@name\relax % driver name
+\let\bxpv@version\relax % version value (eg. 1.4)
+\let\bxpv@compress=t % use compression?
+\let\bxpv@obj@compress=t % use object stream?
+\chardef\bxpv@infolevel=2 % info-log level
+
+%% options
% (PDF version)
\DeclareOption{1.4}{%
\edef\bxpv@version{\CurrentOption}%
@@ -68,46 +71,95 @@
\let\bxpv@drv@type=x%
\def\bxpv@drv@name{dviout}%
}
+\DeclareOption{xdvi}{%
+ \let\bxpv@drv@type=x%
+ \def\bxpv@drv@name{xdvi}%
+}
\DeclareOption{disabled}{%
\let\bxpv@drv@type=0%
\def\bxpv@drv@name{disabled}%
}
-%
+% (other)
+\DeclareOption{lenient}{%
+ \chardef\bxpv@infolevel=1
+}
+
+%% process
\ProcessOptions*
%--------------------------------------- helpers
%% unique tokens
\def\bxpv@end{\bxpv@end@}
+\def\bxpv@mkj{\bxpv@mk@}
\def\bxpv@mt{\bxpv@mt@}
-%--------------------------------------- environment check
+%% \bxpv@csletcs
+\def\bxpv@csletcs#1#2{%
+ \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname
+}
+
+%% \bxpv@detokenize\CS
+\def\bxpv@detokenize#1{%
+ \expandafter\bxpv@detokenize@a\meaning#1\bxpv@end#1%
+}
+\def\bxpv@detokenize@a#1>#2\bxpv@end#3{%
+ \def#3{#2}%
+}
+
+%% \bxpv@fail{<message>}
+% Issues an error or a warning.
+\@onlypreamble\bxpv@fail
+\def\bxpv@fail#1{%
+ \ifcase\bxpv@infolevel % silenced
+ \or % lenient
+ \PackageWarningNoLine\bxpv@pkgname{#1}%
+ \or % strict
+ \PackageError\bxpv@pkgname{#1}{\@ehc}%
+ \fi
+}
+
+%--------------------------------------- internal dispatchers
%% \bxpv@suppress@compress
\@onlypreamble\bxpv@suppress@compress
\def\bxpv@suppress@compress{%
- \bxpv@error{Cannot suppress compression}%
- \bxpv@errh@na
+ \bxpv@fail
+ {Cannot suppress compression, because\MessageBreak
+ the engine/driver does not support the feature}%
}
%% \bxpv@suppress@obj@compress
\@onlypreamble\bxpv@suppress@obj@compress
\def\bxpv@suppress@obj@compress{%
- \bxpv@error{Cannot suppress object compression}%
- \bxpv@errh@na
+ \bxpv@fail
+ {Cannot suppress object compression, because\MessageBreak
+ the engine/driver does not support the feature}%
}
%% \bxpv@set@version
\@onlypreamble\bxpv@set@version
\def\bxpv@set@version{%
- \bxpv@error{Cannot set PDF version}%
- \bxpv@errh@na
-}
-%% \bxpv@errh@na
-\@onlypreamble\bxpv@errh@na
-\def\bxpv@errh@na{%
- This feature is not supported by the engine in use.%
- \MessageBreak\@ehc
+ \bxpv@fail
+ {Cannot set PDF version, because\MessageBreak
+ the engine/driver does not support the feature}%
}
+%% \bxpv@cancel@obj@compress
+% The silent version of \bxpv@suppress@obj@compress.
+\@onlypreamble\bxpv@cancel@obj@compress
+\let\bxpv@cancel@obj@compress\relax
+%% \bxpv@begin@document@hook
+% The begin-document hook.
+\@onlypreamble\bxpv@begin@document@hook
+\let\bxpv@begin@document@hook\@empty
+\AtBeginDocument{\bxpv@begin@document@hook}
+
+%% 'disabled' driver
+\if 0\bxpv@drv@type
+ \chardef\bxpv@infolevel=0
+\fi
+
+%% adjust internal dispatchers
+\ifx 0\bxpv@drv@type\else %--------
\begingroup
%% \bxpv@check@prim\CS{<proc>}
@@ -120,89 +172,83 @@
\fi
}
-%% \bxpv@pdfoutput: use PDF output?
-\ifx\pdfoutput\@undefined
- \chardef\bxpv@pdfoutput\z@
- % XeTeX might support \pdfminorversion etc in the future :)
- \bxpv@check@prim\XeTeXversion{\chardef\bxpv@pdfoutput\@ne}%
- % pTeX-ng
- \bxpv@check@prim\ngbanner{\chardef\bxpv@pdfoutput\@ne}%
-\else
- \chardef\bxpv@pdfoutput\pdfoutput
-\fi
+%% \bxpv@pdfoutput
+\chardef\bxpv@pdfoutput\z@
+\bxpv@check@prim\pdfoutput{\chardef\bxpv@pdfoutput\pdfoutput}
+\bxpv@check@prim\outputmode{\chardef\bxpv@pdfoutput\outputmode}
+\bxpv@check@prim\ngbanner{\chardef\bxpv@pdfoutput\@ne}
-%% adjust internal dispatchers
-\bxpv@okfalse
-\ifnum\bxpv@pdfoutput>\z@ % PDF-output
+%% when in PDF mode
+\ifnum\bxpv@pdfoutput>\z@
\global\let\bxpv@drv@type=p
- % \bxpv@isupp@obj@compress: auto-supress of obj-compression
- \@onlypreamble\bxpv@isupp@obj@compress
- \global\let\bxpv@isupp@obj@compress\relax
- % \bxpv@iunsupp@obj@compress: un-auto-supress
- \@onlypreamble\bxpv@iunsupp@obj@compress
- \global\let\bxpv@iunsupp@obj@compress\relax
- %% If \pdfcompresslevel is available, use it.
- \bxpv@check@prim\pdfcompresslevel{%
+ \global\let\bxpv@@compresslevel\pdfcompresslevel
+ \global\let\bxpv@@objcompresslevel\pdfobjcompresslevel
+ \global\let\bxpv@@minorversion\pdfminorversion
+ \bxpv@check@prim\pdfvariable{%
+ \protected\xdef\bxpv@@compresslevel{\pdfvariable compresslevel}%
+ \protected\xdef\bxpv@@objcompresslevel{\pdfvariable objcompresslevel}%
+ \protected\xdef\bxpv@@minorversion{\pdfvariable minorversion}%
+ }%
+ % If \pdfcompresslevel is available, use it.
+ \ifx\bxpv@@compresslevel\@undefined\else
\gdef\bxpv@suppress@compress{%
- \global\pdfcompresslevel\z@
+ \global\bxpv@@compresslevel\z@
}%
- }
- %% If \pdfobjcompresslevel is available, use it.
- \bxpv@check@prim\pdfobjcompresslevel{%
- \global\chardef\bxpv@org@pdfobjcompresslevel\pdfobjcompresslevel
+ \fi
+ % If \pdfobjcompresslevel is available, use it.
+ \ifx\bxpv@@objcompresslevel\@undefined\else
+ \global\chardef\bxpv@org@objcompresslevel\bxpv@@objcompresslevel
\gdef\bxpv@suppress@obj@compress{%
- \global\pdfobjcompresslevel\z@
- \global\let\bxpv@iunsupp@obj@compress\relax
+ \global\bxpv@@objcompresslevel\z@
}%
- \gdef\bxpv@isupp@obj@compress{%
- \global\pdfobjcompresslevel\z@
+ \global\let\bxpv@cancel@obj@compress\bxpv@suppress@obj@compress
+ \fi
+ % If \pdfminorversion is available, use it.
+ \ifx\bxpv@@minorversion\@undefined\else
+ \global\chardef\bxpv@org@minorversion\bxpv@@minorversion
+ \gdef\bxpv@set@version{%
+ \ifx\bxpdfverMinorVersion\relax
+ \global\bxpv@@minorversion\bxpv@org@minorversion
+ \else
+ \global\bxpv@@minorversion\bxpdfverMinorVersion
+ \fi
}%
- \gdef\bxpv@iunsupp@obj@compress{%
- \global\pdfobjcompresslevel\bxpv@org@pdfobjcompresslevel
+ \g@addto@macro\bxpv@begin@document@hook{%
+ \ifnum\bxpv@@minorversion<5
+ \bxpv@cancel@obj@compress
+ \fi
}%
- }
- \bxpv@check@prim\pdfminorversion\bxpv@oktrue
-\fi
-\ifbxpv@ok % \pdfminorversion is available
- \global\chardef\bxpv@org@pdfminorversion\pdfminorversion
- \gdef\bxpv@set@version{%
- \ifx\bxpv@mversion\relax
- \global\pdfminorversion\bxpv@org@pdfminorversion
- \else
- \global\pdfminorversion\bxpv@mversion
- \fi
- \ifnum\pdfminorversion<5
- \bxpv@isupp@obj@compress
- \else
- \bxpv@iunsupp@obj@compress
- \fi
- }%
+ \fi
\else
- % XeTeX now does not have \pdfminorversion,
- % so do it just as dvipdfmx.
+ % XeTeX should do just as dvipdfmx.
\bxpv@check@prim\XeTeXversion{%
\global\let\bxpv@drv@type=d%
}
\fi
-%% driver check
+%% when in DVI mode
\if x\bxpv@drv@type % 'bad' driver
- \bxpv@error{Unsupported driver '\bxpv@drv@name'}\@ehc
+ \bxpv@fail{Unsupported driver '\bxpv@drv@name'}%
% no further errors
- \let\bxpv@drv@type=0\relax
-\fi
-\if d\bxpv@drv@type % 'dvipdfmx'
- \global\let\bxpv@set@version\relax
- \AtBeginDocument{%
- \bxpv@set@version@dvipdfmx
- }
-\else\if 0\bxpv@drv@type % 'disabled'
- \global\let\bxpv@set@version\relax
+ \global\chardef\bxpv@infolevel=0
+\else\if d\bxpv@drv@type % 'dvipdfmx'
\global\let\bxpv@suppress@compress\relax
\global\let\bxpv@suppress@obj@compress\relax
-\fi\fi
+ \global\let\bxpv@set@version\relax
+ \g@addto@macro\bxpv@begin@document@hook{%
+ \bxpv@begin@document@dvipdfmx
+ }
+ \AtEndOfPackage{\g@addto@macro\bxpv@begin@document@hook{%
+ \bxpv@cache@finalize
+ }}
+\else\if \relax\bxpv@drv@type % no driver
+ \bxpv@fail
+ {No driver option is given}%
+ \global\chardef\bxpv@infolevel=0
+\fi\fi\fi
\endgroup
+\fi %--------
%--------------------------------------- public interface
@@ -210,12 +256,14 @@
\@onlypreamble\suppresspdfcompression
\newcommand*\suppresspdfcompression{%
\bxpv@suppress@compress
+ \global\bxpdfverCompressionSuppressedtrue
}
%%<*> \suppresspdfobjcompression
\@onlypreamble\suppresspdfobjcompression
\newcommand*\suppresspdfobjcompression{%
\bxpv@suppress@obj@compress
+ \global\bxpdfverObjCompressionSuppressedtrue
}
%%<*> \setpdfversion{<version>}
@@ -226,15 +274,34 @@
\bxpv@set@version
}
+%%<+> \ifbxpdfverCompressionSuppressed
+\newboolean{bxpdfverCompressionSuppressed}
+
+%%<+> \ifbxpdfverObjCompressionSuppressed
+\newboolean{bxpdfverObjCompressionSuppressed}
+
+%%<+> \bxpdfverMinorVersion
+% The PDF minor version (eg. '4' for 1.4) that this package
+% will impose. It is a number constant, or \relax.
+% (number constant or \relax)
+\@ifdefinable{\bxpdfverMinorVersion}{%
+ \let\bxpdfverMinorVersion\relax
+}
+
%--------------------------------------- version values
+%% variables
+\let\bxpv@mversion\relax % minor version (temporary)
+
%% \bxpv@get@mversion
-% Sets \bxpv@mversion.
-% Note: \bxpv@version is assumed to be already expnaded.
+% Sets \bxpdfverMinorVersion.
\@onlypreamble\bxpv@get@mversion
\def\bxpv@get@mversion{%
- \let\bxpv@mversion\relax
- \ifx\bxpv@version\@empty\else
+ \edef\bxpv@version{\bxpv@version}%
+ \ifx\bxpv@version\@empty
+ \global\let\bxpdfverMinorVersion\relax % unset
+ \else
+ \let\bxpv@mversion\relax
\@tfor\bxpv@x:=456789\do{%
\edef\bxpv@tmpa{1.\bxpv@x}%
\ifx\bxpv@version\bxpv@tmpa
@@ -245,14 +312,17 @@
\bxpv@file@mversion
\fi
\ifx\bxpv@mversion\relax
- \bxpv@error{Invalid value given for PDF version\MessageBreak
+ \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
or the name of a PDF file from which the version is pulled.%
\MessageBreak\@ehc}%
\else
- \bxpv@info{Output PDF version is set to 1.\the\bxpv@mversion
+ \PackageInfo\bxpv@pkgname
+ {Output PDF version is set to 1.\the\bxpv@mversion
\MessageBreak}%
+ \global\let\bxpdfverMinorVersion\bxpv@mversion
\fi
\fi
}
@@ -260,44 +330,33 @@
%% \bxpv@file@mversion
\@onlypreamble\bxpv@file@mversion
\def\bxpv@file@mversion{%
- \begingroup
- \expandafter\bxpv@file@mversion@a\bxpv@version\bxpv@end
- \global\let\bxpv@gtmpa\bxpv@mversion
- \endgroup
- \let\bxpv@mversion\bxpv@gtmpa
+ \let\bxpv@mversion\relax
+ \expandafter\bxpv@file@mversion@a\bxpv@version\bxpv@end
}
\@onlypreamble\bxpv@file@mversion@a
\def\bxpv@file@mversion@a#1\bxpv@end{%
- \bxpv@okfalse
- \lowercase{\bxpv@file@mversion@b#1}%
- \bxpv@mark.pdf\bxpv@mark\bxpv@end
- \ifbxpv@ok
- \openin\@inputcheck=#1\relax
- \bxpv@file@mversion@c
- \closein\@inputcheck
+ \filename@parse{#1}%
+ \edef\bxpv@next{%
+ \lowercase{\def\noexpand\filename@ext{\filename@ext}}%
+ }\bxpv@next
+ \def\bxpv@tmpb{pdf}%
+ \ifx\filename@ext\bxpv@tmpb
+ \global\let\bxpv@gtmpa\relax
+ \bxpv@read@file{#1}{%
+ \bxpv@file@mversion@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@tmpb
+ \ifx\bxpv@x\bxpv@gtmpa
\chardef\bxpv@mversion=\bxpv@x\relax
\fi
}%
\fi
}
-\@onlypreamble\bxpv@file@mversion@b
-\def\bxpv@file@mversion@b#1.pdf\bxpv@mark#2\bxpv@end{%
- \ifx\bxpv@mt#2\bxpv@mt\else \bxpv@oktrue \fi
-}
-\@onlypreamble\bxpv@file@mversion@c
-\def\bxpv@file@mversion@c{%
- \@tempcnta\z@
- \loop\ifnum\@tempcnta<\@cclvi
- \catcode\@tempcnta12 %
- \advance\@tempcnta\@ne
- \repeat
- \endlinechar=32
- \catcode32=10
- \read\@inputcheck to\bxpv@tmpb
- \expandafter\bxpv@file@mversion@xa\bxpv@tmpb\bxpv@end
-}
% some more subprocedures
\@onlypreamble\bxpv@file@mversion@xa
\@onlypreamble\bxpv@file@mversion@xb
@@ -305,7 +364,7 @@
\begingroup
\escapechar\m@ne
\def\bxpv@tmpa#1\bxpv@end{%
- \gdef\bxpv@file@mversion@xa##1\bxpv@end{%
+ \gdef\bxpv@file@mversion@xa##1{%
\bxpv@file@mversion@xb##1#1\bxpv@end
}%
\gdef\bxpv@file@mversion@xb##1#1##2\bxpv@end{%
@@ -314,7 +373,7 @@
\fi
}%
\gdef\bxpv@file@mversion@xc##1 ##2\bxpv@end{%
- \def\bxpv@tmpb{##1}%
+ \gdef\bxpv@gtmpa{##1}%
}%
}
\edef\bxpv@tmpb{{\expandafter\string\csname\string\%PDF-1.\endcsname}}%
@@ -325,29 +384,341 @@
\ifx d\bxpv@drv@type % 'dvipdfmx'
%% required packages
-\RequirePackage{atbegshi}[2009/07/70]
+\RequirePackage{atbegshi}[2007/04/19]% v1.2
+
+%% variables
+\let\bxpv@C@value\relax
+
+%% \bxpv@page@specials
+\let\bxpv@page@specials\@empty
-%% \bxpv@set@version@dvipdfmx
-\@onlypreamble\bxpv@set@version@dvipdfmx
-\def\bxpv@set@version@dvipdfmx{%
- \ifx\bxpv@mversion\relax\else
- % special added to every page
+%% \bxpv@begin@document@dvipdfmx
+\@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}%
+ }%
+ \fi
+ % compression
+ \ifbxpdfverCompressionSuppressed
+ \bxpv@check@dvipdfmx@version{Cannot suppress compression}%
+ \ifbxpv@ok
+ % New dvipdfmx supports this special.
+ \g@addto@macro\bxpv@page@specials{%
+ \special{dvipdfmx:config z 0}%
+ }%
+ \fi
+ \fi
+ % object compression
+ \ifbxpdfverObjCompressionSuppressed
+ \bxpv@check@dvipdfmx@version{Cannot suppress object compression}%
+ \ifbxpv@ok
+ \bxpv@cache@fetch{dvipdfmxcfg}%
+ \def\bxpv@C@value{0}%
+ \ifx\bxpv@cache@@dvipdfmxcfg\@empty\else
+ \def\bxpv@next##1##2{\def\bxpv@C@value{##1}}%
+ \expandafter\bxpv@next\bxpv@cache@@dvipdfmxcfg
+ \fi
+ \bxpv@rc@bitset{\bxpv@C@value}{64}%
+ \let\bxpv@C@value\bxpv@rc@num
+ \g@addto@macro\bxpv@page@specials{%
+ \special{dvipdfmx:config C \bxpv@C@value}%
+ }%
+ \fi
+ \fi
+ % special added to every page
+ \ifx\bxpv@page@specials\@empty\else
+ \edef\bxpv@page@specials{\bxpv@page@specials}%
\AtBeginShipout{%
\setbox\AtBeginShipoutBox=\vbox{%
\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@
- \special{pdf:minorversion \the\bxpv@mversion}%
+ \bxpv@page@specials
\copy\AtBeginShipoutBox
}%
}%
\fi
}
+%% \bxpv@check@dvipdfmx@version
+\@onlypreamble\bxpv@check@dvipdfmx@version
+\def\bxpv@check@dvipdfmx@version#1{%
+ \bxpv@cache@fetch{dvipdfmxver}%
+ \bxpv@okfalse
+ \ifnum\bxpv@cache@@dvipdfmxver=\z@
+ \bxpv@fail
+ {#1, because the\MessageBreak
+ version of dvipdfmx in use is unknown
+ \MessageBreak (v.20160307 or later is required)}%
+ \else\ifnum\bxpv@cache@@dvipdfmxver<20160307
+ \bxpv@fail
+ {#1, because the\MessageBreak
+ version of dvipdfmx in use (v.\bxpv@cache@@dvipdfmxver) is too old
+ \MessageBreak (v.20160307 or later is required)}%
+ \else
+ \PackageInfo\bxpv@pkgname
+ {dvipdfmx version is \bxpv@cache@@dvipdfmxver\@gobble}%
+ \bxpv@oktrue
+ \fi\fi
+}
+
\fi
+%--------------------------------------- software version
+
+%% \bxpv@cache@get@@newtex
+% Returns 1 if the version of TeX is 3.14159265 (released on
+% 2014/01/20) or later, 0 otherwise.
+\@onlypreamble\bxpv@cache@get@@newtex
+\def\bxpv@cache@get@@newtex{%
+ \edef\bxpv@tmpa{\expandafter\noexpand\csname\endcsname}%
+ \def\bxpv@tmpb##1 ##2##3\@nil{\gdef\bxpv@g@value{##2}}%
+ \expandafter\bxpv@tmpb\meaning\bxpv@tmpa1 0\@nil
+}
+
+%% \bxpv@cache@get@@dvipdfmxver
+% Returns the version of dvipdfmx (eg. 20110311).
+% It returns 0 in failure.
+\@onlypreamble\bxpv@cache@get@@dvipdfmxver
+\def\bxpv@cache@get@@dvipdfmxver{%
+ % Here the version of TeX is checked, bacause on old TeX
+ % engines on Windows, pipe inputs will fail when the
+ % command line has arguments.
+ \bxpv@cache@fetch{newtex}%
+ \global\let\bxpv@gtmpa\relax
+ \ifnum\bxpv@cache@@newtex>\z@
+ \def\bxpv@tmpc{This is extractbb Version }%
+ \bxpv@detokenize\bxpv@tmpc
+ \bxpv@read@file{"|extractbb --version"}{%
+ \bxpv@split@at{\bxpv@tmpc}{##1}%
+ \ifx\bxpv@pre\relax\else
+ \global\let\bxpv@gtmpa\bxpv@post
+ \fi
+ }%
+ \fi
+ \ifx\bxpv@gtmpa\relax % failed somewhere
+ \gdef\bxpv@g@value{0}%
+ \else
+ \global\let\bxpv@g@value\bxpv@gtmpa
+ \fi
+}
+
+%--------------------------------------- dvipdfmx config
+
+%% variables
+\let\bxpv@rc@num\relax
+
+%% \bxpv@cache@get@@dvipdfmxcfg
+\@onlypreamble\bxpv@cache@get@@dvipdfmxcfg
+\def\bxpv@cache@get@@dvipdfmxcfg{%
+ % check TeX version
+ \bxpv@cache@fetch{newtex}%
+ \ifnum\bxpv@cache@@newtex>\z@
+ % search dvipdfmx.cfg
+ \global\let\bxpv@gtmpa\@empty
+ \bxpv@read@file{%
+ "|kpsewhich --progname=dvipdfmx --format=othertext dvipdfmx.cfg"%
+ }{%
+ \gdef\bxpv@gtmpa{##1}%
+ \bxpv@read@file@finish
+ }%
+ % read the file
+ \ifx\bxpv@gtmpa\@empty\else
+ \gdef\bxpv@g@rc@tmp@C{0}%
+ \def\bxpv@rc@tmp@C{C }%
+ \bxpv@detokenize\bxpv@rc@tmp@C
+ \gdef\bxpv@g@rc@tmp@V{5}%
+ \def\bxpv@rc@tmp@V{V }%
+ \bxpv@detokenize\bxpv@rc@tmp@V
+ \bxpv@read@file{\bxpv@gtmpa}{%
+ \bxpv@split@at{\bxpv@rc@tmp@C}{##1}%
+ \ifx\bxpv@pre\@empty
+ \bxpv@rc@parse@num{\bxpv@post}%
+ \global\let\bxpv@g@rc@tmp@C\bxpv@rc@num
+ \fi
+ \bxpv@split@at{\bxpv@rc@tmp@V}{##1}%
+ \ifx\bxpv@pre\@empty
+ \bxpv@rc@parse@num{\bxpv@post}%
+ \global\let\bxpv@g@rc@tmp@V\bxpv@rc@num
+ \fi
+ }%
+ % the return value
+ \xdef\bxpv@g@value{{\bxpv@g@rc@tmp@C}{\bxpv@g@rc@tmp@V}}%
+ \fi
+ \fi
+}
+
+%% \bxpv@rc@parse@num{<string>}
+% Returns to \bxpv@rc@num.
+\def\bxpv@rc@parse@num#1{%
+ \edef\bxpv@tmpy{#1\relax\relax}%
+ \expandafter\bxpv@rc@parse@num@a\bxpv@tmpy\bxpv@end
+}
+\def\bxpv@rc@parse@num@a#1#2\bxpv@end{%
+ % skip leading spaces and change to uppercase
+ \uppercase{\bxpv@rc@parse@num@b#1#2\bxpv@end}%
+}
+\def\bxpv@rc@parse@num@b#1#2#3\bxpv@end{%
+ \def\bxpv@tmpy{#1#2#3}%
+ \if0#1\if X#2% convert '0x' to '"'
+ \def\bxpv@tmpy{"#3}%
+ \fi\fi
+ \afterassignment\bxpv@rc@parse@num@c\@tempcnta=\bxpv@tmpy
+}
+\def\bxpv@rc@parse@num@c#1\relax{% discard trailer
+ \edef\bxpv@rc@num{\the\@tempcnta}%
+}
+
+%% \bxpv@rc@bitset{<number1>}{<number2>}
+% Returns to \bxpv@rc@num.
+\def\bxpv@rc@bitset#1#2{%
+ \@tempcnta=#1\relax \divide\@tempcnta#2\relax
+ \@tempcnta=\ifodd\@tempcnta\z@\else#2\relax\fi
+ \advance\@tempcnta#1\relax
+ \edef\bxpv@rc@num{\the\@tempcnta}%
+}
+
+%--------------------------------------- string splitter
+
+%% variables
+\let\bxpv@pre\relax
+\let\bxpv@post\relax
+
+%% \bxpv@split@at{<sep>}{<text>}
+% Splits the text by the given separator.
+% In success, it will set \bxpv@pre and \bxpv@post.
+\def\bxpv@split@at#1#2{%
+ \edef\bxpv@next{{#1}{#2}}%
+ \expandafter\bxpv@split@at@a\bxpv@next
+}
+\def\bxpv@split@at@a#1#2{%
+ \def\bxpv@next##1#1##2\bxpv@end{%
+ \bxpv@split@at@b{##1}{##2}}%
+ \bxpv@next#2\bxpv@mk#1\bxpv@end
+}
+\def\bxpv@split@at@b#1#2{%
+ \ifx\bxpv@mt#2\bxpv@mt
+ \let\bxpv@pre\relax \let\bxpv@post\relax
+ \else
+ \def\bxpv@pre{#1}%
+ \bxpv@split@at@c#2\bxpv@end
+ \fi
+}%
+\def\bxpv@split@at@c#1\bxpv@mk#2\bxpv@end{%
+ \def\bxpv@post{#1}%
+}%
+
+%--------------------------------------- file reader
+
+%% variables
+\let\bxpv@rf@parse\relax % line parser
+\let\bxpv@rf@line\relax % line content
+\let\bxpv@rf@cont\relax % continue to read?
+
+%% \ifbxpv@read@file@ok
+% Whether or not the last \bxpv@read@file succeeded.
+\newboolean{bxpv@read@file@ok}
+
+%% \bxpv@read@file{<file-name>}{<line-parser-code>}
+% Reads from a text file. The line parser takes as #1 the
+% content of each line.
+\def\bxpv@read@file#1{%
+ \bxpv@read@file@oktrue
+ \begingroup
+ \openin\@inputcheck=#1\relax
+ \afterassignment\bxpv@read@file@a
+ \def\bxpv@rf@parse##1%
+}
+\@onlypreamble\bxpv@read@file@a
+\def\bxpv@read@file@a{%
+ \ifeof\@inputcheck
+ \aftergroup\bxpv@read@file@okfalse
+ \else
+ % freeze special characters
+ \@tempcnta\z@
+ \loop\ifnum\@tempcnta<\@cclvi
+ \catcode\@tempcnta12
+ \advance\@tempcnta\@ne
+ \repeat
+ \endlinechar\m@ne
+ % go to loop
+ \chardef\bxpv@rf@cont\@ne
+ \bxpv@read@file@b
+ \fi
+ \endgroup
+}
+\@onlypreamble\bxpv@read@file@b
+\def\bxpv@read@file@b{%
+ \read\@inputcheck to\bxpv@rf@line
+ \bxpv@detokenize\bxpv@rf@line
+ \expandafter\bxpv@rf@parse\expandafter{\bxpv@rf@line}%
+ \ifeof\@inputcheck
+ \chardef\bxpv@rf@cont\z@
+ \fi
+ \ifnum\bxpv@rf@cont>\z@
+ \expandafter\bxpv@read@file@b
+ \fi
+}
+
+%% \bxpv@read@file@finish
+\@onlypreamble\bxpv@read@file@finish
+\def\bxpv@read@file@finish{%
+ \chardef\bxpv@rf@cont\z@
+}
+
+%--------------------------------------- simple cache system
+% - \bxpv@cache@xxx can be invoked only in \AtBeginDocument.
+% - \bxpv@cache@finalize must be called last.
+
+%% \bxpv@g@value
+% The return variable for fetchers.
+\@onlypreamble\bxpv@g@value
+\let\bxpv@g@value\@undefined
+
+%% \bxpv@cache@fetch{<key>}
+\@onlypreamble\bxpv@cache@fetch
+\def\bxpv@cache@fetch#1{%
+ \begingroup
+ \expandafter\ifx\csname bxpv@cache@@#1\endcsname\relax
+ \global\let\bxpv@g@value\@empty
+ \@nameuse{bxpv@cache@get@@#1}%
+ \bxpv@cache@store{#1}{\bxpv@g@value}%
+ \bxDebug{cache-fetch:#1=\@nameuse{bxpv@cache@@#1}}%
+ \fi
+ \endgroup
+}
+
+%% \bxpv@cache@store{<key>}{<value>}
+\def\bxpv@cache@store#1#2{%
+ \expandafter\ifx\csname bxpv@cache@@#1\endcsname\relax
+ \expandafter\xdef\csname bxpv@cache@@#1\endcsname{#2}%
+ \g@addto@macro\bxpv@cache@keylist{{#1}}%
+ \fi
+}
+\@onlypreamble\bxpv@cache@keylist
+\let\bxpv@cache@keylist\@empty
+
+%% \bxpv@cache@finalize
+\@onlypreamble\bxpv@cache@finalize
+\def\bxpv@cache@finalize{%
+ \if@filesw
+ \ifx\bxpv@cache@keylist\@empty\else
+ \immediate\write\@auxout{%
+ \string\providecommand\string\bxpv@cache@store[2]{}}%
+ \fi
+ \def\bxpv@x{\@tfor\bxpv@x:=}%
+ \expandafter\bxpv@x\bxpv@cache@keylist\do{%
+ \immediate\write\@auxout{%
+ \string\bxpv@cache@store{\bxpv@x}{\@nameuse{bxpv@cache@@\bxpv@x}}}}%
+ \fi
+ \global\let\bxpv@cache@store\@gobbletwo % for end-document clear-up
+}
+
%--------------------------------------- start-up
\ifx t\bxUseDebug
\typeout{%
- mversion=\meaning\bxpv@mversion^^J%
+ mversion=\meaning\bxpdfverMinorVersion^^J%
compress=\meaning\bxpv@compress^^J%
objcompress=\meaning\bxpv@obj@compress^^J%
drvtype=\meaning\bxpv@drv@type^^J%
@@ -370,14 +741,13 @@
%% Applies the setting specified by package options
\ifx\bxpv@version\relax\else
- \bxpv@get@mversion
- \bxpv@set@version
+ \setpdfversion{\bxpv@version}
\fi
\if t\bxpv@compress\else
- \bxpv@suppress@compress
+ \suppresspdfcompression
\fi
\if t\bxpv@obj@compress\else
- \bxpv@suppress@obj@compress
+ \suppresspdfobjcompression
\fi
%--------------------------------------- all done