Convet font point size to pixel size more like Qt does in the crash reporter

This commit is contained in:
Ilya Fedin 2022-04-30 02:02:57 +04:00 committed by John Preston
parent 2b383a4236
commit e3f65d2346

View file

@ -44,17 +44,9 @@ PreLaunchWindow::PreLaunchWindow(QString title) {
p.setColor(QPalette::Window, QColor(255, 255, 255)); p.setColor(QPalette::Window, QColor(255, 255, 255));
setPalette(p); setPalette(p);
constexpr auto processDpi = [](const QDpi &dpi) { const auto dpi = screen()->handle()->logicalDpi().second;
return (dpi.first + dpi.second) * 0.5; auto font = this->font();
}; font.setPixelSize(base::SafeRound(std::floor(font.pointSizeF() * dpi / 72. * 100. + 0.5) / 100.));
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));
_size = QFontMetrics(font).height(); _size = QFontMetrics(font).height();
int paddingVertical = (_size / 2); int paddingVertical = (_size / 2);