Jump to content

Tools: Image2Fnt Converter (Atari 8-bit)


Torq

81 views

IMAGE2FNT - Converts Bit-Mapped Files to Atari 8-bit .FNT Files

 

This tool was born out of a need, or at least desire, for a quick and easy way to create character sets/fonts for some Atari 8-bit projects I'm working on - most notably my Oregon Trail homage "The Woebegone Trail".  As I talked about in this post, I tried a variety of such tools, some free, some commercial, some Atari 8-bit native, some for modern systems.  None quite worked the way I wanted them too (even though most are excellent in their own right; they scratch a slightly different itch).  So I decided to create a tool that'd let me work with essentially ANY image editor (including most of those I had just examined), save the results simple losslessly-encoded* bitmap graphic files (e.g. .GIF or .PNG etc.) and convert them to directly useable .FNT files:

 

Usage: image2fnt.py [OPTIONS] COMMAND [ARGS]...

  Converts bitmapped images to Atari 8-bit .FNT files.
  
Options: --version Show the version and exit.
         --help Show this message and exit.
         
Commands: convert Converts bitmapped images to Atari 8-bit .FNT files.
          info    Displays image metrics, color/palette data, and character layout.


As a bonus, if you then wanted to convert those .FNT files to either includable SOURCE files for your favorite Assembler, or DATA statements for your next BASIC program, you can run an earlier tool I wrote (discussed here), FNT2DATA, to do that.

 

The tool has built-in help, and I will extend the instructions, as well as add an end-to-end walkthrough of its usage sometime in the next few days.  If you have questions, feel free to ask!

 

Anyway ...

 

IMAGE2FNT will take a simple file, of either 256x32 or 128x64 pixels, such as the one below, and convert it to a .FNT file.  It can handle 1-bit per pixel (on/off or two "color") and 2-bit per pixel characters (for ANTIC modes 4 and 5, four colors), as well as deal with source images using both true 1:1 and 2:1 aspect ratio pixels.  It'll also let you use a 1:1 source aspect ratio, but in 2:1 format, and interpret it properly (for image editors that don't support different pixel aspect ratios, but where you want to draw them as such).

 

image.thumb.png.d2a161a18346c435bbc5b15caab80d79.png

 

Note: The checker-board background is from the image editing tool, and actually translates to a solid color (transparent in this case, but the ACTUAL color doesn't matter).

 

A "color" option allows you to determine which colors in the source image map to what bit pattern/output in the converted image.  And the "info" command will display the raw color values (for non-paletted images, e.g. most .PNG files) and the color indexes (and their RGB values) for paletted images (e.g. .GIF files).

 

Templates & Fonts

 

I created some initial templates for creating new character sets.  The first set are for the GIMP, as I wanted to make this available to anyone and not require paid image-editing software.  Photoshop templates will follow (but they're just 256x32 pixel images, the templates just pre-set the grids and guidelines).

 

And there are (and I will add more as I create them) additional non-blank templates and fonts in the repository as well.  These provide a point of reference for the standard Atari System Font/Character Set, so you can see "what characters go where".

 

---

 

Random Musings on Writing Tools

 

This began as a 10 line one-off/special-purpose (hard-coded paths, magic numbers, no options, etc.) Python script to convert a .PNG file I create for some ANTIC mode 4 characters.  That took about 5 minutes to write.  In doing it, I thought it would be nice to have a proper tool to do the job, support some other options, and share it.

 

By the time I had accounted for a command-line interface, options/support for 1 and 2 bits per pixel output, 1:1 and 2:1 aspect ratios, and both direct-color (RGB) and palette/indexed color formats, the overall code grew to 334 lines, two template files, two example character set builds, and a couple of hours of writing documentation.

 

The irony, for me, was the FIRST thing I wrote in my TODO: section in my notes for this tool was "KEEP IT SIMPLE!".

 

But ... it's done ... absent some edge-case testing, and creating templates for Photoshop.

 

And I'd say, while it's kept me from working on the game that necessitated writing this in the first place for 2.5 days more than I planned, it's worth it - as now I can use Photoshop, GIMP, Pixelmator, Aseprite, Pixaki, or any other of myriad tools native to macOS or iPad OS ... MUCH more fluidly than anything else I've found, and in a manner that works for my odd brain.

 

---

*It probably works with .JPG and other lossless/perceptually encoded files too - I haven't tested it that way - but the results may not be as clean.

 

 

1 Comment


Recommended Comments

I found (and fixed) an issue with this, when dealing with output that needs 2-bits per pixel (i.e. ANTIC Mode 4 characters/4-color images), which I have corrected in the linked repository.

 

I also added some other fonts I'd created/interpreted/converted.

 

 

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...