rachelle
Topic Author
Posts: 4
Joined: 26 Mar 2021, 01:39

Custom fonts defined in a theme failing to load after upgrading to 3.1.0

02 Sep 2021, 02:07

We have just upgraded our Unity integration to NoesisGUI 3.1.0. We have a folder structure like this:
-- Assets
    --  Scripts
         -- Runtime
            -- Client
               -- UI
                  -- Themes
                      GameTheme.xaml
                      GameTheme.Fonts.xaml
                      -- Fonts
                         CustomFontA.otf
                         CustomFontB.otf
                         CustomFontC.otf
GameTheme.xaml looks something like this:
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="GameTheme.Fonts.xaml" />
    </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>
GameTheme.Fonts.xaml looks something like this:
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <FontFamily x:Key="Font.Family.CustomFontA">/Blend;component/Assets/Scripts/Runtime/Client/UI/Themes/Fonts/#Custom Font A</FontFamily>
    <FontFamily x:Key="Font.Family.CustomFontB">/Blend;component/Assets/Scripts/Runtime/Client/UI/Themes/Fonts/#Custom Font B</FontFamily>
    <FontFamily x:Key="Font.Family.CustomFontC">/Blend;component/Assets/Scripts/Runtime/Client/UI/Themes/Fonts/#Custom Font C</FontFamily>
</ResourceDictionary>
We specify the paths this way so that the fonts show up correctly in our Unity game as well as in Blend where our designers are directly editing the UI layouts.

All of our TextBlocks in the xaml files driving the UI we're using in-game make reference to these custom fonts by specifying the FontFamily property, like this:
FontFamily="{StaticResource Font.Family.CustomFontA}"
For each of our custom fonts, though, we are seeing this error:
[noesis] Assets/Scripts/Runtime/Client/UI/Themes/GameTheme.Fonts.xaml(8): Font not found '/Blend;component/Assets/Scripts/Runtime/Client/UI/Themes/Fonts/#Custom Font A'
The custom fonts are still showing up in Blend, but the "not found" errors in Unity are preventing the custom fonts from showing up in-game. This worked before the upgrade, when we were on NoesisGUI 3.0.12. I am having trouble finding documentation for how to use custom fonts defined in custom themes, and nothing I've tried so far is working. What can I try to resolve this?
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: Custom fonts defined in a theme failing to load after upgrading to 3.1.0

02 Sep 2021, 18:36

Hi Rachelle,

In 3.1 font assets use a new NoesisFontImporter and we recently found that doing an upgrade from previous versions of Noesis to 3.1 leaves existing fonts with the default Unity importer. This is causing that font dependencies can't be found.

We just fixed the upgrade script to force a reimport of xamls and fonts so they are overriden with the proper importer . You can manually do a Reimport on your Themes folder to force that now. Please let me know if that works for you.
 
rachelle
Topic Author
Posts: 4
Joined: 26 Mar 2021, 01:39

Re: Custom fonts defined in a theme failing to load after upgrading to 3.1.0

02 Sep 2021, 18:43

Unfortunately this doesn't resolve the issue. I re-imported the Themes folder, continued to see this error, and then re-imported the entire UI folder (the xaml that makes use of Themes and Fonts lives in various subfolders of UI) for good measure. Still no luck, same error:
[noesis] Assets/Scripts/Runtime/Client/UI/Themes/GameTheme.Fonts.xaml(6): Font not found '/Blend;component/Assets/Scripts/Runtime/Client/UI/Themes/Fonts/#Custom Font A'
Anything else I should try?
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: Custom fonts defined in a theme failing to load after upgrading to 3.1.0

02 Sep 2021, 19:07

I was able to reproduce the problem, could you please report this in our bugtracker?

It is not working when the Uri contains the assembly part. In the meantime you can use a relative path:
<FontFamily x:Key="Font.Family.CustomFontA">Fonts/#Custom Font A</FontFamily>
or an absolute path without the assembly part:
<FontFamily x:Key="Font.Family.CustomFontA">/Assets/Scripts/Runtime/Client/UI/Themes/Fonts/#Custom Font A</FontFamily>
 
rachelle
Topic Author
Posts: 4
Joined: 26 Mar 2021, 01:39

Re: Custom fonts defined in a theme failing to load after upgrading to 3.1.0

02 Sep 2021, 19:24

Bug submitted here: https://www.noesisengine.com/bugs/view.php?id=2103

The workaround (I chose the absolute path) is resolving the issue in-game, but I look forward to the bug fix to get things working again in Blend for our designers. Thank you!
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: Custom fonts defined in a theme failing to load after upgrading to 3.1.0

02 Sep 2021, 19:39

Thanks for the report.

Who is online

Users browsing this forum: vinick and 23 guests