From b59508c74f4961c1fa83ac4d2906c98e40bd2650 Mon Sep 17 00:00:00 2001 From: Hironobu Yamashita Date: Wed, 6 Feb 2019 10:59:29 +0000 Subject: pdfsavepos (ptex and friends 2 of 5) git-svn-id: svn://tug.org/texlive/trunk@49956 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/eptexdir/ChangeLog | 8 ++++ Build/source/texk/web2c/eptexdir/eptex.ech | 4 +- Build/source/texk/web2c/eptexdir/eptex_version.h | 2 +- Build/source/texk/web2c/eptexdir/pdfutils.ch | 46 ++++++++-------------- .../texk/web2c/eptexdir/tests/pdfsavepos.tex | 12 ++++++ 5 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 Build/source/texk/web2c/eptexdir/tests/pdfsavepos.tex diff --git a/Build/source/texk/web2c/eptexdir/ChangeLog b/Build/source/texk/web2c/eptexdir/ChangeLog index b1ad6f6545b..a88c403b096 100644 --- a/Build/source/texk/web2c/eptexdir/ChangeLog +++ b/Build/source/texk/web2c/eptexdir/ChangeLog @@ -1,3 +1,11 @@ +2019-01-31 Hironori Kitagawa + + * pdfutils.ch: Improve \pdfsavepos when papersize special + at the middle of shipout procedure is involved. + Pointed out by N. Abe. + https://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=2564 + * tests/pdfsavepos.tex: Added. + 2019-01-23 Hironobu Yamashita * eptex.defines: Add dumpkanji and undumpkanji. diff --git a/Build/source/texk/web2c/eptexdir/eptex.ech b/Build/source/texk/web2c/eptexdir/eptex.ech index 057904b52cb..5cc86a0093d 100644 --- a/Build/source/texk/web2c/eptexdir/eptex.ech +++ b/Build/source/texk/web2c/eptexdir/eptex.ech @@ -26,8 +26,8 @@ @y @d eTeX_version_string=='-2.6' {current \eTeX\ version} @# -@d epTeX_version_string=='-180901' -@d epTeX_version_number==180901 +@d epTeX_version_string=='-190131' +@d epTeX_version_number==190131 @z @x e-pTeX: banner diff --git a/Build/source/texk/web2c/eptexdir/eptex_version.h b/Build/source/texk/web2c/eptexdir/eptex_version.h index 28bcc2bf34e..cd40e324dec 100644 --- a/Build/source/texk/web2c/eptexdir/eptex_version.h +++ b/Build/source/texk/web2c/eptexdir/eptex_version.h @@ -1 +1 @@ -#define EPTEX_VERSION "180901" +#define EPTEX_VERSION "190131" diff --git a/Build/source/texk/web2c/eptexdir/pdfutils.ch b/Build/source/texk/web2c/eptexdir/pdfutils.ch index 92c41b2e1ee..a805b730a9d 100644 --- a/Build/source/texk/web2c/eptexdir/pdfutils.ch +++ b/Build/source/texk/web2c/eptexdir/pdfutils.ch @@ -1406,8 +1406,8 @@ end; @ Next, we implement \.{\\pdfsavepos} and related primitives. @= -@!cur_page_width: scaled; {width of page being shipped} -@!cur_page_height: scaled; {height of page being shipped} +@!cur_page_width: scaled; {"physical" width of page being shipped} +@!cur_page_height: scaled; {"physical" height of page being shipped} @!pdf_last_x_pos: integer; @!pdf_last_y_pos: integer; @@ -1424,57 +1424,46 @@ begin dir_dtou: begin pdf_last_x_pos := cur_v; pdf_last_y_pos := -cur_h; end; endcases; pdf_last_x_pos := pdf_last_x_pos + 4736286; - case dvi_dir of - dir_tate,dir_dtou: - pdf_last_y_pos := cur_page_height - pdf_last_y_pos - 4736286; - dir_yoko: - pdf_last_y_pos := cur_page_height - pdf_last_y_pos - 4736286; - endcases; + pdf_last_y_pos := cur_page_height - pdf_last_y_pos - 4736286; {4736286 = 1in, the funny DVI origin offset} end @ @= if pdf_page_height <> 0 then cur_page_height := pdf_page_height - else if (type(p)=dir_node) then begin - if (box_dir(list_ptr(p))=dir_tate)or(box_dir(list_ptr(p))=dir_dtou) then - cur_page_height := width(p) + 2*v_offset + 2*4736286 - else - cur_page_height := height(p) + depth(p) + 2*v_offset + 2*4736286; - end + else if (box_dir(p)=dir_tate)or(box_dir(p)=dir_dtou) then + cur_page_height := width(p) + 2*v_offset + 2*4736286 else cur_page_height := height(p) + depth(p) + 2*v_offset + 2*4736286; + {4736286 = 1in, the funny DVI origin offset} if pdf_page_width <> 0 then cur_page_width := pdf_page_width - else if (type(p)=dir_node) then begin - if (box_dir(list_ptr(p))=dir_tate)or(box_dir(list_ptr(p))=dir_dtou) then - cur_page_width := height(p) + depth(p) + 2*h_offset + 2*4736286 - else - cur_page_width := width(p) + 2*h_offset + 2*4736286; - end + else if (box_dir(p)=dir_tate)or(box_dir(p)=dir_dtou) then + cur_page_width := height(p) + depth(p) + 2*h_offset + 2*4736286 else - cur_page_width := width(p) + 2*h_offset + 2*4736286; + cur_page_width := width(p) + 2*h_offset + 2*4736286 + {4736286 = 1in, the funny DVI origin offset} @ Of course \epTeX\ can produce a \.{DVI} file only, not a PDF file. A \.{DVI} file does not have the information of the page height, which is needed to implement \.{\\pdflastypos} correctly. To keep the information of the page height, I (H.~Kitagawa) -adopted \.{\\pdfpageheight} primitive from pdf\TeX. +adopted \.{\\pdfpageheight} primitive from pdf\TeX. -In \pTeX (and \hbox{\epTeX}), the papersize special +In \pTeX (and \hbox{\epTeX}), the papersize special \.{\\special\{papersize=\,\\}} is commonly used -for specifying page width/height. +for specifying page width/height. If \.{\\readpapersizespecial} is greater than~0, the papersize special also changes the value of \.{\\pdfpagewidth} and \.{\\pdfpageheight}. This process is done in the following routine. {\def\<#1>{\langle\hbox{#1\/}\rangle} -In present implementation, the papersize special $\$, +In present implementation, the papersize special $\$, which can be interpreted by this routine, is defined as follows. $$\eqalign{% \ &\longrightarrow \.{papersize=}\\.{,}\\cr - \ &\longrightarrow \ + \ &\longrightarrow \ \\\cr \ &\longrightarrow \.{.} \mid \\ \mid \\\cr @@ -1495,16 +1484,13 @@ ifps(10) @, (sop(k+9)<>'=') then goto done; k:=k+10; @; -ifps(1) @, sop(k)=',' then begin +ifps(1) @, sop(k)=',' then begin incr(k); cw:=s; @; if pool_ptr>k then goto done; geq_word_define(dimen_base+pdf_page_width_code,cw); geq_word_define(dimen_base+pdf_page_height_code,s);@| cur_page_height := s; cur_page_width := cw; - if (dvi_dir=dir_tate)or(dvi_dir=dir_dtou) then begin - t:=cur_page_height; cur_page_height:=cur_page_width; - cur_page_width:=t; end; end; end; diff --git a/Build/source/texk/web2c/eptexdir/tests/pdfsavepos.tex b/Build/source/texk/web2c/eptexdir/tests/pdfsavepos.tex new file mode 100644 index 00000000000..7bde48aa574 --- /dev/null +++ b/Build/source/texk/web2c/eptexdir/tests/pdfsavepos.tex @@ -0,0 +1,12 @@ +\documentclass[dvipdfmx]{tarticle} +\setlength{\pdfpagewidth}{\paperwidth} +\setlength{\pdfpageheight}{\paperheight} +% 以下二行をコメントアウトしたりしなかったりして試してみる. +\special{papersize=\the\paperwidth,\the\paperheight}% (a) +\AtBeginDvi{\special{papersize=\the\paperwidth, \the\paperheight}}% (b) +\begin{document} +A\pdfsavepos +\newpage +\message{pdflatexpos = \the\dimexpr\pdflastxpos sp, pdflastypos = \the\dimexpr\pdflastypos sp, + pdfpagewidth = \the\pdfpagewidth, pdfpageheight = \the\pdfpageheight} +\end{document} \ No newline at end of file -- cgit v1.2.3