diff --git a/demo/Ursa.Demo.Browser/Assets/SourceHanSansCN-Regular.otf b/demo/Ursa.Demo.Browser/Assets/SourceHanSansCN-Regular.otf new file mode 100644 index 00000000..c13789be Binary files /dev/null and b/demo/Ursa.Demo.Browser/Assets/SourceHanSansCN-Regular.otf differ diff --git a/demo/Ursa.Demo.Browser/AvaloniaAppBuilderExtensions.cs b/demo/Ursa.Demo.Browser/AvaloniaAppBuilderExtensions.cs new file mode 100644 index 00000000..eb3c4b76 --- /dev/null +++ b/demo/Ursa.Demo.Browser/AvaloniaAppBuilderExtensions.cs @@ -0,0 +1,16 @@ +using Avalonia; +using Avalonia.Media; + +namespace Ursa.Demo.Browser; + +public static class AvaloniaAppBuilderExtensions +{ + private static string DefaultFontFamily => "avares://Ursa.Demo.Browser/Assets#Source Han Sans CN"; + + public static AppBuilder WithSourceHanSansCNFont(this AppBuilder builder) => + builder.With(new FontManagerOptions + { + DefaultFamilyName = DefaultFontFamily, + FontFallbacks = new[] { new FontFallback { FontFamily = new FontFamily(DefaultFontFamily) } } + }); +} \ No newline at end of file diff --git a/demo/Ursa.Demo.Browser/Program.cs b/demo/Ursa.Demo.Browser/Program.cs index f6656416..5c9ef40e 100644 --- a/demo/Ursa.Demo.Browser/Program.cs +++ b/demo/Ursa.Demo.Browser/Program.cs @@ -10,6 +10,7 @@ namespace Ursa.Demo.Browser; internal sealed partial class Program { private static Task Main(string[] args) => BuildAvaloniaApp() + .WithSourceHanSansCNFont() .StartBrowserAppAsync("out"); public static AppBuilder BuildAvaloniaApp() diff --git a/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj b/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj index 0b2c8c45..df3278d5 100644 --- a/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj +++ b/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj @@ -13,6 +13,7 @@ + diff --git a/demo/Ursa.Demo/Views/SingleView.axaml b/demo/Ursa.Demo/Views/SingleView.axaml index 20659738..3539f1a0 100644 --- a/demo/Ursa.Demo/Views/SingleView.axaml +++ b/demo/Ursa.Demo/Views/SingleView.axaml @@ -7,8 +7,9 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Ursa.Demo.Views.SingleView"> - - - - + + + + +