Open SKProCH opened 1 month ago
The default font is defined as a FontFamily resource name MaterialDesignFonts
in Material.Styles/Resources/Themes/FontFamily.axaml.
I tried creating resources with the same name in Application.Resources
, but this didn't work.
<Application>
<Application.Styles>
<themes:MaterialTheme BaseTheme="Light" PrimaryColor="Green" SecondaryColor="Blue" />
</Application.Styles>
<Application.Resources>
<FontFamily x:Key="MaterialDesignFonts">
Microsoft Yahei, 微软雅黑,Simsun, SimHei, PingFang SC, 苹方-简, 宋体-简, 宋体, Microsoft JhengHei, Microsoft JhengHei UI, $Default
</FontFamily>
</Application.Resources>
</Application>
Screenshot:
Finally, I ended up defining several styles applied to TextBlock/TextBox/AccessText, like this:
<Application >
<Application.Resources>
<FontFamily x:Key="MaterialDesignFonts">
Microsoft Yahei, 微软雅黑,Simsun, SimHei, PingFang SC, 苹方-简, 宋体-简, 宋体, Microsoft JhengHei, Microsoft JhengHei UI, $Default
</FontFamily>
</Application.Resources>
<Application.Styles>
<themes:MaterialTheme BaseTheme="Light" PrimaryColor="Green" SecondaryColor="Blue" />
<Style Selector="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignFonts}" />
</Style>
<Style Selector="TextBox">
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignFonts}" />
</Style>
<Style Selector="AccessText">
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignFonts}" />
</Style>
</Application.Styles>
</Application>
Discussed in https://github.com/AvaloniaCommunity/Material.Avalonia/discussions/406