qt5base-lts/tests/auto/gui
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
..
image Improve support for saving QImage to QSaveFile 2021-07-14 11:02:25 +00:00
itemmodels emit layoutAboutToBeChanged timely 2021-07-20 21:27:27 +01:00
kernel testlib: Deprecate QWARN() in favor of qWarning() 2021-08-04 19:31:51 +02:00
math3d tst_QMatrixNxN: fix type-punning warning 2021-06-30 23:13:28 +02:00
painting Refix for avoiding huge number of tiny dashes 2021-08-10 12:00:13 +02:00
platform Move QtX11Extras into QtGui as private API 2021-05-10 21:19:46 +00:00
qopengl Block flaky rhi and OpenGL tests on Android 2021-05-30 23:02:53 +02:00
qopenglconfig Remove the qmake project files 2021-01-07 15:32:28 +01:00
qvulkan vulkan: Update legacy tests and examples to the modern validation layer 2021-05-31 17:16:49 +02:00
rhi rhi: Be more graceful when one destroys a resource after the QRhi 2021-08-02 14:35:33 +02:00
text Fix bug with NoFontMerging when font does not support script 2021-08-19 13:35:40 +02:00
util QTextureFileData: support key value metadata 2021-02-09 13:39:47 +01:00
CMakeLists.txt Move QtX11Extras into QtGui as private API 2021-05-10 21:19:46 +00:00