qt5base-lts/tests/auto/gui/text
Eskil Abrahamsen Blomfeldt 43a63901f4 Fix bug with NoFontMerging when font does not support script
When using NoFontMerging, no fallbacks should be resolved. If the
font does not support a specific character in the text, we should
display a box instead of merging it with another font.

But in practice, Qt would still apply the fallback mechanism for
one specific case: If the font itself does not support the script
of the text, we would get no match and do a search for a fallback
instead. Since NoFontMerging is set, we would then force this
as preresolved for *all* scripts in the QFont's private data
(logically, the match should only have a single response for
NoFontMerging).

The end result was that if you set the font family before updating
the text, you would get broken rendering. This can happen e.g. in
Qt Quick, where you could update the font family of a text label
while it contains characters which are not supported by the new
font. Qt would then pick a fallback instead. When you subsequently
update the text, the fallback would already be preresolved for
whatever script this is. If it does not support the updated text,
we would then see boxes, even if the requested font actually would
have supported it.

The fix is simply to do an additional pass if NoFontMerging is set
and we were not able to match with the specified script. Since
the same family might be available in different foundries, with
different writing system support, we still want to do a pass first
to see if we can match the exact script of the text.

Note that QRawFont::fromFont() exploited the bug by using
NoFontMerging for getting the fallback font for a specific
writing system. To keep this working without having to rewrite
fromFont() and risk introducing regressions, we add an argument
to make the findFont() function behave as before. It isn't
super-pretty, but since it is private API it is hopefully fine.

[ChangeLog][QtGui][Text] Fixed an issue with NoFontMerging and
changing font families dynamically, where boxes would be seen in
place of the correct text.

Pick-to: 5.15 6.1 6.2
Done-with: Andy Shaw
Fixes: QTBUG-81770
Change-Id: Ide9a36d7528a1040172c5864fa99e7a82eac4e83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-19 13:35:40 +02:00
..
qabstracttextdocumentlayout Remove the qmake project files 2021-01-07 15:32:28 +01:00
qcssparser tests: Use QT_TESTCASE_SOURCEDIR define 2021-08-11 21:03:56 +02:00
qfont BLACKLIST tst_qfont for Red Hat 2021-04-06 07:35:24 +03:00
qfontcache Remove the qmake project files 2021-01-07 15:32:28 +01:00
qfontdatabase Remove the qmake project files 2021-01-07 15:32:28 +01:00
qfontmetrics Remove the qmake project files 2021-01-07 15:32:28 +01:00
qglyphrun Fix compiler warning: don't mix signed and unsigned int in comparison 2021-02-11 21:06:00 +01:00
qinputcontrol Remove the qmake project files 2021-01-07 15:32:28 +01:00
qrawfont Fix bug with NoFontMerging when font does not support script 2021-08-19 13:35:40 +02:00
qstatictext Remove QEXPECT_FAIL for tests that pass now on Android 2021-03-31 17:31:12 +02:00
qsyntaxhighlighter Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextblock Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextcursor Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextdocument Remove Qt6 switches from QtGui 2021-05-05 19:26:56 +02:00
qtextdocumentfragment Allow background inheritance between non-body block elements 2021-05-08 09:28:02 +02:00
qtextdocumentlayout Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextformat Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextimagehandler Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextlayout Avoid overflow in text layout 2021-06-17 09:58:27 +00:00
qtextlist Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextmarkdownimporter tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qtextmarkdownwriter tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qtextobject Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextodfwriter tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qtextpiecetable Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextscriptengine Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtexttable tst_qtexttable: fix fail on QEMU ARMv7 2021-02-05 18:36:51 +00:00
qzip Remove the qmake project files 2021-01-07 15:32:28 +01:00
CMakeLists.txt Android: exclude tests crashing at start 2020-11-16 13:35:44 +02:00