refactor: Move FontFamily exts into own file
This resolves some nagging namespace conflicts w/ FontFamily (in System.Windows.Media and mbts.ui.utility.text) TODO: Get rid of mbts.ui.utility.text.FontFamily (it was an ill-advised enum to begin with)
This commit is contained in:
1 parent
5a45d5e12a
commit
9d7e16fbf7
7 files changed
+18
-8
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using bts.proto;
|
||||
|
||||
using mbts.ui;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility.text;
|
||||
|
||||
@@ -43,7 +44,9 @@ namespace mbts.spark {
|
||||
font = new FontParamsProto {
|
||||
font_color = font_color.rgb_color(),
|
||||
font_size = font_size,
|
||||
typeface = new TypefaceProto(font_family.name_or_default(), font_weight.ToOpenTypeWeight())
|
||||
typeface = new(
|
||||
font_family.name() ?? TextUtils.StandardFontFamilyName,
|
||||
font_weight.ToOpenTypeWeight())
|
||||
},
|
||||
background_color = background_color.rgb_color(),
|
||||
show_label = show_label
|
||||
|
||||
@@ -3,6 +3,7 @@ using bts.utils;
|
||||
|
||||
using mbts;
|
||||
using mbts.ui;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.utility.text;
|
||||
|
||||
using ProtoBuf;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility.text;
|
||||
|
||||
@@ -7,6 +7,7 @@ using bts.utils;
|
||||
using mbts.collections;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
|
||||
@@ -3,6 +3,7 @@ using bts.utils;
|
||||
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#nullable enable
|
||||
|
||||
namespace mbts.ui.extensions {
|
||||
using System.Linq;
|
||||
|
||||
static class FontFamilyExtensions {
|
||||
public static string? name(this System.Windows.Media.FontFamily font_family) =>
|
||||
font_family.FamilyNames.Values.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@@ -120,13 +120,6 @@ namespace mbts.ui.utility.text {
|
||||
.Where(p => p.PropertyType == typeof(FontWeight))
|
||||
.Select(p => (FontWeight)p.GetValue(null)).Distinct();
|
||||
|
||||
|
||||
public static string name(this System.Windows.Media.FontFamily font_family) =>
|
||||
font_family.FamilyNames.Values.FirstOrDefault() ?? string.Empty;
|
||||
|
||||
public static string name_or_default(this System.Windows.Media.FontFamily font_family) =>
|
||||
font_family?.FamilyNames?.Values?.FirstOrDefault() ?? StandardFontFamilyName;
|
||||
|
||||
public static string display_name(this System.Windows.Media.FontFamily family, double size) =>
|
||||
$"{family}, {size} pt";
|
||||
|
||||
|
||||
Reference in new issue
Block a user