Code covered by the BSD License  

Highlights from
printeps

4.66667

4.7 | 15 ratings Rate this file 38 Downloads (last 30 days) File Size: 2.02 KB File ID: #7501

printeps

by

 

21 Apr 2005 (Updated )

This works around MATLABs tendency to call all fonts 'Helvetica' in .eps files.

| Watch this File

File Information
Description

When you export a figure to .eps in MATLAB, it will only use a small number of allowed fonts, even if the user has changed these fonts to something specific to their system. In most cases, you'll end up with 'Helvetica' specified in the resulting eps file. That is, if you import this file into Illustrator and have no font exactly called 'Helvetica' then you will end up substituting something else for it, often times doing bizarre things to your kerning, etc. like moving your subscripts to Siberia.

This script writes the .eps as usual, but figures out what font you actually used in the figure and does a find and replace to place your font (presumably actually resident on your system) back into the file. Currently this does not discriminate between the axis font and other text fonts in the figure (i.e., the title and added text), so everything gets changed to the axis font.

This is just a workaround until Mathworks decides their .eps exporting is problematic.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
08 Jan 2014 Edison

Works well. I would repeat the comment of Nick Gravish below, with regards to exact font name. I wanted all text in my exported EPS to be Arial, and I had to make actualfont = 'ArialMT'; for this to work. Setting actualfont = 'Arial' made the EPS have courier fonts.

Another comment, printeps can be called on an EPS figure made by export_fig, which for me is the perfect way to create vector figures from MATLAB.

Top job Jose!

03 Jun 2013 Sebastian

Very nice an easy to use.

I found one weird bug that is not important I guess. The text field of the y-label is sometimes split into two text fields. Here the example code:
---
x=1:10;
y=sin(x);
fig=figure(1);
plot(x,y);
ylabel('amplitude [µV]', 'FontSize', 11);
xlabel('test label [µV]');
set(0, 'DefaultAxesFontName', 'Arial');
printeps(fig, 'test.eps');
---

if you change the ylabel to the following everything is ok:
ylabel('amplitude [µV] ', 'FontSize', 11);

using Matlab 2012b on Windows 7.

Thanks for the tool!

19 Jun 2012 Francis

I have the problem that when I look at the eps version of a plot produced with printeps, the text in the title and in the legend get cut off. Does anyone have a good idea of how to fix that? Thanks!

30 Apr 2012 Alexandra  
03 Jun 2011 Terrance Nearey

Thanks Jose for saving me some time finding out what Matlab should make clear in documentation. (Wish I'd spotted your contribution a couple of days ago!). The fonts actually supported in PRINT or SAVEAS in espc2 formats is apparently version- and platform-dependent.
On MATLAB Mac OS X Version: 10.6.7 Build: 10J869, the only fonts I could find that wound up in eps files were these: 'Courier' 'Helvetica' 'Palatino' 'Symbol' 'Times' 'Times New Roman' 'Zapf Dingbats'

Both Times New Roman and Times showed up as 'Times-Roman' in the eps file, but at least they weren't changed to 'Helvetica'.

22 May 2011 Céldor  
15 Apr 2011 Nick

I work with eps figures in adobe illustrator and it has been a continual pain reconfiguring the fonts from matlab exported eps files. Thanks for the function.

One comment for illustrator users. Adobe illustrator (at least on my system) uses the times new roman font TimesNewRomanPSMT, so embedding the actual font name "Times New Roman" returned from get(gca,'FontName') still gives an error in illustrator. My workaround was to hard code actualfont = 'TimesNewRomanPSMT' since I always work with times. Just a heads up for anyone in a similar position.

04 Oct 2010 Andrey Kan  
23 Apr 2009 Ted S

Thank you, I assumed this is how MATLAB should have worked, and I was confused why I was having problems.... Works great with this.

25 Sep 2008 J W

works like a charm

29 Jun 2008 Ken Campbell

Simple, but it works. Thanks for solving this annoying problem.

02 Feb 2008 Dario Redaelli

I have exeprienced continuous problems to introduce matlab .eps files in latex ducments! You provided a simple solution, and exactly what I was looking for! Thank you very much.

10 Jan 2008 L Matthews

Thank you,this has been driving me nuts. Why cant They sort real issues like this out.

09 Jul 2007 Maxim Ts

Thanks. It solves the problem!

18 Jan 2006 Hannah S

I haven't checked it thoroughly, but it solved my problem - thanks!

Contact us