4

I was wondering how to get an EPS file to find the fonts of my PDF. I usually input PostScript into my file (Plain TeX) like this

test.ps:

%!PS-Adobe-3.0 EPSF-3.0%%BoundingBox: 0 0 400 70%%HiResBoundingBox: 0 0 400 70/nine {/CMMI10 findfont 9 scalefont setfont} def/ninetext {/CMR10 findfont 9 scalefont setfont} def/sixtext {/CMR6 findfont 6 scalefont setfont} def/symsix {/CMSY9 findfont 6 scalefont setfont} defnewpath50 50 moveto nine (This text should be CMMI10 \(at 9-point\)) show50 40 moveto ninetext (This text should be CMR10 \(at 9-point\)) show50 30 moveto sixtext (This text should be CMR6 \(at 6-point\)) show50 20 moveto symsix (This text should be CMSY9 \(at 6-point\)) showclosepathshowpage

test.tex:

\input epsf$$\epsfbox{test.ps}$$\bye

But this doesn't get the fonts to show up right.

enter image description here

In the past, I've managed to get certain glyphs to work, and a large amount of (highly unscientific) trial and error seemed to suggest that I could load symbols if the same font was loaded earlier on the same page.

But adding a lorem ipsum to the beginning of my.tex file doesn't seem to make the CMR typeface appear in theepsfbox:

enter image description here

So I can't seem to make a MWE of this "font loading earlier" suspicion (which might well be ill-founded), butsomething worked for many previous papers I've written. Here's an example from my Master's thesis:

enter image description here

In it, I just inputted fonts in the exact same way I did in the MWE above.

Once you appreciate how glitchy this is, you'll be horrified to learn that for all my previous papers, I've always just tried moving theepsfbox until all the glyphs I needed showed up correctly. (I feel like I remember instances where moving theepsfbox in thetex file changed the fonts that showed up, even if the output ended up in the same place due to e.g.\topinsert).

But now I'm writing a paper in which there is a figure with a large amount of variables and some glyphs simply won't load (I'm having particular trouble with the CMSY font). I thought it was time to really get to the bottom of what is happening, why sometimes the Computer Modern fonts load and why sometimes they won't.

Some clue might lie in the output of$ pdffonts test.pdf:

name                                 type              encoding         emb sub uni object ID------------------------------------ ----------------- ---------------- --- --- --- ---------QHKTMF+CMR10                         Type 1C           Builtin          yes yes yes      4  0BYOTSC+CMMI10                        Type 1C           WinAnsi          yes yes no       6  0LQZARU+CMR10                         Type 1C           WinAnsi          yes yes no      10  0YBPRKH+CMR6                          Type 1C           WinAnsi          yes yes no      13  0GUBEFN+CMSY9                         Type 1C           WinAnsi          yes yes no      16  0

This seems to suggest that the instance of CMR10 that is used to display the lorem ipsum text is not the same as the one I invoked in my PostScript program. How to I reference the correct (Builtin) CMR10 from PostScript itself?

All of these outputs came from a local MWE, but I would appreciate help as well with doing this on Overleaf, since the actual project I'm working on is on Overleaf. So if the solution involves putting files in certain paths, etc., it would be great if I could get some info about how to emulate that behaviour within Overleaf as well!

Also, I don't need a Plain TeX solution, LaTeX is fine. (But I would like to try keeping with PostScript for the time being—eventually I will have to learn how to use something like Tikz but I have used PS for years and don't want to give it up just yet because of some font troubles.)

This was a really long question. Sorry if I'm asking for a lot, really I would be happy with any sort of clue!

Edit 1. Here is the requested.log file:

