User avatar
ARPP3
Topic Author
Posts: 21
Joined: 20 Jun 2023, 21:22

Font fallback best practices?

11 Mar 2025, 11:58

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
 
User avatar
jsantos
Site Admin
Posts: 4266
Joined: 20 Jan 2012, 17:18
Contact:

Re: Font fallback best practices?

12 Mar 2025, 09:38

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}">
 
User avatar
ARPP3
Topic Author
Posts: 21
Joined: 20 Jun 2023, 21:22

Re: Font fallback best practices?

12 Mar 2025, 13:25

Thank you! This helps a ton, 😁

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests