CoreText: Fix fonts with synthetic stretch
If a font is synthetically condensed / expanded, we need to scale the advances as well as the bounding boxes for the glyph cache. The logic is adapted from DirectWrite font engine, where the same scaling is already in place. [ChangeLog][macOS] Fixed a bug where synthetically stretched fonts would get the wrong advances and sometimes glyphs would be clipped. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-103838 Change-Id: I09fc87b245d1f2de980c10ad9253b9a83571f714 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
81fdfcfc4a
commit
992a318d39
|
|
@ -503,7 +503,11 @@ glyph_metrics_t QCoreTextFontEngine::alphaMapBoundingBox(glyph_t glyph, const QF
|
|||
return QFontEngine::alphaMapBoundingBox(glyph, subPixelPosition, matrix, format);
|
||||
|
||||
glyph_metrics_t br = boundingBox(glyph);
|
||||
qcoretextfontengine_scaleMetrics(br, matrix);
|
||||
|
||||
QTransform xform = matrix;
|
||||
if (fontDef.stretch != 100 && fontDef.stretch != QFont::AnyStretch)
|
||||
xform.scale(fontDef.stretch / 100.0, 1.0);
|
||||
qcoretextfontengine_scaleMetrics(br, xform);
|
||||
|
||||
// Normalize width and height
|
||||
if (br.width < 0)
|
||||
|
|
@ -848,8 +852,9 @@ void QCoreTextFontEngine::loadAdvancesForGlyphs(QVarLengthArray<CGGlyph> &cgGlyp
|
|||
QVarLengthArray<CGSize> advances(numGlyphs);
|
||||
CTFontGetAdvancesForGlyphs(ctfont, kCTFontOrientationHorizontal, cgGlyphs.data(), advances.data(), numGlyphs);
|
||||
|
||||
qreal stretch = fontDef.stretch != QFont::AnyStretch ? fontDef.stretch / 100.0 : 1.0;
|
||||
for (int i = 0; i < numGlyphs; ++i)
|
||||
glyphs->advances[i] = QFixed::fromReal(advances[i].width);
|
||||
glyphs->advances[i] = QFixed::fromReal(advances[i].width * stretch);
|
||||
}
|
||||
|
||||
QFontEngine::FaceId QCoreTextFontEngine::faceId() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue