aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <[email protected]>2020-05-27 12:03:37 +0200
committerEskil Abrahamsen Blomfeldt <[email protected]>2020-05-27 14:16:49 +0000
commit5ce2d540be875041b38b481e3caef295071c79ee (patch)
tree19174d5ddca1a8f0a41041f3b9c66cb149e8f32e
parent756c4c9e6d51564bc32c99701efd939303ce31ff (diff)
Fix a clipping bug in software-rendered text
ac179e235ba0c01fff6dd5f4ad2cc9696fe78822 fixed a clipping issue with software rendering and text by using the actual bounding rect of the alpha map (which may be extended to allow for margins around the glyph). But it did not account for the margins on the top and left sides of the glyph, causing QTBUG-84042. By a coincidence, this issue was not reproducible with the DirectWrite engine in Qt 5.15 at the time because of 318a991907b6c08f52786160bafea1e30d3ad9bd in Qt Base, which baked the margins into the top and left positions of the returned bounding rect. But this is not what the other font engines are doing, and caused issues where the margin would be accounted for twice in the output. So 318a991907b6c08f52786160bafea1e30d3ad9bd was reverted. This change shifts the bounding rect by the margins (if any), avoiding clipping on the left and top sides. Task-number: QTBUG-80180 Fixes: QTBUG-84042 Pick-to: 5.15 Change-Id: I942f05f0e8c8eb8c5b3071a73406e3e744b7d5a0 Reviewed-by: Andy Nichols <[email protected]>
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
index 04e9b361ca..481d1f0304 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
@@ -63,13 +63,15 @@ QRectF calculateBoundingRect(const QPointF &position, const QGlyphRun &glyphs)
QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None ? fontEngine->glyphFormat : QFontEngine::Format_A32;
+ int margin = fontEngine->glyphMargin(glyphFormat);
+
const QVector<uint> glyphIndexes = glyphs.glyphIndexes();
const QVector<QPointF> glyphPositions = glyphs.positions();
for (int i = 0, n = qMin(glyphIndexes.size(), glyphPositions.size()); i < n; ++i) {
glyph_metrics_t gm = fontEngine->alphaMapBoundingBox(glyphIndexes.at(i), QFixed(), QTransform(), glyphFormat);
- gm.x += QFixed::fromReal(glyphPositions.at(i).x());
- gm.y += QFixed::fromReal(glyphPositions.at(i).y());
+ gm.x += QFixed::fromReal(glyphPositions.at(i).x()) - margin;
+ gm.y += QFixed::fromReal(glyphPositions.at(i).y()) - margin;
if (i == 0) {
minX = gm.x;