1

I have a document written in plain TeX from which I generate a PDF file by means of dvips and ps2pdf. Let version A of this document be the following.

\input epsf

\newbox\fb \newbox\cb
\setbox\fb\hbox{\epsfxsize=0pt \epsfysize=0pt \epsfbox{test.eps}}%
%\setbox\cb\hbox{foo bar baz quux foo bar baz quux foo bar baz quux
%foo bar baz quux foo bar baz quux foo bar baz quux}%
\topinsert \ifvoid\cb \else$$\hbox{\hsize=\the\wd\fb
\vbox{\noindent{\bf Figure}:\enspace \unhbox\cb}}$$\fi
$$\box\fb$$\endinsert

\bye

Let version B of the document differ from version A only by uncommenting the lines

%\setbox\cb\hbox{foo bar baz quux foo bar baz quux foo bar baz quux
%foo bar baz quux foo bar baz quux foo bar baz quux}%

The unexpected side-effect arises when I generate version B of the document: the font in the graphic changes! Why?

Here's an image of the PDF file of version A.

version A

And here's an image of the PDF file of version B.

version B

I'm using kerTeX (http://www.kergis.com/en/kertex.html).

Here follow the contents of the "test.eps", as requested by @ShreevatsaR .

%!PS-Adobe-3.0
%%DocumentNeededResources: font CMR10
%%+ font CMBX10
%%+ font CMSL10
%%+ font CMBXSL10
%%+ font CMSY10 CMBSY10 CMMI10
%%DocumentMedia: letter 612 792 0 () ()
%%Title: R Graphics Output
%%Creator: R Software
%%Pages: (atend)
%%Orientation: Portrait
%%BoundingBox: 90 252 522 540
%%EndComments
%%BeginProlog
/bp  { gs sRGB gs } def
% begin .ps.prolog
/gs  { gsave } bind def
/gr  { grestore } bind def
/ep  { showpage gr gr } bind def
/m   { moveto } bind def
/l  { rlineto } bind def
/np  { newpath } bind def
/cp  { closepath } bind def
/f   { fill } bind def
/o   { stroke } bind def
/c   { newpath 0 360 arc } bind def
/r   { 4 2 roll moveto 1 copy 3 -1 roll exch 0 exch rlineto 0 rlineto -1 mul 0 exch rlineto closepath } bind def
/p1  { stroke } bind def
/p2  { gsave bg fill grestore newpath } bind def
/p3  { gsave bg fill grestore stroke } bind def
/p6  { gsave bg eofill grestore newpath } bind def
/p7  { gsave bg eofill grestore stroke } bind def
/t   { 5 -2 roll moveto gsave rotate
       1 index stringwidth pop
       mul neg 0 rmoveto show grestore } bind def
/ta  { 4 -2 roll moveto gsave rotate show } bind def
/tb  { 2 -1 roll 0 rmoveto show } bind def
/cl  { grestore gsave newpath 3 index 3 index moveto 1 index
       4 -1 roll lineto  exch 1 index lineto lineto
       closepath clip newpath } bind def
/rgb { setrgbcolor } bind def
/s   { scalefont setfont } bind def
% end   .ps.prolog
/sRGB { [ /CIEBasedABC
          << /DecodeLMN
               [ { dup 0.03928 le
                        {12.92321 div}
                        {0.055 add 1.055 div 2.4 exp }
                     ifelse
                 } bind dup dup
               ]
             /MatrixLMN [0.412457 0.212673 0.019334
                         0.357576 0.715152 0.119192
                         0.180437 0.072175 0.950301]
             /WhitePoint [0.9505 1.0 1.0890]
           >>
         ] setcolorspace } bind def
