From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/plain/contrib/epsf-dvipdfmx/README | 51 ++++++++++++++++++++ .../plain/contrib/epsf-dvipdfmx/epsf-dvipdfmx.tex | 56 ++++++++++++++++++++++ macros/plain/contrib/epsf-dvipdfmx/testepdpx.eps | 22 +++++++++ macros/plain/contrib/epsf-dvipdfmx/testepdpx.tex | 13 +++++ 4 files changed, 142 insertions(+) create mode 100644 macros/plain/contrib/epsf-dvipdfmx/README create mode 100644 macros/plain/contrib/epsf-dvipdfmx/epsf-dvipdfmx.tex create mode 100644 macros/plain/contrib/epsf-dvipdfmx/testepdpx.eps create mode 100644 macros/plain/contrib/epsf-dvipdfmx/testepdpx.tex (limited to 'macros/plain/contrib/epsf-dvipdfmx') diff --git a/macros/plain/contrib/epsf-dvipdfmx/README b/macros/plain/contrib/epsf-dvipdfmx/README new file mode 100644 index 0000000000..6a14341b4d --- /dev/null +++ b/macros/plain/contrib/epsf-dvipdfmx/README @@ -0,0 +1,51 @@ +epsf-dvipdfmx.tex is a plain TeX file to be \input after epsf.tex when +using plain TeX with dvipdfmx. As in: + +\input epsf +\input epsf-dvipdfmx + +It is needed when an .eps file has anything except the origin (0,0) for +the lower-left of its bounding box. + +An alternative is to use the LaTeX graphicx package from your plain TeX +document, as in: + \input miniltx + \input graphicx.sty + \input dvipdfmx.def % needed tex+dvipdfmx only, omit for xetex +Loading graphicx can also be done through Eplain (http://tug.org/eplain). +Of course graphicx has many more features than epsf.tex. + +That's the whole usage. The rest of this document is the explanation of +why it is necessary. +----------------------------------------------------------------------------- +The ultimate source of the problem is that the dvipdfmx driver has a +feature to autoconvert .eps files to .pdf in order to generate its PDF +output. By default, the conversion is done using Ghostscript. +Ghostscript forces the lower-left in the output to 0,0 regardless of the +input, and graphics programs (e.g., MetaPost) can create an .eps with a +lower-left that can be anything, depending on what is actually drawn +(e.g., a graph starting at (-10,-10)). + +Since this conversion happens at DVI processing time, it conflicts with +what the TeX code sees. The result is that the output is wrong; part of +the graphic is lost. Included in this distribution is a trivial TeX +file, graphic, and the bad output by default (the circle is cut off and +misplaced). You can observe that uncommenting the \input epsf-dvipdfmx +in the input file and rerunning tex+dvipdfmx produces good output (the +whole circle). + +This cannot be fixed in epsf.tex, which looks at the graphic as it +exists, with the arbitrary lower-left (and handles it properly), and has +no way of knowing that a driver is going to transform it. The two +reasonable workarounds for users are given above. + +It also cannot be fixed in the dvipdfmx program because the graphic +inclusion in TeX might also use the trim or viewport options, and +sufficient information is not passed through to handle them properly. + +The two viable workarounds for the problem that we have found are given above. +----------------------------------------------------------------------------- +This README was originally written in 2014 by Karl Berry. +The epsf-dvipdfmx.tex and test files were originally written in 2014 +by Akira Kakuto. +All released to the public domain. diff --git a/macros/plain/contrib/epsf-dvipdfmx/epsf-dvipdfmx.tex b/macros/plain/contrib/epsf-dvipdfmx/epsf-dvipdfmx.tex new file mode 100644 index 0000000000..b6267dde1b --- /dev/null +++ b/macros/plain/contrib/epsf-dvipdfmx/epsf-dvipdfmx.tex @@ -0,0 +1,56 @@ +% epsf-dvipdfmx.tex - \input after epsf.tex when using dvipdfmx +% Originally written by Akira Kakuto, 2014. Public domain. +% +% (x)dvipdfmx patch for epsf.tex - translate bounding box to have (0,0) LL. +% +\newdimen\epsfdpxtexdimen +% +% from latex.ltx +% +\begingroup + \catcode`P=12 + \catcode`T=12 + \lowercase{\def\x{\def\rempt##1.##2PT{##1\ifnum##2>0pt.##2\fi}}} + \expandafter\endgroup\x +\def\strippt{\expandafter\rempt\the} +% +\def \epsfspecial #1{% + \epsftmp=10\epsfxsize + \divide \epsftmp by \pspoints + \ifnum \epsfrsize = 0% + \relax + \epsfdpxtexdimen=\epsfurx pt + \advance\epsfdpxtexdimen -\epsfllx pt + \edef\epsfurxx{\strippt\epsfdpxtexdimen}% + \epsfdpxtexdimen=\epsfury pt + \advance\epsfdpxtexdimen -\epsflly pt + \edef\epsfuryy{\strippt\epsfdpxtexdimen}% + \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space + llx=0\space + lly=0\space + urx=\epsfurxx\space + ury=\epsfuryy\space + rwi=\number\epsftmp + \epsfclipstring + }% + \else + \epsfrsize=10\epsfysize + \divide \epsfrsize by \pspoints + \epsfdpxtexdimen=\epsfurx pt + \advance\epsfdpxtexdimen -\epsfllx pt + \edef\epsfurxx{\strippt\epsfdpxtexdimen}% + \epsfdpxtexdimen=\epsfury pt + \advance\epsfdpxtexdimen -\epsflly pt + \edef\epsfuryy{\strippt\epsfdpxtexdimen}% + \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space + llx=0\space + lly=0\space + urx=\epsfurxx\space + ury=\epsfuryy\space + rwi=\number\epsftmp + rhi=\number\epsfrsize + \epsfclipstring + }% + \fi +}% +\endinput diff --git a/macros/plain/contrib/epsf-dvipdfmx/testepdpx.eps b/macros/plain/contrib/epsf-dvipdfmx/testepdpx.eps new file mode 100644 index 0000000000..232600a2c4 --- /dev/null +++ b/macros/plain/contrib/epsf-dvipdfmx/testepdpx.eps @@ -0,0 +1,22 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: -40 -40 40 40 +%%CreationDate: 2014.09.15:0921 +%%BeginProlog +/bd{bind def}bind def/fshow {exch findfont exch scalefont setfont show}bd +/fcp{findfont dup length dict begin{1 index/FID ne{def}{pop pop}ifelse}forall}bd +/fmc{FontMatrix dup length array copy dup dup}bd/fmd{/FontMatrix exch def}bd +/Amul{4 -1 roll exch mul 1000 div}bd/ExtendFont{fmc 0 get Amul 0 exch put fmd}bd +/ScaleFont{dup fmc 0 get Amul 0 exch put dup dup 3 get Amul 3 exch put fmd}bd +/SlantFont{fmc 2 get dup 0 eq{pop 1}if Amul FontMatrix 0 get mul 2 exch put fmd}bd +%%EndProlog + 1 0 0 setrgbcolor +newpath 40 0 moveto +40 10.60913 35.78491 20.78247 28.28369 28.28369 curveto +20.78247 35.78491 10.60913 40 0 40 curveto +-10.60913 40 -20.78247 35.78491 -28.28369 28.28369 curveto +-35.78491 20.78247 -40 10.60913 -40 0 curveto +-40 -10.60913 -35.78491 -20.78247 -28.28369 -28.28369 curveto +-20.78247 -35.78491 -10.60913 -40 0 -40 curveto +10.60913 -40 20.78247 -35.78491 28.28369 -28.28369 curveto +35.78491 -20.78247 40 -10.60913 40 0 curveto closepath fill +%%EOF diff --git a/macros/plain/contrib/epsf-dvipdfmx/testepdpx.tex b/macros/plain/contrib/epsf-dvipdfmx/testepdpx.tex new file mode 100644 index 0000000000..582d2fb1d0 --- /dev/null +++ b/macros/plain/contrib/epsf-dvipdfmx/testepdpx.tex @@ -0,0 +1,13 @@ +% Public domain. +% +% To see the problem, as described in the README: +% tex testepdpx; dvipdfmx testepdpx + +\input epsf + +% Uncomment to observe the problem being fixed: +%\input epsf-dvipdfmx + +\nopagenumbers +\centerline{\epsfxsize=8cm\epsfbox{testepdpx.eps}} +\bye -- cgit v1.2.3