Drawing a text with standard windows fonts?

BlitzMax Forums/BlitzMax Programming/Drawing a text with standard windows fonts?

Sanctus(Posted 2008) [#1]
How can I do that?
I only know how to use image fonts.


degac(Posted 2008) [#2]
Graphics 640 , 480

Local dir$ = getenv_("WINDIR") 
Print dir
Local font:timagefont = LoadImageFont(dir+"\fonts\times.ttf" , 64) 
If font
	SetImageFont font
End If

While Not AppTerminate() 
	Cls
	
	DrawText "Hallo" , 100 , 100
	
	Flip
	PollSystem
Wend
End



Sanctus(Posted 2008) [#3]
Works with ttf's too?
Now how can I get a list of all the fonts installed? (like when you try to draw with paint you have that list)


Bremer(Posted 2008) [#4]
I modified the above code to load the names of all fonts and pick one at random.

Graphics 640 , 480

SeedRnd(MilliSecs())

Local dir$ = getenv_("WINDIR")+"\fonts\"
Print dir

Local files:String[]=LoadDir(dir)

For t$=EachIn files
	Print t	
Next

Local fontcount:Int = Len(files)

Print "Number of fonts: "+fontcount

Local random:Int = Rnd(fontcount)

Print "Loading font number: "+random+" called "+files[random]

Local font:timagefont = LoadImageFont(dir+files[random] , 64) 
If font
	SetImageFont font
End If

While Not AppTerminate() 
	Cls
	
	DrawText "Hallo" , 100 , 100
	
	Flip
	PollSystem
Wend
End



Sanctus(Posted 2008) [#5]
W00t thx man...