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

GameMaker Problem with letters not displaying evenly with draw_text_ext

B

blackhat91

Guest
Hi!

I've been wracking my brain for a couple days on this. I current have two methods to display text - one in a button form for menus, one in a message form for dialogue and the like. Messages display 100% fine, but buttons have the letters displaying almost in a wave. Example to see what I mean (shows best in "Continue" button). Weirdest part is this ONLY occurs in windowed. Fullscreen is fine (also included in the example album). All resolutions are 640x360, even full screen (i just set fullscreen to true, resolution does not change).

Today, in an effort to fix it, I redid the entire way buttons are created and displayed to more closely match the way messages are handled, but the exact same issue remains...

Here's the method buttons are created, using the title menu as an example (as the screenshots are of the same). In the create of the title menu object, the buttons are created by this call:
GML:
dx = display_get_gui_width()/2;
dy = display_get_gui_height() - GetButtonHeight() * 4 - 20;

buttons = [];
buttons[0] = DrawMenuButton(dx,dy,-1,true,GetString("newGame"),true);
buttons[1] = DrawMenuButton(dx,dy+GetButtonHeight(),-1,false,GetString("contGame"),true);
buttons[2] = DrawMenuButton(dx,dy+GetButtonHeight()*2,-1,false,GetString("gameOptions"),true);
buttons[3] = DrawMenuButton(dx,dy+GetButtonHeight()*3,-1,false,GetString("exitGame"),true);

The DrawMenuButton script:
GML:
///DrawMenuButton(x_po,y_pos,width,active?,string);
///@arg x
///@arg y
///@arg width
///@arg active
///@arg string
///@arg [center_x?]
///@arg [font]

var bx, by, act, bw, str, but, fnt, cent;

bx = argument[0];
by = argument[1];
bw = argument[2];
act = argument[3];
str = argument[4];
cent = false;
if (argument_count > 5) { cent = argument[5]; };
fnt = fntGeneral;
if (argument_count > 6) { fnt = argument[6]; };

but = instance_create_layer(bx,by,"Instances",menuButton);
with (but) {
    if (bw != -1) { bwid = bw; };
    active = act;
    text = str;
    font = fnt;
    if (cent) {
        x = x - bwid/2;
    };
};

return but;

the menuButton object only has step and draw gui events

Step:
GML:
/// @description Insert description here
// You can write your code in this editor

draw_set_font(font);

strx = x + (bwid/2 - string_width_ext(text,-1,bwid-bborder*2)/2);
stry = y + (bheight/2 - string_height(text)/2);

floor(strx);
floor(stry);

draw gui:
GML:
/// @description Insert description here
// You can write your code in this editor

//draw button
DrawWindow(x,y,bwid,bheight,active);

//draw text
if (active) { draw_set_color(c_white); draw_set_alpha(1); } else { draw_set_color(c_gray); draw_set_alpha(0.5);};

draw_set_font(font);
draw_text(strx,stry,text);

draw_set_color(c_white);
draw_set_alpha(1);

Anyone have any ideas what I'm doing wrong here?
 
Last edited by a moderator:

Sirham

Member
Didn't even know it supported interpolation, so probably not, unless its on by default :D
GMS1 it's on by default for whatever reason. So I'd assume it'd be for GMS2 I don't have GMS2 on this machine yet so I can't check for myself.
 
B

blackhat91

Guest
GMS1 it's on by default for whatever reason. So I'd assume it'd be for GMS2 I don't have GMS2 on this machine yet so I can't check for myself.
Thanks! Checked, and the setting is mine is unchecked and everything I can find says it off by default, so I think I'm good there?
 

Sirham

Member
Thanks! Checked, and the setting is mine is unchecked and everything I can find says it off by default, so I think I'm good there?
Yeah if it's off then you're good there. I haven't run into this before other than that.

Something with the font perhaps?
 
Does it happen with all fonts? I've run into this issue a few times but have never managed to find a true solution to it. The same thing can happen when drawing text using draw_text_ext with a scaling factor of 1, the text draws with some slight distortion that does not appear if the line is replaced with draw_text (even though drawing at a scale of 1 SHOULD be exactly the same as not using draw_text_ext). I've found that some fonts are much worse than others and some fonts don't display the problem at all (in the same way that some fonts have really bizarre scalings for line height and things like that that generally require magic numbers to fix alignment).
 
B

blackhat91

Guest
Does it happen with all fonts? I've run into this issue a few times but have never managed to find a true solution to it. The same thing can happen when drawing text using draw_text_ext with a scaling factor of 1, the text draws with some slight distortion that does not appear if the line is replaced with draw_text (even though drawing at a scale of 1 SHOULD be exactly the same as not using draw_text_ext). I've found that some fonts are much worse than others and some fonts don't display the problem at all (in the same way that some fonts have really bizarre scalings for line height and things like that that generally require magic numbers to fix alignment).
Yeah if it's off then you're good there. I haven't run into this before other than that.

Something with the font perhaps?
I'm not sure if it's something with the font, but that does seem to affect it. The one I used initially was Arial Bold. Changing it to others (Courier, Garamond, etc, all bold) has a more or less noticeable effect. Garamond is the closest to not having an issue. Is it a bug with GM displaying certain fonts maybe?
 

Bart

WiseBart
I haven't experienced this issue myself yet, but some things that may be worth looking into:
  • How does the font look on the texture page? Are the letters aligned there? You should be able to check that by generating a preview of the textures. Or by using the debugger (if I'm not mistaken).
  • If that looks alright you could also have a look at the font options.
  • If you disable blending using gpu_set_blendenable you can see the actual bounding boxes of the letters. Maybe there's something going on there.
Not sure if any of these will help but they could give a bit more insight in what is going on behind the scenes.
 
B

blackhat91

Guest
I haven't experienced this issue myself yet, but some things that may be worth looking into:
  • How does the font look on the texture page? Are the letters aligned there? You should be able to check that by generating a preview of the textures. Or by using the debugger (if I'm not mistaken).
  • If that looks alright you could also have a look at the font options.
  • If you disable blending using gpu_set_blendenable you can see the actual bounding boxes of the letters. Maybe there's something going on there.
Not sure if any of these will help but they could give a bit more insight in what is going on behind the scenes.
Thanks! This actually does make me think its a bug.

Using arial again (which was the original font I was having issues with), I messed with the font options and the only thing that fixed it was disabling scaling. Unfortunately, that means I can't set the font's size under presets (or anywhere else), so that doesn't fix my problem (the "unscaled" font is a bit bigger than 20pt I'm using), but does reassure me that its not a bug I created!

I'm going to report this bug and hopefully it'll be fixed in the future. A bit annoying but I can just use another font that doesn't have this issue for now (like Georgia).
 
Top