'generates a png file containing latex\'s rendering of tex string
returns the filename'

def make_png(self, tex, fontsize, dpi):

    basefile = self.get_basefile(tex, fontsize, dpi)
    pngfile = (u'%s.png' % basefile)
    if (DEBUG or (not os.path.exists(pngfile))):
        dvifile = self.make_dvi(tex, fontsize)
        command = [str(u'dvipng'), u'-bg', u'Transparent', u'-D', str(dpi), u'-T', u'tight', u'-o', os.path.basename(pngfile), os.path.basename(dvifile)]
        mpl.verbose.report(command, u'debug')
        try:
            report = subprocess.check_output(command, cwd=self.texcache, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as exc:
            raise RuntimeError((u'dvipng    was    not    able    to    process    the    following    string:\n%s\n\nHere    is    the    full    report    generated    by    dvipng:\n%s    \n\n' % (repr(tex.encode(u'unicode_escape')), exc.output.decode(u'utf-8'))))
        mpl.verbose.report(report, u'debug')
    return pngfile
