nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

LocalFontProvider is affected by LocalXamlProvider ?

20 Sep 2017, 09:34

I have the following directory setup:
<root>/Xaml/*.xaml
<root>/Font/*.ttf
and a xaml file which load a font "Fonts/#Arial Unicode MS", as follows.
<UserControl x:Class="NoesisTutorial.Tutorial"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:NoesisTutorial"
             FontFamily="Fonts/#Arial Unicode MS" 
             FontSize="20"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="NoesisStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <StackPanel>
    </StackPanel>
</UserControl>
If I set my LocalXamlProvider to the directory <root>/Xaml and my LocalFontProvider to directory <root>, everything works fine.

Then I changed the directory of my LocalXamlProvider to <root>, and adjust my code to call LoadXaml with filename prefixed with "Xaml" (e.g. "Xaml/Test.xaml" instead of "Test.xaml"). The Xaml can be loaded correctly, but it fails to load the font.

Is it intended behavior ?
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: LocalFontProvider is affected by LocalXamlProvider ?

22 Sep 2017, 13:06

Then I changed the directory of my LocalXamlProvider to <root>, and adjust my code to call LoadXaml with filename prefixed with "Xaml" (e.g. "Xaml/Test.xaml" instead of "Test.xaml"). The Xaml can be loaded correctly, but it fails to load the font.

Is it intended behavior ?
Yes, because this
FontFamily="Fonts/#Arial Unicode MS"
is an URI relative to the XAML. So, it is trying to load the font from Xaml/Fonts/...

You can avoid this behavior by using a non-relative URI:
FontFamily="/Fonts/#Arial Unicode MS"
 
nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

Re: LocalFontProvider is affected by LocalXamlProvider ?

25 Sep 2017, 02:22

Ah, my bad. Didn't realize that the path can be absolute or relative. Thanks.
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: LocalFontProvider is affected by LocalXamlProvider ?

26 Sep 2017, 21:03

You welcome. Marking this as solved.

Who is online

Users browsing this forum: No registered users and 2 guests