Skip to content

Commit

Permalink
Merge pull request #420 from AvaloniaCommunity/fontsRework
Browse files Browse the repository at this point in the history
Remove explicit FontFamily setters in styles, allowing to inherit font properly. Fix #407
  • Loading branch information
SKProCH authored Dec 25, 2024
2 parents affcbd2 + fc0927b commit 5a04af8
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 36 deletions.
1 change: 0 additions & 1 deletion Material.Styles/MaterialToolKit.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<ResourceInclude Source="avares://Material.Ripple/Theme.axaml" />

<!-- Avalonia controls -->
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/AccessText.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/AdornerLayer.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/AutoCompleteBox.axaml" />
<ResourceInclude Source="avares://Material.Styles/Resources/Themes/Button.axaml" />
Expand Down
10 changes: 0 additions & 10 deletions Material.Styles/Resources/Themes/AccessText.axaml

This file was deleted.

2 changes: 0 additions & 2 deletions Material.Styles/Resources/Themes/ComboBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
BasedOn="{StaticResource MaterialComboBox}">
<Setter Property="Background" Value="{DynamicResource MaterialTextFieldBoxBackgroundBrush}" />
<Setter Property="ContextFlyout" Value="{StaticResource DefaultTextBoxMenuFlyout}" />
<Setter Property="FontFamily" Value="avares://Material.Styles/Fonts/Roboto#Roboto" />
<Setter Property="Padding" Value="16,8" />
<Setter Property="Template">
<ControlTemplate>
Expand Down Expand Up @@ -283,7 +282,6 @@
<Setter Property="BorderBrush" Value="{DynamicResource MaterialBodyBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="ContextFlyout" Value="{StaticResource DefaultTextBoxMenuFlyout}" />
<Setter Property="FontFamily" Value="avares://Material.Styles/Fonts/Roboto#Roboto" />
<Setter Property="Padding" Value="16,8" />
<Setter Property="Template">
<ControlTemplate>
Expand Down
6 changes: 3 additions & 3 deletions Material.Styles/Resources/Themes/EmbeddableControlRoot.axaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="MaterialEmbeddableControlRoot" TargetType="EmbeddableControlRoot">
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFonts}" />
<Setter Property="FontSize" Value="{DynamicResource MaterialDesignFontSize}" />
<Setter Property="Background" Value="{DynamicResource MaterialPaperBrush}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialBodyBrush}" />
<Setter Property="TextElement.FontWeight" Value="Regular" />
<Setter Property="Foreground" Value="{DynamicResource MaterialBodyBrush}" />
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}">
Expand Down
8 changes: 2 additions & 6 deletions Material.Styles/Resources/Themes/FontFamily.axaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FontFamily x:Key="MaterialDesignFonts">
avares://Material.Styles/Fonts/Roboto#Roboto,
Noto Sans, BlinkMacSystemFont, Segoe UI, Helvetica Neue, Helvetica, Cantarell, Ubuntu, Arial,
Hiragino Kaku Gothic Pro, MS UI Gothic, MS PMincho, Microsoft JhengHei, Microsoft JhengHei UI,
Microsoft YaHei New, Microsoft Yahei, SimHei, $Default
</FontFamily>
<FontFamily x:Key="MaterialDesignFonts">avares://Material.Styles/Fonts/Roboto#Roboto, $Default</FontFamily>
<x:Double x:Key="MaterialDesignFontSize">14</x:Double>
</ResourceDictionary>
4 changes: 4 additions & 0 deletions Material.Styles/Resources/Themes/OverlayPopupHost.axaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="MaterialOverlayPopupHost" TargetType="OverlayPopupHost">
<Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFonts}" />
<Setter Property="FontSize" Value="{DynamicResource MaterialDesignFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontStyle" Value="Normal" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<ControlTemplate>
Expand Down
4 changes: 4 additions & 0 deletions Material.Styles/Resources/Themes/PopupRoot.axaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="MaterialPopupRoot" TargetType="PopupRoot">
<Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFonts}" />
<Setter Property="FontSize" Value="{DynamicResource MaterialDesignFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontStyle" Value="Normal" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="TransparencyLevelHint" Value="Transparent" />
<Setter Property="Template">
Expand Down
9 changes: 1 addition & 8 deletions Material.Styles/Resources/Themes/TextBlock.axaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="MaterialDefaultFontFamily"
TargetType="Control">
<Setter Property="TextBlock.FontFamily" Value="{StaticResource MaterialDesignFonts}" />
</ControlTheme>

<ControlTheme x:Key="MaterialTextBlock"
TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignFonts}" />
</ControlTheme>
TargetType="TextBlock" />

<ControlTheme x:Key="{x:Type TextBlock}" TargetType="TextBlock"
BasedOn="{StaticResource MaterialTextBlock}" />
Expand Down
3 changes: 0 additions & 3 deletions Material.Styles/Resources/Themes/TextBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@
<Setter Property="SelectionForegroundBrush" Value="{DynamicResource MaterialPrimaryMidForegroundBrush}" />
<Setter Property="ContextFlyout" Value="{OnFormFactor Desktop={StaticResource DefaultTextBoxMenuFlyout}, Mobile={StaticResource HorizontalTextBoxMenuFlyout}}" />
<Setter Property="CaretBrush" Value="{DynamicResource MaterialPrimaryMidBrush}" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignFonts}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Watermark" Value="{x:Static system:String.Empty}" />
<!-- Enable IME system by default -->
<Setter Property="InputMethod.IsInputMethodEnabled" Value="True" />
Expand Down
6 changes: 3 additions & 3 deletions Material.Styles/Resources/Themes/Window.axaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="MaterialWindow" TargetType="Window">
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="{DynamicResource MaterialDesignFonts}" />
<Setter Property="FontSize" Value="{DynamicResource MaterialDesignFontSize}" />
<Setter Property="Background" Value="{DynamicResource MaterialPaperBrush}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialBodyBrush}" />
<Setter Property="TextElement.FontWeight" Value="Regular" />
<Setter Property="Foreground" Value="{DynamicResource MaterialBodyBrush}" />
<Setter Property="Template">
<ControlTemplate>
<Panel>
Expand Down

0 comments on commit 5a04af8

Please sign in to comment.