Eskil Abrahamsen Blomfeldt 2b5533af92 Improve underline drawing for fonts in QPainter
In the underline drawing code in QPainter there were
some issues causing

First of all, if an underline was very thick, then we would
still just offset the drawing by 0.5 (as if it were 1 pixel
wide) causing part of the underline to appear on top of the
text. The shift here is intended to move the top edge of the
underline to the top edge of the pixel where we want to
draw it, so we need to offset it by half of the actual line
thickness.

In addition, fractional line widths look bad when drawn with
aliased painting, which is the default. Depending on where
the text would be, the thickness of a line might vary. Even
if it's very close to an integer, e.g. 1.04 as in one case,
then it will still sometimes fill two pixels if it happens to
be placed directly between them. To ensure that we always fill
the same number of pixels, we round the line thickness to
nearest integer when antialiasing is not enabled.

Pick-to: 6.8 6.9
Fixes: QTBUG-134626
Change-Id: I95bae3ac16010fc133995e5f9b6c2e5d022e3743
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-25 10:30:31 +01:00
..
2024-11-27 12:39:55 +01:00
2024-02-25 21:40:47 +00:00