Skip to content

Commit

Permalink
fix: Use SymbolThemeFontFamily instead of hard-coded Segoe MDL2 Assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Sep 1, 2021
1 parent 63e9cde commit 9dae693
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 23 deletions.
9 changes: 9 additions & 0 deletions src/Uno.UI.FluentTheme/Resources/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Overrides our root .editorconfig to match https://github.com/microsoft/microsoft-ui-xaml/blob/fd22d7ff96871f58fec5d9b284eba02fe762c60e/.editorconfig#L120-L126

[**.{xaml,xml}]
indent_style = space
indent_size = 4
charset = utf-8-bom
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = crlf
Original file line number Diff line number Diff line change
Expand Up @@ -639,21 +639,21 @@
Grid.Column="0"
HorizontalAlignment="Left"
Margin="0">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE8C1;" />
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE8C1;" />
</Button>
<Button x:Name="LanguageSwitcherSettingsPenAndInkSettingsButton"
Background="{ThemeResource MenuFlyoutItemBackground}"
Grid.Column="1"
HorizontalAlignment="Center"
Margin="0">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE713;" />
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE713;" />
</Button>
<Button x:Name="LanguageSwitcherSettingsHelpButton"
Background="{ThemeResource MenuFlyoutItemBackground}"
Grid.Column="2"
HorizontalAlignment="Right"
Margin="0">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE9CE;" />
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE9CE;" />
</Button>
</Grid>
</ControlTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,7 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="ContentPresenter" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" AutomationProperties.AccessibilityView="Raw" />
<TextBlock x:Name="ChevronTextBlock" Grid.Column="1" FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" Margin="6,0,0,0" AutomationProperties.AccessibilityView="Raw" />
<TextBlock x:Name="ChevronTextBlock" Grid.Column="1" FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" Margin="6,0,0,0" AutomationProperties.AccessibilityView="Raw" />
</Grid>
</Grid>
</ControlTemplate>
Expand Down Expand Up @@ -2844,7 +2844,7 @@
<Button x:Name="PrimaryButton" Grid.Column="0" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding CommandParameter}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Padding="{TemplateBinding Padding}" IsTabStop="False" AutomationProperties.AccessibilityView="Raw" />
<Button x:Name="SecondaryButton" Grid.Column="2" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0,0,9,0" IsTabStop="False" AutomationProperties.AccessibilityView="Raw">
<Button.Content>
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" AutomationProperties.AccessibilityView="Raw" />
<TextBlock FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" AutomationProperties.AccessibilityView="Raw" />
</Button.Content>
</Button>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<TextBlock
x:Name="ChevronTextBlock"
Grid.Column="1"
FontFamily="Segoe MDL2 Assets"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12"
Text="&#xE70D;"
VerticalAlignment="Center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- 9794813: retire these two properties as customisation points once all resource keys available -->
<Setter Property="Foreground" Value="{ThemeResource RatingControlCaptionForeground}"/>
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}"/>
<Setter Property="ItemInfo" Value="{ThemeResource MUX_RatingControlDefaultFontInfo}"/>
<!-- IsFocusEngagementEnabled means the control has to be "engaged" with
using the A button before it actually receives key input from gamepad. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
FontSize="32"
Text="&#xE734;"
AutomationProperties.AccessibilityView="Raw"
FontFamily="Segoe MDL2 Assets"/>
FontFamily="{ThemeResource SymbolThemeFontFamily}"/>
</DataTemplate>

<DataTemplate x:Key="ForegroundGlyphDefaultTemplate">
Expand All @@ -58,7 +58,7 @@
FontSize="32"
Text="&#xE735;"
AutomationProperties.AccessibilityView="Raw"
FontFamily="Segoe MDL2 Assets"/>
FontFamily="{ThemeResource SymbolThemeFontFamily}"/>
</DataTemplate>

