Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » [A4] Fonts VS sprite atlas

This thread is locked; no one can reply to it. rss feed Print
[A4] Fonts VS sprite atlas
larienna
Member #3,185
January 2003
avatar

I am working on a turn based GUI engine that draws a stack of windows in a buffer of characters, and then blit the final buffer onto the screen. Everything is a character, even the window frame. I was currently using FONTs for the purpose, and intended to have one font for the background+window frames and a second one for the text.

But while thinking about it, since I am using a fixed width font, I could also simply take a BITMAP and split it into sub bitmap for every characters. I am currently drawing all the glyphs in the buffer char by char. I am wondering which one is the best as both option has pro and cons:

FONT

  • Monocolored fonts and be colored on demand at runtime (It might be possible with tinted bliting)

  • Allow variable glyph width (which is useless for me)

  • Has unicode support (Currently not a priority)

BITMAP

  • Can use any bitmap editor to make the atlas (partially true with fonts).

  • Allow 16+ bit color glyph without the need of a palette.

  • Can use all 256 characters in the ASCII map.

  • Easier to make an SDL or an allegro 5 port since both libs can handle bitmaps. More universal across GL.

One solution could be to use both: BITMAP for frame and background glyphs and FONT for text glyphs.

Any other pro and cons that I missed?

Enjoy! and have fun

Niunio
Member #1,975
March 2002
avatar

Using fonts were useful in old systems (C64, ZX, MSX...) because the way they managed their video memory. Even some of these systems (or at least MSX) used the word tile in their technical documentation. Also it helped with porting (printing text routines work the same way in any system while drawing graphics doesn't).

I think today it would be better to use bitmaps. Anyway you can use a bitmap to build an Allegro text font, so who cares?

-----------------
Current projects: Allegro.pas | MinGRo

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I would use an array of sub bitmaps sized 256, then you could draw directly from the array with a char index.

Also, beware starting a gui project. I started mine in 2009 and I'm still working on it. Granted it's been through some transformations, but still.

larienna
Member #3,185
January 2003
avatar

I understand that GUI library can be intense to build. Still, it not a "Regular" GUI library, for example, there is no widgets, events, or other conventional GUI stuff. So it would be way easier make and use than for example the Allegro GUI and DeGUI. The idea is to be able to build a dialog with basically: 1) An SQL query with 2) a display format like printf. So no widgets, everything is build into a character buffer, and displayed on the screen with fixed width characters.

I am currently refactoring my Wizardry Legacy's GUI code into a stand alone GUI library, so a portion of the code, or the concepts of the GUI is already implemented. So I do not start entirely from scratch.

Both of you seems to favor BITMAP over FONT. One advantage of using FontED, is that each character was separated when editing, I wonder if FontEd can draw true color bitmap fonts. Else if I use another image editor, I would need some kind of grid to make sure characters are drawn in the right area of the bitmap. Else another idea was to draw the font into 256 separate files, then make a small tool that loads each glyph file and build a single bitmap for the font.

Enjoy! and have fun

Go to: