GMS 2 Resolution changing with font

Aleksander

Member
Okay so my resolution changing is working but font is blurry when higher resolution
How can I solve this problem?

HERE IS THE SCRIPT

switch(argument0){
case 0: window_set_size(800,600); break;
case 1: window_set_size(1024,768); break;
case 2: window_set_size(1280,800); break;
case 3: window_set_size(1600,900); break;
case 4: window_set_size(1920,1080); break;
}
So my goal is to change resolution with font at the same time. Anyone can help? Im really a begginer with programming
 

Aleksander

Member
yes and with it turned off it looks even worse.
I want smooth font in main menu, but with it off or on on higher resolution, the edges are really sharp and shattered
 
You'll just have to use a bigger font size and/or a different font. If you take comic sans and stretch it to 8x its original size, it probably won't look great. But if you made the font at that size in the first place, it'd look fine.

Remember that fonts are just sprites (in Game Maker) just like anything else that draws to the screen.
 

Aleksander

Member
Are you resizing the application surface or camera size, or do you want everything scaled up/down?
Im resizing the window of the game and I want to make font bigger with higher resolution
For example if screen 800x600 have font size 30, I want font size 60 if the window is 1920x1080, just a example

When Im scaling up font its becoming blurry
 

Aleksander

Member
Im aware of that. I have to idea how to write a script which will change font size based on window resolution.
I tried it a lot of times and it always ended up in crash or it wasn't working at all
 
F

FuRyvok

Guest
So, you have to make fonts with bigger letters, what it fit better to the resolution.
Code:
switch(argument0){
case 0: window_set_size(800,600);
draw_set_font(fontFor800x600);
break;
case 1: window_set_size(1024,768);
draw_set_font(fontFor1024x768);
 break;
}
 

Aleksander

Member
So, you have to make fonts with bigger letters, what it fit better to the resolution.
Code:
switch(argument0){
case 0: window_set_size(800,600);
draw_set_font(fontFor800x600);
break;
case 1: window_set_size(1024,768);
draw_set_font(fontFor1024x768);
 break;
}

I did what you told me to do but font still is only scaling up and going blurry instead of getting bigger

MY CODE:

switch(argument0){
case 0: window_set_size(800,600);
draw_set_font(MenuFont800); break;
case 1: window_set_size(1024,768);
draw_set_font(MenuFont1024); break;
case 2: window_set_size(1280,800);
draw_set_font(MenuFont1280); break;
case 3: window_set_size(1600,900);
draw_set_font(MenuFont1600); break;
case 4: window_set_size(1920,1080);
draw_set_font(MenuFont); break
}

Did I miss something?
Yes I made another fonts with diffrent sizes
 

Aleksander

Member
Okay so now it almost works
Now I have to find out why the project starts with totally diffrent font I didn't choose and changing to my font after resolution change

But thanks, now it works :D
 

TheouAegis

Member
Post the code for drawing your menu. You are probably still setting the font there. Or somewhere else, maybe.

What I wouow do is just set a global variable to the font you want to use at each resolution and use that variable in all draw_set_font() calls.

draw_set_font(global.menufont);

"Totally different font" sounds like it's usin& the default Arial 12 font.
 

Aleksander

Member
My code for DRAW GUI

if(!global.Menu) exit;

var gwidth = global.view_width, gheight = global.view_height;

var ds_grid = menu_pages[page], ds_height = ds_grid_height(ds_grid);
var y_buffer = 64, x_buffer = 32;
var start_y = (gheight/2) - ((((ds_height-1)/2) * y_buffer)), start_x = gwidth/2;

// Draw Pause Menu "BACK"
var c = c_black
draw_rectangle_color(0,0,gwidth,gheight, c,c,c,c, false);




//Draw Elements on Left Side
draw_set_valign(fa_middle);
draw_set_halign(fa_right);


//draw_set_font (MenuFont1600);
//draw_set_halign(fa_center);
draw_set_color(c_ltgray);

var ltx = start_x - x_buffer, lty;

