diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index b30a504da91df9dcab2e9bd9d584f95050ffeda7..5cca474ea17df5cb78efa2c35a1178859b97dfcc 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -59,6 +59,21 @@ static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity)
     return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);
 }
 
+static inline int qsg_device_pixel_ratio(QOpenGLContext *ctx)
+{
+    int devicePixelRatio = 1;
+    if (ctx->surface()->surfaceClass() == QSurface::Window) {
+        QWindow *w = static_cast<QWindow *>(ctx->surface());
+        if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(w))
+            devicePixelRatio = qw->effectiveDevicePixelRatio();
+        else
+            devicePixelRatio = w->devicePixelRatio();
+    } else {
+        devicePixelRatio = ctx->screen()->devicePixelRatio();
+    }
+    return devicePixelRatio;
+}
+
 class QSGTextMaskShader : public QSGMaterialShader
 {
 public:
@@ -102,6 +117,7 @@ void QSGTextMaskShader::initialize()
     m_matrix_id = program()->uniformLocation("matrix");
     m_color_id = program()->uniformLocation("color");
     m_textureScale_id = program()->uniformLocation("textureScale");
+    program()->setUniformValue("dpr", (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext()));
 }
 
 void QSGTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
@@ -351,16 +367,8 @@ void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
                         : QFontEngine::Format_A32;
         }
 
-        qreal devicePixelRatio;
-        if (ctx->surface()->surfaceClass() == QSurface::Window) {
-            QWindow *w = static_cast<QWindow *>(ctx->surface());
-            if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(w))
-                devicePixelRatio = qw->effectiveDevicePixelRatio();
-            else
-                devicePixelRatio = w->devicePixelRatio();
-        } else {
-            devicePixelRatio = ctx->screen()->devicePixelRatio();
-        }
+        qreal devicePixelRatio = qsg_device_pixel_ratio(ctx);
+
 
         QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
         if (!fontEngine->supportsTransformation(glyphCacheTransform))
diff --git a/src/quick/scenegraph/shaders/styledtext.vert b/src/quick/scenegraph/shaders/styledtext.vert
index 14fefc2564e2e92082217afb55ab2c45ceaa05a2..7001bbc2627f18ef446542c471e75845a8080d85 100644
--- a/src/quick/scenegraph/shaders/styledtext.vert
+++ b/src/quick/scenegraph/shaders/styledtext.vert
@@ -1,6 +1,7 @@
 uniform highp mat4 matrix;
 uniform highp vec2 textureScale;
 uniform highp vec2 shift;
+uniform highp float dpr;
 
 attribute highp vec4 vCoord;
 attribute highp vec2 tCoord;
@@ -12,5 +13,5 @@ void main()
 {
      sampleCoord = tCoord * textureScale;
      shiftedSampleCoord = (tCoord - shift) * textureScale;
-     gl_Position = matrix * floor(vCoord + 0.5);
+     gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr;
 }
diff --git a/src/quick/scenegraph/shaders/styledtext_core.vert b/src/quick/scenegraph/shaders/styledtext_core.vert
index 65bdb66814eb7ef9cecaef812ac00013119c63fc..c522877bb36ae0fe83631bdf2b881bb126814b48 100644
--- a/src/quick/scenegraph/shaders/styledtext_core.vert
+++ b/src/quick/scenegraph/shaders/styledtext_core.vert
@@ -9,10 +9,11 @@ out vec2 shiftedSampleCoord;
 uniform mat4 matrix;
 uniform vec2 textureScale;
 uniform vec2 shift;
+uniform float dpr;
 
 void main()
 {
      sampleCoord = tCoord * textureScale;
      shiftedSampleCoord = (tCoord - shift) * textureScale;
-     gl_Position = matrix * round(vCoord);
+     gl_Position = matrix * round(vCoord * dpr) / dpr;
 }
diff --git a/src/quick/scenegraph/shaders/textmask.vert b/src/quick/scenegraph/shaders/textmask.vert
index dd8918839eb4f50cba430d6e1576736404576a34..4c678270d0e2a89fc1dbce83887bcabdb31fb4b9 100644
--- a/src/quick/scenegraph/shaders/textmask.vert
+++ b/src/quick/scenegraph/shaders/textmask.vert
@@ -1,5 +1,6 @@
 uniform highp mat4 matrix;
 uniform highp vec2 textureScale;
+uniform highp float dpr;
 
 attribute highp vec4 vCoord;
 attribute highp vec2 tCoord;
@@ -9,5 +10,5 @@ varying highp vec2 sampleCoord;
 void main()
 {
      sampleCoord = tCoord * textureScale;
-     gl_Position = matrix * floor(vCoord + 0.5);
+     gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr;
 }
diff --git a/src/quick/scenegraph/shaders/textmask_core.vert b/src/quick/scenegraph/shaders/textmask_core.vert
index d145d331953a7cbd41c910be7f735b38b88f4742..f996040f7010813e0ff4ed4376464dca494c9c43 100644
--- a/src/quick/scenegraph/shaders/textmask_core.vert
+++ b/src/quick/scenegraph/shaders/textmask_core.vert
@@ -7,9 +7,10 @@ out vec2 sampleCoord;
 
 uniform mat4 matrix;
 uniform vec2 textureScale;
+uniform float dpr;
 
 void main()
 {
      sampleCoord = tCoord * textureScale;
-     gl_Position = matrix * round(vCoord);
+     gl_Position = matrix * round(vCoord * dpr) / dpr;
 }