Can I set localized fonts differently?

Announcements, support questions, and discussion for the Dialogue System.
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

Can I set localized fonts differently?

Post by minomod »

Currently, all national language fonts are used the same.

Can I set localized fonts differently?

English = A font
Chinese = B font
Korea = C font
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I set localized fonts differently?

Post by Tony Li »

It's not built in, but it's an excellent idea. The Dialogue System uses Text Table assets for non-dialogue database text. I'll add a feature so that you can assign a font to each language defined in the Text Table. Dialogue UIs and LocalizeUI components (for non-dialogue text) will then be able to automatically check the Text Table and make sure they use the correct font for the current language.

If this feature doesn't get into version 2.2.5, I'll try to get it into 2.2.6.

In the meantime, you could write a short script to do it yourself. It might look something like this:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
// Add this to a GameObject with a UI Text component.
public class SetFontForLanguage : MonoBehaviour
{
    public Font defaultFont; //<--ASSIGN IN INSPECTOR
    public Font englishFont;
    public font chineseFont;
    public font koreanFont;
    
    void OnEnable()
    {
        var text = GetComponent<UnityEngine.UI.Text>();
        if (text == null) return;
        if (Localization.language == "en") text.font = englishFont;
        else if (Localization.language == "zh") text.font = chineseFont;
        else if (Localization.language == "ko") text.font = koreanFont;
        else text.font = defaultFont;
}
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

Re: Can I set localized fonts differently?

Post by minomod »

I don't need to buy another UI localize eset.
Thank you for creating such a nice set of etsets.
mgregoirelds
Posts: 106
Joined: Wed Aug 23, 2017 4:10 pm
Location: Canada

Re: Can I set localized fonts differently?

Post by mgregoirelds »

Just to make sure, if you use TextMesh Pro, you can set a Fallback Font to any TMP font.

Let's say that by default, you use latin character and you display Japanese text, by default, it wont display properly. But by using the Fallback system, you can set a font that will be used in the case the character can't be found. It is really useful to support CKJ languages.

You can see more here:

(Sorry didn't want to hijack the thread).
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I set localized fonts differently?

Post by Tony Li »

That's a good point. Thanks for sharing!

I'll still plan to add localized font settings to the Dialogue System so you'll have total control over which font is used for each language. You could even use it for the same language but simply to offer different font choices. Some visual novels provide this nice feature nowadays. You can choose a more stylized font to match the atmosphere of the game, or a simpler font to make it more readable on smaller displays.
Light Novels Hub
Posts: 1
Joined: Fri Jun 25, 2021 5:37 pm

Re: Can I set localized fonts differently?

Post by Light Novels Hub »

Thank you for creating such a nice set of etsets and i am glad you shate this information,
manta__fanta
Posts: 12
Joined: Tue Feb 22, 2022 11:23 am

Re: Can I set localized fonts differently?

Post by manta__fanta »

Tony Li wrote: Mon Jan 13, 2020 1:09 pm That's a good point. Thanks for sharing!

I'll still plan to add localized font settings to the Dialogue System so you'll have total control over which font is used for each language. You could even use it for the same language but simply to offer different font choices. Some visual novels provide this nice feature nowadays. You can choose a more stylized font to match the atmosphere of the game, or a simpler font to make it more readable on smaller displays.
Hi Tony, does this feature exist now? Was looking through the documentation but can't find it. Thanks!
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I set localized fonts differently?

Post by Tony Li »

Hi,

It's currently available as a patch on the Dialogue System Extras page (direct download) because the documentation on it isn't up yet.

Briefly:

1. Create a Localized Fonts asset (Assets > Create > Pixel Crushers > Common > UI > Localized Fonts). Set default fonts for Text and/or TextMesh Pro, and then add records for each language that has its own font.

2. Add a UILocalizationManager component to your Dialogue Manager if it doesn't already have one. Assign the Localized Fonts asset to it.

3. LocalizeUI components will set their fonts accordingly.

4. To tell Text and TextMeshProUGUI components in dialogue UIs, quest log windows, etc., to set their fonts, add SetLocalizedFont components to them.
manta__fanta
Posts: 12
Joined: Tue Feb 22, 2022 11:23 am

Re: Can I set localized fonts differently?

Post by manta__fanta »

Thank you! I got that working. Is there a way to also set the font size differently per language? Maybe by modifying the LocalizedFonts script?
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I set localized fonts differently?

Post by Tony Li »

In the next full release, I can add font size to LocalizedFonts.

Should this be an absolute font size (e.g., 12-point font) or relative to the default font size (e.g., 1.2 * default font size)?
Post Reply