exportgraphics seems to embed fonts incorrectly
68 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Daniel
le 12 Mai 2022
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 commentaires
Kiran Felix Robert
le 21 Juin 2021
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)
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!