Browse Source

Try all font styles to find a fallback typeface

pull/5370/head
Benedikt Schroeder 6 years ago
parent
commit
fe6f66e77d
  1. 6
      src/Skia/Avalonia.Skia/SKTypefaceCollection.cs

6
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;
}
}
}

Loading…
Cancel
Save