diff --git a/src/plugins/help/qlitehtml/container_qpainter.cpp b/src/plugins/help/qlitehtml/container_qpainter.cpp
index 3249bb4c30b..aa44428750b 100644
--- a/src/plugins/help/qlitehtml/container_qpainter.cpp
+++ b/src/plugins/help/qlitehtml/container_qpainter.cpp
@@ -505,7 +505,8 @@ void DocumentContainer::draw_text(litehtml::uint_ptr hdc,
int DocumentContainer::pt_to_px(int pt)
{
- return pt;
+ // magic factor of 11/12 to account for differences to webengine/webkit
+ return m_paintDevice->physicalDpiY() * pt * 11 / m_paintDevice->logicalDpiY() / 12;
}
int DocumentContainer::get_default_font_size() const
@@ -847,6 +848,11 @@ void DocumentContainer::get_language(litehtml::tstring &language, litehtml::tstr
Q_UNUSED(culture)
}
+void DocumentContainer::setPaintDevice(QPaintDevice *paintDevice)
+{
+ m_paintDevice = paintDevice;
+}
+
void DocumentContainer::setScrollPosition(const QPoint &pos)
{
m_scrollPosition = pos;
diff --git a/src/plugins/help/qlitehtml/container_qpainter.h b/src/plugins/help/qlitehtml/container_qpainter.h
index a1f935550f1..0d2c0425e02 100644
--- a/src/plugins/help/qlitehtml/container_qpainter.h
+++ b/src/plugins/help/qlitehtml/container_qpainter.h
@@ -29,6 +29,7 @@
#include
#include
+#include
#include
#include
#include
@@ -120,6 +121,7 @@ public:
void get_media_features(litehtml::media_features &media) const override;
void get_language(litehtml::tstring &language, litehtml::tstring &culture) const override;
+ void setPaintDevice(QPaintDevice *paintDevice);
void setDocument(const QByteArray &data, litehtml::context *context);
litehtml::document::ptr document() const;
void setScrollPosition(const QPoint &pos);
@@ -166,6 +168,7 @@ private:
QUrl resolveUrl(const QString &url, const QString &baseUrl) const;
void drawSelection(QPainter *painter, const QRect &clip) const;
+ QPaintDevice *m_paintDevice = nullptr;
litehtml::document::ptr m_document;
QString m_baseUrl;
QRect m_clientRect;
diff --git a/src/plugins/help/qlitehtml/qlitehtmlwidget.cpp b/src/plugins/help/qlitehtml/qlitehtmlwidget.cpp
index 63f4916c1ce..bcb63567592 100644
--- a/src/plugins/help/qlitehtml/qlitehtmlwidget.cpp
+++ b/src/plugins/help/qlitehtml/qlitehtmlwidget.cpp
@@ -422,6 +422,7 @@ QUrl QLiteHtmlWidget::url() const
void QLiteHtmlWidget::setHtml(const QString &content)
{
+ d->documentContainer.setPaintDevice(viewport());
d->documentContainer.setDocument(content.toUtf8(), &d->context);
verticalScrollBar()->setValue(0);
horizontalScrollBar()->setValue(0);