Dynamic font change in game?

I have a game on the Nintendo Switch and it’s using a special font. Works fine BUT for languages like Japanese the text is only showing ??? question marks and not using another standard font automatically.
How can I change a font dynamically in the game? For example I can choose the language in the game but how do I manage to change the texts on screen then using another font?
Btw: The problem only occurs on device and not in the simulator.

Any help welcome!

you need to add .ttf font files in your project folder
define your fonts as variables in you code like:

english_Font = "Tahoma"
Japanese_Font = "ArbFONTS-TheSans-Bold.ttf"

current_Font = ""

Then again in your code

if Language_ID == "E" then
        current_Font  = english_Font
elseif Language_ID == "J" then
        current_Font = Japanese_Font

Finally your text object:

mainTitle = display.newText( theT, display.contentCenterX,display.contentCenterY, current_Font , 50 )

and so on

Thx for your help.

But is it possible to change a font dynamically after a display.newText object has been created?

I have a language selection menu in my game and a LOT of text already shown on screen. So when choosing Japanese on the simulator and mobile devices the system is just using a different font. But on the Nintendo Switch for example it is not… so I have to change it somehow with already existing text objects. ?

As far as i know, you can use

textBox.font = native.newFont( "Helvetica-Bold" , 16 )

but this works for input objects not text or label objects.

Normally when changing language on any system you need to restart your app or refresh your page at least

or avoid placing many titles in language selection page, just make a simple screen that displays languages, and each language can be represented by a text object with hardcoded font, or at least all of them in one English font, and other things will have a separate font like Japanese, Arabic, Indian, etc.

Thank you for your help! Much appreciated!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.