Download customfont.zip
These routines allow you to print strings(text) in various custom made fonts with PSET, TRANS or ALPHA(in 16bit mode; you set the alpha blender). Before using these routines you need to include a .bi file into your source. Printing is simple and looks like this:
Code: Select all
PrintFont 20, 100, "Hello world!", MyFont, 1, 1
Loading fonts is equally simple(one subroutine call). Refer to "Usage" section in the readme file.
Also, the package comes with 3 demos which are more than illustrative.
Screenshots:
http://fileanchor.com/18571-r.gif
http://fileanchor.com/18572-r.gif
Fonts are loaded from BMP files and font characters need to be drawn in a special format I devised(a grid).
This package includes 5 normal sized fonts and one extra large. 4 normal sized fonts were extracted from PP256(3 Chris Chadwick's and one mine from Ball Blazing Fantasy) while the 5th is the standard ASCII DOS font(extracted from The Griffon Legend's font file). The extra large font is around 48*47 pixels large(width depends on the character) and was extracted from Deluxe Paint II. Fell free to use them but credit the original authors(credits are in the readme file). You are encouraged to create your own fonts or modify/advance the old ones. If you create a new font and want to make it public domain email the font to me(lachie13@yahoo.com).
I'm not sure how difficult is to port this routine to some other graphics library. It uses BLOAD, GET and PUT so if that graphics library features logical substitutes for those statements it shouldn't be a problem. If you manage to do something like that email me.
The only real flaw of these routines is not the most economical memory usage. I'll copy and paste some stuff from the readme file.
These routines don't feature the most "sexiest" code, especially in the way font arrays inside the user defined type are dimensioned and in memory usage. I gave up on using pointers to store all the characters in one dimension and to calculate characters' widths from it since I suck(I did try). Anyway, VonGodric's pointers tutorial from QB Express #7 scared the $%#@ out of me.
In this version, no matter how small font is, when you load it, it will take the amount of memory the biggest possible font in that grid would.
So the memory consumption is a bit bloaty but I think ignorable in any larger project(one loaded font will take around 240 KB of memory in 8bit mode while in 16bit mode around 550 KB of memory). If you really hate this you can change 2308 in customfont.bi and line 'FontBuffer(97, 2308) AS INTEGER' to the amount needed for the fonts that will be used in your program. For example, if you are going to work in 8bit mode and only use fonts featuring characters no larger than 8*8 pixels then you should change 2308 to 68(8*8 + 4). As you see you'll save up a lot of memory.
Whatever the case is you really don't have an excuse to use the PRINT statement in your GFXlib products anymore.
I need feedback.