Fonts
- Posted by John DeHope <jwap at TAMPABAY.RR.COM> Nov 01, 1998
- 724 views
I believe that the fastest way to draw any bitmap using Euphoria (without getting into compiled sprites) is to use EMemCopy by Michael Bolin. I have implemented my own font routines. Since they are so integrated into my own code I won't bother distributing them, but I'll take a shot at explaining how my font code works. First off you need a generic blitting procedure, which is basically a wrapper for EMemCopy. It needs to be able to blit part or all of a bitmap onto another bitmap. Not too difficult. The font file can be as simple as a BMP file. I use a BMP file where each character is separated by a space (a column of color #00). To load the font you simply scan through the bitmap and when you reach a blank column make a note of the x-position and the number of columns scanned in since the last blank (the width of the current character). So the first x-position is the offset for the first character, the second x-position is the offset for the second character, and so on. The bitmap file's height is the same height as your font, so there is no need to track the y-position of each character, it is always #00. Now when you need to blit a character you simply blit a portion of your total font file. The offset is equal to the x-position you tracked during loading, the width is the width of the character (also tracked during loading). EMemCopy does this *really* fast. Simple, right? I hope this offers a clear alternative to using the pixel routine. I think RDS included it for the sake of being complete, but it has *no* place in any graphics library that even wants to dream of speed. John.