MATLAB: I can’t seem to change figure font name

figurefontnameMATLAB

I run the following simple code and get Helvetica as a font.
fntsz=10;
font='LibreBaskerville-Regular';
axes1=axes('FontName',font,'FontSize',fntsz);
plt1=plot(TDMAINVTAO{1}.sd(:,1),TDMAINVTAO{1}.sd(:,2),'b');
set(plt1,'parent',axes1)
xlabel('Diameter (nm)')
ylabel('dN/dD{p} (#/cc/nm)')
I have tried the following as well…
set(findall(fig1,'-property','FontName'),'FontName',font)
When I try to change the axes font using the axes property editor, LibreBaskerville-Regular is not available.
However, when I run listfonts, LibreBaskerville-Regular is in the list.
I am currently running R2012a.
Chris

Best Answer

Set the default values for the fonts, when you create the figure:
font = 'LibreBaskerville-Regular';
figure('DefaultTextFontName', font, 'DefaultAxesFontName', font);
axes;
text(0.5, 0.5, 'Hello!');
Now the text and the tick labels use the wanted font.