diff options
-rw-r--r-- | src/runtime/q3dsscenemanager.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp index d7df8ac..08b2fed 100644 --- a/src/runtime/q3dsscenemanager.cpp +++ b/src/runtime/q3dsscenemanager.cpp @@ -5186,8 +5186,15 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN float cy2 = cy1 + float(metrics.height); if (text3DS->shadow()) { - cx2 += shadowOffsetX; - cy2 += shadowOffsetY; + if (shadowOffsetX < 0.0) + cx1 += shadowOffsetX * fontScale; + else + cx2 += shadowOffsetX * fontScale; + + if (shadowOffsetY < 0.0) + cy1 += shadowOffsetY * fontScale; + else + cy2 += shadowOffsetY * fontScale; } float tx1 = float(c.x + c.xMargin); @@ -5195,12 +5202,22 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN float ty1 = float(c.y + c.yMargin); float ty2 = ty1 + float(c.height); + // Preserve original bounds of glyphs + float ttx1 = tx1; + float tty1 = ty1; float ttx2 = tx2; float tty2 = ty2; if (text3DS->shadow()) { - tx2 += float(c.width) * shadowOffsetX / float(metrics.width); - ty2 += float(c.height) * shadowOffsetY / float(metrics.height); + if (shadowOffsetX < 0.0) + tx1 += float(c.width) * shadowOffsetX * fontScale / float(metrics.width); + else + tx2 += float(c.width) * shadowOffsetX * fontScale / float(metrics.width); + + if (shadowOffsetY < 0.0) + ty1 += float(c.height) * shadowOffsetY * fontScale / float(metrics.height); + else + ty2 += float(c.height) * shadowOffsetY * fontScale / float(metrics.height); } const QSGDistanceFieldGlyphCache::Texture *texture = cache->glyphTexture(glyphIndex); @@ -5226,8 +5243,8 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN vertexes.append(ty1); if (text3DS->shadow()) { - vertexes.append(tx1); - vertexes.append(ty1); + vertexes.append(ttx1); + vertexes.append(tty1); vertexes.append(ttx2); vertexes.append(tty2); } @@ -5239,8 +5256,8 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN vertexes.append(ty1); if (text3DS->shadow()) { - vertexes.append(tx1); - vertexes.append(ty1); + vertexes.append(ttx1); + vertexes.append(tty1); vertexes.append(ttx2); vertexes.append(tty2); } @@ -5252,8 +5269,8 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN vertexes.append(ty2); if (text3DS->shadow()) { - vertexes.append(tx1); - vertexes.append(ty1); + vertexes.append(ttx1); + vertexes.append(tty1); vertexes.append(ttx2); vertexes.append(tty2); } @@ -5265,8 +5282,8 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN vertexes.append(ty2); if (text3DS->shadow()) { - vertexes.append(tx1); - vertexes.append(ty1); + vertexes.append(ttx1); + vertexes.append(tty1); vertexes.append(ttx2); vertexes.append(tty2); } |