summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qglyphrun
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-02-02 12:29:44 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-02-02 15:10:41 +0000
commit3e238113f84de92cb571ff7129f41f6b4724c1dc (patch)
treed4bb95aaab206739ef71252751b32ab80393f736 /tests/auto/gui/text/qglyphrun
parent89501f9a7b0c7b228906412b337becb6a43ff9b4 (diff)
Accept error margin in QGlyphRun/QStaticText test for decorations
When calculating the width of a text for drawing decorations on top, we use the effective advance of the whole text after it has been through the shaper. However, in the case of QStaticText and QGlyphRun, there is shortcut: Since we only have the glyph indexes and position of each glyph, we use the position + advance of the right-most glyph to find the right-most edge of the decoration. For this, however, we use the advance of the glyph *out of context* of the rest of the string, because the whole idea is to avoid doing the shaping of the string with every draw call. In some rare cases, the advance of the right-most character, in the context of the string, is different from the advance of the standalone glyph. Now, one way of fixing this would be to store the width of the text in QStaticText and QGlyphRun, but since it is a very rare artifact which is barely visible, I have opted to just work around it in the test instead, the workaround being to force integer metrics so that we don't get the small 0.2 pixel error. Task-number: QTBUG-55217 Change-Id: I8d16d52f2ef27275cabb7d3865aeeaa31617ba3d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/gui/text/qglyphrun')
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
index 7c60c8c9f8..21b2697b90 100644
--- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
+++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
@@ -527,6 +527,7 @@ void tst_QGlyphRun::drawStruckOutText()
QFont font;
font.setStrikeOut(true);
+ font.setStyleStrategy(QFont::ForceIntegerMetrics);
QTextLayout layout(s);
layout.setFont(font);
@@ -569,6 +570,7 @@ void tst_QGlyphRun::drawOverlinedText()
QFont font;
font.setOverline(true);
+ font.setStyleStrategy(QFont::ForceIntegerMetrics);
QTextLayout layout(s);
layout.setFont(font);
@@ -611,6 +613,7 @@ void tst_QGlyphRun::drawUnderlinedText()
QFont font;
font.setUnderline(true);
+ font.setStyleStrategy(QFont::ForceIntegerMetrics);
QTextLayout layout(s);
layout.setFont(font);