Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
Description
I have a board using EGLFS with the eglfs_kms integration.
The physical display is 65x120mm, with a resolution of 720x1280 pixels. That's ~300dpi. The physical size is passed to Qt using the QT_QPA_EGLFS_PHYSICAL_WIDTH / HEIGHT env variables.
The problem is that, by default, EGLFS reports this resolution as a logical DPI, not just as a physical DPI. It seems that the relative code is indeed calculating this logical DPI here:
QDpi QEglFSKmsScreen::logicalDpi() const { const QSizeF ps = physicalSize(); const QSize s = geometry().size(); if (!ps.isEmpty() && !s.isEmpty()) return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); else return QDpi(100, 100); }
This causes font sizes specified in points to become N times bigger than they should be. Forcing that code to return a fake logical DPI (like 96,96) makes the font point sizes to work again. Quick hack:
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index 959f17eba3..508b02ecd8 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -160,6 +160,9 @@ QSizeF QEglFSKmsScreen::physicalSize() const QDpi QEglFSKmsScreen::logicalDpi() const { + if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_DPI_OVERRIDE")) + return QDpi(96, 96); + const QSizeF ps = physicalSize(); const QSize s = geometry().size();