• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

HTML5 Simple draw_text does not work

TimVN

Member
I can't seem to get this working. I've started up GMS 1.4 for the first time in years, but this should be very easy. I'm trying to draw a simple string of text on fixed coords, but nothing shows up.

I'm typecasting the variable to a string even though it already is.
Object is visible.
It's in the draw event.
Object is placed in the room.
I've tried the Draw GUI event.

It is literally the only object in the project. What could I possible be doing wrong?
 
are you drawing the text in coordinates that are inside of the view or gui?

is your text colour the same as the background colour?

is the object doing anything else that could be preventing it from showing the text?
 
W

Wraithious

Guest
Are you using a font added in the fonts for the game? html will not draw fonts unless you specifically add them to the font resources and use them in the draw event with
draw_set_font(yourFont) ;
draw_text(x,y,"your text") ;
 

CMAllen

Member
Right. Turns out I have to set the font before it will draw anything. Thanks for your help!
Correct. HTML5 does *not* package any 'default' fonts into an application. You have to add a font to your project (and set it as the active font, obviously) before you can draw text in HTML5. When building for the windows platform, there is a 'default' windows-based font that will get packaged into an application, which is why you can draw text without specifying a font (but failing to do so can cause some quirky draw_text() behavior, so you still shouldn't do this except for development/testing purposes).
 
Top