Windows DPI awareness

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Windows DPI awareness

Post by blueznl »

Edit: Ignore this feature request. It was pretty much wrong :-)


See also here: http://www.purebasic.fr/english/viewtop ... 56#p343856

1. Font size.

Though we can compensate for changed text sizes when using different DPI settings, it's in a way silly we have to do so. Wouldn't it make more sense to keep font sizes as they are, without adjusting them to the DPI settings? (Ie. isn't it silly that the font is enlarged in higher DPI settings whilst all other elements are not?)

I suggest font size is not adjusted, or (if Windows is actually the culprit) to have PureBasic adjust it downwards properly.

I would like to have an optional parameter like #PB_DPIOLD. If set behaviour is what it is now. If left out LoadFont() shouldn't force the PureBasic programmer to mess around with GetDeviceCaps_(). Impact on existing code would be minimal, and it would make more sense for the future (see also next part).

2. DesktopWidth().

... always reports the actual screen size. Yet when dealing with high DPI settings in non XP-style DPI mode (something that will be happening more and more with increasing resolutions and Windows 7 users) one also needs the 'adjusted' screen size. Here I request the same flag #PB_DPIOLD. When passing this flag, DesktopWidth() should report the real screen size, as it does now. When leaving this flag out, it should report the adjusted width.

With these two changes there is no need to resort to WinApi when writing software for other DPI settings.
Last edited by blueznl on Fri Jan 21, 2011 9:14 am, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Windows DPI awareness

Post by Trond »

1. When people adjust DPI to get bigger fonts, it's because they can't read the smaller fonts. Scaling the fonts down again is just evil.

2. What is the adjusted width? The screen has a width in pixels and it will be the same regardless of the DPI.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Windows DPI awareness

Post by blueznl »

1. When people adjust DPI to get bigger fonts, they do not only want the fonts to increase, they need the whole GUI to upscale. Simply adjusting the font only will not improve things, in fact it will make things LESS readable. If you want to support higher DPI's read the DPI, then adjust all GUI elements accordingly. It's silly that we currently have to adjust fonts in size to keep things readable as none of the other GUI elements scale.

My request is to simplify matters for scaling issues, leaving user controlled scaling as well as automatic scaling possible. Note that Windows 7 and Windows Vista allow 'Non XP-style DPI' which takes care of all resizing without the application even being aware of it.

Which is why we need a way to deal with high DPI settings as well, so we can make the best use of available screen resolutions.

> 2. What is the adjusted width? The screen has a width in pixels and it will be the
> same regardless of the DPI.

No, that is not the case! If you have Windows 7 or Windows Vista, set your DPI to something higher than 144 and disable 'XP-style DPI' and see what happens. Suddenly the screen size reported back is smaller, which is logical as the application is upscaled to the higher DPI.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Windows DPI awareness

Post by blueznl »

And for the non-believers (scroll down to the last two images)...

http://www.xs4all.nl/~bluez/purebasic/p ... 17.htm#top
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Re: Windows DPI awareness

Post by Rescator »

Just for reference as the discussion in the thread is interesting (and relevant to this thread):
http://www.purebasic.fr/english/viewtop ... 12&t=40507
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Windows DPI awareness

Post by Trond »

After looking at your images I agree about DesktopWidth() and Height. They should return the same as GetSystemMetrics_().
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Windows DPI awareness

Post by blueznl »

Well, there's also the High DPI aware flavour, so perhaps the flag option is better...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Windows DPI awareness

Post by Trond »

blueznl wrote:Well, there's also the High DPI aware flavour, so perhaps the flag option is better...
IMO no flag is needed because either your program is running with real pixels, or it's not. If it's running with real pixels, the flag to get the "fake" width would be useless. If it's scaled behind the scenes, the flag to get the "real" width would be useless.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Windows DPI awareness

Post by blueznl »

I see what you mean. You're right, it doesn't make sense.

So, in retrospect:

- no autoscaling on a font
- desktopwidth etc. returning adjusted size
- some way to support high dpi
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Windows DPI awareness

Post by blueznl »

After thinking this over, and fooling around with code on higher DPI's, I would like to change my request to only one thing: leave the font as is, do not adjust the font to match the DPI setting as seems to be done now.

(If this is regular Windows behaviour, then boooooooo at Windows :-))
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Windows DPI awareness

Post by Trond »

blueznl wrote:(If this is regular Windows behaviour, then boooooooo at Windows :-))
This is Windows behaviour, it's not something that PB does.

By the way, font sizes are specified in points. A point is a physical unit that is 1/72th of an inch. But how does windows know what an inch is on screen? It looks on the dpi setting, which sets the number of pixels in one inch...

I hope you see that not adjusting the font to match the dpi setting would be wrong, since font sizes are indeed directly dependent on the dpi setting. If you don't want the font to change, don't change the dpi setting, it's that simple.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Windows DPI awareness

Post by blueznl »

Indeed I had a bit of a misunderstanding with the whole DPI / resize issue, partially triggered by a PureBasic bug...

I think the only thing we need is an option to be high DPI aware, and that should be it.

I'll add a page to the Survival Guide to help others avoid falling in the same trap.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply