'Get the width, total height and descent for a text typesetted by the
current LaTeX environment.'

def get_width_height_descent(self, text, prop):

    prop_cmds = _font_properties_str(prop)
    textbox = (u'\\sbox0{%s    %s}' % (prop_cmds, text))
    if (textbox in self.str_cache):
        return self.str_cache[textbox]
    self._stdin_writeln(textbox)
    try:
        self._expect_prompt()
    except LatexError as e:
        msg = u"Error    processing    '%s'\nLaTeX    Output:\n%s"
        raise ValueError((msg % (text, e.latex_output)))
    self._stdin_writeln(u'\\typeout{\\the\\wd0,\\the\\ht0,\\the\\dp0}')
    try:
        answer = self._expect_prompt()
    except LatexError as e:
        msg = u"Error    processing    '%s'\nLaTeX    Output:\n%s"
        raise ValueError((msg % (text, e.latex_output)))
    try:
        (width, height, offset) = answer.splitlines()[0].split(u',')
    except:
        msg = (u"Error    processing    '%s'\nLaTeX    Output:\n%s" % (text, answer))
        raise ValueError(msg)
    (w, h, o) = (float(width[:(-2)]), float(height[:(-2)]), float(offset[:(-2)]))
    self.str_cache[textbox] = (w, (h + o), o)
    return (w, (h + o), o)
