Configure font size on zoom level changes (in Windows) #824
Unanswered
akoch-yatta
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am currently working on automatic rescaling with different zoom levels on Windows (e.g. #131). I am struggling with how to adjust fonts properly, when there are different zoom levels used. I think for the system fonts (font == null) I found a proper way to handle it, but when an explicit font is set, I do not see a good solution. The main problem is how the make sure, that the font is applied correctly to each control depending on the monitor zoom. Having it refreshed when the zoom change is happening is fine, but when it is set in between, e.g. as done by the CSS SWT Engine with its own caching, fonts will be reapplied with the original size.
The obvious idea was to adapt the place, where FontData is used to create a font. In
Font.init(...)
device.computePixels
is called, which usesLOGPIXELSY
to calculate the scale factor.int pixels = -(int)(0.5f + (height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY) / 72f));
As this uses the primary monitor, this won't work in a monitor setup with different zoom levels. As there is only one instance of
Display
even with multiple monitors I don't see a way to handle it there.Second idea was to adapt Control::setFont to resize fonts if necessary. That does not sound great as well. When called, there is already a font created and should be set for this control and this could lead to the creation of a new one that needs to be managed. Additionally one would need to recalculate the font size taking the zoom of the primary monitor and the one of the controls monitor into consideration, which sounds rather complicated.
Anyone has another idea for an approach about that topic or am I missing a basic concept here?
Beta Was this translation helpful? Give feedback.
All reactions