nsresult
nsThebesFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
                                        nsThebesRenderingContext *aContext,
                                        nsBoundingMetrics &aBoundingMetrics)
{
    if (aLength == 0) {
        aBoundingMetrics.Clear();
        return NS_OK;
    }

    AutoTextRun textRun(this, aContext, aString, aLength);
    if (!textRun.get())
        return NS_ERROR_FAILURE;

    GetTextRunBoundingMetrics(textRun.get(), 0, aLength, aContext, aBoundingMetrics);
    return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextQt::GetBoundingMetrics(const char *aString,PRUint32 aLength,
                                         nsBoundingMetrics &aBoundingMetrics)
{
    aBoundingMetrics.Clear();
    if (0 >= aLength || !aString || !mCurrentFont)
        return(NS_ERROR_FAILURE);

    QString str = QString::fromLatin1(aString, aLength);
    QFontMetrics fm(mCurrentFont->font);
    QRect br = fm.boundingRect(str);
    aBoundingMetrics.width = NSToCoordRound(br.width() * mP2T);
    aBoundingMetrics.ascent = NSToCoordRound(-br.y() * mP2T);
    aBoundingMetrics.descent = NSToCoordRound(br.bottom() * mP2T);
    aBoundingMetrics.leftBearing = NSToCoordRound(br.x() * mP2T);
    aBoundingMetrics.rightBearing = NSToCoordRound(fm.rightBearing(str.at(aLength - 1)) * mP2T);
    return NS_OK;
}