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

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.

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:
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.

I also encountered this problem for many times, and I have an simple but effective way that never fails me (on Windows, need GSview).
1) save fig as PDF
2) save PDF as ps
3) open ps with GSview, then click "File->PS to EPS", specify a file name and done.
Hope this helps.

Related

Is EPS image editable

I converted a matlab fig to eps, I need to add the grid to this figure which now I have in eps format. Is there any possibility. I know I can change the title or labels using ultraedit or similar programs but cant identify the relevant place for grid.
Yes, you simply need to read the PostScript program and then modify it to be suitable for your needs.
You will, however, probably need a working knowledge of the PostScript language in order to understand the program and succesfully modify it.

What fonts are actually available for MATLAB graphics text? [duplicate]

I have a Matlab program where I need to include a plane icon (Zapf Dingbats 40) in the plot. Everytime I run it, it falls back to a system font.
Is there anything that I am doing wrong? This is not the exact code, but illustrates the problem:
title(char(40),'fontname','ZapfDingbats','fontsize',50);
The resulting plot always displays ( instead of the Dingbats plane icon ✈.
I verified that the font is installed and I can type with it on Word.
I am using Matlab R2013b on Mac OSX 10.9.1.
EDIT: It prints correctly to a pdf, but does not display correctly.
You may use the 'Wingdings' font for that. The following code
text(0.5, 0.5, char(81), 'fontname', 'Wingdings', 'fontsize',50);
gives
The 'ZapfDingbats' font may not be in the /Library/Font folder (but 'Wingdings' is), even if listfonts tells you that the font is there. Actually, the listfonts
function adds some extra fonts to the list of the available fonts, and I don't get the rational of that.
% always add postscipt fonts to the system fonts list.
systemfonts = [fonts;
{
'AvantGarde';
'Bookman';
'Courier';
'Helvetica';
'Helvetica-Narrow';
'NewCenturySchoolBook';
'Palatino';
'Symbol';
'Times';
'ZapfChancery';
'ZapfDingbats';
}];

MatLab Eps Print Webdings interpreter

So recently I decided to not use the standard markers that Matlab provides and use my own via: a set of fonts including Webdings or WingDings. I make a standard scatter plot, and plot the text (in wingdings), using the text command, over the locations of the markers.
When I save these plots as png files, they print perfectly. They also appear perfectly on my screen after plotting.
However when I save these plots as eps files, the webdings are turning into their original letters 'l' or 'w'. It also looks like it's plotting them in a Courier font, but my default is Helvetica.
I've read through this previous post, but my question differs in that he is looking to use Latex as the interpreter and to include fonts, whereas I don't want to use Latex as the interpreter. However, it seems like my default interpreter (not sure what that is), isn't doing the job when converting to EPS.
Example:
imageR='w'
text(xf2,yf2,imageR,'fontName',font,'FontSize',fontR,'HorizontalAl','left','color','w')
I figured it out....took me way too long.
Ghostscript / Postscript only export with a few fonts when you are exporting eps files.
This link was incredibly helpful.
I just switched from wingdings/webdings to ZapfDinbats...Practically the same thing...

MATLAB: figure fonts

A command of the form xlabel('$<stuff>$','interpreter','latex'); will produce an axis label that is typeset by TeX using a font that is presumably ComputerModern. However, the axis tick labels (e.g., 0, 1, 2, ...) appear in the default font (Helvetica?). I would like to synchronize all the fonts in the figure (preferably to ComputerModern).
Toward that end, I presume that a command of the form set(0,'DefaultAxesFontName', '<fontname>') may be useful. However, I need to know the exact name or path of the font used by the MATLAB TeX interpreter. How can I retrieve a string value for the font name or a path pointing to the font file for the default figure font and the default TeX-interpreted font?
You could also plot the axis ticks with latex, look here:
http://alex.bikfalvi.com/research/latex_in_matlab_ticks/
Actually, your command was right to mget the default font (when NOT using latex):
get(0,'defaultaxesfontname')
But I didn't find any to get the default latex font. Perhaps it would be possible by using the internal java routines (to get some ideas, look at http://undocumentedmatlab.com/)
You can download the computer modern font, and install it on your local machine. For Mac, you'll need to download the OTF format (i'm not sure on windows machines).
Then, researt matlab, and you can use
set(0,'DefaultAexsFontName', 'CMU Serif')
to make things look like latex font.

Add text to PDF

I've got an exported version of a MATLAB diagram, similar to the one below. The problem is, that there are no axis captions. It's not possible to export the file again from MATLAB. I need to edit the PDF programmatically and edit about 100 diagrams, all with the same axis positions.
Is there a clean and fast way to paste the Strings X and Y at the corresponding positions in the pdf based on a batch process?
Create a PDF file with the captions. Add that as a background with to the PDF files with pdftk.
if know how to use LaTeX, the pstool package can bring you far on this on, including replacing labels (or actually any text on an eps figure) with TeX symbolic expressions. Neat if you're already working in LaTeX.