Full disclosure: I posted the following already on StackOverflow last week, but received no views or answers, so I am hoping I will have better luck here and nobody minds me reposting this. Thanks!
I understand that in GTK >= 3.x all metrics are in logical pixels which will be scaled by a given scale factor (e.g. env var GDK_SCALE), resulting in the actual physical pixel metrics. Unfortunately the scale factor is an integer and as such rather coarse, frequently not really fitting the given combination of screen resolution and physical screen size-- resulting in an UI that is either too large or still too small.
There is also the possibility to combine said scale factor with mere font scaling (e.g. env var GDK_DPI_SCALE) which is a fractional number. This can help to a certain extend but non-text UI elements like icons and such, will still be either too large or too small.
GTK also offers certain CSS styling features-- amongst others, metrics in different units than logical pixels like (r)em (which is based on the user’s font size). At the very least, using CSS to style the UI does add further complexity to the code and I am unsure if this is actually the recommended approach or is more targeted for developing GTK themes.
Personally, I have a 4k 27" screen, which is problematic with GTK since I cannot set the proper scale factor. So, developing a GTK app that also looks nice on all sorts of other screens, is not the easiest thing to do.
So, back to my question: Are there recommended best practices for developing resolution independent / responsive UIs with GTK/gtkmm? Should one lean towards using CSS for setting metrics and stay away from doing it through the API in logical pixels? Or is this a use-case that is not actually covered by GTK and one should simply set arbitrary pixel values for margins and such, and hope for the best that it works with other (Hi)DPI screens as well?
Thanks for any tips and hints in advance.