summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-02-10 08:14:26 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-02-10 14:56:34 +0100
commitfc33fea999365c36ed446eee0db0d59d94be306b (patch)
tree8c27f21df22e0ef13489dfe2502380f90ff26f4c
parent9086bc7fd3dbe619fe28871690de2f70162af643 (diff)
Don't do font merging for PUA characters
The "Private Use Area" are subsets of Unicode which are not considered regular characters, but reserved for fonts to provide custom glyphs. If these were used and the main font did not have support for them, we would look them up in other fonts and sometimes display an arbitrary selection of glyphs, based on whatever existed on the platform. This is unexpected and different from how native apps work on Windows, for instance. [ChangeLog][QtGui][Text] Font merging (automatic assignment of alternative fonts) is no longer applied for characters in the Private Use Areas of Unicode. Pick-to: 6.5 Fixes: QTBUG-110502 Change-Id: Id2c63786aafda59bf170e0d7263eb78a391fe46d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/gui/text/qfontengine.cpp3
-rw-r--r--tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp39
2 files changed, 41 insertions, 1 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 6b764dee54..5035b61fe9 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1862,7 +1862,8 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
&& ucs4 != QChar::LineSeparator
&& ucs4 != QChar::LineFeed
&& ucs4 != QChar::CarriageReturn
- && ucs4 != QChar::ParagraphSeparator) {
+ && ucs4 != QChar::ParagraphSeparator
+ && QChar::category(ucs4) != QChar::Other_PrivateUse) {
if (!m_fallbackFamiliesQueried)
const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) {
diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
index f28478dafd..d3267d024b 100644
--- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -56,6 +56,9 @@ private slots:
void shapingDisabledDevanagari();
void shapingDisabledLatin();
+
+ void privateUseArea();
+
private:
bool haveTestFonts;
};
@@ -1312,5 +1315,41 @@ void tst_QTextScriptEngine::shapingDisabledDevanagari()
QCOMPARE(noShapingRuns.first().glyphIndexes().size(), normalRuns.first().glyphIndexes().size());
}
+void tst_QTextScriptEngine::privateUseArea()
+{
+ QString privateUseAreaString = QString::fromUtf8("");
+
+ QFont font;
+ QList<QGlyphRun> withFontMerging;
+ {
+ QTextLayout layout;
+ layout.setText(privateUseAreaString);
+ layout.setFont(font);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ withFontMerging = layout.glyphRuns();
+ }
+
+ font.setStyleStrategy(QFont::NoFontMerging);
+ QList<QGlyphRun> withoutFontMerging;
+ {
+ QTextLayout layout;
+ layout.setText(privateUseAreaString);
+ layout.setFont(font);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ withoutFontMerging = layout.glyphRuns();
+ }
+
+ QCOMPARE(withFontMerging.size(), withoutFontMerging.size());
+
+ for (int i = 0; i < withFontMerging.size(); ++i)
+ QCOMPARE(withFontMerging.at(i).glyphIndexes(), withoutFontMerging.at(i).glyphIndexes());
+}
+
QTEST_MAIN(tst_QTextScriptEngine)
#include "tst_qtextscriptengine.moc"