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

GML How to use font_add to support Asian languages?

M

mino_dev

Guest
So, I'm trying to add support for Asian languages in my game. However, the languages have so many characters that, if I just try to add the all the characters in the editor they won't fit on a texture page.

So, I want to use font_add to create a font for the languages at runtime by looking at the text they need to draw and only adding those characters to the font. But, font_add only lets you put in a start and an end point, and then returns a new font, correct? So how do I only add specific characters?

Just as an example, if I try to make a font with all the Japanese characters I need through the editor (by just passing in all the text in the game) it ranges from ~8000 to like ~65000, but it's only really using a few characters in between here and there. I don't need to add like 60000 characters to a font just to use character 9834 and 65374 next to each other, right?
 
M

mino_dev

Guest
Sorry to bump this thread, but /u/YawningDad over on reddit answered my question, and I thought I would post it here just in case this thread is found in a Google search later. Since I'm not allowed to post links yet, I'll just quote his answer here:

This is something I've been looking into as well. I recently posted a tutorial on localizing games in GameMaker, but I want to do a follow-up on handling Asian fonts in a better way. You don't have to worry about the unicode ranges when using font_add; it ignores those arguments anyway . font_add gives you access to all glyphs within the font, and it's the best way in GameMaker to properly handle Chinese or Japanese kanji. It will let you dynamically render any character within the font. One caveat: after something like 200 different characters, it has to free up its memory and start anew, meaning it can cause some performance lag. That is, when you use draw_text using your font, it can slow things down when there are more than 200 unique characters in a given string. To get around this, you can draw your strings to a surface, and then draw the surface each step to prevent performance lag.

I hope that helps. I'll post a video about this after I get my game launched. :D
I haven't implemented it in my game to see if it works, but hopefully his answer will help anyone who might have a similar question.
 
Top