Installed font not working when saving figure

13 Ansichten (letzte 30 Tage)
Brian Bak
Brian Bak am 26 Jul. 2012
Hi
I have installed a computer modern font on my win 7 machine to use it when plotting figures in matlab. The figure I get on the screen uses this font, but in the .eps file generated using saveas or print is with another font. If I use a standard font like 'Times' I get the right font in the .eps files. The code I use is the following:
set(0, 'defaultaxesfontname', 'CMU Serif'); % Computer modern.
set(0, 'defaulttextfontname', 'CMU Serif');
% set(0, 'defaultaxesfontname', 'Times'); % Times new roman.
% set(0, 'defaulttextfontname', 'Times');
set(0, 'defaultaxesfontsize',8);
set(0, 'defaulttextfontsize',8);
h = figure('units','pixels ','position',[0 0 100 200]);
plot([1,2],[1,2]
set(gca, 'OuterPosition', [-0.01 -0.005 0.99 0.99]);
set(gcf, 'PaperPositionMode', 'manual'); % Setup figure size
set(gcf, 'PaperUnits', 'centimeters ');
set(gcf, 'PaperPosition', [0 0 figWidth figHeight]);
saveas(h,'figure.eps', 'psc2')
print -depsc figure
Does anyone knows what the problem is?
Thanks in advance!
Regards Brian.
  1 Kommentar
Brian Bak
Brian Bak am 27 Jul. 2012
The fonts I have installed can be found at this link: http://canopus.iacp.dvo.ru/~panov/cm-unicode/download.html
It is the .otf files i have installed.
If i print to .pdf from the figure window I get the right font but if i use saveas from the figure window it uses the default font in matlab.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Fadime Bekmambetova
Fadime Bekmambetova am 4 Jun. 2023
A workaround that worked for me was to save as .svg and use Inkscape to create a PDF.

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by