Installed font not working when saving figure

조회 수: 7 (최근 30일)
Brian Bak
Brian Bak 2012년 7월 26일
답변: Fadime Bekmambetova 2023년 6월 4일
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
Brian Bak
Brian Bak 2012년 7월 27일
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.

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

답변 (1개)

Fadime Bekmambetova
Fadime Bekmambetova 2023년 6월 4일
A workaround that worked for me was to save as .svg and use Inkscape to create a PDF.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by