bryanedds / Nu

Repository hosting the open-source Nu Game Engine and related projects.
MIT License
1.1k stars 155 forks source link

Allow Gaia to display non-english text. #541

Open reinux opened 1 year ago

reinux commented 1 year ago

EDIT BY BRYAN: We no longer experience the hang due to what we presume is a common Windows update. However, entering CJK text doesn't work because the default imgui font we use doesn't support those characters. Also, the Windows IME helper window doesn't show up in Gaia either.

Trying to type in Japanese using IME first seems to cause diacritics on Latin letters as opposed to Japanese, and then eventually causes a crash.

IMGUI seems to support IME so I'm neither worried nor in a hurry, but it might be good to at least work around it (maybe even by disabling IME) to prevent crashing.

image

bryanedds commented 1 year ago

Is there a quick way to duplicate this on a standard US keyboard?

reinux commented 1 year ago

On Windows, you can add new keyboards in the Language & region settings.

image

Once you have it installed, you can switch to Japanese on the bottom right of the Taskbar. Start + Space to switch between different keyboards, but Japanese also has a legacy English mode built in, so you may also need to do Alt + Backtick (`) to finally start typing.

After that, you can type as you normally would if you were typing Japanese in English, and then hit space for an (increasingly shoddy, AI-driven) autocomplete/autocorrect menu.

bryanedds commented 1 year ago

A couple notes:

I think SDL is also part of this input pipeline as well, since we get the text from the SDL_TEXTINPUT event.

Also, I'm using the standard, out-of-box ImGui font which I'm pretty sure only shows non-extended characters.

reinux commented 1 year ago

I think in an ideal situation it would be using fallback fonts given by the system, so that Latin/ASCII characters are rendered using ImGui's monospace font, and everything else by the system font.

Or, something that might get a lot of people excited is one of the SNES style fonts, like the 8x8px Misaki or the 10x10 and 12x12 M+ BITMAP. Both have simple and very permissive licenses:

http://mplus-fonts.osdn.jp/mplus-bitmap-fonts/index.html#license https://littlelimit.net/font.htm#license

bryanedds commented 1 year ago

This may be related - https://github.com/ocornut/imgui/issues/5535

bryanedds commented 9 months ago

Here's some additional context -

https://discourse.libsdl.org/t/can-i-use-sdl-disable-windows-ime-and-ignore-other-input-at-the-same-time-without-hacks/24468

https://github.com/Rust-SDL2/rust-sdl2/issues/1041

https://github.com/glfw/glfw/issues/41

As a workaround, I'm trying to disable windows IME in SDL2, but I'm not yet able to figure out how via SDL2-CS -

https://github.com/search?q=repo%3Aflibitijibibo%2FSDL2-CS+IME

bryanedds commented 4 months ago

whole tags of maybe related - https://github.com/ocornut/imgui/labels/ime

bryanedds commented 4 months ago

I added japanese lang support to my Windows 10 install and typed various japanese characters in Gaia, but was still unable to trigger a hang. Perhaps the OS call that led to the hang has been patched in a Windows update?

I asked rei to give me a specific japanese phrase to type so we can at least verify what seems to be a lack of hanging.