Re: minisphere
Reply #43 –
So I finally got Allegro loading RFN fonts, and it actually seems to work pretty well. Only issue: Apparently RFN fonts are actually stored fixed-width (including the default system font), despite vanilla Sphere rendering them variable-width--and the format supports it even! This means naively rendering characters according to their associated glyphs' widths causes the string to be spaced quite far apart. Still haven't figured out how to fix this yet.
I guess I could crop the glyph bitmaps at load time, but I'm reluctant to do so because that would mess with RFNs that were actually saved variable-width and would thus already be tuned for proper kerning, etc.
EDIT: Nevermind, ignore me, I'm an idiot. The cause of my incorrect text rendering was this brain fart here:
static int
rfn_render_char(const ALLEGRO_FONT* f, ALLEGRO_COLOR color, int ch, float x, float y)
{
rfn_font_t* rfn = f->data;
rfn_glyph_t* glyph = &rfn->glyphs[ch];
al_draw_tinted_bitmap(glyph->bitmap, color, x, y, 0x0);
return glyph->header.height; // <-- see, it's supposed to return the WIDTH of the char...
}