HiDPI aware and font scaling (MSW)

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

On MSW,
VS 2022, Windows 11, wx 3.1.6
if I set my manifest to HiDPI aware,
wxSystemSettings::GetMetric(wxSYS_SCREEN_X) etc returns the full resolution screen size.
Under this manifest setting, if I use a font in wxDC to draw text,
the font gets scaled by wxWidgets or Windows I assume.
If I don't set HiDPI aware,
wxSystemSettings::GetMetric(wxSYS_SCREEN_X) etc returns a lower resolution screen size.
I assume wx or Windows scales the entire app's window in this case.

Is is possible to have the app at full resolution and not have automatic font scaling?
Perhaps I'm missing some setting somewhere?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: HiDPI aware and font scaling (MSW)

Post by doublemax »

Rohit Agarwal wrote: Thu May 12, 2022 4:15 am I assume wx or Windows scales the entire app's window in this case.
Windows does it, yes.
Rohit Agarwal wrote: Thu May 12, 2022 4:15 amIs is possible to have the app at full resolution and not have automatic font scaling?
What exactly is the issue? Font sizes can be set in pixels and points (which is dpi independent), and i would expect wxDC to obey these values (but i haven't tested it myself).
Use the source, Luke!
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

Re: HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

doublemax wrote: Thu May 12, 2022 6:28 am
Rohit Agarwal wrote: Thu May 12, 2022 4:15 am I assume wx or Windows scales the entire app's window in this case.
Windows does it, yes.
Rohit Agarwal wrote: Thu May 12, 2022 4:15 amIs is possible to have the app at full resolution and not have automatic font scaling?
What exactly is the issue? Font sizes can be set in pixels and points (which is dpi independent), and i would expect wxDC to obey these values (but i haven't tested it myself).
This is not a show-stopper for me.

When I use the HiDPI aware manifest,
I observe that whatever font size I set (using wxFontInfo( double pointSize )),
the displayed font appears to be a scaled version of the requested font
(possibly, to account for the HiDPI of the monitor?).

i.e. If I don't use HiDPI aware and set a font size
and I use HiDPI aware and set the same font size, the results are not different.
On a high res monitor, if I set HiDPI aware, I would have expected to use a much larger font size
to account for the increase in resolution.
But it appears that wx or windows is scaling the font size I dial in in the HiDPI aware setting
which I was not expecting it to do.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: HiDPI aware and font scaling (MSW)

Post by doublemax »

The behavior is expected, because the "point" size used for fonts is not in pixels, it has a unit of 1/72th inch, which means it's resolution independent. I.e. if the font size is 18 point, it should have a visible size of 0.635mm no matter on which device.
Use the source, Luke!
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

Re: HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

OK. Got it. Thanks!
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

Re: HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

FWIW,
While MSW and Linux display the requested (points-based) resolution independent sizes,
OSX for some reason displays a much smaller size.
This is likely a WXOSX implementation issue.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: HiDPI aware and font scaling (MSW)

Post by ONEEYEMAN »

Hi,
Can you try the non-wx application? TextEdit for example?

Thank you.
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

Re: HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

I ran TextEdit and looked at font size adjustments.
It does not say whether those sizes are in points or not.
But a setting of 12, which is the point-size(12.0) I'm using in my wx app
gives about the same size font as my wx app does on OSX.
It's a lot smaller than a 12.0 font on MSW or Linux.
A TextEdit font size setting of 18 gives roughly the same size
as a 12.0 font on MSW or Linux.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: HiDPI aware and font scaling (MSW)

Post by doublemax »

Are you testing on a real Mac or in a VM?
Use the source, Luke!
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

Re: HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

MacMini with 20" 1600x900 HP Monitor
Display Resolution set as Default for display.
wxSystemSettings::GetMetrics returns 1600 x 900 for the screen size
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: HiDPI aware and font scaling (MSW)

Post by doublemax »

Rohit Agarwal wrote: Fri May 20, 2022 3:58 pm MacMini with 20" 1600x900 HP Monitor
Display Resolution set as Default for display.
wxSystemSettings::GetMetrics returns 1600 x 900 for the screen size
The question is whether the OS knows the PPI of the screen. Can you see that anywhere in OSX?
Use the source, Luke!
Rohit Agarwal
Earned some good credits
Earned some good credits
Posts: 119
Joined: Wed May 19, 2021 11:17 pm
Contact:

Re: HiDPI aware and font scaling (MSW)

Post by Rohit Agarwal »

I'm guessing OSX does not know the PPI of the screen.
The only clue it has is the name of the monitor (HP 20wd),
from which it infers the default resolution.
It's connected via a DisplayPort to DVI connector.
Perhaps the protocol (in this case DVI) tells it the screen size
though I doubt that.
The PPI in this case is pretty low (~100).
So if the OS does not know and is using a default setting
it will likely assume the lowest PPI setting.
Still points to a wxMAC implementation issue.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: HiDPI aware and font scaling (MSW)

Post by ONEEYEMAN »

Hi,
You should test on the actual Mac machine with Retina display.
I don't know if Mac can get this from external monitors...

Thank you.
Post Reply