YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
21 stars 8 forks source link

Font Editor: Range values are limited to 65535, so there is no way to add emoji ranges #6320

Open KyoumaGames opened 2 months ago

KyoumaGames commented 2 months ago

Description

Noticed when trying to add a range to my font, the limit is 65535. Most emojis are in the 100,000+ range. I believe this is an old limit that should've gotten removed long ago but was forgott n about. Two reasons why.

  1. The Gamemaker manual says:

"GameMaker also has full four byte wide Unicode character support, allowing you to decode and encode Unicode characters in the upper bounds of the standard (including - but not limited to - emoji)"

  1. When trying to troubleshoot this issue, I found out arrays use to have the same limit, 65535. But that got removed. The limit for fonts probably should've gotten removed around that same time but was overlooked.

Expected Change

Limit removed for font range, or extended into the millions to actually support most emojis

Steps To Reproduce

  1. Start GameMaker
  2. Load a game project
  3. Create a font asset
  4. Open Font Editor
  5. Click Add Range
  6. Type 70,000 into one of the range boxes and watch as it default back down to 65535 when you click out of the box

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2024.4.1 (Monthly)

Which operating system(s) are you seeing the problem on?

Windows 10

Are you running GameMaker from inside your Steam library?

No

Contact Us Package Attached?

Sample Project Added?

YYDan commented 2 months ago

You can add extended ranges via font_add() at game time and draw emojis - there's nothing stopping you from doing this right now.

However, yes, https://manual.gamemaker.io/monthly/en/#t=The_Asset_Editors%2FFonts.htm does not actually document this restriction or say about needing to use font_add() at runtime to load larger fonts, so I would agree that page needs this all added, regardless of whether we change the Font Editor for this request or not.

https://manual.gamemaker.io/monthly/en/#t=GameMaker_Language%2FGML_Reference%2FAsset_Management%2FFonts%2Ffont_add.htm does talk about this already and says it's how to add Asian languages and Arabic, but does not explicitly mention this is how you would achieve emojis. Again, we could mention emojis there and better align the wording on both pages so they point to each other more when talking about limitations.

rwkay commented 2 months ago

Our current runtime is limited to 65535, we plan on rewriting the text routines in GMRT to allow unicode characters outside the 0...65535 range

KyoumaGames commented 2 months ago

So at the moment there is no actual way to add emoji support for my game? Bummer. Well, thanks for the quick responses, btw! And it's at least good to know this seems planned

cameron-home commented 1 month ago

I have looked at how font_add() works with large range values, and ranges above 65535 work for this. Having tested with Google's open source Noto Emoji font, I have found that Unicode symbols show both in GML and in the project when using large ranges. Emojis themselves are being returned as "?" in GML, and not shown in the game even when large ranges are used.

Runner_1eJGQnSCcZ GameMaker_vxf6PI23pj

font_add.zip

KyoumaGames commented 1 month ago

I have looked at how font_add() works with large range values, and ranges above 65535 work for this. Having tested with Google's open source Noto Emoji font, I have found that Unicode symbols show both in GML and in the project when using large ranges. Emojis themselves are being returned as "?" in GML, and not shown in the game even when large ranges are used. Runner_1eJGQnSCcZ GameMaker_vxf6PI23pj

font_add.zip

Yeah, it's the ability to natively type emojis on the user's side, I was wanting. Not pretyped emojis in the code. User typed emojis don't work with font_add either as mentioned above. I went ahead and found myself a workaround though, took quite the effort. Basically used FontForge to edit the font and moved all emojis from outside the 65k range to empty cells that were inside the 65k range. Then I made two array, one with all the old Unicodes and one with all the new unicodes (about 1600 entries in both), and then made it so whenever the player was typing, if an old Unicode was registered, it'd replace it with the new Unicode I set that emoji to. And it works.

rwkay commented 1 month ago

But what cameron is saying is that at runtime using font_add it will work - you just need a font that has emojis in it.

KyoumaGames commented 1 month ago

But what cameron is saying is that at runtime using font_add it will work - you just need a font that has emojis in it.

His test was using emojis added with code. Trying to type them, with a phone, in-game, they will not work. Not even with font_add. I already tried this and the devs have already confirmed this in this thread. Originally, they changed the title of my post to say that emojis could be used with font_add (in the way I am talking about), but then later edited it again to say they can't after another dev came in and said it's being bottlenecked by the runtime only supporting 65k:

"Our current runtime is limited to 65535, we plan on rewriting the text routines in GMRT to allow unicode characters outside the 0...65535 range"

"changed the title Font Editor: Range values are limited to 65535, so the only way to add ranges beyond this is font_add() at runtime to Font Editor: Range values are limited to 65535, so there is no way to add emojis in VM/YYC"

rwkay commented 1 month ago

I am the dev in question and I was wrong which is why QA went to test it out (cameron is QA here at GM)

This should work with user typed in strings as well (as long as they are encoded as UTF-8)

KyoumaGames commented 1 month ago

I am the dev in question and I was wrong which is why QA went to test it out (cameron is QA here at GM)

This should work with user typed in strings as well (as long as they are encoded as UTF-8)

Ah, my bad. I swore, I did test it with font_add with a font that used emojis, but I'll give it another try. Thanks Cameron for double checking that

KyoumaGames commented 1 month ago

So I did just try the font_add method again, and as I thought, it didn't work. It's the same issue I had with it before. The emojis are invisible. I did:

global.varFont = font_add("NotoEmoji-SemiBold.ttf", 24, true, false, 32, 1200000);

And then

draw_set_font(global.varFont);

In one screenshot, I type the peace sign, which is one of the few emojis under the 65k limit, you can see its number at the top, it's 9996, and it works. But then when I type the throw-up emoji, which is 129326, it does not get rendered. Doesn't even give the error block. It's just invisible. And as you can see from my font_add() line, I am also using Google's open source noto emoji pack.

Screenshot_20240703_122605_Created with GameMaker Screenshot_20240703_123429_Created with GameMaker

rwkay commented 1 month ago

can you create an issue with your project so we can take a look and work out what is going wrong? Cameron attached his project above - can you test that one and see if it works.

The problem may not be font related but reading the string from the keyboard.

KyoumaGames commented 1 month ago

Went ahead and downloaded Cameron's and modified it a bit to test. Added:

if !keyboard_virtual_status() { keyboard_virtual_show(kbv_type_default, kbv_returnkey_send, kbv_autocapitalize_sentences, true); }

To the step event and then in the Draw GUI event, I added:

draw_set_font(emojifont) draw_text(500, 500, string(ord(keyboard_string))); draw_text(200, 200, keyboard_string)

Those are the only changes I made and then exported it to android to test. Same result for their project (have a video of it this time). If you still need me to send mine over though, I can.

https://github.com/YoYoGames/GameMaker-Bugs/assets/173166892/91d92359-8cbb-46e7-9280-c9478163bef8

YYDan commented 4 weeks ago

I've now split this issue, as we're moving well away from what the description and title here say ;)

For all in-game stuff and using emoji keyboards, please see the issue linked immediately above.