ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
ReFreezed
Party member
Posts: 230
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)

Post by ReFreezed »

Image

This is a command line program that converts a simple custom bitmap font format to BMFont (loaded with love.graphics.newFont). There is also some basic support for rasterizing TrueType fonts.

Why does this exist?

LÖVE supports two bitmap font formats: BMFont, and its own format (ImageFont, loaded with love.graphics.newImageFont).

The ImageFont format is very simple but also very limited. The BMFont format has all the necessary features for rendering fonts nicely, but its files are very user-unfriendly to edit by hand. This program tries to simplify the creation of BMFont files using a font file format that's similar to ImageFont.

The ReFreezed Bitmap Font consists of two files: an image with all the glyphs separated by a border (similar to ImageFont, but with multiple rows) and a descriptor file (.rbmf) that specifies what glyphs are in the image (but not any coordinates, unlike BMFont).

Who is this for?

If you're making bitmap fonts in an image editing program but ImageFont is too limited in what it can do, this program could be what you're looking for. There are other programs that focus on rasterizing TrueType fonts into bitmaps - this program however is focusing more on converting a more user-friendly bitmap format to BMFont.

Download .exe or .love from GitHub

See the full README for more info and documentation. Also see the code repository.

Example

Code: Select all

$ RbmfConverter.exe fontSources/coolPixelFont.rbmf --outdir fonts
Input image:

Image

Input descriptor:

Code: Select all

version=1

[in]
colored=true

[out]
fileImage=<name>.png
fileDescriptor=<name>.fnt
outlineWidth=1
outlineColor=1 0 .7 .8
glyphPadding=1
custom.lineHeight=1.25

# ASCII characters
[1]
glyphs=ABCDEFGHIJKLMNOPQRSTUVWXYZ
[2]
glyphs=abcdefghijklmnopqrstuvwxyz
[3]
glyphs=0123456789
glyphs= !#$%&'()*+,-./:;<=>[email protected][\]^_`{|}~

# Gamepad icons
[4]
icons=hatu hatr hatd hatl
icons=axislu axislr axisld axisll axisru axisrr axisrd axisrl
icons=axisbtnl axisbtnr
[5]
icons=xboxa xboxb xboxx xboxy xboxlb xboxrb xboxlt xboxrt xboxback xboxstart
icons=pst psc psx pss psl1 psr1 psl2 psr2 psselect psstart

[kerning]
# Uppercase letters:      ABCDEFGHIJKLMNOPQRSTUVWXYZ
# Small letters:          acemnorsuvwxz
# Tall lowercase letters: bdfhiklt
# Low letters:            gpqy
# Low+tall letters:       j

# f
forward=f acdefgmnopqrsuvwxyz.,_ -1

# P
forward=P .,_ -1

# T
bothways=T acemnorsuvwxzgpqy.,_ -1
forward=Lbhkt T d -1

# Vv
bothways=Vv .,_ -1

# Other
forward=r a -1
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
User avatar
ReFreezed
Party member
Posts: 230
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)

Post by ReFreezed »

Update 1.1

Changes since 1.0:
  • Outputted glyphs are packed a lot better.
  • Added [edit] parameter 'trim' for controlling trimming of transparent pixels around glyphs.
  • Added [out] parameter 'imageBounds' for controlling the dimensions of outputted images (e.g. power-of-two).
  • Added [out] parameter 'imageEncoding' for outputting other encodings than PNG.
  • Added [out] parameter 'glyphColor'.
  • Added [out] parameter 'glyphAlignment' (may be relevant for mipmaps).
  • Added [out] parameter 'transparentColorFix' for controlling the RGB values of transparent pixels.
  • Added --missing option for outputting missing characters to a file.
  • paddingAffectsRenderSpacing and outlineAffectsRenderSpacing affect outputted line height value.
  • Color parameters have more formats.
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
User avatar
ReFreezed
Party member
Posts: 230
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)

Post by ReFreezed »

Update 1.2

Changes since 1.1:
  • Added character filters for limiting what glyphs gets outputted.
  • Added [in] parameter 'imageFile' for specifying the filename of the input image.
  • Added "builtin" as a special value for the fontFile parameter.
  • Added --silent option for disabling output to stdout.
  • More filename parameters can contain variables.
  • Better error messages when encountering invalid UTF-8 data.
  • Updated examples.
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests