2
\$\begingroup\$

Is there a way to "convert" an existing PNG file with the characters' images into a bitmap font? Basically, I want to create a FNT file using an image like this...
font image
(source: opengameart.org)

...without the access to a TTF file of the image's characters or any other typical font formats.

\$\endgroup\$
2
\$\begingroup\$

The characters in such a monospace font are ordered in increasing ASCII codepoint row-major order.

This means that you can derive the cell offset by simple arithmetic. Given the codepoint base of the top left character, the cell index col,row of a codepoint ch is:

col= (ch-base) % columns
row= (ch-base) / columns

You can then compute X and Y of the rectangle by multiplying the cell index by the width/height of a cell.

Given the computed extents of each character, you can then emit a FNT file based on the FNT specification, or try to find a FNT generator that you can provide with input regions and a bitmap.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Good to know, I wasn't aware that the characters' order is actually according to ASCII. Still, sadly, it's not enough to easily create a bitmap font out of it - is there a tool that could process such image or do I have to write an application which could generate a FNT file according to the given sheet? Guess I'll probably have to study the FNT file structure. \$\endgroup\$ – JustACluelessNewbie May 10 '14 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.