Convert size from pixels to points for use in setPointSize (#3452)

Currently, size is computed from the QWidget geometry height in pixels and then used to set the font size in points. In many cases the result is not that bad because, depending on the screen size and resolution, the pizel size is not that far from one point. We now convert from pixels to inch (DPI) and then from inches to points (72 points/inch). This solves the problem of the text being clipped sometimes or the margin being too large.
This commit is contained in:
Michel Dagenais
2020-06-10 17:24:53 -04:00
committed by GitHub
parent df2d436a02
commit 2418d3b95b

View File

@@ -542,7 +542,7 @@ void DialWindow::resizeEvent(QResizeEvent * )
} else {
// set point size within reasonable limits for low dpi screens
int size = geometry().height()-24;
int size = (geometry().height() - 24) * 72 / logicalDpiY();
if (size <= 0) size = 4;
if (size >= 64) size = 64;