Save figure as pdf without changing fontname

Hello everyone, if I try to save a plot figure as pdf, where the font name of the axes and legend is changed to LM Roman, the text in the saved pdf hasn't LM Roman as font name. How can I fix this bug?
A short example:
plot(rand(10,1)); set(gca, 'FontName','LM Roman 10');
Thank you for your help.

댓글 수: 4

Check the below FAQ link,
https://in.mathworks.com/matlabcentral/answers/311820-save-a-figure-as-pdf
jonas
jonas 2018년 8월 22일
How are you saving the figure? I don't have any problem with print nor export_fig.
Johannes
Johannes 2018년 8월 23일
편집: Johannes 2018년 8월 23일
Hello Jonas, if I use the "save as" button, or if I use the print function, it always changes the font to the standard Font.
The first image shows, the figure before exporting with LM Roman
The second picture shows the pdf-result after exporting the file.
jonas
jonas 2018년 8월 23일
Have you tried with a different font, say Times new roman?

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

답변 (5개)

Johannes
Johannes 2018년 8월 22일

0 개 추천

Thank you for your answer. But the problem isn't how to export a figure to pdf.
The problem is, that the Font Name is changed during exporting the figure to pdf.
Lilly Verso
Lilly Verso 2018년 8월 31일

0 개 추천

I have exactly the same issue. Please let me know if you solved it.
Best

댓글 수: 2

Scott Cohen
Scott Cohen 2019년 10월 11일
I have exactly the same issue as well. And export_fig does has not helped me with it.

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

Scott Cohen
Scott Cohen 2019년 10월 11일

0 개 추천

I'm no expert on matlab, or any of these kinds of things, but after finding no resolution from this answer or anywhere else, I think I may have found a solution. I printed my figure using Microsoft XPS Document Writer, saving as an .oxps file. Then I searched online to find how to convert from .oxps to .eps, which is what I wanted. I found this site, which did the trick: https://convertio.co/oxps-eps/
Ankit Labh
Ankit Labh 2026년 5월 21일 10:41
편집: Ankit Labh 2026년 5월 21일 10:41

0 개 추천

Hi there,
One potential way (which I use) is the following:
(1) saveas the figure in svg to keep the fonts as it is.
(2) Use online tool "tools.pdf24.org" for converting it into pdf.
(3) Use online pdf cropper such as "www.ilovepdf.com" for cutting it into (manually) tighter margin.
This works perfectly.
I hope you will get this done.
To Matlab engineers: You must come up with a method which exports figure (as it is, including fonts) in pdf in vector format, transparent background and with tight margins (Padding) for normal offline users. If you don't do that. you would loose a big value. Thanks.

댓글 수: 1

Ankit Labh
Ankit Labh 2026년 6월 2일 7:53
I have found another way: (1) Export as pdf, (2) import in Inkspace where the original matlab fonts come back.

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

카테고리

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

제품

질문:

2018년 8월 22일

댓글:

2026년 6월 2일 7:53

Community Treasure Hunt

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

Start Hunting!

Translated by