• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

SOLVED Font scaling issue

Hey guys! I recently added text boxes into a project I'm working on. But the text is appearing MASSIVE and very pixelated for some reason. It never used to do this before the update so I'm wondering if there is some kind of command I need to use to scale it down. I'm well aware you can change the font size but this appears to be a scaling issue.
 

DaveInDev

Member
Is it possible that your room size does not equal your window size ? Then the whole window content would be scaled, and the texts too.

Try something like this at the beginning :

GML:
    view_width = window_get_width();
    view_height = window_get_height();
    surface_resize(application_surface,view_width,view_height);
    display_set_gui_size(view_width,view_height);
       
    room_width = view_width;
    room_height = view_height;
EDIT: and if your room size is deliberatly scaled, then to keep a nice text, draw it in the Draw GUI event, and use the display_set_gui_size function above.
 
Last edited:
Is it possible that your room size does not equal your window size ? Then the whole window content would be scaled, and the texts too.

Try something like this at the beginning :

GML:
    view_width = window_get_width();
    view_height = window_get_height();
    surface_resize(application_surface,view_width,view_height);
    display_set_gui_size(view_width,view_height);
      
    room_width = view_width;
    room_height = view_height;
EDIT: and if your room size is deliberatly scaled, then to keep a nice text, draw it in the Draw GUI event, and use the display_set_gui_size function above.
Hi! Thanks for replying! Is there any particular event or instance I need to place this code? Also the window size is much bigger than the room size as my sprites are very small (the character you play as is roughly 16x16 pixels). Thanks!
 

DaveInDev

Member
Hi! Thanks for replying! Is there any particular event or instance I need to place this code? Also the window size is much bigger than the room size as my sprites are very small (the character you play as is roughly 16x16 pixels). Thanks!
if you want to keep this window size bigger than the room that's fine.
Then as I said before, just draw text in the draw gui event of a special object you could call obj_display. In the Game start event of this object, you could add :
GML:
   display_set_gui_size(window_get_width(),window_get_height());
to be sure that the GUI layer will be at the same size as the window . Then text will be nice at 1:1 scale.
Put one instance of this object in the room.
 
I was actually able to factor this into my code and make it work! But now for some reason the text is appearing near the top of the screen waaaaay above my textbox. I don't know if you're familiar with friendly cosmonaut's textbox code but that's what I used for this. Thank you for your help though! I should be able to figure the rest out.
 

DaveInDev

Member
I was actually able to factor this into my code and make it work! But now for some reason the text is appearing near the top of the screen waaaaay above my textbox. I don't know if you're familiar with friendly cosmonaut's textbox code but that's what I used for this. Thank you for your help though! I should be able to figure the rest out.
you have to understand that now your room and you GUI do not have the same scale. If you want to display texts of the GUI above certains objects of the room, you will have to do some scaling conversions. This was not necessary when everything was drawn on the same surface, but hen your text were zoomed and pixelated... ;)
 
I'm not quite sure I understand (still trying to learn all the ins and outs. The manual hasn't been much help) but I'll find a solution : )
 
to understand the difference between window, room, camera, you could have a look here :

but the manual is very helpful (I know, because I started GMS 1 month ago ;) )
and
and
Loooove Friendly Cosmonaut's videos! I've seen this one before and understand the difference between views, cameras, and windows. I actually did her tutorial on asteroids (a game with much smaller sprites than mine) and I didn't have an issue with font sizes. Right now my room size is 160x144 with my camera being the same size and my viewport is 800x720 so that the player can see what they're doing. The sprites look good with these settings but I am sort of beginning to understand how the gui is affecting it.
 
For anyone who may be having the same problem I was, I discovered a function called draw_sprite_ext_transformed which allows you to control the scale of your font. Fixed the issue and now things are looking good!
 
Top