From 97d7042c457e5eeacdf7def765566e0a31e064b9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Jun 2022 08:18:48 +0200 Subject: [PATCH] Fix font rendering when Qt is configured with -no-harfbuzz When Qt was configured with -no-harfbuzz, we would get overlapping glyphs, because we skipped the shaping step but did not set up things correctly before that. Instead, we force the PreferNoShaping code path when there is no shaper available. [ChangeLog][Text] Fixed font layouts when Qt was configured without Harfbuzz. Fixes: QTBUG-100361 Change-Id: I1c54dbc457dbb235548b9d70324d607a0ee6d501 Reviewed-by: Lars Knoll (cherry picked from commit 81fdfcfc4aec643d987a506c56eca440545f2fbf) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/qtextengine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index bc19504c180..f4899339400 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1403,15 +1403,17 @@ void QTextEngine::shapeText(int item) const bool kerningEnabled; bool letterSpacingIsAbsolute; - bool shapingEnabled; + bool shapingEnabled = false; QFixed letterSpacing, wordSpacing; #ifndef QT_NO_RAWFONT if (useRawFont) { QTextCharFormat f = format(&si); QFont font = f.font(); kerningEnabled = font.kerning(); +# if QT_CONFIG(harfbuzz) shapingEnabled = QFontEngine::scriptRequiresOpenType(QChar::Script(si.analysis.script)) || (font.styleStrategy() & QFont::PreferNoShaping) == 0; +# endif wordSpacing = QFixed::fromReal(font.wordSpacing()); letterSpacing = QFixed::fromReal(font.letterSpacing()); letterSpacingIsAbsolute = true; @@ -1420,8 +1422,10 @@ void QTextEngine::shapeText(int item) const { QFont font = this->font(si); kerningEnabled = font.d->kerning; +#if QT_CONFIG(harfbuzz) shapingEnabled = QFontEngine::scriptRequiresOpenType(QChar::Script(si.analysis.script)) || (font.d->request.styleStrategy & QFont::PreferNoShaping) == 0; +#endif letterSpacingIsAbsolute = font.d->letterSpacingIsAbsolute; letterSpacing = font.d->letterSpacing; wordSpacing = font.d->wordSpacing;