diff --git a/widget/src/DpiCommon.cpp b/widget/src/DpiCommon.cpp index eb58e22..a000469 100644 --- a/widget/src/DpiCommon.cpp +++ b/widget/src/DpiCommon.cpp @@ -29,8 +29,6 @@ #include "Dpi/DpiCommon.h" #include -#include -#include #include namespace Dpi { @@ -40,16 +38,25 @@ int ScreenInfo::dpi() return qRound(96.0 * toNative()); } +// Qt widgets/QPainter/QFont already operate in device-independent pixels +// and scale to the physical display automatically (see +// https://doc.qt.io/qt-6/highdpi.html) - unlike the original LCL app, +// which had no such automatic scaling and needed every pixel value +// manually converted. Returning anything other than 1.0 here double- +// scales all geometry/fonts on top of Qt's own scaling (invisible at +// 100% display scaling, since multiplying by 1.0 is a no-op, but very +// visible - overlapping text, misplaced/oversized bitmaps - at any other +// scale factor, e.g. a 4K screen set to 125%). Kept as a function (not +// removed) so callers that genuinely need the physical/native pixel +// ratio in the future have one obvious, documented place to get it from. double ScreenInfo::toNative() { - QScreen *screen = QGuiApplication::primaryScreen(); - return screen ? screen->devicePixelRatio() : 1.0; + return 1.0; } double ScreenInfo::fromNative() { - const double ratio = toNative(); - return ratio != 0.0 ? 1.0 / ratio : 1.0; + return 1.0; } int scaleToNative(int value)