ohos: build the platform theme fonts on first request
QOhosPlatformTheme builds its fonts in its constructor, and a QFont
keeps the DPI that is current when it is created. Under QTEST_MAIN,
which sets Qt::AA_Use96Dpi only after constructing the application,
the theme fonts are therefore at the screen's 72 dpi in every test.
That is right for a QApplication test, whose widgets measure at 72,
but a system font built that way would put the application font of a
QGuiApplication test at 72 dpi while its QImage painters measure at
96, which tst_QTextDocument::task240325 fails on.
Build the fonts on the first font() request instead, through a memoizing
supplier, so no code path can read the map before it is built.
QApplication asks for its widget fonts while it is constructed, so
nothing changes there, while a QGuiApplication test asks only after the
attribute is set. The supplier holds the map through a shared pointer,
as it returns its value by copy and font() hands out pointers into the
map. As in QCoreTextFontDatabase, it is not locked: the first theme font
request is expected on the GUI thread.
Task-number: QTBUG-149732
Pick-to: 6.12
Change-Id: I0b3a30052a2bb72425ef3016087283ecc2f780de
Reviewed-by: SanthoshKumar Selvaraj <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Arkadiusz Zarębski <arkadiusz.zarebski@qt.io>