• 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!

Mac OSX [SOLVED] Text not displaying using sprite font

D

djrain

Guest
So I added a sprite font in the created event of the first object created in the room like so:

Code:
global.myFont = font_add_sprite(s_font, ord(" "), false, 2);
And then in the draw event of my score display object I have this:

Code:
draw_set_font(global.myFont);
draw_set_color(c_white);
draw_set_halign(fa_center);
draw_text(x, y, "abc");

I have s_font added as a sprite with 94 frames each having one character (starting with space, and ordered according to the font table). However, no text is displayed. But if I set the draw font to one created through the GUI, it appears as expected. What am I doing wrong?

It may be relevant that I just purchased the mobile export (was using trial before). I thought it would work after upgrading since adding fonts through code is supposedly not supported in trial version, but now I'm just confused.
 
Last edited by a moderator:

Simon Gust

Member
Maybe it's the ord() that causes the problem.
Does
Code:
global.myFont = font_add_sprite_ext(s_font, "ABCDEFGHIJKLMNOPQ...", false, 2);
This function work where you have to map the subimages to the keys manually?
 
D

djrain

Guest
Maybe it's the ord() that causes the problem.
Does
Code:
global.myFont = font_add_sprite_ext(s_font, "ABCDEFGHIJKLMNOPQ...", false, 2);
This function work where you have to map the subimages to the keys manually?
Nope, unfortunately that doesn't work either.
 
I have just been using the font_add_sprite() and it works for me.

What version of the IDE and runtime are you using? I assume from your topic Tag you are using Mac Beta GMS 2?

Most importantly, after you upgraded, did you log out of GMS 2 using File->Logout and then login again to validate your license?

That's the only thing I can see as an issue, your code looks fine to me.
 
D

djrain

Guest
Yep, I'm on the Mac Beta.
IDE Version: 2.0.7.173
Runtime: 2.0.7.110

I did log out and in, I don't have the trial restrictions so I know that worked alright.
 
My Code that is working for me:

Create Event
Code:
global.fnt_gui = font_add_sprite(spr_gui_16x16, ord(" "), false, 0);
Draw Event:
Code:
draw_set_font(global.fnt_gui);
draw_text(4, 50, "Stars Amount");
Try changing the separation value to 0 instead of 2, see if it makes a difference.
 
D

djrain

Guest
My Code that is working for me:

Create Event
Code:
global.fnt_gui = font_add_sprite(spr_gui_16x16, ord(" "), false, 0);
Draw Event:
Code:
draw_set_font(global.fnt_gui);
draw_text(4, 50, "Stars Amount");
Try changing the separation value to 0 instead of 2, see if it makes a difference.
Thanks for the suggestion.

I was able to get it working, but I'm not completely sure what actually did it. I think the problem was that the origin got misplaced on my font image, but I'm a bit confused because I think I centered the origin before and it still wasn't showing up. Anyhow, I'm just glad to have text!
 
Top