<DataTemplate x:Key="BackgroundImageDefaultTemplate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<Button x:Name="PrimaryButton" Grid.Column="0" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding CommandParameter}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Padding="{TemplateBinding Padding}" IsTabStop="False" AutomationProperties.AccessibilityView="Raw" />
<Button x:Name="SecondaryButton" Grid.Column="2" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0,0,9,0" IsTabStop="False" AutomationProperties.AccessibilityView="Raw">
<Button.Content>
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" IsTextScaleFactorEnabled="False" AutomationProperties.AccessibilityView="Raw" />
<TextBlock FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" IsTextScaleFactorEnabled="False" AutomationProperties.AccessibilityView="Raw" />
</Button.Content>
</Button>
</Grid>
Expand Down
20 changes: 10 additions & 10 deletions src/Uno.UI.FluentTheme/themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5320,13 +5320,13 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button x:Name="LanguageSwitcherSettingsLanguageSettingsButton" Background="{ThemeResource MenuFlyoutItemBackground}" Grid.Column="0" HorizontalAlignment="Left" Margin="0">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE8C1;" />
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE8C1;" />
</Button>
<Button x:Name="LanguageSwitcherSettingsPenAndInkSettingsButton" Background="{ThemeResource MenuFlyoutItemBackground}" Grid.Column="1" HorizontalAlignment="Center" Margin="0">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE713;" />
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE713;" />
</Button>
<Button x:Name="LanguageSwitcherSettingsHelpButton" Background="{ThemeResource MenuFlyoutItemBackground}" Grid.Column="2" HorizontalAlignment="Right" Margin="0">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE9CE;" />
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE9CE;" />
</Button>
</Grid>
</ControlTemplate>
Expand Down Expand Up @@ -8493,7 +8493,7 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="ContentPresenter" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" AutomationProperties.AccessibilityView="Raw" />
<TextBlock x:Name="ChevronTextBlock" Grid.Column="1" FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" Margin="6,0,0,0" AutomationProperties.AccessibilityView="Raw" />
<TextBlock x:Name="ChevronTextBlock" Grid.Column="1" FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" Margin="6,0,0,0" AutomationProperties.AccessibilityView="Raw" />
</Grid>
</Grid>
</ControlTemplate>
Expand Down Expand Up @@ -8722,7 +8722,7 @@
<Button x:Name="PrimaryButton" Grid.Column="0" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding CommandParameter}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Padding="{TemplateBinding Padding}" IsTabStop="False" AutomationProperties.AccessibilityView="Raw" />
<Button x:Name="SecondaryButton" Grid.Column="2" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0,0,9,0" IsTabStop="False" AutomationProperties.AccessibilityView="Raw">
<Button.Content>
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" AutomationProperties.AccessibilityView="Raw" />
<TextBlock FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" AutomationProperties.AccessibilityView="Raw" />
</Button.Content>
</Button>
</Grid>
Expand Down Expand Up @@ -14896,7 +14896,7 @@
</Grid.ColumnDefinitions>
<!-- Uno workaround: template-bind ContentTemplateSelector because it's not automatically propagated from the ContentControl -->
<ContentPresenter x:Name="ContentPresenter" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" AutomationProperties.AccessibilityView="Raw" />
<TextBlock x:Name="ChevronTextBlock" Grid.Column="1" FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" Margin="6,0,0,0" IsTextScaleFactorEnabled="False" AutomationProperties.AccessibilityView="Raw" />
<TextBlock x:Name="ChevronTextBlock" Grid.Column="1" FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" Margin="6,0,0,0" IsTextScaleFactorEnabled="False" AutomationProperties.AccessibilityView="Raw" />
</Grid>
</Grid>
</ControlTemplate>
Expand Down Expand Up @@ -19388,7 +19388,7 @@
<!-- 9794813: retire these two properties as customisation points once all resource keys available -->
<Setter Property="Foreground" Value="{ThemeResource RatingControlCaptionForeground}" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
<Setter Property="ItemInfo" Value="{ThemeResource MUX_RatingControlDefaultFontInfo}" />
<!-- IsFocusEngagementEnabled means the control has to be "engaged" with
using the A button before it actually receives key input from gamepad. -->
Expand Down Expand Up @@ -19459,11 +19459,11 @@
</Style>
<DataTemplate x:Key="BackgroundGlyphDefaultTemplate">
<!-- -8, -8 are to compensate for the default scale down, plus factoring in margins -->
<TextBlock Foreground="{ThemeResource RatingControlUnselectedForeground}" Margin="-8,-8,0,0" FontSize="32" Text="&#xE734;" AutomationProperties.AccessibilityView="Raw" FontFamily="Segoe MDL2 Assets" />
<TextBlock Foreground="{ThemeResource RatingControlUnselectedForeground}" Margin="-8,-8,0,0" FontSize="32" Text="&#xE734;" AutomationProperties.AccessibilityView="Raw" FontFamily="{ThemeResource SymbolThemeFontFamily}" />
</DataTemplate>
<DataTemplate x:Key="ForegroundGlyphDefaultTemplate">
<!-- -8, -8 are to compensate for the default scale down, plus factoring in margins -->
<TextBlock Margin="-8,-8,0,0" FontSize="32" Text="&#xE735;" AutomationProperties.AccessibilityView="Raw" FontFamily="Segoe MDL2 Assets" />
<TextBlock Margin="-8,-8,0,0" FontSize="32" Text="&#xE735;" AutomationProperties.AccessibilityView="Raw" FontFamily="{ThemeResource SymbolThemeFontFamily}" />
</DataTemplate>
<DataTemplate x:Key="BackgroundImageDefaultTemplate">
<Image Margin="-8,-8,0,0" AutomationProperties.AccessibilityView="Raw" />
Expand Down Expand Up @@ -20521,7 +20521,7 @@
<Button x:Name="PrimaryButton" Grid.Column="0" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Content="{TemplateBinding Content}" ContentTransitions="{TemplateBinding ContentTransitions}" ContentTemplate="{TemplateBinding ContentTemplate}" Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding CommandParameter}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Padding="{TemplateBinding Padding}" IsTabStop="False" AutomationProperties.AccessibilityView="Raw" />
<Button x:Name="SecondaryButton" Grid.Column="2" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0,0,9,0" IsTabStop="False" AutomationProperties.AccessibilityView="Raw">
<Button.Content>
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" IsTextScaleFactorEnabled="False" AutomationProperties.AccessibilityView="Raw" />
<TextBlock FontFamily="{ThemeResource SymbolThemeFontFamily}" FontSize="12" Text="&#xE70D;" VerticalAlignment="Center" HorizontalAlignment="Right" IsTextScaleFactorEnabled="False" AutomationProperties.AccessibilityView="Raw" />
</Button.Content>
</Button>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

