Drawing a text with standard windows fonts?
BlitzMax Forums/BlitzMax Programming/Drawing a text with standard windows fonts?
| ||
| How can I do that? I only know how to use image fonts. |
| ||
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
|
| ||
| 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) |
| ||
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
|
| ||
| W00t thx man... |