Skip to content

Commit

Permalink
feat: web demo font.
Browse files Browse the repository at this point in the history
  • Loading branch information
zdpcdt committed Jul 10, 2024
1 parent f66edd5 commit db137ef
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Avalonia;
using Avalonia.Media;

namespace Semi.Avalonia.Demo.Web;

public static class AvaloniaAppBuilderExtensions
{
private static string DefaultFontFamily => "avares://Semi.Avalonia.Demo.Web/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) } }
});
}
1 change: 1 addition & 0 deletions demo/Semi.Avalonia.Demo.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Semi.Avalonia.Demo.Web;
internal sealed partial class Program
{
private static Task Main(string[] args) => BuildAvaloniaApp()
.WithSourceHanSansCNFont()
.StartBrowserAppAsync("out");

public static AppBuilder BuildAvaloniaApp()
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
<AvaloniaResource Include="Assets\**"/>
<TrimmerRootDescriptor Include="Roots.xml"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj" />
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)"/>
</ItemGroup>

<ItemGroup>
<TrimmerRootDescriptor Include="linker.xml" />
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj"/>
</ItemGroup>
</Project>

0 comments on commit db137ef

Please sign in to comment.