Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.6.1, 6.2.0
-
None
-
4748369eb2e458e12f5228a113b9a6dda440b24b (qt/tqtc-qtbase/dev)
Description
When I use
QRect bounds = QFontMetrics.boundingRect(0, 0, maxWidth, 0, Qt::TextWordWrap, string);
the resulting bounds rectangle is not always big enough to render the same string using the call
drawText(bounds, Qt::TextWordWrap, string);
because those two functions use different algorithms to calculate the font width metrics that affect the word break position.
In the first attached screen shot, the bounding rectangle of the string "Effets de bureau" is used to draw the text, which gets then cropped to "Effets de".
In the second screen shot, the bounding rectangle returned by QFontMetrics is enlarged by 2 pixels in width, and drawText() now renders the string
correctly.
This bug depends on used font, font size, server DPI, and actual text, so no test case to reproduce.
Attachments
Issue Links
- is duplicated by
-
QTBUG-15974 QFontMetrics::boundingRect() returns too-small result
- Closed
- relates to
-
QTBUG-79144 FontMetrics and Text element report different width for the same text
- Closed
-
QTBUG-73002 QLabel::fontMetrics().boundingRect(text) != rendered width for some fonts
- Closed
-
QTBUG-85936 TextMetrics.width does not always give a correct width for the given text and is sometimes too short depending on the font used
- Closed