Use native text rendering for qml windows
authorJeremy Plsek <jeremyplsek@gmail.com>
Fri, 11 Sep 2020 00:36:28 +0000 (20:36 -0400)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Wed, 23 Sep 2020 08:00:46 +0000 (08:00 +0000)
Signed-off-by: Jeremy Plsek <jeremyplsek@gmail.com>
src/gui/main.cpp

index f4cac4b9cc8624dccf7f89f25b92a61a162cc222..f35c4ef86734bffdc86ae1819daea2f388d531d7 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <QtGlobal>
 
+#include <cmath>
 #include <csignal>
 
 #ifdef Q_OS_UNIX
@@ -34,6 +35,7 @@
 #include <QMessageBox>
 #include <QDebug>
 #include <QQuickStyle>
+#include <QQuickWindow>
 
 using namespace OCC;
 
@@ -99,6 +101,15 @@ int main(int argc, char **argv)
         return 0;
     }
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+    QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
+#else
+    // See https://bugreports.qt.io/browse/QTBUG-70481
+    if (std::fmod(app.devicePixelRatio(), 1) == 0) {
+        QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
+    }
+#endif
+
 // check a environment variable for core dumps
 #ifdef Q_OS_UNIX
     if (!qEnvironmentVariableIsEmpty("OWNCLOUD_CORE_DUMP")) {