diff --git a/Source/SVGImage/SVG/Utils/FontResolver.cs b/Source/SVGImage/SVG/Utils/FontResolver.cs index 7b63d91..373e527 100644 --- a/Source/SVGImage/SVG/Utils/FontResolver.cs +++ b/Source/SVGImage/SVG/Utils/FontResolver.cs @@ -27,15 +27,15 @@ public class FontResolver public FontResolver(int maxLevenshteinDistance = 0) { _availableFonts = Fonts.SystemFontFamilies - .Select(ff => new { NormalName = ff.Source, Family = ff }) - .ToDictionary(x => x.NormalName, x => x.Family, StringComparer.OrdinalIgnoreCase); + .GroupBy(ff => ff.Source, StringComparer.OrdinalIgnoreCase) + .ToDictionary(g => g.Key, g => g.First(), StringComparer.OrdinalIgnoreCase); _normalizedFontNameMap = new Dictionary(_availableFonts.Count); - foreach (var font in _availableFonts.Keys) - { - var name = Normalize(font); - if (!_normalizedFontNameMap.ContainsKey(name)) - _normalizedFontNameMap.Add(name, font); + foreach (var font in _availableFonts.Keys) + { + var name = Normalize(font); + if (!_normalizedFontNameMap.ContainsKey(name)) + _normalizedFontNameMap.Add(name, font); } MaxLevenshteinDistance = maxLevenshteinDistance; } @@ -157,7 +157,7 @@ private static string Normalize(string fontName) return string.Empty; } return _normalizationRegex.Replace(fontName, String.Empty).ToLowerInvariant(); - + } private static int[,] CreateDistanceMatrix(int length1, int length2) @@ -201,7 +201,7 @@ private static int Levenshtein(string string1, string string2) return string1.Length; } - + int[,] distanceMatrix = CreateDistanceMatrix(string1.Length, string2.Length); for (int i = 1; i <= string1.Length; i++) @@ -221,5 +221,5 @@ private static int Levenshtein(string string1, string string2) } } - + }