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 import generated BMFont .fnt file. #95523

Closed
vitawrap opened this issue Aug 14, 2024 · 12 comments · Fixed by #95529
Closed

Can't import generated BMFont .fnt file. #95523

vitawrap opened this issue Aug 14, 2024 · 12 comments · Fixed by #95529

Comments

@vitawrap
Copy link

Tested versions

Tested on v4.2.2.stable.official [15073af] Forward+ and Compatibility

System information

Godot v4.2.2.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4060 Ti (NVIDIA; 31.0.15.5123) - AMD Ryzen 7 7800X3D 8-Core Processor (16 Threads)

Issue description

Importing an AngelCode BMFont seems to completely fail, no matter how much i wrangle with BMFont's export settings and presets.

For an ANSI page i get 2000+ errors of just this:

  modules/text_server_adv/text_server_adv.cpp:3281 - Condition "!_ensure_cache_for_size(fd, size)" is true.
  modules/text_server_adv/text_server_adv.cpp:1327 - Condition "p_size.x <= 0" is true. Returning: false
  modules/text_server_adv/text_server_adv.cpp:2512 - Condition "!_ensure_cache_for_size(fd, size)" is true.
  modules/text_server_adv/text_server_adv.cpp:1327 - Condition "p_size.x <= 0" is true. Returning: false
  modules/text_server_adv/text_server_adv.cpp:2544 - Condition "!_ensure_cache_for_size(fd, size)" is true.

Steps to reproduce

  • Create a new Godot project
  • Generate any font with BMFont and import it.
  • The editor freezes and throws thousands of those errors.

Minimal reproduction project (MRP)

N/A

@AThousandShips
Copy link
Member

This is very hard to debug without an example to try, please upload an MRP to test with:

  • A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).
  • Having an MRP is very important for contributors to be able to reproduce the bug in the same way that you are experiencing it. When testing a potential fix for the issue, contributors will use the MRP to validate that the fix is working as intended.
  • Drag and drop a ZIP archive to upload it (max 10 MB). Do not select another field until the project is done uploading.
  • Note for C# users: If your issue is not C#-specific, please upload a minimal reproduction project written in GDScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a .NET setup available.

@vitawrap
Copy link
Author

my bad, here's the MRP
bmtest.zip

@bruvzg
Copy link
Member

bruvzg commented Aug 14, 2024

Your font file have size=-20 set in it, which does not make sense. Not sure what it supposed to represent, which app did you use to generate it?. Remove it or set to a reasonable value (any positive) and it should work (image file in MPR is solid white, not sure if it's another issue with the font or was done deliberately).

@vitawrap
Copy link
Author

vitawrap commented Aug 14, 2024

I was using the actual BMFont software
image

but yeah I did also try to change smoothing and cell options along with the font pixel size, to no avail.
i also tried using the default "White text on black (no alpha)" preset.

@AThousandShips
Copy link
Member

Sounds like a third party issue if the original files come this way from the software, not on the Godot end

@vitawrap
Copy link
Author

vitawrap commented Aug 14, 2024

so what is a reliable way to generate a fnt for use in Godot?
The importer in Godot specifically names "AngelCode BMFont" which is this very software.

@vitawrap
Copy link
Author

Your font file have size=-20 set in it, which does not make sense. Not sure what it supposed to represent, which app did you use to generate it?. Remove it or set to a reasonable value (any positive) and it should work (image file in MPR is solid white, not sure if it's another issue with the font or was done deliberately).

interesting, i wonder if this is a crude way for the software to encode 2 different units (possibly pixels and points?)

@AThousandShips
Copy link
Member

That's not really something we can solve though regardless if we recommend it or not, so if the problem is with BMFont please report it to them

@bruvzg
Copy link
Member

bruvzg commented Aug 14, 2024

Seems like latest version of the BMFont do set negative size if you select "Match char height" (probably a new option, not sure what it is doing), so I guess we should support it. For the existing versions of Godot you should be able to simply uncheck it.

Default single channel image config should work fine with Godot:

Screenshot 2024-08-14 at 23 22 34

@vitawrap
Copy link
Author

vitawrap commented Aug 14, 2024

Oh, I was experimenting locally and figured that only the binary format was correctly parsed by godot, and yeah after testing the "Match char height" checkbox also breaks everything...

While this is probably an issue in BMFont i feel like Godot should display some more helpful errors in the importer regarding incompatible exports.

@rakkarage
Copy link
Contributor

https://www.angelcode.com/products/bmfont/doc/file_format.html

`

info

This tag holds information on how the font was generated.

face This is the name of the true type font.
size The size of the true type font.

`

the docs say that this is the size of the original font... these properties are not needed to display the font.

"This tag holds information on how the font was generated."
"The size of the true type font."

you can get the actual size of the bitmap font using the other tags that are not related to the original ttf file like lineheigt etc.

other programs (unity etc) not worry about original ttf size when displaying bmfont files idk why godot does...

#83853

@akien-mga akien-mga added this to the 4.4 milestone Aug 16, 2024
@vitawrap
Copy link
Author

Just adding to this issue because the importer also fails when the fnt file only contains "glyph" data when Godot expects "outline" data, shouldn't it attempt to pick either? (they both look the same in the generated bitmap?)

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