• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Massive slow downs when adding larg fonts

A

Asis2013

Guest
Hi,
So I'm working on a game and I'm trying to draw text using a custom font. When I add the font using font_add() with a size of 30, it works fine, but if I set the font size to something like 132 the game will start slowing down.

I was wondering if there's a way around this or simple a better way of getting larger text. Using draw_text_transformed() isn't going to work for me because it stretches the text and makes it look terrible.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
You might want to increase font texture page size using font_texture_page_size - sounds like your font just doesn't fit so GMS is spending a lot of time shuffling characters back and forth in a futile attempt to fit them.
 
A

Asis2013

Guest
You might want to increase font texture page size using font_texture_page_size - sounds like your font just doesn't fit so GMS is spending a lot of time shuffling characters back and forth in a futile attempt to fit them.
That function seams to only work in GMS 2, is there an alternative for GMS 1?
 

Mert

Member
That's because your font does not fit into one "texture page" and therefore needed to be distributed into 2 or 3 or more.. When you draw a text, Game Maker swaps another texture page to fetch the letter. Imagine the letter "L" and "A" is placed in separate pages. If you have a text like "LA LA LAND", it means that Game Maker has to swap texture pages 6 times just to draw this text.

The only alternative for you at the moment is to sacrifice performance / quality, or distribute the texture pages by yourself.

Method A : Draw your big texts(let's say 128 sized) with draw_text_transformed with 64 sized fonts. This way, you sacrifice quality for performance. Wouldn't look so weird tho.
Method B : If you big-big font uses only a set of letters. (Imagine, your font is only needed for drawing "The Last Goodnight", do only include the letters T-h-e-L-a-s-t-G-o-d-n-i-g-h-t. This way, you dramatically reduce the texture page size.
Method C : If your big font is needed in any situation(like user's nickname can be any letter), then make sure to organize your draw calls.

Code:
draw_set_font(big_font)
draw_text(x,y,first_line);
draw_text(x,y,second_line);

draw_set_font(small_font);
draw_text(x,y,first_line_answer);
//etc..
Good luck ;)
 
A

Asis2013

Guest
That's because your font does not fit into one "texture page" and therefore needed to be distributed into 2 or 3 or more.. When you draw a text, Game Maker swaps another texture page to fetch the letter. Imagine the letter "L" and "A" is placed in separate pages. If you have a text like "LA LA LAND", it means that Game Maker has to swap texture pages 6 times just to draw this text.

The only alternative for you at the moment is to sacrifice performance / quality, or distribute the texture pages by yourself.

Method A : Draw your big texts(let's say 128 sized) with draw_text_transformed with 64 sized fonts. This way, you sacrifice quality for performance. Wouldn't look so weird tho.
Method B : If you big-big font uses only a set of letters. (Imagine, your font is only needed for drawing "The Last Goodnight", do only include the letters T-h-e-L-a-s-t-G-o-d-n-i-g-h-t. This way, you dramatically reduce the texture page size.
Method C : If your big font is needed in any situation(like user's nickname can be any letter), then make sure to organize your draw calls.

Code:
draw_set_font(big_font)
draw_text(x,y,first_line);
draw_text(x,y,second_line);

draw_set_font(small_font);
draw_text(x,y,first_line_answer);
//etc..
Good luck ;)
Thanks for the reply, I need this font to work in any situation so I can't use method B, I tried method C but it still lags far too much, method A is the one I'm using until I can find something better. I would rather not sacrifice the quality if possible.
 
Top