Skip to content

Commit

Permalink
Merge pull request #4510 from huynhsontung/fluent-icons
Browse files Browse the repository at this point in the history
TextIconExtension to use Segoe Fluent Icons by default
  • Loading branch information
michael-hawker authored Mar 28, 2022
2 parents 4f394ce + dc0f575 commit 3bf88b8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public abstract class TextIconExtension : MarkupExtension
public double FontSize { get; set; }

[ThreadStatic]
private static FontFamily segoeMDL2AssetsFontFamily;
private static FontFamily symbolThemeFontFamily;

/// <summary>
/// Gets the reusable "Segoe MDL2 Assets" <see cref="FontFamily"/> instance.
/// Gets the reusable "Segoe Fluent Icons,Segoe MDL2 Assets" <see cref="FontFamily"/> instance.
/// </summary>
protected static FontFamily SegoeMDL2AssetsFontFamily
protected static FontFamily SymbolThemeFontFamily
{
get => segoeMDL2AssetsFontFamily ??= new FontFamily("Segoe MDL2 Assets");
get => symbolThemeFontFamily ??= new FontFamily("Segoe Fluent Icons,Segoe MDL2 Assets");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FontIconExtension : TextIconExtension
public string Glyph { get; set; }

/// <summary>
/// Gets or sets the font family to use to display the icon. If <see langword="null"/>, "Segoe MDL2 Assets" will be used.
/// Gets or sets the font family to use to display the icon. If <see langword="null"/>, "Segoe Fluent Icons,Segoe MDL2 Assets" will be used.
/// </summary>
public FontFamily FontFamily { get; set; }

Expand All @@ -30,7 +30,7 @@ protected override object ProvideValue()
var fontIcon = new FontIcon
{
Glyph = Glyph,
FontFamily = FontFamily ?? SegoeMDL2AssetsFontFamily,
FontFamily = FontFamily ?? SymbolThemeFontFamily,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FontIconSourceExtension : TextIconExtension
public string Glyph { get; set; }

/// <summary>
/// Gets or sets the font family to use to display the icon. If <see langword="null"/>, "Segoe MDL2 Assets" will be used.
/// Gets or sets the font family to use to display the icon. If <see langword="null"/>, "Segoe Fluent Icons,Segoe MDL2 Assets" will be used.
/// </summary>
public FontFamily FontFamily { get; set; }

Expand All @@ -30,7 +30,7 @@ protected override object ProvideValue()
var fontIcon = new FontIconSource
{
Glyph = Glyph,
FontFamily = FontFamily ?? SegoeMDL2AssetsFontFamily,
FontFamily = FontFamily ?? SymbolThemeFontFamily,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override object ProvideValue()
var fontIcon = new FontIcon
{
Glyph = unchecked((char)Symbol).ToString(),
FontFamily = SegoeMDL2AssetsFontFamily,
FontFamily = SymbolThemeFontFamily,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override object ProvideValue()
var fontIcon = new FontIconSource
{
Glyph = unchecked((char)Symbol).ToString(),
FontFamily = SegoeMDL2AssetsFontFamily,
FontFamily = SymbolThemeFontFamily,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Test_FontIconExtensionMarkupExtension
{
[TestCategory("FontIconExtensionMarkupExtension")]
[UITestMethod]
public void Test_FontIconExtension_MarkupExtension_ProvideSegoeMdl2Asset()
public void Test_FontIconExtension_MarkupExtension_ProvideSymbolThemeFont()
{
var treeroot = XamlReader.Load(@"<Page
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
Expand All @@ -35,7 +35,7 @@ public void Test_FontIconExtension_MarkupExtension_ProvideSegoeMdl2Asset()
Assert.IsNotNull(icon, $"Could not find the {nameof(FontIcon)} element in button.");

Assert.AreEqual(icon.Glyph, "\uE105", "Expected icon glyph to be E105.");
Assert.AreEqual(icon.FontFamily.Source, "Segoe MDL2 Assets", "Expected font family to be Segoe MDL2 Assets");
Assert.AreEqual(icon.FontFamily.Source, "Segoe Fluent Icons,Segoe MDL2 Assets", "Expected font family to be \"Segoe Fluent Icons,Segoe MDL2 Assets\"");
}

[TestCategory("FontIconExtensionMarkupExtension")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Test_FontIconSourceExtensionMarkupExtension
{
[TestCategory("FontIconSourceExtensionMarkupExtension")]
[UITestMethod]
public void Test_FontIconSourceExtension_MarkupExtension_ProvideSegoeMdl2Asset()
public void Test_FontIconSourceExtension_MarkupExtension_ProvideSymbolThemeFont()
{
var treeRoot = XamlReader.Load(@"<Page
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
Expand All @@ -37,7 +37,7 @@ public void Test_FontIconSourceExtension_MarkupExtension_ProvideSegoeMdl2Asset()
Assert.IsNotNull(icon, $"Could not find the {nameof(FontIcon)} element in button.");

Assert.AreEqual(icon.Glyph, "\uE105", "Expected icon glyph to be E105.");
Assert.AreEqual(icon.FontFamily.Source, "Segoe MDL2 Assets", "Expected font family to be Segoe MDL2 Assets");
Assert.AreEqual(icon.FontFamily.Source, "Segoe Fluent Icons,Segoe MDL2 Assets", "Expected font family to be \"Segoe Fluent Icons,Segoe MDL2 Assets\"");
}

[TestCategory("FontIconSourceExtensionMarkupExtension")]
Expand Down

0 comments on commit 3bf88b8

Please sign in to comment.