forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FontSource.cs
37 lines (30 loc) · 1.05 KB
/
FontSource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#nullable enable
using System;
namespace Microsoft.Maui.Graphics
{
public struct FontSource : IEquatable<FontSource>
{
public FontSource(string filename, int weight = FontWeights.Normal, FontStyleType fontStyleType = FontStyleType.Normal)
{
Name = filename;
Weight = weight;
FontStyleType = fontStyleType;
}
public readonly string Name;
public readonly int Weight;
public readonly FontStyleType FontStyleType;
public bool Equals(FontSource other)
=> Name.Equals(other.Name, StringComparison.Ordinal)
&& Weight.Equals(other.Weight)
&& FontStyleType.Equals(other.FontStyleType);
public override int GetHashCode() => Name.GetHashCode(
#if !NETSTANDARD2_0
StringComparison.Ordinal
#endif
)
^ Weight.GetHashCode() ^ FontStyleType.GetHashCode();
public override bool Equals(object? obj) => obj is FontSource other && Equals(other);
public static bool operator ==(FontSource left, FontSource right) => left.Equals(right);
public static bool operator !=(FontSource left, FontSource right) => !(left == right);
}
}