Dashboard/Quik/Media/FontInfo.cs

48 lines
1.2 KiB
C#

using System;
namespace Quik.Media
{
public struct FontInfo : IEquatable<FontInfo>
{
public string Family { get; }
public FontStyle Style { get; }
public float Size { get; }
public override string ToString()
{
return $"{Family} {Style} {Size}";
}
public override int GetHashCode()
{
return Family.GetHashCode() ^
(Style.GetHashCode() * 3976061) ^
(Size.GetHashCode() * 9428791);
}
public static bool operator==(FontInfo a, FontInfo b)
{
return (a.Style == b.Style) &&
(a.Size == b.Size) &&
(a.Family == a.Family);
}
public static bool operator!=(FontInfo a, FontInfo b)
{
return (a.Style != b.Style) ||
(a.Size != b.Size) ||
(a.Family != b.Family);
}
public bool Equals(FontInfo other)
{
return this == other;
}
public override bool Equals(object obj)
{
return (obj.GetType() == typeof(FontInfo)) &&
this == (FontInfo)obj;
}
}
}