Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get around MATLAB's limitation on font embedding in vector format files?

According to the MATLAB manual, when you save a figure using print or by choosing file|save, if you choose the painters renderer and save to PDF or EPS vector formats, all fonts get substituted. Is there a way to get around this limitation?

Whenever I output a figure, whether I use print or export_fig, the fonts get substituted, and so they no longer match the fonts in the document that I plan on putting the figure into. I would prefer to keep them in a vector format, because I use LaTeX and so I want to be able to use the same figures in my documents as in my beamer presentations and have them scale nicely without bloating the file size.

like image 202
craigim Avatar asked Oct 03 '22 23:10

craigim


1 Answers

If I'm reading that link correctly, not all fonts get substituted. From 'Choosing a Printer Driver':

The table below lists the fonts supported by the MATLAB PostScript and Ghostscript drivers when generated with the Painters renderer (fully vectorized output). This same set of fonts is supported on both Windows and UNIX:

AvantGarde
Helvetica-Narrow
Times-Roman
Bookman
NewCenturySchlbk
ZapfChancery
Courier
Palatino
ZapfDingbats
Helvetica
Symbol

So, if you use one of the above fonts, the output vector-format figure should maintain the correct font. See for example:

list_fonts = listfonts
figure('renderer','painters'),
plot(peaks),
xlabel('this font is Helvetica','fontname','Helvetica','fontsize',24)
set(gcf,'paperpositionmode','auto')
print(gcf,'-depsc2','test1.eps')

Which produces:

example output

So, choose one of the fonts from the list above, and the font will be output correctly. Otherwise, change the font in your presentation to match one of the above fonts.

like image 133
David_G Avatar answered Oct 13 '22 12:10

David_G