[latex3-commits] [git/LaTeX3-latex3-latex3] master: Basic support for /FitR destinations (ed5760d)

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Apr 28 15:29:16 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/ed5760d3def3f35d07162ac75e68e8e728405f05

>---------------------------------------------------------------

commit ed5760d3def3f35d07162ac75e68e8e728405f05
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sun Apr 28 14:29:16 2019 +0100

    Basic support for /FitR destinations
    
    Works for pdfTeX/LuaTeX/dvips but not yet
    (x)dvipdfmx: need an interface for \pdfsavepos.


>---------------------------------------------------------------

ed5760d3def3f35d07162ac75e68e8e728405f05
 l3kernel/l3drivers-pdf.dtx              |   72 ++++++++++++++++++++++++++++---
 l3kernel/l3drivers.dtx                  |   10 +++++
 l3kernel/testfiles/m3expl001.luatex.tlg |    3 ++
 l3kernel/testfiles/m3expl001.ptex.tlg   |    3 ++
 l3kernel/testfiles/m3expl001.tlg        |    3 ++
 l3kernel/testfiles/m3expl001.uptex.tlg  |    3 ++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    3 ++
 l3kernel/testfiles/m3expl003.luatex.tlg |    3 ++
 l3kernel/testfiles/m3expl003.ptex.tlg   |    3 ++
 l3kernel/testfiles/m3expl003.tlg        |    3 ++
 l3kernel/testfiles/m3expl003.uptex.tlg  |    3 ++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    3 ++
 12 files changed, 107 insertions(+), 5 deletions(-)

diff --git a/l3kernel/l3drivers-pdf.dtx b/l3kernel/l3drivers-pdf.dtx
index 3f01f35..c2e026f 100644
--- a/l3kernel/l3drivers-pdf.dtx
+++ b/l3kernel/l3drivers-pdf.dtx
@@ -76,6 +76,13 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{variable}{\l_@@_pdf_tmp_box}
+%   For fitting destinations.
+%    \begin{macrocode}
+\box_new:N \l_@@_pdf_tmp_box
+%    \end{macrocode}
+% \end{variable}
+%
 % \subsection{\texttt{dvips} driver}
 %
 %    \begin{macrocode}
@@ -1046,9 +1053,11 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\driver_pdf_destination:nn}
+% \begin{macro}{\driver_pdf_destination:nn, \driver_pdf_destination_rectangle:nn}
+% \begin{macro}{driver.dest.llx, driver.dest.lly}
 %   Here, we need to turn the zoom into a scale. We also need to know where
-%   the current anchor point actually is: worked out in PostScript.
+%   the current anchor point actually is: worked out in PostScript. For the
+%   rectangle version, we have a bit more PostScript: we need two points.
 %    \begin{macrocode}
 \cs_new_protected:Npn \driver_pdf_destination:nn #1#2
   {
@@ -1075,8 +1084,38 @@
         /DEST
       }
   }
