Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextIconExtension to use Segoe Fluent Icons by default #4510

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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