/srgb { setcolor } bind def
% begin encoding
/TeXtextEncoding [
 /minus /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon
 /Phi /Psi /Omega /ff /fi /fl /ffi /ffl
 /dotlessi /dotlessj /grave /acute /caron /breve /macron /ring
 /cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash
 /space /exclam /quotedblright /numbersign /dollar /percent /ampersand /quoteright
 /parenleft /parenright /asterisk /plus /comma /minus /period /slash
 /zero /one /two /three /four /five /six /seven
 /eight /nine /colon /semicolon /exclamdown /equal /questiondown /question
 /at /A /B /C /D /E /F /G
 /H /I /J /K /L /M /N /O
 /P /Q /R /S /T /U /V /W
 /X /Y /Z /bracketleft /quotedblleft /bracketright /circumflex /dotaccent
 /quoteleft /a /b /c /d /e /f /g
 /h /i /j /k /l /m /n /o
 /p /q /r /s /t /u /v /w
 /x /y /z /endash /emdash /hungarumlaut /tilde /dieresis
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
]
 def
% end encoding
% begin encoding
/SymbolEncoding [
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /space /exclam /universal /numbersign /existential /percent /ampersand /suchthat
 /parenleft /parenright /asteriskmath /plus /comma /minus /period /slash
 /zero /one /two /three /four /five /six /seven
 /eight /nine /colon /semicolon /less /equal /greater /question
 /congruent /Alpha /Beta /Chi /Delta /Epsilon /Phi /Gamma
 /Eta /Iota /theta1 /Kappa /Lambda /Mu /Nu /Omicron
 /Pi /Theta /Rho /Sigma /Tau /Upsilon /sigma1 /Omega
 /Xi /Psi /Zeta /bracketleft /therefore /bracketright /perpendicular /underscore
 /radicalex /alpha /beta /chi /delta /epsilon /phi /gamma
 /eta /iota /phi1 /kappa /lambda /mu /nu /omicron
 /pi /theta /rho /sigma /tau /upsilon /omega1 /omega
 /xi /psi /zeta /braceleft /bar /braceright /similar /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
 /Euro /Upsilon1 /minute /lessequal /fraction /infinity /florin /club
 /diamond /heart /spade /arrowboth /arrowleft /arrowup /arrowright /arrowdown
 /degree /plusminus /second /greaterequal /multiply /proportional /partialdiff /bullet
 /divide /notequal /equivalence /approxequal /ellipsis /arrowvertex /arrowhorizex /carriagereturn
 /aleph /Ifraktur /Rfraktur /weierstrass /circlemultiply /circleplus /emptyset /intersection
 /union /propersuperset /reflexsuperset /notsubset /propersubset /reflexsubset /element /notelement
 /angle /gradient /registerserif /copyrightserif /trademarkserif /product /radical /dotmath
 /logicalnot /logicaland /logicalor /arrowdblboth /arrowdblleft /arrowdblup /arrowdblright /arrowdbldown
 /lozenge /angleleft /registersans /copyrightsans /trademarksans /summation /parenlefttp /parenleftex
 /parenleftbt /bracketlefttp /bracketleftex /bracketleftbt /bracelefttp /braceleftmid /braceleftbt /braceex
 /.notdef /angleright /integral /integraltp /integralex /integralbt /parenrighttp /parenrightex
 /parenrightbt /bracketrighttp /bracketrightex /bracketrightbt /bracerighttp /bracerightmid /bracerightbt /.notdef
] def
% end encoding
/mergefonts
{ /targetencoding exch def
  /fontarray exch def
  fontarray 0 get dup maxlength dict begin
  { 1 index /FID ne { def } { pop pop } ifelse } forall
  % Create a new dictionary
  /CharStrings 256 dict def
  % Add a definition of .notdef
  fontarray
  { /CharStrings get dup /.notdef known
    { /.notdef get /result exch def exit }
    { pop } ifelse
  } forall
  CharStrings /.notdef result put
  % Add in the other definitions
  targetencoding
  { /code exch def
    % Check that it is not a .notdef
    code /.notdef eq
    { /.notdef }
    { fontarray
      { /CharStrings get dup code known
        { code get /result exch def /found true def exit }
        { pop /found false def } ifelse
      } forall
      % define character if it was found and accumulate encoding
      found { CharStrings code result put code } { /.notdef } ifelse
    } ifelse
  } forall
  % grab new encoding off of stack
  256 array astore /Encoding exch def
  % Undefine some local variables
  currentdict /fontarray undef
  currentdict /targetencoding undef
  currentdict /code undef
  currentdict /result undef
  currentdict /found undef
  % Leave new font on the stack
  currentdict
  end
} def
%%IncludeResource: font CMR10
%%IncludeResource: font CMSY10
[ /CMR10 findfont /CMSY10 findfont ] TeXtextEncoding mergefonts
/Font1 exch definefont pop
%%IncludeResource: font CMBX10
%%IncludeResource: font CMBSY10
[ /CMBX10 findfont /CMBSY10 findfont ] TeXtextEncoding mergefonts
/Font2 exch definefont pop
%%IncludeResource: font CMSL10
[ /CMSL10 findfont /CMSY10 findfont ] TeXtextEncoding mergefonts
/Font3 exch definefont pop
%%IncludeResource: font CMBXSL10
[ /CMBXSL10 findfont /CMBSY10 findfont ] TeXtextEncoding mergefonts
/Font4 exch definefont pop
%%IncludeResource: font CMMI10
[ /CMR10 findfont /CMSY10 findfont /CMMI10 findfont ] SymbolEncoding mergefonts
/Font5 exch definefont pop
%%EndProlog
%%Page: 1 1
bp
90.00 252.00 522.00 540.00 cl
/Font1 findfont 10 s
0 0 0 srgb
289.44 255.60 (normal quan) 0 ta
-0.270 (tile) tb gr
100.80 385.70 (sample quan) 90 ta
-0.270 (tile) tb gr
139.20 301.20 508.80 538.80 cl
/Font1 findfont 10 s
0 0 0 srgb
152.89 306.42 (A) .5 0 t
308.33 442.25 (B) .5 0 t
324.00 442.25 (C) .5 0 t
495.11 526.59 (D) .5 0 t
414.26 519.09 (AB) .5 0 t
348.43 460.53 (A) 0 ta
-0.270 (C) tb gr
292.21 434.92 (BC) .5 0 t
233.74 398.09 (AD) .5 0 t
275.07 431.25 (BD) .5 0 t
372.93 475.25 (CD) .5 0 t
204.43 365.20 (ABC) .5 0 t
443.57 522.75 (ABD) .5 0 t
328.49 449.53 (A) 0 ta
-0.270 (CD) tb gr
256.08 423.92 (BCD) .5 0 t
391.92 500.86 (ABCD) .5 0 t
90.00 252.00 522.00 540.00 cl
/Font1 findfont 10 s
0 0 0 srgb
230.70 279.60 (-1) .5 0 t
324.00 279.60 (0) .5 0 t
417.30 279.60 (1) .5 0 t
124.80 310.00 (-10) .5 90 t
124.80 383.33 (-5) .5 90 t
124.80 456.67 (0) .5 90 t
124.80 530.00 (5) .5 90 t
139.20 301.20 508.80 538.80 cl
0 0 0 srgb
0.75 setlinewidth
[] 0 setdash
1 setlinecap
1 setlinejoin
10.00 setmiterlimit
np
139.20 372.42 m
348.63 167.58 l
o
ep
%%Trailer
%%Pages: 1
%%EOF
4
  • Are you forced to use plain TeX? :) – Dr. Manuel Kuehner Apr 18 '18 at 19:20
  • @Dr.ManuelKuehner : Nope! – user3143179 Apr 18 '18 at 21:25
  • Can you include / link to test.eps here? It may be relevant – ShreevatsaR Apr 18 '18 at 22:02
  • 1
    In fact it's hard to test or reproduce this example without having access to your test.eps figure. – ShreevatsaR Apr 19 '18 at 16:07
2

Note that the file may have been given an .eps extension but it is not an EPS file. The heading is

%!PS-Adobe-3.0

but it should be

%!PS-Adobe-3.0 EPSF-3.0

an EPS file is a restricted version of PostScript that guarantees a level of "encapsulation" which means basically, that the problem you describe does not occur, and the file can be included into different documents and have the same appearance and not affect the rest of the document.

Most tex "eps" inclusion mechanisms do not actually check that the file meets all the requirements of being an EPS file and will include arbitrary PostScript content. Often that just works as the file meets or nearly meets the requirements of being EPS, but here you don't get that lucky, the included file has external font dependencies.

If you still have access to the source of that postscript file, the simplest would be to re-save it in EPS format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.