Page 1 of 2

Can I set localized fonts differently?

Posted: Wed Jan 08, 2020 4:50 am
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

Re: Can I set localized fonts differently?

Posted: Wed Jan 08, 2020 8:40 am
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;
}

Re: Can I set localized fonts differently?

Posted: Sat Jan 11, 2020 3:08 pm
by minomod
I don't need to buy another UI localize eset.
Thank you for creating such a nice set of etsets.

Re: Can I set localized fonts differently?

Posted: Mon Jan 13, 2020 12:52 pm
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).

Re: Can I set localized fonts differently?

Posted: Mon Jan 13, 2020 1:09 pm
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.

Re: Can I set localized fonts differently?

Posted: Fri Jun 25, 2021 5:44 pm
by Light Novels Hub
Thank you for creating such a nice set of etsets and i am glad you shate this information,

Re: Can I set localized fonts differently?

Posted: Sun Jul 31, 2022 10:48 am
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!

Re: Can I set localized fonts differently?

Posted: Sun Jul 31, 2022 12:56 pm
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.

Re: Can I set localized fonts differently?

Posted: Sun Jul 31, 2022 4:54 pm
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?

Re: Can I set localized fonts differently?

Posted: Sun Jul 31, 2022 5:42 pm
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)?