Page 1 of 1

Font fallback best practices?

Posted: 11 Mar 2025, 11:58
by ARPP3
Hi,

I am working on a project that allows users to submit content. This content can be in any language and so I want to have fallbacks for all languages that we localize to. So far this is including Russian characters, Chinese characters, and Persian to name a few. Currently I handle fallbacks like this, when the font family is set to the default.
    <FontFamily x:Key="Font.Family.Default">
        ./../../Fonts/RedHat/#Red Hat Display,
        ./../../Fonts/NotoSans/#Noto Sans,
        ./../../Fonts/Rubik/#Rubik,
        ./../../Fonts/LXGW/#LXGW WenKai TC
    </FontFamily>
Do I need to include these fallbacks for every font family resource definition I add? If I want to switch to a monospace font for instance, I understand that I might want a monospace font in these other languages but, for most font families I can't find equivalents. Is there a way to set fallbacks globally?

I know there's an option in Unity for loading platform fonts but, to explicitly have fallbacks like this what is the best practice?

Thanks,
David

Re: Font fallback best practices?

Posted: 12 Mar 2025, 09:38
by jsantos
There is a default font fallback list that can be set using Noesis.GUI.SetFontFallbacks(). However, a default setup of system fonts is already configured using that API in SetDefaultFont() in Unity (if platform fonts are enabled). I think we should allow this list to be extended in the settings panel. If you disable system fonts, you could use that API for your own purposes.

If not, your approach of setting the fallbacks in XAML (probably as a globally shared resource) at the root of the XAML is fine.
<Page ... FontFamily="{StaticResource TheFont}">

Re: Font fallback best practices?

Posted: 12 Mar 2025, 13:25
by ARPP3
Thank you! This helps a ton, 😁