RE: [AD] Font loadin: Feature Request

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 28 Nov 2001 at 15:38, Shawn Hargreaves wrote:

> > I think it's pretty strange that the FONT is the only data 
> > which cannot be loaded directly. 
> 
> People keep raising this as a 'problem', and I have to say,
> I've never understood why.

Well, to be honest, I think it's because most people find this:

FONT *font = load_font("font.fnt#AFONT");
 
More readable than this:

DATAFILE *dat = load_datafile_object("font.fnt", "AFONT");
FONT *font = dat->dat;
unload_datafile_object(dat);

> For one thing, what is 'not direct' about writing:
> 
>  FONT *font = load_datafile("font.dat")->dat;
> 
> If it really bothers you so much to be doing this with a
> datafile, why not just rename font.dat to font.font, and 
> #define load_datafile() to load_font()?

And then skip reading datafiles at all? :)
 
> More seriously, the reason there is no dedicated load_font()
> function is that there is no useful font format, either.
> Samples and bitmaps already have standard file formats
> that are useful for Allegro to support, but there is a lack
> of widespread font formats that match the type of bitmap
> font Allegro wants to use (sure, you can write loaders
> for things like .ttf files, but those are complicated and
> belong in addons).

Not to mention the fact that ttf loading (especially with smoothing) is 
soooo slow (if you want proof, try Allegttf). 

> So, you need some sort of conversion process to turn
> bitmaps into something that Allegro can use as a font.
> There is no point doing this at load time - wherever
> possible, it makes more sense to preconvert your data
> in an offline tool, so the runtime loader can be very
> small and simple. Hence the grabber.

> We could invent an "Allegro font" format, but that would
> be stupid because it would end up exactly the same as
> a datafile, maybe just with a different file header or
> something. There's no point doing that when a perfectly 
> suitable file format and loader code already exists...
> 

It may be stupid but it could make for controlled redundancy, iow it 
makes for easier coding, but more code to write and more files to 
maintain.

> -- 
> Shawn
> 

I suggest that you write a load_font() function, one way or another. One 
way would be to write a font structure from scratch, and a datafile-alike 
format with it. The other way would - I guess - be that you make it an 
inline function that loads a datafile, makes a FONT * point to its dat 
pointer, and unload the datafile.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/