feat: browser demo font.
This commit is contained in:
BIN
demo/Ursa.Demo.Browser/Assets/SourceHanSansCN-Regular.otf
Normal file
BIN
demo/Ursa.Demo.Browser/Assets/SourceHanSansCN-Regular.otf
Normal file
Binary file not shown.
16
demo/Ursa.Demo.Browser/AvaloniaAppBuilderExtensions.cs
Normal file
16
demo/Ursa.Demo.Browser/AvaloniaAppBuilderExtensions.cs
Normal file
@@ -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) } }
|
||||
});
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
<TargetFramework>net8.0-browser</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<TrimmerRootDescriptor Include="Roots.xml"/>
|
||||
<AvaloniaResource Include="Assets\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)"/>
|
||||
</ItemGroup>
|
||||
@@ -11,8 +16,4 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ursa.Demo\Ursa.Demo.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<TrimmerRootDescriptor Include="linker.xml"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user