title: How to make fonts available to the LaTeX interpreter in Matlab R2013a?
body: <p>It is possible to embed LaTeX-formatted text and equations into Matlab plots by setting the <code>text</code> property 'Interpreter' to the value 'latex', e.g.</p>
  
  <pre><code>text(0.1, 0.5, 'Einstein: $E = m c^2$', ...
      'Interpreter', 'latex', 'FontSize', 32)
  </code></pre>
  
  <p>These equations appear on screen as well as in illustrations exported to eps files.</p>
  
  <p>Through the appropriate LaTeX commands, it is also possible to change the font from the default Computer Modern Serif to e.g. Computer Modern Typewriter</p>
  
  <pre><code>text(0.1, 0.5, '\fontfamily{cmtt}\selectfont Einstein: $E = m c^2$', ...
      'Interpreter', 'latex', 'FontSize', 32)
  </code></pre>
  
  <p><strong>My question is:</strong> Is it possible to insert additional fonts into the Matlab installation, such that these fonts become available for use with 'Interpreter' 'latex', for rendering on screen as well as producing eps files? And if yes, how?</p>
  
  <h3>Background</h3>
  
  <p>(All paths relative to the Matlab installation, <code>/opt/MATLAB/R2013a</code> on my Linux system.)</p>
  
  <p>Matlab includes a customized version of the (La)TeX interpreter. It is called via a frontend m-file called <code>tex.m</code> in <code>toolbox/matlab/graphics</code> which takes LaTeX code as an argument and returns dvi data within its output argument. The customized LaTeX installation is found in <code>sys/tex</code> and includes TeX font metric files under <code>sys/tex/tfm</code>.</p>
  
  <p>I do not have any information on the parts of Matlab that render this dvi. However, font data for rendering are found under <code>sys/fonts/ttf</code> and <code>sys/fonts/type1</code>.</p>
  
  <p>Making additional fonts usable therefore consists of two parts: Making it available for the LaTeX interpreter, and making it available for the rendering function. The first part can be tackled by manipulating <code>tex.m</code>, such that it generates the dvi through an independent regular installation of LaTeX, and installing the font to this LaTeX in the usual way (e.g. font packages). See <a href="http://undocumentedmatlab.com/blog/matlab-latex-interface/#comment-209656" rel="nofollow noreferrer">undocumentedmatlab</a>.</p>
  
  <p>The second part of the question is therefore the crucial one: How to insert additional fonts into <code>sys/fonts/ttf</code> and <code>sys/fonts/type1</code> such that they become usable by the dvi renderer component of Matlab.</p>
  
  <h3>Concrete case</h3>
  
  <p>I tried to concretely solve the second problem for a special case: The Computer Modern Sans font is included in the Matlab-LaTeX installation through <code>tex/tfm/cmss10.tfm</code>, but the corresponding ttf and pfb-files are missing from <code>sys/fonts</code> such that it does not get rendered.</p>
  
  <p>Matlab's collection of ttf-files does not appear to have some kind of inventory. I therefore simply copied the file <code>cmss10.ttf</code> from an installation of matplotlib to <code>sys/fonts/ttf/cm/mwa_cmss10.ttf</code>, following the file and folder naming conventions of the other files present. This procedure was reported to be working on <a href="http://www.alecjacobson.com/weblog/?p=2775" rel="nofollow noreferrer">Alec's Web Log</a> for Matlab 2011b on Max OS X, but on my system it has no effect, neither for screen display nor eps export.</p>
  
  <p>Matlab's collection of type1 fonts has a complex inventory, distributed over files <code>fonts.dir</code>, <code>fonts.scale</code>, <code>encodings.dir</code> and a folder <code>encodings</code> full of enc-files. Again I found cmss10.pfb, this time from a TeXlive installation, renamed and copied it, and made entries in the inventory files following the example of the other fonts listed. Again, this procedure has no effect at all.</p>
  
  <p>Does anyone know more about how Matlab uses ttf and pfb-files, and can give me a hint on how to make the cmss10-files accessible to Matlab rendering? Or does anyone have a suggestion how to debug this and find out more about the <a href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/330973" rel="nofollow noreferrer">inner workings</a> of Matlab's LaTeX support?</p>