Using Fonts in Blitz

Blitz3D Forums/Blitz3D Programming/Using Fonts in Blitz

Matty(Posted 2005) [#1]
In my game I use a particular font that is not standard to windows, ie I had to download from somewhere. In order to use it in Blitz I had to copy the font to my windows\fonts directory. Is there some way that a font can be loaded without needing the player to put the font in their windows\fonts directory and just have it in the same directory/folder as the game and load it from there. I realise I could solve this easily by just using bitmap fonts but would rather be able to just use the truetype font in blitz with the text command.


jfk EO-11110(Posted 2005) [#2]
yes, put the font file to the game folder and use it's full name to load it, eg.

Eurostar black extended.ttf

the real font name can be determined by opening the font file with a doulble click. Probably you'll have to rename to file to that name (plus .ttf).

It is a good idea to include uncommon fonts this way (not all windows versions come with the same fonts), tho I don't know how legal this s going to be. Best would be to include a selfmade ttf font.


Matty(Posted 2005) [#3]
Thanks.


John Blackledge(Posted 2005) [#4]
In addition to the above...

I also found there was a loading problem if the font was in a folder e.g. called 'fonts\' next to the main engine.
LoadFont gave no error(?), but the the font never appeared (defaulted to Arial)!

By trial and error I found that the font would load if I gave a 'fuller' path (though a drive letter was not necessary) e.g. \Projects\Game\fonts\myfont.ttf which effectively indicates the root of the drive, and the folder path upwards from there.

So make use of CurrentDir$() in building the font filename.

No other resources needed this approach!


Rook Zimbabwe(Posted 2005) [#5]
I use PNG fonts and it seems simpler than distributing a font that may be copyrighted.
RZ


_PJ_(Posted 2005) [#6]
I have always just renamed he file to match the true font name, and placed it into the root folder alongside the .exe or .bb file. Although there are still occasional problems.

I have noticed the general concensus is to use image-based fonts. Check the Code Archives for lots of help on this!


jfk EO-11110(Posted 2005) [#7]
It depends on the situation. Bitmap Fonts usually cannot b scaled nicely unless they are saved in a huge size, and kerning usually isn't solved well. (like, an "i" requires less place than an "m", so there appears a hole right after every "i"). Additionally, if you wyant to let the user choose a font, it can be very useful when he can choose any of the fonts that are installed on his machine (check the BlitzSys dll for a font requester)


Rook Zimbabwe(Posted 2005) [#8]
Or... to flagellate the obvoious... simply use the basic font set that comes with Uncle Bill's Magic Machine (Windows.)
RZ