Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High DPI (hidpi) support #2219

Closed
dhardy opened this issue Nov 19, 2017 · 34 comments
Closed

High DPI (hidpi) support #2219

dhardy opened this issue Nov 19, 2017 · 34 comments
Labels
Enhancement Issues that are requests for new features or changes to existing ones. UI User interface issues, including both back-end and front-end issues.

Comments

@dhardy
Copy link

dhardy commented Nov 19, 2017

Wesnoth is too small to be playable using my laptop's native screen resolution (276 DPI). It would be nice to have the option for pixel doubling or scaling of individual elements.

Currently there is a text-scaling option but it's very buggy (layout not adjusted so lots of clipping occurs), and maxes out at 150% (still small).

@sevu
Copy link
Member

sevu commented Nov 19, 2017

There's a zooming function too (I use this) with I think "ctrl" + "+", or ctrl + the button where on American layout "+" is.
However, it's buggy too.

@Vultraz Vultraz added Enhancement Issues that are requests for new features or changes to existing ones. UI User interface issues, including both back-end and front-end issues. labels Nov 19, 2017
@Vultraz
Copy link
Member

Vultraz commented Nov 19, 2017

HighDPI support sadly isn't as simple as flicking a switch. I've tried some basic implementations, but none have been completely successful. Your best bet right now is to use OS app scaling.

@CelticMinstrel
Copy link
Member

CelticMinstrel commented Dec 9, 2017

It may not be as simple as flicking a switch, but a simple "draw everything scaled up" option isn't that difficult. I recently added it to another project, and if I recall correctly it only took me about a day to do it (maybe two).