This is TeX, Version 3.141592653 (TeX Live 2023/Debian) (preloaded format=tex 2025.4.4)  7 OCT 2025 10:18**test(./test.tex (/home/marcel/.config/texmf/tex/plain/epsf.texThis is `epsf.tex' v2.7.4 <14 February 2011>\epsffilein=\read0\epsfframemargin=\dimen16\epsfframethickness=\dimen17\epsfrsize=\dimen18\epsftmp=\dimen19\epsftsize=\dimen20\epsfxsize=\dimen21\epsfysize=\dimen22\pspoints=\dimen23)(fig.ps)[1] )Output written on test.dvi (1 page, 820 bytes).

Edit 2. Here is the output ofdvipdfm -v test.dvi:

<FONTMAP:/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:/var/lib/texmf/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:/usr/share/texlive/texmf-dist/fonts/map/dvipdfmx/ckx.map>DVI Comment:  TeX output 2025.10.07:1018test.dvi -> test.pdf<AGL:texglyphlist.txt><AGL:pdfglyphlist.txt><AGL:glyphlist.txt>[1<[email protected](TFM:cmr10)pdf_font>> Simple font "cmr10.pfb" enc_id=<builtin,-1> font_id=<cmr10,0>.>(Image:fig.ps[PS],Page:1)](cmr10.pfb[Type1])Compression saved 4445 bytes15161 bytes written
asked22 hours ago
marcelgoh's user avatar
11
  • (0) never post textual output as images. copy-paste as text and format as code. images can't be searched and are inaccessible to screen readers (unless you give alt equivalent). (1)cmmi10 andcmsy9 are maths fonts. you are testing them with text. (2)Builtin does not refer to thefont, but to theencoding. (3)WinAnsi looks very odd. (4) If you are actually using CM in original form, you will get poor results as they are not scalable. For printing it can be ok if you use the correct optical sizes, but scaling is a bad idea and you will anyway get poor results in pdf viewers.Commented21 hours ago
  • can you post the log for your example? but you should say whether this is for plain or latex as font config is quite different. please also specify the engine you're using.Commented21 hours ago
  • why are you making eps??? it looks to have been made by tex so you could more simply have made pdf which could then be directly inserted into your pdftex document without having to be converted.Commented15 hours ago
  • Yes, sorry, I do know whatcmmi andcmsy are, I need cmsy to get a "prime" symbol (which i believe is/060).Commented11 hours ago
  • @cfr Sorry, I'll replace the picture of the text output with the actual text, if I can find it. My run also didn't produce a.log file, is there a way to force it to?Commented10 hours ago

2 Answers2

1

The EPS file is invalid. It is PostScript but notEncapuslated PostScript.

For EPS, the fonts should (preferably) be embedded or failing that there should be a DSC comment declaring that font resources are needed, such as%%DocumentNeededFonts: or%%DocumentFonts:

answered9 hours ago
David Carlisle's user avatar
1
  • This was the solution that worked for me in the end, though I very much appreciated cfr's answer below as well as it helped me understand a lot of things I was doing wrong. I should also mention that to get this solution to work, I also seem to needdvips +ps2pdf instead ofdvipdfm.Commented9 hours ago
8

Your actual example will produce garbled output becauseCMMI10 andCMSY9 are maths fonts. Using them in text mode results in nonsensical results.

For LaTeX, use the extension.eps so the file is found and converted:

\begin{filecontents*}{\jobname-1.eps}%!PS-Adobe-3.0 EPSF-3.0%%BoundingBox: 0 0 400 70%%HiResBoundingBox: 0 0 400 70/nine {/CMMI10 findfont 9 scalefont setfont} def/ninetext {/CMR10 findfont 9 scalefont setfont} def/sixtext {/CMR6 findfont 6 scalefont setfont} def/symsix {/CMSY9 findfont 6 scalefont setfont} defnewpath50 50 moveto nine (This text should be CMMI10 \(at 9-point\)) show50 40 moveto ninetext (This text should be CMR10 \(at 9-point\)) show50 30 moveto sixtext (This text should be CMR6 \(at 6-point\)) show50 20 moveto symsix (This text should be CMSY9 \(at 6-point\)) showclosepathshowpage\end{filecontents*}\documentclass{article}\usepackage[T1]{fontenc}\usepackage{graphicx}\begin{document}\includegraphics{\jobname-1}\end{document}

I compiled with pdfLaTeX, but different workflows should also work.

Forplain,

\input epsf$$\epsfbox{\jobname-1.eps}$$\bye

works for me with any of

  • tex +dvipdf
  • etex +dvipdf
  • xetex.

XeTeX gave the most plausible results forplain. A.ps extension is also fine forplain.

All cases produce a warning concerning the postscript file

[1]**** Warning: glyf overlaps cmap, truncating. )

Note that the resulting PDF is arguablyworse than the output you show precisely because the requested fonts are used. Trying to typeset English text with fonts which do not include the characters required to typeset English doesn't produce intelligible output.

However, I'm assuming your actual postscript files use the fonts in some more sensible way ....

output (pdfLaTeX)

Here's thepdffonts output from pdfLaTeX:

name                                 type              encoding        emb sub uni object ID------------------------------------ ----------------- --------------- --- --- --- ---------TLOBKS+CMMI10                        Type 1            Custom          yes yes yes     10  0HQPJMH+CMR10                         Type 1            Custom          yes yes yes     13  0BBHPFO+CMR6                          Type 1            Custom          yes yes yes     16  0YEWXNU+CMSY9                         Type 1            Custom          yes yes yes     19  0

Or for XeLaTeX:

name                                 type              encoding        emb sub uni object ID------------------------------------ ----------------- --------------- --- --- --- ---------WTYGPU+CMSY9                         Type 1C           Custom          yes yes yes      5  0KZJIGT+CMMI10                        Type 1C           Custom          yes yes yes     11  0ROEVGV+CMR10                         Type 1C           Custom          yes yes yes     16  0TALMIG+CMR6                          Type 1C           Custom          yes yes yes     21  0

The results are similar forplain.

Notes:

  • ensure you havecm-super installed so that scalable fonts are available;
  • if using LaTeX, donot specify the extension in the\includegraphics{} command - this will speed conversion on subsequent runs, if required;
  • XeLaTeX is not recommended for new documents, but it may be easier here, if you don't have issues with it;
  • forplain, XeTeX may be most straightforward (and there is no recommendation against it fromplain's author!).
answered20 hours ago
cfr's user avatar
5
  • Nice and detailed and clean explanationCommented18 hours ago
  • 1
    @Marijn corrected. thanks.Commented11 hours ago
  • I triedxetex test instead oftex test (without changing anything else), and the output looks the same, unfortunately. I also ransudo apt install cm-super and it informed me that it is already installed (though I'm not sure if I'm using it correctly).Commented10 hours ago
  • @marcelgoh this is why we need the.log. if you get different output from running the same commands on the same code, the problem is probably in your setup. the.log would very likely tell us what that problem is. you don't have to do anything to usecm-super. if it is installed, scalable fonts are almost certainly configured to be preferred by you tex installation. but that is a guess. the.log would eliminate the guesswork.Commented9 hours ago
  • Hi! I updated my post with thelog a couple minutes ago, are you able to see it? (Thanks for the ongoing help, by the way!)Commented9 hours ago

You mustlog in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.