Using Fonts

BlitzPlus Forums/BlitzPlus Programming/Using Fonts

Runtime Error(Posted 2003) [#1]
Hey kids,

Just a quick question about using different fonts in Blitz 2d.

There are a whole lot of extra fonts, and I was just wondering how to load them into a particular code?

Thanks for your time.


semar(Posted 2003) [#2]
In Blitz, a font is loaded using the LoadFont command.

But if you want to use a font that is not probably present on the target pc, then bare in mind that:

- the font has two names: one, is the file name, another is the font name.

Which is the file name, is clear. The font name, instead, is written inside the font file, and may be the same of the file name (without extention), but may be also not.

So, to use a font, make sure that you:

- provide the font with the file name being the same of the font name.
- loadfont ("font_name.ttf" (or .fon)) in blitz

So, for example, if you want to use thefont.ttf in your game, and need to distribute it, then first open the font file, and look which is the real name of the font.
If the name is the same as the file name, then no prob.
If the name is different, then rename the file name with that name.

Put the new font file in your game directory, refer to it with loadfont command - Done.

Hope this helps,
Sergio.


darklordz(Posted 2003) [#3]
I prefer Bitmapped Fonts. It's a bitmap/image with all letters and chars you'll need. Load it in as an animimage and draw the letters based on certain frames. Write a function that will parse a $ and auto draw centences.....
I wrote my own "Text" cmd in blitz....


Grisu(Posted 2003) [#4]
I also prefer BMP fonts. They are much faster than using the normal text command and are not slowed down by buggy NVidia Drivers!

If you are looking for a freeware solution take Cyberseth's FontlibV2 (includes Source and a fontmaker).

Link: http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=cyberseth05162003013142&comments=no

If you want to see how these Fonts work in action, have a look at my Cardwar program (link in signature).

P.S.:
A 3D Text Libary can be found here:
http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=gillissie01022003212523&comments=no