using SplitButton = Microsoft.UI.Xaml.Controls.SplitButton;
using ToggleSplitButton = Microsoft.UI.Xaml.Controls.ToggleSplitButton;
using Uno.UI.RuntimeTests.Helpers;
using Windows.UI.Xaml.Media;
using Private.Infrastructure;

namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
{
Expand Down Expand Up @@ -82,6 +85,25 @@ public void VerifyIsCheckedProperty()
Verify.IsTrue(isChecked, "ToggleSplitButton is not checked");
});
}

[TestMethod]
[Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")]
public void VerifyFontFamilyForChevron()
{
SplitButton splitButton = null;
using (StyleHelper.UseFluentStyles())
{
RunOnUIThread.Execute(() =>
{
splitButton = new SplitButton();
TestServices.WindowHelper.WindowContent = splitButton;

var secondayButton = splitButton.GetTemplateChild("SecondaryButton");
var font = ((secondayButton as Button).Content as TextBlock).FontFamily;
Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font);
});
}
}
}

// CanExecuteChanged is never used -- that's ok, disable the compiler warning.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Uno.UI.RuntimeTests.Helpers;
using MUXControlsTestApp.Utilities;
using Private.Infrastructure;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Common;

namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
{
[TestClass]
public class ToggleSplitButtonTests
{
[TestMethod]
[Description("Verifies that the TextBlock representing the Chevron glyph uses the correct font")]
public void VerifyFontFamilyForChevron()
{
Microsoft.UI.Xaml.Controls.ToggleSplitButton toggleSplitButton = null;
using (StyleHelper.UseFluentStyles())
{
RunOnUIThread.Execute(() =>
{
toggleSplitButton = new Microsoft.UI.Xaml.Controls.ToggleSplitButton();
TestServices.WindowHelper.WindowContent = toggleSplitButton;

var secondayButton = toggleSplitButton.GetTemplateChild("SecondaryButton");
var font = ((secondayButton as Button).Content as TextBlock).FontFamily;
Verify.AreEqual((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"], font);
});
}
}
}
}
Loading

0 comments on commit 9dae693

Please sign in to comment.