<div dir="ltr">Hi all,<div><br></div><div>I have a custom font file (ttf) I would like to use with matplotlib. I don't have sudo access, so can't just add it to the standard fonts directory, but would like to add it to matplotlib's list of known fonts.</div><div><br></div><div>I know that I can do something like this for one-off uses:</div><div><br></div><div><div>from matplotlib import font_manager</div><div>fp = font_manager.FontProperties(fname='myfont.ttf')</div><div><div>fig = pyplot.figure()</div><div>ax = fig.gca()</div><div>ax.plot([1, 2, 3, 4, 5])</div><div>ax.set_xlabel('X-axis label', fontproperties=fp)</div></div><div><br></div><div>But I would like to use the font as the default for all text objects in my figure. I have tried using rcParams:</div><div><br></div><div><div>rcParams['font.family'] = fp.get_family()</div><div>rcParams['font.sans-serif'] = fp.get_name()</div></div><div><div><br></div><div>but I get the standard warning:</div><div><br></div><div>UserWarning: findfont: Font family [u'sans-serif'] not found. Falling back to Bitstream Vera Sans<br></div><div><br></div><div>and it uses the default font, even after blowing away my fontList.cache file (many times). I suspect that I have loaded the font using the FontProperties object, but haven't actually 'registered' it with matplotlib so it knows what to do when I specify the font name, or something like that.</div><div><br></div><div>Any help would be great.</div><div><br></div><div><br></div><div>Many thanks</div><div>Duncan</div>-- <br><div class="gmail_signature"><div dir="ltr">Duncan Macleod<br><a href="mailto:duncan.macleod@ligo.org" target="_blank">duncan.macleod@ligo.org</a><div>LIGO Data Grid systems development</div><div>Louisiana State University</div></div></div>
</div></div></div>