remove unused FontFamily enum
This commit is contained in:
1 parent
c9a10a1c37
commit
7ee6aed043
2 files changed
+8
-86
No files matched your search
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace mbts.ui.utility.text {
|
||||
/// <summary>
|
||||
/// Contains a font family, size, and foreground (uint).
|
||||
/// <para/> NOTE: does not account for font weight, or typeface.
|
||||
/// </summary>
|
||||
struct FontParams : IEquatable<FontParams> {
|
||||
public readonly FontFamily font_family;
|
||||
public readonly double font_size;
|
||||
public readonly uint foreground;
|
||||
|
||||
public FontParams(FontFamily font_family, double font_size, uint foreground) {
|
||||
this.font_family = font_family;
|
||||
this.font_size = font_size;
|
||||
this.foreground = foreground;
|
||||
}
|
||||
|
||||
public bool Equals(FontParams other) =>
|
||||
other.font_family == font_family &&
|
||||
other.font_size == font_size &&
|
||||
other.foreground == foreground;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is FontParams fsk && Equals(fsk);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
font_family.GetHashCode() ^
|
||||
font_size.GetHashCode() ^
|
||||
foreground.GetHashCode();
|
||||
|
||||
public static bool operator ==(FontParams x, FontParams y) =>
|
||||
x.Equals(y);
|
||||
|
||||
public static bool operator !=(FontParams x, FontParams y) =>
|
||||
!x.Equals(y);
|
||||
}
|
||||
|
||||
struct FontParamsKey<T> where T : struct, IEquatable<T> {
|
||||
public readonly T key;
|
||||
public readonly FontParams font_params;
|
||||
|
||||
public FontParamsKey(T key, FontParams font_params) {
|
||||
this.key = key;
|
||||
this.font_params = font_params;
|
||||
}
|
||||
|
||||
public bool Equals(FontParamsKey<T> other) =>
|
||||
other.key.Equals(key) &&
|
||||
other.font_params == font_params;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is FontParamsKey<T> fpk && Equals(fpk);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
key.GetHashCode() ^
|
||||
font_params.GetHashCode();
|
||||
|
||||
public static bool operator ==(FontParamsKey<T> x, FontParamsKey<T> y) =>
|
||||
x.Equals(y);
|
||||
|
||||
public static bool operator !=(FontParamsKey<T> x, FontParamsKey<T> y) =>
|
||||
!x.Equals(y);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using bts.utils;
|
||||
using mbts.spark.utilities;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
@@ -10,15 +9,10 @@ using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.utility.text {
|
||||
public enum FontFamily {
|
||||
Standard,
|
||||
Unknown
|
||||
}
|
||||
|
||||
static class TextUtils {
|
||||
public const string WPFNewLine = "
";
|
||||
public static readonly string StandardFontFamilyName;
|
||||
public static readonly System.Windows.Media.FontFamily StandardFontFamily;
|
||||
public static readonly FontFamily StandardFontFamily;
|
||||
public static readonly Typeface StandardTypeface;
|
||||
public static readonly GlyphTypeface StandardGlyphTypeface;
|
||||
public static readonly GlyphContext StandardGlyphContext;
|
||||
@@ -26,9 +20,9 @@ namespace mbts.ui.utility.text {
|
||||
static TextUtils() {
|
||||
// try to guarentee a standard font
|
||||
var preferred_fonts = new[] {
|
||||
new System.Windows.Media.FontFamily("Segoe UI"),
|
||||
new FontFamily("Segoe UI"),
|
||||
SystemFonts.MessageFontFamily,
|
||||
(System.Windows.Media.FontFamily)TextElement.FontFamilyProperty.DefaultMetadata.DefaultValue
|
||||
(FontFamily)TextElement.FontFamilyProperty.DefaultMetadata.DefaultValue
|
||||
};
|
||||
foreach (var f in preferred_fonts) {
|
||||
StandardTypeface = new Typeface(f, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
|
||||
@@ -64,7 +58,7 @@ namespace mbts.ui.utility.text {
|
||||
public static Typeface with(this Typeface typeface, FontWeight font_weight) =>
|
||||
new Typeface(typeface.FontFamily, typeface.Style, font_weight, typeface.Stretch);
|
||||
|
||||
public static Typeface with(this Typeface typeface, System.Windows.Media.FontFamily font_family) =>
|
||||
public static Typeface with(this Typeface typeface, FontFamily font_family) =>
|
||||
new Typeface(font_family, typeface.Style, typeface.Weight, typeface.Stretch);
|
||||
|
||||
/// <summary>
|
||||
@@ -100,14 +94,7 @@ namespace mbts.ui.utility.text {
|
||||
}
|
||||
}
|
||||
|
||||
public static FontFamily ParseFontFamily(string family_name) {
|
||||
// TODO
|
||||
switch (family_name) {
|
||||
default: return FontFamily.Standard;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<FontWeight> available_weights(this System.Windows.Media.FontFamily family) =>
|
||||
public static IEnumerable<FontWeight> available_weights(this FontFamily family) =>
|
||||
family.FamilyTypefaces
|
||||
.Select(ft => ft.Weight)
|
||||
.Distinct()
|
||||
@@ -119,13 +106,13 @@ namespace mbts.ui.utility.text {
|
||||
.Select(p => (FontWeight)p.GetValue(null)).Distinct();
|
||||
|
||||
|
||||
public static string name(this System.Windows.Media.FontFamily font_family) =>
|
||||
public static string name(this FontFamily font_family) =>
|
||||
font_family.FamilyNames.Values.FirstOrDefault() ?? string.Empty;
|
||||
|
||||
public static string display_name(this System.Windows.Media.FontFamily family, double size) =>
|
||||
public static string display_name(this FontFamily family, double size) =>
|
||||
$"{family}, {size} pt";
|
||||
|
||||
public static string display_name(this System.Windows.Media.FontFamily family, FontWeight weight, double size) =>
|
||||
public static string display_name(this FontFamily family, FontWeight weight, double size) =>
|
||||
$"{family} {weight}, {size} pt";
|
||||
|
||||
public static bool is_space_type(this char c) => CharSets.spaces.Contains(c);
|
||||
|
||||
Reference in new issue
Block a user