From fbfa7fe997cb31e13af1dde4518f571de9e9d8bc Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Fri, 12 Aug 2016 09:50:24 +0100 Subject: [PATCH] implemented Equals and GetHashCode in FontKey for skia typeface cache. --- src/Skia/Avalonia.Skia/TypefaceCache.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Skia/Avalonia.Skia/TypefaceCache.cs b/src/Skia/Avalonia.Skia/TypefaceCache.cs index 3d1bf8add0..c5f3d371ad 100644 --- a/src/Skia/Avalonia.Skia/TypefaceCache.cs +++ b/src/Skia/Avalonia.Skia/TypefaceCache.cs @@ -20,7 +20,27 @@ namespace Avalonia.Skia Slant = slant; Weight = weight; } - + + public override int GetHashCode() + { + int hash = 17; + hash = hash * 31 + (int)Slant; + hash = hash * 31 + (int)Weight; + + return hash; + } + + public override bool Equals(object other) + { + return other is FontKey ? Equals((FontKey)other) : false; + } + + public bool Equals(FontKey other) + { + return Slant == other.Slant && + Weight == other.Weight; + } + // Equals and GetHashCode ommitted }