exportgraphics seems to embed fonts incorrectly
68 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to make a PDF figure using exportgraphics, with the Neo Euler font. When I export the graphics, some PDF viewers correctly show the graphics (Sumatra PDF, Foxit viewer), and some dont (Adobe Acrobat, PDF import to Inkscape). Specifically, some characters are exchanged (here: a space becomes an 8 in Adobe). This is not consistent, as for the actual figure (not the minimal example) different characters are replaced (T by e).
Here is a minimal example of the figure:
% Make a figure
f1 = figure('DefaultTextFontName', 'Palatino Linotype');
% create axes
ax1 = axes();
ax1.FontName = 'Neo Euler';
% add text
annotation('textbox',[0.3 0.5 0.4 0.1],'String','M_0 e^{-t/T_2^\ast}','FontName','Palatino Linotype');
annotation('textbox',[0.3 0.3 0.4 0.1],'String','M_0 e^{-t/T_2^\ast}','FontName','Neo Euler');
% export
exportgraphics(f1,'FontTest.pdf','ContentType','vector','Resolution',800)
I'm using Matlab 9.8.0.1323502 (R2020a), and Windows 10 version 1909 64 Bit.
Any help is greatly appreciated!
LB
Screenshot Sumatra PDF
and a screenshot from Acrobat
0 个评论
回答(2 个)
Daniel
2022-5-12
Unfortunately correct exporting (embedding) of fonts is still not fixed in 2022a, which is a bit disappointing. Unclear what fonts are supported for export, and why Matlab has this limitation, while other softwares seem to handle/export/embedd these fonts without issues.
The same issue applies for saving pdfs with "saveas" and "print" and has been around for several releases, but used to work in the past.
Saving to .svg and then run a Matlab "system" command to automatically execute the svg-to-pdf conversion by calling Inkscape works but it takes time and is annoying.
0 个评论
Kiran Felix Robert
2021-6-21
Hi Lars,
I was not able to exactly reproduce your issue, but this behavior has been observed on all platforms.
The reason for font substitution is for legacy print compatibility because not every font is supported for graphics export.
If you do not require vector graphics, use the following workaround:
% Make a figure
f1 = figure('DefaultTextFontName', 'Palatino Linotype');
% create axes
ax1 = axes();
ax1.FontName = 'Neo Euler';
% add text
annotation('textbox',[0.3 0.5 0.4 0.1],'String','M_0 e^{-t/T_2^\ast}','FontName','Palatino Linotype');
annotation('textbox',[0.3 0.3 0.4 0.1],'String','M_0 e^{-t/T_2^\ast}','FontName','Neo Euler');
% export
print -dpdf -opengl FontTest.pdf
exportgraphics(f1,'FontTest.pdf','ContentType','vector','Resolution',800)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!