AATEXT
Version 1.0 beta
designed for DJGPP and Allegro

Anti-aliased text output routines for Allegro

By Doug Eleveld, Dec 1997
D.J.Eleveld@anest.azg.nl

#include <std.disclaimer.h>

"I do not accept responsibility for any effects, adverse or
otherwise, that this code may have on you, your computer, your
sanity, your dog, and anything else that you can think of.  Use it
at your own risk."


What is AATEXT

AATEXT is a collection of functions to produce anti-aliased text
output with Allegro and DJGPP.   Antialiased text means that fonts
have 'soft' edges and blend into their backgrounds smoothly. 
Antialiased fonts are useful because the look a lot better than
non-antialiased fonts, expecially at low resolutions.

One day I saw some code that Domenic Cooney had put on his web page
to draw antialiased text. He used transparant pixels to draw the
antialiasing and I really liked what I saw.  I took his code and
made some optimizations and re-wrote a lot of it.  Now it's a quite
a bit faster in most graphic modes, especially when drawing a
filled background (i.e. Allegro's text_mode >= 0).  It's quite a
bit bigger too because there are now more than a few pretty well
optimized routnes, which are called depending on the graphic mode
colour depth and the text_mode.

AATEXT draws text in 8 bit graphic modes with 6 different
antialiasing levels.  This is also true  when Allegro's text_mode
is >=0 in any graphic mode.  When in a 15,16,24 or 32 bit graphic
mode and with text_mode is <0, then the text is drawn with 255
levels of antialiasing.

AATEXT is not very useful without Allegro since it relies on many
of Allegro's procedures.  The latest version of Allegro can always
be found on ftp://x2ftp.oulu.fi, in  /pub/msdos/programmer/djgpp2/,
and on the Allegro homepage, 
http://www.talula.demon.co.uk/allegro/.

The latest version of AATEXT is always available at:
http://huizen.dds.nl/~deleveld/index.htm  It might or might not
also be available at ftp://x2ftp.oulu.fi, in 
/pub/msdos/programmer/djgpp2/


Copyright
I think that the way Allegro for DJGPP is copyrighted is fantastic
and so I'm going to copyright AATEXT in the same way.  This is from
Allegros' readme.txt with the name Allegro exchanged with AATEXT.

AATEXT is swap-ware. You may use, modify, redistribute, and
generally hack it about in any way you like, but if you do you must
send me something in exchange. This could be a complimentary copy
of a game, an addition or improvement to AATEXT, a bug report, some
money (this is particularly encouraged if you use AATEXT in a
commercial product), or just a copy of your autoexec.bat if you
don't have anything better. If you redistribute parts of AATEXT or
make a game using it, it would be nice if you mentioned me
somewhere in the credits, but if you just want to pinch a few
routines that is OK too. I'll trust you not to rip me off.

Since this whole library was inspired by the work of Domenic
Cooney, I guess that the above copyright also applies to him.  So
if you send me anything, I'll send it to Domenic also.

Of course you must also read DJGPP's and Allegro's copyright too,
I guess.


Using AATEXT

You have to make your own antialiased fonts with the TTF2PCX
program which is available from the Allegro homepage.  Be sure to
use the maximim allowed antialiasing levels. (0-254, I think)

Since AATEXT is only useful with DJGPP and Allegro, I will assume
that you know something about compiling, linking, object files,
library files etc. 

The best way to use AATEXT is to use libaatex.a as a library and
use it during your linking process.  


AATEXT functions

void antialias_init(PALETTE pal)
This function must be called before using any of the functions in
the AATEXT library.  Pass it the palette to use when in 8 bit
colour depth.  If you are using AATEXT in another video mode, you
can use any palette that you want, and it doesn't matter.

void antialias_exit(void)
This function cleans up after the antialiased functions, releasing
any internal memory that was used.  You don't really have to call
this function because it will be done automatically at program
exit.

void aatextout(BITMAP *bmp, FONT *font, char *string, int x, int y,
int colour)
void aatextout_center(BITMAP *bmp, FONT *font, char *string, int x,
int y, int colour)
These functions are the meat and potatoes of the AATEXT library. 
It plots antialiased text on the screen just like Allegro's textout
function.  The FONT structure must contain a valid font with color
levels 0-255, which are most easily produced with the TTF2PCX
utility which is available from the Allegro homepage.

FONT* load_font (const char* filename)
This function loads an Allegro FONT structure from a file and
return a pointer to it.  Don't forget to call the Allegro procedure
destroy_font(FONT*)in order to release the memory associated with
the font.  The code for this function comes almost completely from
Allegro's grabber utility.  It is also in a seperate object file in
the libaatex.a library so unless you use this function, it won't be
included in your final executable.


Bugs

Don't know of any yet, but if you find any bugs, email me about
them.


Change log

Version 1.0 beta - Dec 1997

- Very first version


Future Work

Do you have any suggestions about what to add to AATEXT? Just
e-mail me.


In Conclusion

Why is AATEXT free?  Why are the sources freely available?  Because
I want AATEXT to be the best anti-alised text library that there
is.  When you release your source code and give away your program
for free people will use your program and look at your source code. 
When they find bugs and mistakes they'll tell you and sometimes
even fix the bugs themselves.  They couldn't do that without your
source.  The end result is that everybodys software gets better and
better.  


Thanks

I would like to thank a number of people for making AATEXT
possible:

D. J. Delorie and all the people connected with DJGPP for making
such a powerful tool available for DOS users.  It runs in 32 bit
protected mode, has got tons of virtual memory and mind boggling
optimization.  It's amazingly powerful and yet free. 

Robert Hohne and everyone connected with the extremely useful
RHIDE, an IDE for DJGPP that has the look and feel of the Borland
C++ 3.1 IDE.  One of the best IDE's I have ever used, and yet free.

Shawn Hargreaves and everyone connected with Allegro, the amazing
graphics, sound and hardware programming library for DJGPP.  Fast,
complete, easy to use, and yet free.

Domenic Cooney for producing the original code and the great idea
of producing the antialiasing by plotting pixels of different
transparancies.

Tom Burgess for letting me freely use his pentium timer macros.

Everyone at comp.os.msdos.djgpp for being patient and helpful. 
It's too bad that the other newsgroups aren't useful and as
friendly as this one.


Doug Eleveld
Herepoortenmolendrift 14
9711 DG, Groningen
The Netherlands

D.J.Eleveld@anest.azg.nl