From e3f65d2346117cb895e6cc7a3f8213455b3d6eb9 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 30 Apr 2022 02:02:57 +0400 Subject: [PATCH] Convet font point size to pixel size more like Qt does in the crash reporter --- Telegram/SourceFiles/core/crash_report_window.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/core/crash_report_window.cpp b/Telegram/SourceFiles/core/crash_report_window.cpp index ca74e1b0f8..9f9f8c703d 100644 --- a/Telegram/SourceFiles/core/crash_report_window.cpp +++ b/Telegram/SourceFiles/core/crash_report_window.cpp @@ -44,17 +44,9 @@ PreLaunchWindow::PreLaunchWindow(QString title) { p.setColor(QPalette::Window, QColor(255, 255, 255)); setPalette(p); - constexpr auto processDpi = [](const QDpi &dpi) { - return (dpi.first + dpi.second) * 0.5; - }; - - const auto screen = QGuiApplication::primaryScreen(); - const auto scale = processDpi(screen->handle()->logicalDpi()) - / processDpi(screen->handle()->logicalBaseDpi()); - - auto font = QGuiApplication::font(); - font.setPixelSize(base::SafeRound(font.pointSize() * scale)); - + const auto dpi = screen()->handle()->logicalDpi().second; + auto font = this->font(); + font.setPixelSize(base::SafeRound(std::floor(font.pointSizeF() * dpi / 72. * 100. + 0.5) / 100.)); _size = QFontMetrics(font).height(); int paddingVertical = (_size / 2);