Font not embedded when exporting to EPS

When generating figures I have chosen a font (e.g. CMU Serif) for all the text. When the figure is created, it shows the font perfectly. When I export it as .pdf or .eps (either by print(), saveas(), exportgraphics(),...) it does not embed my chosen font, but overwrites it by changing it to 'Courier'. As I want vector files of the figures, and want to save/print the figures in the code, is there a way to correctly include the chosen font, as previewed in the figure, in the .eps/.pdf file. As per previous threads, I noticed that this was an issue for older versions of Matlab, more specifically that the list of available embeddable fonts was just limited to a select few. Is this still a problem? Can I manually add fonts to the list? Are there any workarounds that do not include the need of manual work, but merely rely on the use of Matlab code?
Kind regards, Daan.

답변 (1개)

Kiran Felix Robert
Kiran Felix Robert 2021년 2월 11일

1 개 추천

Hi Daan,
Current PostScript implementation supports only the fonts listed below,
  1. Courier
  2. Helvetica
  3. ZapfDingbats
  4. Times
  5. Times-Roman
To support other fonts there are several possible workarounds,
  • Print the figure to an SVG file, and then convert it to EPS with Inkscape (https://inkscape.org/en/)
  • Print the figure to a PDF, use ghostscript to embed the fonts, and then convert to EPS. Here is the ghostscript command to run on the command prompt:
gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite
-sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer
-dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true
-dEmbedAllFonts=true -sOutputFile=embed.pdf -f unembed.pdf
In the above command, change only the filenames in red.
You can then convert the PDF to EPS using "pdftops" (a UNIX command) or "pdf2ps" (in ghostscript library).
If you have any issues with the File Exchange submissions, feel free to reach out to the authors.
You can also refer to the answers here for more information

댓글 수: 1

Riccardo
Riccardo 2026년 2월 10일
I really appreciated your detailled comment. Now I am simply wondering if there is any news regarding compatibility with other fonts in the latest MATLAB versions ;-)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2021년 2월 8일

댓글:

2026년 2월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by