1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GML How to use font_add to support Asian languages?

Discussion in 'Programming' started by mino_dev, Jan 18, 2019.

  1. mino_dev

    mino_dev Member

    Joined:
    Apr 20, 2018
    Posts:
    3
    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?
     
  2. mino_dev

    mino_dev Member

    Joined:
    Apr 20, 2018
    Posts:
    3
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice