Skip to content

Conversation

@AristurtleDev
Copy link
Collaborator

Description

While the BMFont file spec shows that the SpacingHoriz and SpacingVert values are bytes, and the angle code bitmap font generator does not allow setting negative spacing values, other tools like LibGDX Hiero do allow negative spacing, and users can edit the files manually.

This PR adds support to the BMFont file parsing to allow negative spacing values and also updates the rendering to take spacing into account when rendering glyphs for both horizontal and vertical spacing.

Related Issues/Tickets

Changes Made

  • Changed SpacingHoriz and SpacingVert to use sbyte as type instead of byte to allow negative values
  • Added new constructor to BitmapFont class that passes in line height, line spacing, and letter spacing
  • Updated BitmapFont.GetStringRectangle to account for line spacing
  • Property render BMFonts with letter and line spacing

Checklist

Please read and check the following items. Pull requests will not be reviewed if all items are not checked.

  • I have verified that there are no existing pull requests that would overlap with this pull request.
  • I have verified that I am following the guidelines as outlined in this project's contribution policy
  • I have verified that this pull request adheres to this project's code of conduct.
  • I have written a descriptive title for this pull request.
  • I have provided appropriate test coverage were applicable.

While the angle code bitmap font generator tool does not allow negative spacing values, its possible to set negative values when using tools like Hiero, or if the user manually edits the .fnt file.

Resolves #1074
@AristurtleDev AristurtleDev self-assigned this Nov 29, 2025
@AristurtleDev AristurtleDev merged commit 395d3bf into develop Nov 29, 2025
1 check passed
@AristurtleDev AristurtleDev deleted the fix/issue-1074-bmfont-negative-spacing branch November 29, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: BMFont spacing values are not actually used in rendering MonoGame.Extended won't load .fnt files with negative spacing

2 participants