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
1 changed files with 3 additions and 11 deletions

View File

@ -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);