jack
New Member
Posts: 9
|
Post by jack on Sept 4, 2015 13:54:17 GMT -6
This example compiles (file cbc is created) then crashes when running with RC Basic 1.1, 1.2 and 1.2.1 :
Sub Display_Text(Text$) Ink ( rgb ( 255, 255, 255)) DrawText ( Text$, 26, 18, 20, 0) End Sub
WindowOpen ( 0,"my window", 198, 114, 285, 270,0) Window ( 0) ScreenOpen ( 0, 285, 270, 0, 0, 285,270, 0) Screen ( 0)
While Inkey()<>27 Update() Wait(10) Display_Text("My Text") Wend
|
|
|
Post by n00b on Sept 4, 2015 17:48:53 GMT -6
You have to load a font with setFont() before drawing text.
|
|
jack
New Member
Posts: 9
|
Post by jack on Sept 5, 2015 1:16:58 GMT -6
Thank you for your help. Now it runs.
In fact, my example was wrong : I did load the font by SetFont in the main program and I called DrawText in a sub-program. Now, I load the font in every sub-program before calling DrawText and it's OK.
|
|
|
Post by n00b on Sept 5, 2015 5:18:46 GMT -6
If your font never changes you should only need to call SetFont() one time. Here is a modification I made to your code:
Sub Display_Text(Text$) Ink ( rgb ( 255, 255, 255)) DrawText ( Text$, 26, 18, 20, 0) End Sub
WindowOpen ( 0,"my window", 198, 114, 285, 270,0) Window ( 0) ScreenOpen ( 0, 285, 270, 0, 0, 285,270, 0) Screen ( 0)
SetFont("FreeMono.ttf")
While Inkey()<>27 Update() Wait(10) Display_Text("My Text") Wend
This is your code but I just loaded a font before the while loop. It only loads the font once and it works just fine. Try it out.
|
|