+\cs_new_protected:Npn \driver_pdf_destination_rectangle:nn #1#2
+  {
+    \group_begin:
+      \hbox_set:Nn \l_@@_pdf_tmp_box {#2}
+      \box_move_down:nn
+        { \box_dp:N \l_@@_pdf_tmp_box }
+        { \hbox:n { \@@_postscript:n { driver.dest.anchor } } }
+      \box_use:N \l_@@_pdf_tmp_box
+      \@@_postscript:n
+        {
+          SDict /driver.dest.llx ~ driver.dest.x ~ put ~
+          SDict /driver.dest.lly ~ driver.dest.y ~ put
+        }
+      \box_move_up:nn
+        { \box_ht:N \l_@@_pdf_tmp_box }
+        { \hbox:n { \@@_postscript:n { driver.dest.anchor } } }
+      \@@_pdfmark:n
+        {
+          /View
+          [
+            /FitR ~
+              driver.dest.llx ~ driver.dest.lly ~
+              driver.dest.x   ~ driver.dest.y
+          ]
+          /Dest ( #1 ) cvn
+          /DEST
+        }
+    \group_end:    
+  }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \subsubsection{Structure}
 %
@@ -1222,10 +1261,11 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\driver_pdf_destination:nn}
+% \begin{macro}{\driver_pdf_destination:nn, \driver_pdf_destination_rectangle:nn}
 %   A simple task: pass the data to the primitive. The |\scan_stop:| deals
 %   with the danger of an unterminated keyword. The zoom given here is a
-%   percentage, but we need to pass it as \emph{per mille}.
+%   percentage, but we need to pass it as \emph{per mille}. The rectangle
+%   version is also easy as everything is build in.
 %    \begin{macrocode}
 \cs_new_protected:Npx \driver_pdf_destination:nn #1#2
   {
@@ -1246,6 +1286,21 @@
           { xyz ~ zoom \exp_not:N \fp_eval:n { #2 * 10 } }
         \scan_stop:
   }
+\cs_new_protected:Npx \driver_pdf_destination_rectangle:nn #1#2
+  {
+    \group_begin:
+      \hbox_set:Nn \l_@@_pdf_tmp_box {#2}
+     \cs_if_exist:NTF \tex_pdfextension:D
+      { \exp_not:N \tex_pdfextension:D dest ~ }
+      { \exp_not:N \tex_pdfdest:D }  
+      name {#1}
+      fitr ~
+        width  \exp_not:N \box_wd:N \l_@@_pdf_tmp_box
+        height \exp_not:N \box_ht:N \l_@@_pdf_tmp_box
+        depth  \exp_not:N \box_dp:N \l_@@_pdf_tmp_box 
+      \box_use:N \l_@@_pdf_tmp_box
+    \group_end:    
+  }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1669,7 +1724,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\driver_pdf_destination:nn}
+% \begin{macro}{\driver_pdf_destination:nn, \driver_pdf_destination_rectangle:nn}
 %   Here, we need to turn the zoom into a scale.
 %   A little translation
 %    \begin{macrocode}
@@ -1694,6 +1749,13 @@
         ]
       }
   }
+\cs_new_protected:Npn \driver_pdf_destination_rectangle:nn #1#2
+  {
+    \group_begin:
+      \hbox_set:Nn \l_@@_pdf_tmp_box {#2}
+      \box_use:N \l_@@_pdf_tmp_box
+    \group_end:    
+  }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3kernel/l3drivers.dtx b/l3kernel/l3drivers.dtx
index d3a4c78..09c3161 100644
--- a/l3kernel/l3drivers.dtx
+++ b/l3kernel/l3drivers.dtx
@@ -550,6 +550,16 @@
 %   A \meta{scale} of zero is equivalent to \texttt{xyz}.
 % \end{function}
 %
+% \begin{function}[added = 2019-04-28]{\driver_pdf_destination_rectangle:nn}
+%   \begin{syntax}
+%     \cs{driver_pdf_destination_rectangle:nn} \Arg{name} \Arg{content}
+%   \end{syntax}
+%   Creates a destination (anchor) called \meta{name}; when a jump is made
+%   by a link to the destination, the viewer will set the zoom such that all
+%   of the \meta{content} is visible taking up the full width or height of the
+%   viewer area.
+% \end{function}
+%
 % \subsection{PDF Catalogue entries}
 %
 % \begin{function}[added = 2019-04-25]{\driver_pdf_catalogue_gput:nn}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index b3908ec..171ecf6 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -6463,6 +6463,8 @@ Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_pdf_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
@@ -6473,6 +6475,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 63869c8..15362bb 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -6505,6 +6505,8 @@ Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
@@ -6533,6 +6535,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_compresslevel:n on line ...
 Defining \driver_pdf_objects_enable: on line ...
 Defining \driver_pdf_objects_disable: on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 01165d9..8a51545 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6804,6 +6804,8 @@ Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_pdf_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
@@ -6814,6 +6816,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index ff7d0c7..172df92 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6802,6 +6802,8 @@ Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
@@ -6830,6 +6832,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_compresslevel:n on line ...
 Defining \driver_pdf_objects_enable: on line ...
 Defining \driver_pdf_objects_disable: on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 1f1a10b..5a293f2 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -6481,6 +6481,8 @@ Defining \__driver_image_getbb_auxvi:nNnn on line ...
 Defining \__driver_image_getbb_pagebox:w on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
@@ -6509,6 +6511,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_compresslevel:n on line ...
 Defining \driver_pdf_objects_enable: on line ...
 Defining \driver_pdf_objects_disable: on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index b3908ec..171ecf6 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -6463,6 +6463,8 @@ Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_pdf_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
@@ -6473,6 +6475,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 63869c8..15362bb 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -6505,6 +6505,8 @@ Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
@@ -6533,6 +6535,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_compresslevel:n on line ...
 Defining \driver_pdf_objects_enable: on line ...
 Defining \driver_pdf_objects_disable: on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 01165d9..8a51545 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6804,6 +6804,8 @@ Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_pdf_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
@@ -6814,6 +6816,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index ff7d0c7..172df92 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6802,6 +6802,8 @@ Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
@@ -6830,6 +6832,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_compresslevel:n on line ...
 Defining \driver_pdf_objects_enable: on line ...
 Defining \driver_pdf_objects_disable: on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 1f1a10b..5a293f2 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -6481,6 +6481,8 @@ Defining \__driver_image_getbb_auxvi:nNnn on line ...
 Defining \__driver_image_getbb_pagebox:w on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \c__driver_pdf_AR_fix_tl on line ...
+Defining \l__driver_pdf_tmp_box on line ...
+\l__driver_pdf_tmp_box=\box...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \driver_pdf_catalog_gput:nn on line ...
@@ -6509,6 +6511,7 @@ Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_destination:nn on line ...
+Defining \driver_pdf_destination_rectangle:nn on line ...
 Defining \driver_pdf_compresslevel:n on line ...
 Defining \driver_pdf_objects_enable: on line ...
 Defining \driver_pdf_objects_disable: on line ...





More information about the latex3-commits mailing list