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...
(source: opengameart.org)
...without the access to a TTF file of the image's characters or any other typical font formats.
1 Answer
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.
-
\$\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\$– CzyzbyMay 10, 2014 at 17:21