Fix default font properties when using raw fonts for text layouts

When a QRawFont is set explicitly on the layout, we would get certain
font properties from the QTextCharFormat instead. But when the properties
had not been set on the QTextCharFormat, we would get the default values
which were always 0/false, not the actual default values used in QFont.

Instead, we calculate a QFont query based on the format and use the
properties from this. This will give us the correct default values
in the cases where they are not overridden.

Change-Id: I53e5103739164c3d9eafaf76fcb4e8bda57bd12a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2019-01-28 08:22:33 +01:00
parent 9906cc57ed
commit 4514cf27b2

View File

@ -1398,11 +1398,12 @@ void QTextEngine::shapeText(int item) const
#ifndef QT_NO_RAWFONT
if (useRawFont) {
QTextCharFormat f = format(&si);
kerningEnabled = f.fontKerning();
QFont font = f.font();
kerningEnabled = font.kerning();
shapingEnabled = QFontEngine::scriptRequiresOpenType(QChar::Script(si.analysis.script))
|| (f.fontStyleStrategy() & QFont::PreferNoShaping) == 0;
wordSpacing = QFixed::fromReal(f.fontWordSpacing());
letterSpacing = QFixed::fromReal(f.fontLetterSpacing());
|| (font.styleStrategy() & QFont::PreferNoShaping) == 0;
wordSpacing = QFixed::fromReal(font.wordSpacing());
letterSpacing = QFixed::fromReal(font.letterSpacing());
letterSpacingIsAbsolute = true;
} else
#endif