aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2021-10-08 16:20:35 +0200
committerOliver Eftevaag <oliver.eftevaag@qt.io>2022-03-02 14:21:09 +0100
commitae62122a8f57b1de654e891125f19d2e18d6f5df (patch)
treec24acf83223093d5b9c449e656dfbe23ac182cbc /tests/auto/qml/qqmlcomponent
parentf2791ba6290c7d22ac9093a948e0f5bef671247b (diff)
QQuickText: fix fractional pointSize rounding error bug
Problem: The layout is initialized with a copy of the current font before the laying out begins. In cases when setupTextLayout() iterates through the main loop multiple times, it will update the layout font, if it differs. (See code below) if (!once) { if (pixelSize) scaledFont.setPixelSize(scaledFontSize); else scaledFont.setPointSizeF(scaledFontSize); if (layout.font() != scaledFont) layout.setFont(scaledFont); } The whole reason why we might update the font in the first place, is because the QQuickText has a fontSizeMode property which can be set to e.g. HorizontalFit, which will cause the layouting to downscale the font in order to fit (assuming the text doesn't fit the space available), instead of eliding. The problem here is that QFont internally uses a float to store the point size, and we would convert that value to an int when temporarily storing it on the stack. This would modify the pointSize value in cases where the pointSize is fractional, and cause a mismatch between the QQuickText and QTextLayout. The lineWidth is set only during the first loop iteration. During successive iterations of the main loop, the layout's font would be updated to one that has either a floored or ceiled pointSize. If the pointSize is a fractional value, and is ceiled when being updated during the second loop iteration, the layout would use a larger font value, which would cause the QTextLayout::naturalTextWidth() to return a larger value than that of the lineWidth, triggering eliding. Solution: Keep the font precision, by storing the values as floats instead of ints. Fixes: QTBUG-92006 Pick-to: 6.2 6.3 Change-Id: Ibf64ac2dfbf262c6aae05b8eb8251d2f5a869b69 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlcomponent')
0 files changed, 0 insertions, 0 deletions