diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2016-06-09 13:58:40 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2016-06-15 07:00:15 +0000 |
commit | 7190aa26f65ab97b4f54c156a107ed7748a11df5 (patch) | |
tree | 74b4d4f59f0e51acf425a83f69e5ea9d4f9f68c0 /src | |
parent | c175beafad259a0c17661e140e745979632fdfdc (diff) |
Support glyphs outside em square in distance field cache
In the distance field cache, we would assume a max height of glyphs
at 64 pixels when the pixel size was 54 (em square size is 54 and
then some margin). This is an arbitrary assumption which does not
necessarily hold true. Indeed, some fonts would be clipped at
the bottom when assuming this.
[ChangeLog][QtQuick][Text] Fixed clipping of glyphs that extend
beyond font's em square.
Task-number: QTBUG-52389
Change-Id: I5f6c9be235d38841e40d1bd60fb380e4712dd41a
Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index dcc485ce17..728d8b6541 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -97,8 +97,10 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph glyph_t glyphIndex = *it; int padding = QSG_DEFAULT_DISTANCEFIELD_GLYPH_CACHE_PADDING; - int glyphWidth = qCeil(glyphData(glyphIndex).boundingRect.width()) + distanceFieldRadius() * 2; - QSize glyphSize(glyphWidth + padding * 2, QT_DISTANCEFIELD_TILESIZE(doubleGlyphResolution()) + padding * 2); + QRectF boundingRect = glyphData(glyphIndex).boundingRect; + int glyphWidth = qCeil(boundingRect.width()) + distanceFieldRadius() * 2; + int glyphHeight = qCeil(boundingRect.height()) + distanceFieldRadius() * 2; + QSize glyphSize(glyphWidth + padding * 2, glyphHeight + padding * 2); QRect alloc = m_areaAllocator->allocate(glyphSize); if (alloc.isNull()) { @@ -107,11 +109,13 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph glyph_t unusedGlyph = *m_unusedGlyphs.constBegin(); TexCoord unusedCoord = glyphTexCoord(unusedGlyph); - int unusedGlyphWidth = qCeil(glyphData(unusedGlyph).boundingRect.width()) + distanceFieldRadius() * 2; + QRectF unusedGlyphBoundingRect = glyphData(unusedGlyph).boundingRect; + int unusedGlyphWidth = qCeil(unusedGlyphBoundingRect.width()) + distanceFieldRadius() * 2; + int unusedGlyphHeight = qCeil(unusedGlyphBoundingRect.height()) + distanceFieldRadius() * 2; m_areaAllocator->deallocate(QRect(unusedCoord.x - padding, unusedCoord.y - padding, padding * 2 + unusedGlyphWidth, - padding * 2 + QT_DISTANCEFIELD_TILESIZE(doubleGlyphResolution()))); + padding * 2 + unusedGlyphHeight)); m_unusedGlyphs.remove(unusedGlyph); m_glyphsTexture.remove(unusedGlyph); |