Custom font printing routines(for 8 and 16bit modes) by me!

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Custom font printing routines(for 8 and 16bit modes) by me!

Post by Lachie Dazdarian »

I'm releasing custom font printing routines I completed 2 weeks ago. They were coded to work with GFXlib and what's most important they support both 8bit and 16bit color depth modes.

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
Where MyFont is the font array you need to declare first, 1 is the spacing and the last parameter sets the mode of pasting(PSET or TRANS). You can declare more font arrays and load more fonts in one program.

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.
Last edited by Lachie Dazdarian on Apr 26, 2006 11:09, edited 2 times in total.
Adigun A. Polack
Posts: 230
Joined: May 27, 2005 15:14
Contact:

Lachie, that is some *truly* good stuff! Well done so far!!

Post by Adigun A. Polack »

Look, as for your routines here, they are really so good (especially in 16-bit color!), I must truly say! :D And telling from your “readme” file, Lachie, apparently my soon-to-be-released game lib of AFlib2 has FINALLY inspired somebody like you to do something creative like this, you know? ^-^=b

One little problem: in the “font_demo3.bas” file and the run-time of it thereof, the original result when I first got your package was:
Image

Everything was correct in a 640x480 mode in 16-bit color, man, but both the big scrolling font and the alpha-blended equation were missing, and I can see right where the problem is indeed. Follow me as I go along. ;-)

Ok. All you have to do in the source code of “font_demo3.bas” is to remove the remark symbols ( ' ) at the beginning of only these following lines.....

Code: Select all

'LoadBFont "Fonts/24bitBFNT1.BMP", Font4, 1

Code: Select all

'PrintFont 640-xmov,140, "HUGE SCROLLING TEXT!!", Font4, 3, 1

Code: Select all

'PrintAlphaFont 135,240, "(5*2)=(7+3)", Font4, 10, sblender
....and compile it again. That way, both your translucent text and your scrollable text would show up like they are supposed to, like this:
Image

Other than that, VERY AWESOME job on your set of font routines, Lachie!!! (^_-)//
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Post by Lachie Dazdarian »

Thanx for taking the trouble to explain the overlook I made but I realized it too when I got home. I don't know how this mistake happened. Since I was already updating the archive I fixed few spelling errors and inputted the RIGHT link to GrafX2 in the readme file. Also, thanx for the kind words.

Anyway, hope someone will actually use this routine.
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Post by Lachie Dazdarian »

Sorry for bumping this thread but I made a significant update.

In the previous version I incorrectly converted the font files from 8 bit mode to 24 bit mode so the transparency with 24 bit fonts didn't work in 24 and 32 bit color depth modes but only in 16 bit. This was corrected entirely so now you can use any color depth higher and including 16 bit when loading 24 bit font files.

I apologize for all the inconveniences that the previous version may have caused.

New download(this has been changed in the original thread too): http://fileanchor.com/24909-d
Post Reply