Qt-interest Archive, April 2008
Maybe a Qt4.4/Qt4.3 bug: incorrect font metrics information
Message 1 in thread
Hi,
I found that QFontMetrics::ascent() and QFontMetrics.descent() may
return wrong values for some fonts. I have checked this with both
Qt4.4 prerelease and Qt4.3 on MacOS X Tiger. You can check it with a
piece of code below:
QFont font;
bool ok;
font = QFontDialog::getFont(&ok, font);
QFontMetrics qm(font);
qDebug("family: %s", font.family().toUtf8().constData());
qDebug("raw name: %s", font.rawName().toUtf8().constData());
qDebug("height: %d", qm.height());
qDebug("ascent: %d", qm.ascent());
qDebug("descent: %d", qm.descent());
For example, the font file "PMingLiU.ttf", which is installed with MS
Office, provides a font "新?明?" ("XinXiMingTi"). This font's ascent
and descent are actually 820 and 204, respectively. You can check it
using FontLab, which is a cool font editor. But Qt gives wrong metrics
information for this font. Just run the code above. It will output
like this:
family: 新?明?
raw name: 新?明?
height: 16
ascent: 10
descent: 5
The ratio of the ascent to the descent should be 820/204 = 4.02, while
Qt gives 10/5 = 2.
I think this is a bug of Qt, but please correct me if I misunderstand
anything.
N?叉??z千u??h?У贽糙蕺绗囤?[^r(??殪够??{az??-⒒ay?雀????wb?+?b?m??+-糙?[^r(??{^?-