Enabler for fractional scaling of text in Qt Quick
As opposed to the raster engine, in Qt Quick we are using unscaled positions for the glyphs and using the vertex shader to scale these after the fact. However, when picking the correct subpixel rendering for each glyph, we would use the unscaled position's fractional part, meaning that we essentially rendered the glyphs at the wrong subpixel position. This was especially visible when doing fractional scaling, e.g. 125%. Thus we need to get the fraction of the actual on-screen position instead. This has to be done both when populating the cache for the Qt Quick case (this enabler adds it as opt-in) and also when actually selecting the correct rendering of the glyph (change in Qt Declarative). Pick-to: 5.15 6.2 6.3 6.4 Task-number: QTBUG-101008 Change-Id: Ie67948b138f578b5f40d6a950c4aa92394a8f09a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
9efaf8bae9
commit
20ae170b35
@ -60,7 +60,8 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine,
|
||||
int numGlyphs,
|
||||
const glyph_t *glyphs,
|
||||
const QFixedPoint *positions,
|
||||
QPainter::RenderHints renderHints)
|
||||
QPainter::RenderHints renderHints,
|
||||
bool includeGlyphCacheScale)
|
||||
{
|
||||
#ifdef CACHE_DEBUG
|
||||
printf("Populating with %d glyphs\n", numGlyphs);
|
||||
@ -89,6 +90,9 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine,
|
||||
m_cy = padding;
|
||||
}
|
||||
|
||||
qreal glyphCacheScaleX = transform().m11();
|
||||
qreal glyphCacheScaleY = transform().m22();
|
||||
|
||||
QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
|
||||
int rowHeight = 0;
|
||||
|
||||
@ -99,6 +103,10 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine,
|
||||
QFixedPoint subPixelPosition;
|
||||
if (supportsSubPixelPositions) {
|
||||
QFixedPoint pos = positions != nullptr ? positions[i] : QFixedPoint();
|
||||
if (includeGlyphCacheScale) {
|
||||
pos = QFixedPoint(QFixed::fromReal(pos.x.toReal() * glyphCacheScaleX),
|
||||
QFixed::fromReal(pos.y.toReal() * glyphCacheScaleY));
|
||||
}
|
||||
subPixelPosition = fontEngine->subPixelPositionFor(pos);
|
||||
if (!verticalSubPixelPositions)
|
||||
subPixelPosition.y = 0;
|
||||
|
@ -78,7 +78,8 @@ public:
|
||||
int numGlyphs,
|
||||
const glyph_t *glyphs,
|
||||
const QFixedPoint *positions,
|
||||
QPainter::RenderHints renderHints = QPainter::RenderHints());
|
||||
QPainter::RenderHints renderHints = QPainter::RenderHints(),
|
||||
bool includeGlyphCacheScale = false);
|
||||
bool hasPendingGlyphs() const { return !m_pendingGlyphs.isEmpty(); }
|
||||
void fillInPendingGlyphs();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user