(Mind you, it's probably a bit harder in Wesnoth because it's a larger project, and it also uses SDL rather than SFML which means I'm not as sure how to do it.)

@renom
Copy link

renom commented Apr 22, 2020

Any plans to implement this?

@vgaming
Copy link
Member

vgaming commented Jun 11, 2020

Hi, I just recently started using a 4k monitor, and I'm confirming it's a pain:
2020 06 11_14:32:17ee
2020 06 11_14:32:41ee
2020 06 11_14:33:12ee

The screenshots are made on a 3840x2160 resolution, downscaled twice so one can easily see it on a 1080p monitor.

On the last picture, you can zoom in the battlefield as @sevu correctly mentions by pressing - and =, but the chat and terrain labels will not be scaled by these keyboard shortcuts.

I wasn't able to find "text scaling" configuration at all. All pictures are from wesnoth-1.14.12.

@vgaming
Copy link
Member

vgaming commented Jun 11, 2020

If there's any need for HiDPI testing - feel free to ping me, I'll try it out.

@Pentarctagon
Copy link
Member

The dpi changes that have been done by @gwhitney so far are on the master branch only, so wouldn't be in 1.14.

@vgaming
Copy link
Member

vgaming commented Jun 11, 2020

@Pentarctagon on nice! From that information I derive that it's being worked on, and gwhitney even already wrote some changes in the master branch!

@gwhitney
Copy link
Contributor

To be clear, I have not worked on comprehensive HiDPI support - certainly nothing like simply drawing everything scaled up by some factor. My efforts so far have been to incrementally make more of the UI text readable on HiDPI displays by scaling the requested text size to the same physical height regardless of the underlying pixel pitch. I have not managed to ferret out all of the different places text sizes are requested (unfortunately they're a bit scattered in the code), nor have I done any work at all on graphical elements (like the sun progressing across the sky) because those are totally outside my experience/skills. Nevertheless, I do feel like it makes a significant improvement to playability on small pixel-pitch screens, especially in combination with the experimental hi-dpi theme I posted at http://forums.wesnoth.org/viewtopic.php?p=654226#p654226 (note that with the recent code changes you do NOT need the message_font_size.lua file). If you are able to install and run from master, vgaming, would be curious to hear how these work for you.

@Frarese
Copy link

Frarese commented Jun 18, 2020

Was trying to use the theme, but I get this error reported every time the game is started:
Macro/file 'LEFT_MARGIN' is missing at <unknown>:408 included from <unknown>:16 included from ~add-ons/HiDPI/_main.cfg:801

@gwhitney
Copy link
Contributor

Two possibilities come to mind:
(1) You're not running the github master version of wesnoth, or
(2) Maybe the block of code in the theme starting from
# Also incorporate @mattsc's change (see
up to and including the next occurrence of [/lua]
needs to be deleted from the theme. I will post the version of _main.cfg without that block.

Thanks for the report and let me know if either/neither of these ideas helps. (But maybe do it in the forum where the theme file is, not in this issue report.)

@Frarese
Copy link

Frarese commented Jun 18, 2020

I confirm the problem was the [lua] block. Thank you for the quick reply

@vgaming
Copy link
Member

vgaming commented Jul 21, 2020

Today-s master branch with 4k (note the unnecessary scroll bars)
Could be unrelated from 4k.
2020 07 21_22:14:02

@gwhitney
Copy link
Contributor

Yes, well, the various small-pixel-pitch changes leave things in a state where window sizes are not as tightly controlled/pre-planned as they were when everything was based on one specific resolution. So some of the window dimensions have not caught up with these scaling possibilities, leaving occasionally scroll bars where ideally there would not be. You see above, the preferences screen ended up not quite wide enough for all of its content. Hopefully over time people will track down and iron out remaining issues like this.

@imposeren
Copy link

Today-s master branch with 4k (note the unnecessary scroll bars)
Could be unrelated from 4k.
2020 07 21_22:14:02

Tested 1.15.5 on Windows 10 with compatibility settings for DPI scaling set to "Application" and to "System":

  • No scrollbars on low-DPI ("System" scaling and game thinks resolution is 1920x1080)
  • Smooter fonts but scrollbars in preferences on high-DPI ("Application" scaling and game sees real resolution 3840x2160)

So problems is for 4k only for sure.

@renom
Copy link

renom commented Oct 24, 2020

Could anybody explain how to enable HiDPI for the git version? When I select the HiDPI theme, I don't see any changes (the game screen doesn't enlarge).

@gwhitney
Copy link
Contributor

I can only comment on the changes I've made: they don't change the size of the game screen. The game screen is resizable, and you can set your display resolution. All of the changes I have made trigger when the pixel dimensions of the game screen are large, and the pixel pitch (i.e., the physical pixel size as reported by SDL) is small. The HiDPI theme linked above enhances those changes by making more text sizes a bit larger in terms of pixels, but again, only if the preconditions are there: a game screen with large pixel dimensions and small pixel pitch. So my advice based on this is to try putting your display at its native resolution mode, resizing the game window to take up as much of the physical display as you like, and if you want to in addition, try installing the HiDPI theme linked above and choosing it, and see how you like the results.

Or of course, you can just choose a display mode with fewer pixels in each direction, so larger effective pixels, and run in a regime that doesn't use any of the changes I made. There's actually not all that much difference in the outcome, since nobody (to the best of my knowledge) has redone any or more than just a bit of the artwork to take advantage of say a 4k screen. My main motivation for the changes I made was just to not have to change the display mode for the sake of even being able to read the text in the game, not actually to take advantage of the fine pixel pitch to make the game actually look better. That would take someone with some actual artistic skill and probably quite a bit of time, neither of which I have.

Hope these remarks help.

@renom
Copy link

renom commented Oct 24, 2020

@gwhitney I tested it with the full screen mode enabled. Now I'm trying to use the window mode, but the HiDPI theme looks exactly the same as the default one (as well as when I ran the game in full screen). My screen resolution is 3840x2160.

@gwhitney
Copy link
Contributor

Yes, 3840x2160 is well into the HiDPI regime. Hmm, well, how is the legibility of the text elements of the game, especially all of the stuff in the right sidebar? Are the fonts too tiny? If you can read the information, there's not much else any of these changes would do. If your text is tiny even with the HiDPI theme selected, then something isn't quite right. Not quite sure what to suggest -- you should be able to change various parameters in the HiDPI theme and see the effects. If not, then maybe somehow Wesnoth is not really reading the theme -- although if you can see the theme to select it in the settings dialog, then there shouldn't be any problem reading the theme. Sorry I don't have any more specific advice than to just try to make sure the theme file is being read. Maybe some of the other commenters in this issue have advice to share on getting things to look a bit better in HiDPI.

@Pentarctagon
Copy link
Member

Screenshots would help more than trying to describe it, I assume. Posting the build information (see the second bullet point here) might also be useful since it contains the DPI and screen resolution that Wesnoth sees.

@renom
Copy link

renom commented Oct 25, 2020

When I start a local game, I get this error in the standard output:

error display: Theme 'proto-hi-res' not found. Trying the default theme.

But the theme is listed in the preferences and I can choose between the default and hidpi one.

@gwhitney
Copy link
Contributor

Aha, so the theme is not actually being read. On my installation, I have the _main.cfg file in ~/.local/share/wesnoth/1.15/data/add-ons/proto-hi-res -- is that the same for you, and is the directory and file readable (for whatever user id is running the wesnoth app)? Definitely seems to be some problem reading the theme.

@renom
Copy link

renom commented Oct 26, 2020

The path on my PC:

~/.local/share/wesnoth/git/data/add-ons/proto-hi-res/_main.cfg

Also I copied my wesnoth config to the 1.15 folder with cp -rf ~/.local/share/wesnoth/git ~/.local/share/wesnoth/1.15, but it didn't help.

@gwhitney
Copy link
Contributor

Well, it does seem like the files are in the right place... I wish I had another suggestion as to why wesnoth is unable to read the theme. But the error message is definitely indicating that it is not. Maybe someone else more experienced with how themes work with wesnoth could help?

Just as a temporary test, not as a long-term solution, you could try replacing the _main.cfg in the default theme with this one (if that makes sense; I think it does, but my understanding of themes is a bit hazy), to see if at least reads OK and if it has positive effects on how your display looks. If it does, then you could return to the question of how to get wesnoth to see it as a theme. Notice that where I posted it, I never packaged it up as a "real" theme or posted it anywhere, and asked for help/advice in doing so, because I don't really understand deeply how themes work and how to make a proper one. I wish I could help more, but I don't really have that experience, and I don't have time at the moment to delve deeply into this. From the discussion, it appears that others have successfully used the theme -- maybe you can reach out to them and try to compare notes on what worked?

@renom
Copy link

renom commented Feb 24, 2021

When I start a local game, I get this error in the standard output:

error display: Theme 'proto-hi-res' not found. Trying the default theme.

But the theme is listed in the preferences and I can choose between the default and hidpi one.

Just installed 1.15.10 and tried it out for hidpi support with the proto-hi-res theme. Got the same message - error display: Theme 'proto-hi-res' not found. Trying the default theme.
Has anybody got it working on 1.15.10? If so, please let me know by writing a message here, and if it's possible write what operating system you're running.
Btw, wesnoth is automatically stretched on wayland (by xwayland), at least on KDE. It's blurry though.

@gwhitney
Copy link
Contributor

Unfortunately I don't have any more ideas than when renom was reporting the same message last fall. Hopefully someone who understands how themes work better than I do can help/comment. My apologies for not having any direct advice on getting Wesnoth to see this (pseudo-)theme. (As I said, I never was able to connect with someone who could advise me on how to turn "proto-hi-res" into a "real" full-fledged theme, or what all exactly that would mean.)

@cooljeanius
Copy link
Contributor

This would help me get some of my friends/family with poorer eyesight get into Wesnoth more easily

@oldherl
Copy link

oldherl commented Aug 23, 2021

I tried 1.15.16 and that proto-hi-res theme and nothing changed. The text and buttons are just as small as the default theme. I am on KDE on Linux, 3840x2160 resolution. My KDE is configured to 2x size.

@cooljeanius
Copy link
Contributor

PR #6629 seems relevant to this issue

@vn971
Copy link
Contributor

vn971 commented Apr 18, 2022

! The linked PR aims at solving many/most problems with HiDPI! Would be good to check that by people who have HiDPI displays. Now's your prime time to help :) (I'm compiling this now as well.)

@mesilliac
Copy link
Contributor

High-DPI support via pixel scaling, with full high-dpi fonts and high-res image support, should be functionally complete in master now. The upcoming 1.17.5 dev release should be able to show it off.

I've been playing a bit with a 3840x2160 display, and from my testing everything looks great at pixel scales 2 and 3 (equivalent to native 1920x1080 and 1280x720 but with full res fonts and background images). It should also work well on innately high-dpi systems such as Apple's Retina displays.

@renom
Copy link

renom commented Jun 15, 2022

Hi @mesilliac, well done. Just tested it out, works fine 👍

@mesilliac
Copy link
Contributor

Closing this as complete.

If any issues crop up during or after 1.17.5, they can be considered bugs and new issues should be opened for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Issues that are requests for new features or changes to existing ones. UI User interface issues, including both back-end and front-end issues.
Projects
None yet
Development

No branches or pull requests