#13852 - Xax - Tue Dec 23, 2003 9:17 pm
Does anyone know of a good way to do variable-width fonts? Is there some source out there that might help? I'm thinking I'd have to use tiles instead of sprites, considering the limit of 128 sprites (and I'd be using around 90 of those just for numbers, upper- and lower-case letters, and punctuation).
There was a demo of variable-width fonts on gbadev.org posted in Oct, but apparently it's no longer available for download.
Thanks!
#13857 - sajiimori - Tue Dec 23, 2003 11:02 pm
Regarding the original character images for a variable-width font, is there any particular reason to store them in VRAM?
#13859 - poslundc - Wed Dec 24, 2003 12:28 am
I assume you're talking about the aforementioned sprite method?
The most obvious reason is to save loading ROM or EWRAM data into VRAM whenever you want to display a string. The algorithm is easier, too: it just becomes a simple matter of having the OAM point to whichever glyph in VRAM matches the glyph in the string.
Plus if you have your font loaded in VRAM, you may not be using all of your glyphs all the time, but at least you are consuming a constant amount of memory and don't have to worry about dynamics based on the size of your string.
That said, I suppose you could write a version where you DMA the necessary font glyphs into VRAM during VBlank. I suppose it depends on how you value the tradeoff between the extra VRAM you'd gain from it versus the additional processing burden of having to load your glyphs in during VBlank. It only increases in complexity if, for example, you decide to have it only load in one of each necessary glyph (so if I print the letter "b" twice, it references the same spot in VRAM). But you could save a lot of VRAM by doing it this way.
For me, though, going the background route was a no-brainer. I'm juggling sprite VRAM all the time, and I've got a ton of scaled and double-sized sprites out there just devouring my available pixels/scanline. Meanwhile I've got about of a third of the background VRAM sitting around doing nothing. May as well put it to good use.
Dan.