diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2019-03-20 14:44:42 +0100 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2019-03-21 05:49:37 +0000 |
commit | f98fbe77e3f4199f35383a90d438f6cf59d34354 (patch) | |
tree | 9f89f72c92e26f164da73b8133b49e946d4493b4 /src | |
parent | e3c0ab60efae81a63e28e5507f5dc777aa13e753 (diff) |
Fix wrong drop shadow offset in distance field text
The offset is used to sample the cache texture, so it needs
to be calculated based on the font size in the texture.
Task-number: QT3DS-3139
Change-Id: I3ea8d2fb4e43985cbf8b5bf4a1e04133138b8e62
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Pasi Keränen <pasi.keranen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime/q3dsdistancefieldglyphcache.cpp | 5 | ||||
-rw-r--r-- | src/runtime/q3dsdistancefieldglyphcache_p.h | 2 | ||||
-rw-r--r-- | src/runtime/q3dsscenemanager.cpp | 6 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/runtime/q3dsdistancefieldglyphcache.cpp b/src/runtime/q3dsdistancefieldglyphcache.cpp index 6086917..a6e5477 100644 --- a/src/runtime/q3dsdistancefieldglyphcache.cpp +++ b/src/runtime/q3dsdistancefieldglyphcache.cpp @@ -248,6 +248,11 @@ void Q3DSDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyph } } +qreal Q3DSDistanceFieldGlyphCache::fontSize() const +{ + return QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution); +} + void Q3DSDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyphs) { // Note: Most of this is copy-pasted from QSGDefaultDistanceFieldGlyphCache in Qt Quick. diff --git a/src/runtime/q3dsdistancefieldglyphcache_p.h b/src/runtime/q3dsdistancefieldglyphcache_p.h index e29f614..72dd164 100644 --- a/src/runtime/q3dsdistancefieldglyphcache_p.h +++ b/src/runtime/q3dsdistancefieldglyphcache_p.h @@ -74,6 +74,8 @@ public: TextureInfo *textureInfoById(uint textureId) const; + qreal fontSize() const; + private: bool loadPregeneratedCache(const QRawFont &font); TextureInfo *textureInfo(int index) const; diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp index 5dc37a3..d7df8ac 100644 --- a/src/runtime/q3dsscenemanager.cpp +++ b/src/runtime/q3dsscenemanager.cpp @@ -5146,8 +5146,10 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN cache->processPendingGlyphs(); qreal fontPixelSize = glyphRun.rawFont().pixelSize(); - float shadowOffsetX = float(fontPixelSize) * text3DS->shadowOffsetX() / 1000.0f; - float shadowOffsetY = float(fontPixelSize) * text3DS->shadowOffsetY() / 1000.0f; + + float shadowOffsetX = float(cache->fontSize()) * text3DS->shadowOffsetX() / 1000.0f; + float shadowOffsetY = float(cache->fontSize()) * text3DS->shadowOffsetY() / 1000.0f; + qreal maxTexMargin = cache->distanceFieldRadius(); qreal fontScale = cache->fontScale(fontPixelSize); qreal margin = 2; |