Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.2.0
-
11189af016c1deeefed476c5cc3a408f6ee79a2d
Description
QPainter::drawText() background is 1 pixel higher than the font height i.e. QFontMetrics::height(). If you set the height in QPainter::drawText() the outcome doesn't always follow the setting. In the attached example the font height is 18 pixels and if you set the height of drawText() to 19 or 18 the outcome is 19 pixels, and with 17 it is 17. I.e. the text rectangle is never 18 pixels high.
The attached example demonstrates this by drawing texts of height 19, 18, 17 and a reference rectangle ( QPainter::drawRect() ) with height 18. The black line is drawn such that the 18 px high rectangle should end on top of it. But as we can see in the attached picture the rectangles of 19 and 18 pixels height end at the bottom of the line.
The problem was seen also with other font sizes. And it is reproducible only on windows.