'generates a dvi file containing latex\'s layout of tex
string. It calls make_tex_preview() method and store the size
information (width, height, descent) in a separte file.
returns the file name'

def make_dvi_preview(self, tex, fontsize):

    basefile = self.get_basefile(tex, fontsize)
    dvifile = (u'%s.dvi' % basefile)
    baselinefile = (u'%s.baseline' % basefile)
    if (DEBUG or (not os.path.exists(dvifile)) or (not os.path.exists(baselinefile))):
        texfile = self.make_tex_preview(tex, fontsize)
        command = [str(u'latex'), u'-interaction=nonstopmode', os.path.basename(texfile)]
        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'LaTeX    was    not    able    to    process    the    following    string:\n%s\n\nHere    is    the    full    report    generated    by    LaTeX:\n%s    \n\n' % (repr(tex.encode(u'unicode_escape')), exc.output.decode(u'utf-8'))))
        mpl.verbose.report(report, u'debug')
        m = TexManager._re_vbox.search(report.decode(u'utf-8'))
        with open((basefile + u'.baseline'), u'w') as fh:
            fh.write(u'    '.join(m.groups()))
        for fname in glob.glob((basefile + u'*')):
            if fname.endswith(u'dvi'):
                pass
            elif fname.endswith(u'tex'):
                pass
            elif fname.endswith(u'baseline'):
                pass
            else:
                try:
                    os.remove(fname)
                except OSError:
                    pass
    return dvifile
