[latex3-commits] [git/LaTeX3-latex3-latex3] master: PDF version, compression (9755d40)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun Jun 2 20:59:29 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/9755d405c2543eda132f4ed67e77b125428a27eb
>---------------------------------------------------------------
commit 9755d405c2543eda132f4ed67e77b125428a27eb
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Sun Jun 2 19:59:29 2019 +0100
PDF version, compression
>---------------------------------------------------------------
9755d405c2543eda132f4ed67e77b125428a27eb
l3trial/l3pdf/build.lua | 5 +-
l3trial/l3pdf/l3pdf.dtx | 157 ++++++++++++++++++++
.../l3pdf/testfiles/m3pdf000.lvt | 5 +-
.../l3pdf/testfiles/m3pdf000.tlg | 4 +-
l3trial/l3pdf/testfiles/m3pdf001.lvt | 25 ++++
.../l3pdf/testfiles/m3pdf001.tlg | 20 ++-
6 files changed, 201 insertions(+), 15 deletions(-)
diff --git a/l3trial/l3pdf/build.lua b/l3trial/l3pdf/build.lua
index bae49f0..ccdeef5 100644
--- a/l3trial/l3pdf/build.lua
+++ b/l3trial/l3pdf/build.lua
@@ -12,9 +12,8 @@ maindir = "../.."
typesetfiles = {"l3pdf.dtx", "l3pdf-code.tex"}
--- Need color support
-checkdeps = {maindir .. "/l3kernel"}
-typesetdeps = checkdeps
+-- Non-standard settings
+checksearch = true
-- Load the common build code
dofile(maindir .. "/build-config.lua")
diff --git a/l3trial/l3pdf/l3pdf.dtx b/l3trial/l3pdf/l3pdf.dtx
index 29c03bf..f72c005 100644
--- a/l3trial/l3pdf/l3pdf.dtx
+++ b/l3trial/l3pdf/l3pdf.dtx
@@ -54,6 +54,50 @@
%
% \section{\pkg{l3pdf} documentation}
%
+% \subsection{Version}
+%
+% \begin{function}[pTF, EXP, added = 2019-06-02]{\pdf_version_compare:Nn}
+% \begin{syntax}
+% \cs{pdf_version_compare:NnTF} \meta{comparator} \Arg{version} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Compares the version of the PDF being created with the \meta{version}
+% string specified, using the \meta{comparator}. Either the \meta{true code}
+% or \meta{false code} will be left in the output stream.
+% \end{function}
+%
+% \begin{function}[added = 2019-06-02]
+% {\pdf_version_gset:n, \pdf_version_min_gset:n}
+% \begin{syntax}
+% \cs{pdf_version_gset:n} \Arg{version}
+% \end{syntax}
+% Sets the \meta{version} of the PDF being created. The |min| version will
+% not alter the output version unless it is currently lower than the
+% \meta{version} requested.
+%
+% This function may only be used up to the point where the PDF file is
+% initialised.
+% \end{function}
+%
+% \begin{function}[EXP, added = 2019-06-02]
+% {\pdf_version:, \pdf_version_major:, \pdf_version_minor:}
+% \begin{syntax}
+% \cs{pdf_version:}
+% \end{syntax}
+% Expands to the currently-active PDF version.
+% \end{function}
+%
+% \subsection{Compression}
+%
+% \begin{function}[added = 2019-06-02]{\pdf_uncompress:}
+% \begin{syntax}
+% \cs{pdf_uncompress:}
+% \end{syntax}
+% Disables any compression of the PDF, where possible.
+%
+% This function may only be used up to the point where the PDF file is
+% initialised.
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
@@ -75,6 +119,119 @@
%</package>
% \end{macrocode}
%
+% \begin{variable}{\g_@@_init_bool}
+% A flag so we have some chance of avoiding setting things we are not
+% allowed to.
+% \begin{macrocode}
+\bool_new:N \g_@@_init_bool
+%<*package>
+\cs_if_exist:NT \documentclass
+ {
+ \AtBeginDocument
+ { \bool_gset_true:N \g_@@_init_bool }
+ }
+%</package>
+% \end{macrocode}
+% \end{variable}
+%
+% \subsection{Compression}
+%
+% \begin{macro}{\pdf_uncompress:}
+% Simple to do.
+% \begin{macrocode}
+\cs_new_protected:Npn \pdf_uncompress:
+ {
+ \bool_if:NF \g_@@_init_bool
+ {
+ \@@_backend_compresslevel:n { 0 }
+ \@@_backend_compress_objects:n { \c_false_bool }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Version}
+%
+% \begin{macro}{\pdf_version_compare:Nn}
+% \begin{macro}
+% {
+% @@_version_compare_=:w ,
+% @@_version_compare_<:w ,
+% @@_version_compare_>:w
+% }
+% \begin{macrocode}
+% To compare version, we need to split the given value then deal with both
+% major and minor version
+\prg_new_conditional:Npnn \pdf_version_compare:Nn #1#2 { p , T , F , TF }
+ { \use:c { @@_version_compare_ #1 :w } #2 . . \q_stop }
+\cs_new:cpn { @@_version_compare_=:w } #1 . #2 . #3 \q_stop
+ {
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn \@@_backend_version_major: = {#1} }
+ { \int_compare_p:nNn \@@_backend_version_minor: = {#2} }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_new:cpn { @@_version_compare_<:w } #1 . #2 . #3 \q_stop
+ {
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn \@@_backend_version_major: < {#1} }
+ {
+ \bool_lazy_and_p:nn
+ { \int_compare_p:nNn \@@_backend_version_major: = {#1} }
+ { \int_compare_p:nNn \@@_backend_version_minor: < {#2} }
+ }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_new:cpn { @@_version_compare_>:w } #1 . #2 . #3 \q_stop
+ {
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn \@@_backend_version_major: > {#1} }
+ {
+ \bool_lazy_and_p:nn
+ { \int_compare_p:nNn \@@_backend_version_major: = {#1} }
+ { \int_compare_p:nNn \@@_backend_version_minor: > {#2} }
+ }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\pdf_version_gset:n, \pdf_version_min_gset:n}
+% \begin{macro}{\@@_version_gset:w}
+% Split the version and set.
+% \begin{macrocode}
+\cs_new_protected:Npn \pdf_version_gset:n #1
+ { \@@_version_gset:w #1 . . \q_stop }
+\cs_new_protected:Npn \pdf_version_min_gset:n #1
+ {
+ \pdf_version_compare:NnT < {#1}
+ { \@@_version_gset:w #1 . . \q_stop }
+ }
+\cs_new_protected:Npn \@@_version_gset:w #1 . #2 . #3\q_stop
+ {
+ \bool_if:NF \g_@@_init_bool
+ {
+ \@@_backend_version_major_gset:n {#1}
+ \@@_backend_version_minor_gset:n {#2}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\pdf_version:, \pdf_version_major:, \pdf_version_minor:}
+% Wrappers.
+% \begin{macrocode}
+\cs_new:Npn \pdf_version:
+ { \@@_backend_version_major: . \@@_backend_version_minor: }
+\cs_new:Npn \pdf_version_major: { \@@_backend_version_major: }
+\cs_new:Npn \pdf_version_minor: { \@@_backend_version_minor: }
+% \end{macrocode}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}
diff --git a/l3experimental/l3benchmark/testfiles/m3benchmark000.lvt b/l3trial/l3pdf/testfiles/m3pdf000.lvt
similarity index 77%
copy from l3experimental/l3benchmark/testfiles/m3benchmark000.lvt
copy to l3trial/l3pdf/testfiles/m3pdf000.lvt
index 0cd38b0..592e855 100644
--- a/l3experimental/l3benchmark/testfiles/m3benchmark000.lvt
+++ b/l3trial/l3pdf/testfiles/m3pdf000.lvt
@@ -1,5 +1,5 @@
%
-% Copyright (C) 2017,2018 The LaTeX3 Project
+% Copyright (C) 2019 The LaTeX3 Project
%
\documentclass{minimal}
@@ -14,5 +14,6 @@
\ExplSyntaxOff
\START
-\RequirePackage{l3benchmark}
+\AUTHOR{Joseph Wright}
+\RequirePackage{l3pdf}
\END
diff --git a/l3experimental/l3sys-shell/testfiles/m3sys-shell000.tlg b/l3trial/l3pdf/testfiles/m3pdf000.tlg
similarity index 60%
copy from l3experimental/l3sys-shell/testfiles/m3sys-shell000.tlg
copy to l3trial/l3pdf/testfiles/m3pdf000.tlg
index f9a2475..c722276 100644
--- a/l3experimental/l3sys-shell/testfiles/m3sys-shell000.tlg
+++ b/l3trial/l3pdf/testfiles/m3pdf000.tlg
@@ -1,6 +1,6 @@
This is a generated file for the LaTeX (2e + expl3) validation system.
Don't change this file in any respect.
Author: Joseph Wright
-(l3sys-shell.sty
-Package: l3sys-shell ....-..-.. L3 Experimental system shell functions
+(l3pdf.sty
+Package: l3pdf ....-..-.. L3 Experimental core PDF support
)
diff --git a/l3trial/l3pdf/testfiles/m3pdf001.lvt b/l3trial/l3pdf/testfiles/m3pdf001.lvt
new file mode 100644
index 0000000..06a9a72
--- /dev/null
+++ b/l3trial/l3pdf/testfiles/m3pdf001.lvt
@@ -0,0 +1,25 @@
+\input{regression-test}
+\RequirePackage{l3pdf}
+\START
+\AUTHOR{Ulrike Fischer, Joseph Wright}
+
+\ExplSyntaxOn
+
+\TESTEXP { Version~comparison }
+ {
+ \pdf_version_compare:NnTF > { 1.4 } \TRUE \ERROR \NEWLINE
+ \pdf_version_compare:NnTF > { 2.0 } \ERROR \FALSE \NEWLINE
+ \pdf_version_compare:NnTF = { 1.5 } \TRUE \ERROR \NEWLINE
+ \pdf_version_compare:NnTF = { 2.0 } \ERROR \FALSE \NEWLINE
+ \pdf_version_compare:NnTF < { 1.4 } \ERROR \FALSE \NEWLINE
+ \pdf_version_compare:NnTF < { 2.0 } \TRUE \ERROR
+ }
+
+\TESTEXP { Version }
+ {
+ \pdf_version: \NEWLINE
+ \pdf_version_major: \NEWLINE
+ \pdf_version_minor:
+ }
+
+\END
\ No newline at end of file
diff --git a/l3kernel/testfiles/m3str002.ptex.tlg b/l3trial/l3pdf/testfiles/m3pdf001.tlg
similarity index 76%
copy from l3kernel/testfiles/m3str002.ptex.tlg
copy to l3trial/l3pdf/testfiles/m3pdf001.tlg
index fccc5ed..42e0bd4 100644
--- a/l3kernel/testfiles/m3str002.ptex.tlg
+++ b/l3trial/l3pdf/testfiles/m3pdf001.tlg
@@ -1,16 +1,20 @@
This is a generated file for the LaTeX (2e + expl3) validation system.
Don't change this file in any respect.
-Author: Joseph Wright
+Author: Ulrike Fischer, Joseph Wright
============================================================
-TEST 1: Simple Latin case folding
+TEST 1: Version comparison
============================================================
-"abc 123 abc !@"
-" abc 123 abc !@ "
-"some $&## odd text { } "
+TRUE
+FALSE
+TRUE
+FALSE
+FALSE
+TRUE
============================================================
============================================================
-TEST 2: Checking category codes
+TEST 2: Version
============================================================
-FALSE
-TRUE
+1.5
+1
+5
============================================================
More information about the latex3-commits
mailing list