Skip to content

Simple script for converting a pixel font sprite sheet into AngelCode bitmap font format.

Notifications You must be signed in to change notification settings

romadox/pxlfont

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a tool for creating simple Bitmap Fonts from a pixel art spritesheet. I use it for adding simple pixel-art fonts in Godot.

It is a Python script, so you'll need Python (and the Pillow library). After that, simply run py pxlfont.py.

This is a small implementation & assumes that positioning, letter spacing, etc. are handled within the sprite-sheet. As such, it does not manage Bitmap Font properties like offset or kerning.

Info for parsing the font can be provided via a small configuration text-file (recommended), or manually in the Python window (cumbersome).

The config file parameters are as follows:

  • name -- The font name
  • alph -- The alphabet
    • Each char in the sprite-sheet, in order.
    • No line breaks--the script will figure these out on its own.
    • No spaces, unless you are indicating a space character.
  • lheight -- Line height for this font (pixels)
  • base -- Pixels from top of line to base of glyphs (defaults to lheight)
  • width -- Character widths.
    • Separate multiple widths with commas.
    • If all chars are the same width, only 1 number is needed.
  • tail -- The amount of unused space at the end of the rows.
    • Defaults to 0.
    • Separate multiple tails with commas.
    • If all rows have the same tail size, only 1 number is needed.

(See fntcfg.txt for an example config file.)

The script will ask for the image file path, then ask if you have a config file. Alternately, you can supply these as arguments, i.e.: py pxlfont.py spritesheet.png cfg.txt.

The output is a .fnt file containing the Bitmap Font info in text format. You'll need to have the .fnt in the same folder as your spritesheet for it to work!

This uses Pillow for parsing the image file.

About

Simple script for converting a pixel font sprite sheet into AngelCode bitmap font format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages