loadimagefont

BlitzMax Forums/BlitzMax Programming/loadimagefont

slenkar(Posted 2008) [#1]
Im trying to load a font called "Balthazar.TTF"
but it says 'invalid stream' meaning that it cant find the font file. I put it in the same directory as the program so i dont know why it wont work


Gabriel(Posted 2008) [#2]
I don't know how BlitzMax font loading relates to font loading in previous versions of Blitz, but in previous versions you could only load the font if the filename was the same name as the font name. With other libraries, I've even found that the filename is ignored and the font name is used instead. Some of them only load from the Windows/Fonts folder too, but I don't think this is true of BlitzMax

Double click the font, get the name of it and try using that instead. If no go, try renaming the file to match the font name. And if still no go, try putting it back in Windows/Fonts and repeat from the beginning.


SebHoll(Posted 2008) [#3]
Im trying to load a font called "Balthazar.TTF"
but it says 'invalid stream' meaning that it cant find the font file. I put it in the same directory as the program so i dont know why it wont work

Have you cut down on the no. of default modules imported (e.g. using are you using the Framework keyword)?

Also, are you doing anything special with the file? I.e. using IncBin or the ZipStream module.


Brucey(Posted 2008) [#4]
If you are using Framework, you'll need to Import BRL.FreeTypeFont

You may also need to provide the full path....


slenkar(Posted 2008) [#5]
hmm still not having any success, im not doing anything with the file or using framework

heres the code:
Local trev:TImageFont = LoadImageFont("Balthazar.TTF", 11)
SetImageFont(trev)

setimagefont returns an error (e.g. trev doesnt exist)


Gabriel(Posted 2008) [#6]
And what's the font name?


tonyg(Posted 2008) [#7]
Have you enabled a graphics mode?
Graphics 800,600
Local trev:TImageFont = LoadImageFont("Balthazar.TTF", 11) 
SetImageFont(trev) 
DrawText "Hello World",0,0
Flip
WaitKey()



slenkar(Posted 2008) [#8]
I opened it and the name was Balthazar Regular
I tried typing that in but it didnt work.

Tonyg - you solved my problem,
I didnt realize fonts were tied in with the graphics code so much, i just thought they were binary files or something.

it works now!


tonyg(Posted 2008) [#9]
The doc does mention this but 99.9% of people would type in LoadImageFont then F1F1. What you really need to do is scroll to the top of the Max2D page where it states :

Before using any of the Max2D commands, you must first create a Max2D graphics object. The easiest way to do this is using the Graphics command.


Bit cack-handed but there you go.


slenkar(Posted 2008) [#10]
oh yeah thanks


Yan(Posted 2008) [#11]
I didnt realize fonts were tied in with the graphics code so much, i just thought they were binary files or something.

loadimagefont...loadimagefont...loadIMAGEfont...

|o]


[edit]
Yes...I *am* bored... ;o)
[/edit]


slenkar(Posted 2008) [#12]
youuuu son of a.......... - you guessed it!-.......

biatcha!