Unsolved Qt 5.14.2 Display wrong text in QML for android
-
I move my android application from Qt 5.13.2 to Qt 5.14.2. and found it has a problem with the wrong text display for Latin text.
So now I just strict with Qt 5.13.2 (Even I would like to use a new feature for app bundle ) but I just curious why no one has the problem with display the wrong text after the move to Qt 5.14.2.
You may notice my code below need to set the font to all text elements to display text correctly which very tedious and never happen before in the previous Qt version.I try all method from this post Wrong text display: Qt 5.14 only
and also load the font in QML and set the font to all display text but some text still displays wrong text i.e. under Menu title as below it shows "Language" as "Mbohvbhft" which seem like it displays ASCII code +1TitleMenu.qml
Menu { id: homeOptionsMenu modal: true dim: false closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape x: parent.width - width transformOrigin: Menu.TopRight Menu { title: qsTr("Languages") font: Fonts.fontDefault cascade: true modal: true dim: false closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape transformOrigin: Menu.TopLeft MenuItem { text: "ภาษาไทย" font: Fonts.fontDefault icon.source: "qrc:/images/Flags-Icon-Set/24x24/TH.png" icon.color: "transparent" onTriggered: { logic.languageChanged("th") } } MenuItem { text: "English" font: Fonts.fontDefault icon.source: "qrc:/images/Flags-Icon-Set/24x24/US.png" icon.color: "transparent" onTriggered: { logic.languageChanged("en_US") } } MenuItem { text: "中文" font: Fonts.fontDefault icon.source: "qrc:/images/Flags-Icon-Set/24x24/CN.png" icon.color: "transparent" onTriggered: { logic.languageChanged("cn") } } } MenuItem { text: qsTr("About") font: Fonts.fontDefault onTriggered: navigationIndex = aboutNavigationIndex } MenuSeparator { } MenuItem { text: qsTr("Quit") font: Fonts.fontDefault onTriggered: Qt.quit() } }
Fonts.qml
Item { readonly property font fontDefault: Qt.font({"family": fontRobotoLight.name, "pixelSize": 14}) readonly property FontLoader fontRobotoLight: FontLoader { id: fontRobotoLight source: "qrc:/fonts/Roboto-Light.ttf" } }
main.cpp
int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); qInstallMessageHandler(Utils::messageOutputHandler); QGuiApplication app(argc, argv); QFontDatabase::addApplicationFont(":/fonts/Roboto-Light.ttf"); app.setFont(QFont("Roboto Light", 12)); QQmlApplicationEngine engine; ...