var yy = 0; repeat(ds_height){
lty = start_y + (yy*y_buffer);
c= c_white;
xo = 0;
if(yy == menu_option[page]){
c = c_red;
xo = -(x_buffer/2);
}

draw_text_color(ltx+xo, lty, ds_grid[# 0, yy], c,c,c,c, 1);
//draw_set_color(c);
//draw_text_transformed(ltx+xo, lty, ds_grid[# 0, yy], 1+global.resolution*0.1, 1+global.resolution*0.1, 0);
yy++;}

//Draw Dividing Line
draw_line(start_x, start_y - 100, start_x, lty+y_buffer);

//Draw Elements on Right Side
draw_set_halign(fa_left);

var rtx = start_x + x_buffer, rty;

yy = 0; repeat(ds_height){
rty = start_y + (yy*y_buffer);
switch(ds_grid[# 1, yy]){

case menu_element_type.shift:
var current_val = ds_grid[# 3, yy];
var current_array = ds_grid[# 4, yy];
var left_shift = "<<";
var right_shift = ">>";

if(current_val == 0) left_shift = "";
if(current_val == array_length_1d(ds_grid[# 4, yy])-1) right_shift = "";

c = c_white;

if(inputting and yy == menu_option[page]){ c = c_yellow;}
draw_text_color(rtx, rty, left_shift+current_array[current_val]+right_shift, c,c,c,c, 1);

break;

case menu_element_type.slider:
var len = 64;
var current_array = ds_grid[# 4, yy];
var current_val = ds_grid[# 3, yy];
var circle_pos = ((current_val - current_array[0]) / (current_array[1] - current_array[0]));
c = c_white;
if(inputting and yy == menu_option[page]){ c = c_yellow;}

draw_line_width(rtx, rty, rtx +len, rty, 5);
draw_circle_color(rtx + (circle_pos*len), rty, 8, c,c, false);
draw_text_color(rtx + (len * 1.2), rty, string(floor(circle_pos*100))+"%", c,c,c,c, 1);
break;

case menu_element_type.toggle:
var current_val = ds_grid[# 3, yy];
var c1, c2;
c = c_white;
if(inputting and yy == menu_option[page]){ c = c_yellow;}
if(current_val == 0) { c1 = c; c2 = c_dkgray; }
else { c1 = c_dkgray; c2 = c; }

draw_text_color(rtx, rty, "ON", c1,c1,c1,c1, 1);
draw_text_color(rtx + 100, rty, "OFF", c2,c2,c2,c2, 1);
break;

case menu_element_type.input:
var current_val = ds_grid[# 3, yy];
var string_val;
switch(current_val){
case vk_up: string_val = "UP KEY"; break;
case vk_left: string_val = "LEFT KEY"; break;
case vk_right: string_val = "RIGHT KEY"; break;
case vk_down: string_val = "DOWN KEY"; break;
case vk_enter: string_val = "E"; break;
case vk_space: string_val = "SPACE"; break;
default: string_val = chr(current_val); break;

}

c = c_white
if(inputting and yy == menu_option[page]){ c = c_yellow;}
draw_text_color(rtx, rty, string_val, c,c,c,c, 1);

break;


}
yy++;


}

draw_set_valign(fa_top);
 

TheouAegis

Member
Hm. So that's good, more or less. All I can say is make sure you set the default font at the very start of the game. You shousld probprobably also save the window size in an INI file so youycan make it so the font and window size will be the same for the player between sessions.
 

Aleksander

Member
And here I have another problem
I set it as default font at the very start of a game in Main Menu but when its set I cant change resolution while in fullscreen. The font is stuck and I can only rescale it but not make it bigger.

But I will try to fix it somehow
 

TheouAegis

Member
Are you using the built-in fullscreen functionality? That's going to stretch everything up to fullscreen. It won't affect the window size.
 

Aleksander

Member
Are you using the built-in fullscreen functionality? That's going to stretch everything up to fullscreen. It won't affect the window size.
Im new to GMS 2 and honestly I have no idea
here is the code for fullscreen


CODE

switch(argument0){
case 0: window_set_fullscreen(false);
draw_set_font(MenuFont); break;
case 1: window_set_fullscreen(true);
draw_set_font(MenuFont); break;
}
 
Top