From fe6f66e77d9ac0f363d9bdc8e741e8970f89b9dc Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Thu, 28 Jan 2021 19:00:20 +0100 Subject: [PATCH] Try all font styles to find a fallback typeface --- src/Skia/Avalonia.Skia/SKTypefaceCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs b/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs index 71deb1235f..7c4ff4edc0 100644 --- a/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs +++ b/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs @@ -32,7 +32,7 @@ namespace Avalonia.Skia weight -= weight % 100; // make sure we start at a full weight - for (var i = (int)key.Style; i < 2; i++) + for (var i = 0; i < 2; i++) { // only try 2 font weights in each direction for (var j = 0; j < 200; j += 100) @@ -57,8 +57,8 @@ namespace Avalonia.Skia } } - //Nothing was found so we use the first typeface we can get. - return typefaces.Values.FirstOrDefault(); + //Nothing was found so we try to get a regular typeface. + return typefaces.TryGetValue(new Typeface(key.FontFamily), out typeface) ? typeface : null; } } }