Installed font not working when saving figure

9 views (last 30 days)
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 Comment
Brian Bak
Brian Bak on 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.

Sign in to comment.

Answers (1)

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

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!