Sans-serif not supported in MATLAB text using latex interpreter

Alec Jacobson

September 06, 2012

weblog/

If I try to issue in MATLAB:
title('\textsf{sans-serif}','interpreter','latex');
I get the following error:
Warning: Font cmss10 is not supported. 
Warning: Font cmss10 is not supported. 
Font creation failed twice.
java.io.IOException when creating Font object
Using File /Applications/MATLAB_R2011b.app/sys/fonts/ttf/cm/mwa_cmss10.ttf to create font mwa_cmss10
File.exists(): false
File.length(): 0
Exception:
java.io.IOException: Can't read /Applications/MATLAB_R2011b.app/sys/fonts/ttf/cm/mwa_cmss10.ttf
	at java.awt.Font.createFont(Font.java:978)
	at com.mathworks.hg.util.FontConverter.loadTexFontSecondAttempt(FontConverter.java:254)
	at com.mathworks.hg.util.FontConverter.loadTexFont(FontConverter.java:218)
	at com.mathworks.hg.util.FontConverter.convertToJavaFont(FontConverter.java:169)
	at com.mathworks.hg.uij.GraphicsContext.SetWindowFont(GraphicsContext.java:1039)
Caused by:
null
Warning: Could not set font mwa_cmss10 
I fixed this by finding cmss10.ttf on the web. And copying on top of /Applications/MATLAB_R2011b.app/sys/fonts/ttf/cm/mwa_cmss10.ttf. Then when I issue the above command I get the correct output and only a few warnings:
Warning: Font cmss10 is not supported.
Warning: Font cmss10 is not supported.