(Using Python 3.6.1 on Win10, in a virtualenv that basically just has numpy/pandas/matplotlib installed, for number-crunching stuff. I don't have Tkinter installed and would prefer to keep it that way.)
I have the following test code, attempting to render MathML text statically:
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plot
def render(mathml):
plot.clf()
plot.rc('font', family='monospace', size=72)
plot.axis('off')
plot.text(0, 0, f'{mathml}')
plot.savefig(f'hax.png')
render('$lorem^{ipsum}$')
The resulting test.png shows the text in the default font (DejaVu Sans Oblique), not in a monospace font:
Explicitly specifying a font (e.g. family='Courier New') also has no effect, and neither does changing the output format. The text is properly resized, and no error or warning appears - the output just doesn't show the right font.
What's going on here? How can I fix it?



tkinteris already apart of the Python Standard Library, so its already installed.