Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
4.7.0
-
None
-
Qt Versions: 4.6.2, 4.7.0beta1
Platforms: Windows 7 64 bit, Linux x86-64
Compilers: MSVC 2008, GCC 4.4.1
Description
At least two routines affected: QFontMetrics[F]::width(const QString &) and QPainter::drawText().
According to Qt documentation of QFontMetrics::width(QChar):
"Returns the logical width of character ch in pixels. This is a distance appropriate for drawing a subsequent character after ch."
This means that drawing solid string should give the same result as drawing sequential set of string character and translating offset to QFontMetrics::width(QChar).
This is wrong for some fonts.
In my example Qt shrinks distance between drawn characters.
I used QFont("Arial", 60, QFont::Bold) and got different results.
This means that it is impossible for example to obtain actual position (in pixels) of character in string on screen.
Please see the example how to reproduce the problem.
The results also added into archive named: wrongImage.png, rightImage.png and wordpadImage.png
wordpadImage.png was created in the standard Window WordPad application with the same font passed (Bold Arial size 60).
WordPad also proves that font rendering in Qt is incorrect, QFontMetrics::width(const QString &) is incorrect too, but QFontMetrics::width(QChar) is correct.