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

Retrieve DPI from get_player_information #10632

Closed
kilbith opened this issue Nov 14, 2020 · 16 comments · Fixed by #12367
Closed

Retrieve DPI from get_player_information #10632

kilbith opened this issue Nov 14, 2020 · 16 comments · Fixed by #12367
Assignees
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API

Comments

@kilbith
Copy link
Contributor

kilbith commented Nov 14, 2020

Problem: font size appears to be much bigger on Windows than on Linux with the same settings. This is problematic when a fixed font size is set on some strings using style*[], it may look good for Linux users but not on Windows or vice versa.

Solution: get the OS info from get_player_information

@v-rob @sfan5

@kilbith kilbith added the Feature request Issues that request the addition or enhancement of a feature label Nov 14, 2020
@sfan5
Copy link
Member

sfan5 commented Nov 14, 2020

What you're seeing is not about Windows, it's DPI scaling.

It'd make sense to expose screen resolution and/or DPI to get_player_information.
Or better yet, maybe some combination (window size adjusted by DPI?) so modders don't have too many variables they need to work with.

@v-rob
Copy link
Member

v-rob commented Nov 14, 2020

This is why absolutely sized fonts aren't recommended. I should have put that somewhere in lua_api.txt. If the problem can be solved with relatively sized fonts, I would say do that. However, I think I heard that there was a problem with DPI scaling or it being fixed to an arbitrary number on Windows or something, although I can't verify that for certain.

Exposing window size to the server in any way isn't a good idea because the window size can change at any time so it could get invalidated or change without the server knowing. DPI isn't likely to change, so that might be OK.

@sfan5
Copy link
Member

sfan5 commented Nov 14, 2020

However, I think I heard that there was a problem with DPI scaling or it being fixed to an arbitrary number on Windows or something

Not anymore, I fixed that in #9586.

@kilbith
Copy link
Contributor Author

kilbith commented Nov 14, 2020

This is why absolutely sized fonts aren't recommended. [...] If the problem can be solved with relatively sized fonts, I would say do that.

I mentionned above: with the same settings on both Linux or Windows. There's no Windows-specific default font size anymore. Absolute or relative sizes do not fix the issue.

@kilbith
Copy link
Contributor Author

kilbith commented Nov 15, 2020

@sfan5
Copy link
Member

sfan5 commented Nov 15, 2020

DPI scaling is implemented for both X11 and Windows and for me it behaves identically on the same hardware. If the font sizes don't match, either your configuration is different or there is another bug.

@hecktest
Copy link
Contributor

Is the DPI setting in .conf still supposed to work? It doesn't for me any more, it's stuck at 96 no matter what the value is. Maybe that's the actual problem.

As for the original request, sniffing the OS and window size is kinda creepy. I don't like when browsers do it, a block game should probably not be doing it either. This info is worthless anyway because it can be spoofed.

@hecktest
Copy link
Contributor

Alright, I just tested, and on Win 7 the game just inherits the system DPI without using the .conf setting at all.

@sfan5
Copy link
Member

sfan5 commented Nov 22, 2020

Is the DPI setting in .conf still supposed to work? It doesn't for me any more, it's stuck at 96 no matter what the value is.

It's only read as fallback, this is suboptimal I know.

@kilbith
Copy link
Contributor Author

kilbith commented Jan 25, 2021

This is why absolutely sized fonts aren't recommended.

This is the same problem with relatively sized fonts: the same font size looks different over different OSes. Moreover, font_size=+<number>/-<number> is based off the default user-set font size, not the compile-time one.

Accessing the DPI setting from get_player_information is still essential to make perfectly scaled GUIs on all setups.

@v-rob
Copy link
Member

v-rob commented Jan 25, 2021

This is why absolutely sized fonts aren't recommended.

The reason I said this is not to say that it fixes this specific problem, but because it accommodates the user. Some people don't have very good eyesight and need larger fonts, or they just prefer a smaller or larger font. By forcing a font size in a GUI, that GUI automatically doesn't accommodate those people.

In addition, even the DPI won't solve the problem. People can set their own font, like a Minecraft-esque pixelly font or a more cursive-like font, use the monospace font, or have a language that requires the fallback font. I've seen all of these myself. A GUI that works with one font won't work with the others. The fact is that it's never possible to make an absolutely-sized GUI like formspecs work with everyone's font. This is why I say that relative fonts are best. If you need big text, do something like *2. If you need small text, use *0.75. The user's font size will determine the rest.

However, this doesn't mean I'm automatically against exposing DPI information. It sounds like it could be a good idea, especially for the HUD. On the other hand, exposing the OS doesn't sound like a good idea and isn't the real root cause of the problem here.

@kilbith
Copy link
Contributor Author

kilbith commented Jan 25, 2021

People can set their own font

Then it should be also possible to know the font size in pixels. Freetype provides it: https://www.freetype.org/freetype2/docs/tutorial/step2.html

@kilbith
Copy link
Contributor Author

kilbith commented Jan 25, 2021

Also it's better to increase gui_scaling than font_size if you have poor eyesight. That way, fonts are still consistent with the rest of the GUI.

@v-rob
Copy link
Member

v-rob commented Jan 25, 2021

Also it's better to increase gui_scaling than font_size if you have poor eyesight. That way, fonts are still consistent with the rest of the GUI.

Quite true, although gui_scaling has its own problems like making the form bigger than the screen. However, there's still the problem of choosing other fonts than the default.

Then it should be also possible to know the font size in pixels.

The difficulty is that a font size in get_player_information will only apply to one font, and not a font with a different font_size. Also troublesome is the fact that formspecs are in coordinates, not pixels, and the coordinate is variable size depending on the overall size of the formspec. I'm still trying to figure out potential ways to do this for the formspec replacement as well without SSCSM, but there might not be a good way.

I'm afraid there really doesn't seem to be a good way to have GUIs work absolutely perfectly on all platforms without proper layouting and/or SSCSM, although DPI and screen size could perhaps alleviate some of the problems.

@sfan5 sfan5 changed the title Get OS info from get_player_information Retrieve DPI from get_player_information Oct 18, 2021
@sfan5 sfan5 added this to the 5.5.0 milestone Oct 18, 2021
@ExeVirus
Copy link
Contributor

So what's left to get this into a merge-able state?

@erlehmann
Copy link
Contributor

Problem: font size appears to be much bigger on Windows than on Linux with the same settings. This is problematic when a fixed font size is set on some strings using style*[], it may look good for Linux users but not on Windows or vice versa.

Solution: get the OS info from get_player_information

I believe such a facility can and will be abused in a similar way that user agent strings are.

@sfan5 sfan5 removed this from the 5.5.0 milestone Jan 27, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 21, 2022
@rubenwardy rubenwardy self-assigned this May 21, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 21, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 22, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 22, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 22, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 22, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue May 22, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue Jun 12, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue Jul 16, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue Aug 14, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue Oct 22, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue Dec 20, 2022
rubenwardy added a commit to rubenwardy/minetest that referenced this issue Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants