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

Can't set font size in themes for BMFont/Angelcode fonts (.fnt) #80497

Closed
mhilbrunner opened this issue Aug 10, 2023 · 6 comments · Fixed by #80605
Closed

Can't set font size in themes for BMFont/Angelcode fonts (.fnt) #80497

mhilbrunner opened this issue Aug 10, 2023 · 6 comments · Fixed by #80605

Comments

@mhilbrunner
Copy link
Member

mhilbrunner commented Aug 10, 2023

Godot version

4.1

Issue description

The Normal/Bold/Italic/Bolt Italic/Mono Font Size options under Theme Override > Font Sizes do not appear to have any effect for .fnt Angelcode/BMFont bitmap fonts.

Same for outlines and probably some other theme font settings, but that makes more sense.

Steps to reproduce

  1. Use .fnt type font
  2. Try to increase font size
  3. Nothing changes
@Calinou
Copy link
Member

Calinou commented Aug 10, 2023

I can confirm this on 4.2.dev 16a9356 (on godotengine/godot-demo-projects#849).

@bruvzg
Copy link
Member

bruvzg commented Aug 11, 2023

Why is this an issue? Bitmap fonts can have only one size, and usually are pixel art fonts not intended for scaling. Besides this, a lot of bitmap fonts do not have size information, so there's no clear way to tell how exactly "size" property should affect them. Adding some sort of scaling with size will likely result in a lot of confusion and incorrectly scaled fonts.

@Calinou
Copy link
Member

Calinou commented Aug 11, 2023

Bitmap fonts can have only one size, and usually are pixel art fonts not intended for scaling.

Fonts displayed with filtering enabled can be freely scaled up and down, although they will look blurry when upscaled and pixelated when downscaled (if mipmaps aren't enabled on the texture). That said, this is also an issue when using the canvas_items stretch mode with a window size different than the base resolution. So I don't think it's that much of a problem for non-pixel art fonts.

For pixel art fonts, it's OK to scale them if using a size that is an integer multiple of the original size. We already document this caveat on the Using fonts page, so I think it would be fine to support scaling for pixel art fonts as well.

Right now, you can rely on Control scaling but it breaks within containers and will also scale the underlying StyleBox (if any).

Besides this, a lot of bitmap fonts do not have size information, so there's no clear way to tell how exactly "size" property should affect them.

For monospace image fonts, can we infer a glyph size based on the size of each character on the image? I don't know how we could handle proportional bitmap fonts though, other than using something like the height of the "x" character.

@mhilbrunner
Copy link
Member Author

mhilbrunner commented Aug 11, 2023

Why is this an issue? Bitmap fonts can have only one size, and usually are pixel art fonts not intended for scaling. Besides this, a lot of bitmap fonts do not have size information, so there's no clear way to tell how exactly "size" property should affect them. Adding some sort of scaling with size will likely result in a lot of confusion and incorrectly scaled fonts.

As Calinou outlines, I expected to be able to (up)scale pixel art fonts at least by even integers or powers of two or something. Even if results are not optimal, for prototyping that is still better than the theme size options plainly doing nothing. :)

Alternatively, if we really do not want this to be possible, the UX should be improved - those settings should be disabled or a warning should appear or any other kind of feedback.

@bruvzg
Copy link
Member

bruvzg commented Aug 11, 2023

It should be easy to enable scaling, but we should avoid the situation when user set custom font, but not font size, and it is auto-scaled (most people will likely expect it to use correct font size automatically).

@bitbrain
Copy link
Contributor

bitbrain commented Dec 4, 2023

This causes an issue for me where the default font size for bitmap fonts in Godot 4.2 seem to be wrong, causing bitmap fonts by default inside themes to be too large:

by default, font size of bitmap font in theme is set to 16, making it too large
scaling-issue

Expected: Set font size to 10 manually in the theme (this is how it looks in Godot 4.1 as well)
fontsize-10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants