How to add Japanese and Hindi characters to label/button text

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gluon

Hello, I have put some code in to change the language on my game and the code works fine for things like English, French, German etc but when I try to add characters like Japanese or Hindi it just displays a blank line on the text. I added some english characters between the words and these show up but the characters for japanese etc dont. Does anyone know what I need to do to have these characters work?

After extensive reading of the godot documentation I have found the following paragraph hidden in the fonts section

“Note: If a DynamicFont doesn’t contain a character used in a string, the character in question will be replaced with codepoint 0xfffd if it’s available in the DynamicFont. If this replacement character isn’t available in the DynamicFont, the character will be hidden without displaying any replacement character in the string.”

It seems therefore that the font I am using doesnt have these characters and the default behaviour when that is the case is to show nothing. I am currently investigating how I can change fonts in code whenever the language is changed. This is a big pain in the proverbial to be honest!

Gluon | 2021-08-08 09:58

Hi Gluon, I’ve answered your question already if you want to check it out below.
tl;dr: https://i.imgur.com/1xHTxVm.gif

Yuminous | 2021-08-08 10:13

Thanks Yuminous I appreciate that, your answer was very helpful. I have now been able to fully implement the change of languages code and it all works. Quite a pain but its all sorted. Thanks so much for your help

Gluon | 2021-08-08 10:53

I mean, I’m glad you got it sorted, but you shouldn’t need to worry about coding anything to support multiple languages.

Font array/fallbacks would allow you to drag and drop all your fonts in one place, which you could then reuse on everything. Maybe for your next project, give it a try! It should be a lot more straightforward and painless.

Yuminous | 2021-08-08 11:21

Thanks Yuminous, I wish I had known about fallbacks sooner lol. Still thanks to you I know now and maybe this thread will help someone else as well. Thanks again for all your help

Gluon | 2021-08-08 11:53

:bust_in_silhouette: Reply From: Yuminous

You need to find and use extra fonts which have those characters/glyphs.
The default font (Droid Sans) as well as the vast majority of fonts you’ll find will only support Latin characters.

There are, of course, many many which do, so the solution is to gather a selection of suitable fonts that have the glyphs you need, Noto is one such example.

Comparison of Different Fonts

An important note: very few font files that actually contain multiple writing systems in them, since the file size quickly becomes ginormous (which can affect load times).

Japanese + Latin

So you’ll need to individually pick each language family you need, apart from Latin.

enter image description here
A great resource for this is Google Fonts. Practically all of the fonts there are free for commercial use. And you can mix and match fonts as you please, as we push the actual work of figuring out which font to use onto Godot.

By using the Fallback array in your Custom Font > Dynamic Font, you can specify as many different writing systems as you need. It’s a little easier once you see it:

Multiple–Language Font

I hope that it helps!