Make imageAt and formatAt more robus against different font metrics
Don't try to locate the text by coordinates at the edge of the text but simply aim at the center vertically _and_ horizontally. Task-number: QTBUG-52991 Change-Id: Ia9e84fc5d12491840e739c4eea730fe13058f3c7 Reviewed-by: Simo Fält <simo.falt@theqtcompany.com>
This commit is contained in:
parent
7833f7bc06
commit
8e29d463dc
@ -1,7 +0,0 @@
|
||||
#QTBUG-53648
|
||||
[imageAt]
|
||||
opensuse-42.1
|
||||
rhel-7.2
|
||||
#QTBUG-52991
|
||||
[formatAt]
|
||||
opensuse-42.1
|
@ -194,7 +194,7 @@ void tst_QAbstractTextDocumentLayout::imageAt()
|
||||
QCOMPARE(documentLayout->anchorAt(imagePoint), QString("link"));
|
||||
|
||||
// imageAt on start returns nothing (there's the "foo" text)
|
||||
QPointF fooPoint(fooBr.width() + blockStart.x(), (fooBr.height() / 2) + blockStart.y());
|
||||
QPointF fooPoint(blockStart.x() + (fooBr.width() / 2), (fooBr.height() / 2) + blockStart.y());
|
||||
QCOMPARE(documentLayout->imageAt(fooPoint), QString());
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ void tst_QAbstractTextDocumentLayout::formatAt()
|
||||
QVERIFY(format.isImageFormat());
|
||||
|
||||
// move over the unformatted "foo" text)
|
||||
QPointF fooPoint(fooBr.width() + blockStart.x(), (fooBr.height() / 2) + blockStart.y());
|
||||
QPointF fooPoint(blockStart.x() + (fooBr.width() / 2), (fooBr.height() / 2) + blockStart.y());
|
||||
format = documentLayout->formatAt(fooPoint);
|
||||
QVERIFY(format.isCharFormat());
|
||||
QVERIFY(!format.toCharFormat().isAnchor());
|
||||
|
Loading…
Reference in New Issue
Block a user