Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
Imports BitmapFont resources from plain PNG images, aiming to implement Allegro's 'al_grab_font_from_bitmap' in Godot.See the readme for usage instructions:https://gitlab.com/snoopdouglas/abfi/-/blob/v2.0.2/README.md
abfi
Allegro Bitmap Font Importer plugin for Godot 3.2+.
abfi provides an importer for BitmapFont resources from plain PNG images. It aims to implement Allegro's al_grab_font_from_bitmap
in Godot.
This allows you to create bitmap fonts in a normal image editor, which is particularly useful for pixel fonts and such. No BMFont required.
Image format
This is heavily adapted from Allegro's documentation.
Let's explain this by example. Here's a valid (albeit tiny) PNG pixel font for the glyphs 123
and ABC
:
Now, let's look at how the importer interprets it. Here's that image scaled-up:
- The top-leftmost pixel defines the delimiter colour. Every outside pixel in the image must also be this colour.
- In the PNG above, the delimiter colour is mid-grey (
#7f7f7f
). - This shouldn't be transparent. Instead - unlike the above - your glyphs should have transparent backgrounds, because the backgrounds will be drawn too! We've just used black so you can see it on the page.
- In the PNG above, the delimiter colour is mid-grey (
- Glyphs are read in left-to-right, then top-to-bottom.
- You'll probably want to arrange the glyphs in their Unicode ordering; you'll see why below.
- Glyphs can vary in width, but must be the same height.
- Every row of glyphs must be separated by a horizontal line with the delimiter colour.
- It's fine to put as much delimiter colour padding as you like between glyphs on the same row.
Even with all of the above, the importer still doesn't know which glyphs correspond to which characters. This leads us onto...
Plugin options
Select a PNG image in the 'FileSystem' tab, then select the 'Import' tab.
Then, select 'BitmapFont (Allegro)' from the dropdown:
Each pair of strings in 'Ranges' defines an inclusive range of Unicode characters to import from the image. So, in the above screenshot, 123
and ABC
are imported - meaning these settings would correctly import the font we used as an example.
'Letter Spacing' is useful for padding out characters or pushing them together (if set to a negative value). The latter is especially useful for reducing the spacing on fonts which have an outline:
The other options (from 'Mipmaps' down) correspond to the texture creation flags.
Once everything's configured, hit 'Reimport'. Hopefully, that should be it, and you can now use your PNG as a font!
Keep an eye on the console for errors; if the image isn't correctly formatted - or your the number of glyphs specified doesn't match it - you'll be warned about it there.
Note: apologies, I'm aware the interface here is a bit janky. It doesn't seem possible to provide detailed property hints for importer options at the moment.
Development
Currently, there are no unit tests. If this plugin gets any bigger, Gut may be employed.
Release procedure
- Manually test:
- Copy
addons/abfi
into a fresh Godot project, and load the example font. - Ensure successful import for the example ranges:
1
-3
,A
-C
. - Ensure errors are shown for
2
-3
andA
-B
. - Check letter spacing works as expected (both positive and negative).
- Check each of the flags works as expected.
- Copy
- Bump the version in
addons/abfi/plugin.cfg
.- Commit with message
vX.Y.Z
. - Add a tag, also
vX.Y.Z
. - Note the commit hash.
- Commit with message
- Edit the asset, updating the commit hash.
License
Imports BitmapFont resources from plain PNG images, aiming to implement Allegro's 'al_grab_font_from_bitmap' in Godot.
See the readme for usage instructions:
https://gitlab.com/snoopdouglas/abfi/-/blob/v2.0.2/README.md
Reviews
Quick Information
Imports BitmapFont resources from plain PNG images, aiming to implement Allegro's 'al_grab_font_from_bitmap' in Godot.See the readme for usage instructions:https://gitlab.com/snoopdouglas/abfi/-/blob/v2.0.2/README.md