Add required font metrics functions to QRawFont

Reviewed-by: Eskil
(cherry picked from commit 2c8df8bfb679885c3cbd2ee02f5e4053fdd554c2)
This commit is contained in:
Jiang Jiang 2011-05-02 14:13:06 +02:00
parent c41153e693
commit 2a8d50ed6a
2 changed files with 56 additions and 0 deletions

View File

@ -301,6 +301,58 @@ qreal QRawFont::descent() const
return d->fontEngine->descent().toReal(); return d->fontEngine->descent().toReal();
} }
/*!
Returns the xHeight of this QRawFont in pixel units.
\sa QFontMetricsF::xHeight()
*/
qreal QRawFont::xHeight() const
{
if (!isValid())
return 0.0;
return d->fontEngine->xHeight().toReal();
}
/*!
Returns the leading of this QRawFont in pixel units.
\sa QFontMetricsF::leading()
*/
qreal QRawFont::leading() const
{
if (!isValid())
return 0.0;
return d->fontEngine->leading().toReal();
}
/*!
Returns the average character width of this QRawFont in pixel units.
\sa QFontMetricsF::averageCharWidth()
*/
qreal QRawFont::averageCharWidth() const
{
if (!isValid())
return 0.0;
return d->fontEngine->averageCharWidth().toReal();
}
/*!
Returns the width of the widest character in the font.
\sa QFontMetricsF::maxWidth()
*/
qreal QRawFont::maxCharWidth() const
{
if (!isValid())
return 0.0;
return d->fontEngine->maxCharWidth();
}
/*! /*!
Returns the pixel size set for this QRawFont. The pixel size affects how glyphs are Returns the pixel size set for this QRawFont. The pixel size affects how glyphs are
rasterized, the size of glyphs returned by pathForGlyph(), and is used to convert rasterized, the size of glyphs returned by pathForGlyph(), and is used to convert

View File

@ -103,6 +103,10 @@ public:
qreal ascent() const; qreal ascent() const;
qreal descent() const; qreal descent() const;
qreal leading() const;
qreal xHeight() const;
qreal averageCharWidth() const;
qreal maxCharWidth() const;
qreal unitsPerEm() const; qreal unitsPerEm() const;