Fix incorrect font sizes (#321)

Recently, when chasing the font size differences between the wayland and xcb Qt backends, I ended up normalizing on the wayland sizing when bypassing the backend's font metrics calculation (#272).  Unfortunately, the wayland backend was not rendering the font sizes correctly, and it was a mistake to duplicate its behavior. 

* Assume a virtual DPI of 72 pixels/in instead of 96 when compulting font size
  - Based on testing, this produces the correct font size
  - Updated reference labels.
* No longer need to scale fonts when importing glabels-3 files.
  - The glabels-3 font sizes were correct afterall!  (#306)
  - No longer need to compensate for scale factor in unit tests when importing glabels-3 files.
This commit is contained in:
Jaye Evins
2026-03-27 15:47:46 -04:00
committed by GitHub
parent 06675f8314
commit d1ee78e58a
5 changed files with 10 additions and 15 deletions
+6 -3
View File
@@ -42,13 +42,16 @@ namespace
///
/// Calculate pixel size
///
/// Assume a virtual DPI of 96 pixels/inch for all QPainter contexts.
/// Assume a virtual DPI of 72 pixels/inch for all QPainter contexts.
/// Ideally, we should use pointSizes for device independence, but as
/// Qt-6.4 on X11, Wayland, and MacOS this approach has better results.
/// of Qt-6.4, the xcb (X11) and Wayland backends will render the same
/// font differently. Currently this function is basically the unity
/// function (i.e. 1 pt = 1 pixel) with rounding, but is a placeholder
/// that may need to be tweaked for different backends.
///
int pixelSize( double pointSize )
{
const double virtual_dpi = 96;
const double virtual_dpi = 72;
return qMax( 1, qRound( pointSize * virtual_dpi/72.0 ) );
}
}