Browse Source
Fix TryCreateGlyphTypeface return on macOS with SkiaSharp 2.88 (#20084)
release/11.3.9
Julien Lebosquain
11 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
12 additions and
0 deletions
-
src/Skia/Avalonia.Skia/FontManagerImpl.cs
|
|
@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; |
|
|
using System.Globalization; |
|
|
using System.Globalization; |
|
|
using System.IO; |
|
|
using System.IO; |
|
|
using System.Text.RegularExpressions; |
|
|
using System.Text.RegularExpressions; |
|
|
|
|
|
using Avalonia.Compatibility; |
|
|
using Avalonia.Media; |
|
|
using Avalonia.Media; |
|
|
using Avalonia.Platform; |
|
|
using Avalonia.Platform; |
|
|
using SkiaSharp; |
|
|
using SkiaSharp; |
|
|
@ -124,6 +125,17 @@ namespace Avalonia.Skia |
|
|
|
|
|
|
|
|
var skTypeface = _skFontManager.MatchFamily(familyName, fontStyle); |
|
|
var skTypeface = _skFontManager.MatchFamily(familyName, fontStyle); |
|
|
|
|
|
|
|
|
|
|
|
// SkiaSharp 2.88 can return the default family name (Helvetica) on macOS here.
|
|
|
|
|
|
// On Windows and Linux, this returns null instead. Adjust the behavior on macOS to return null instead.
|
|
|
|
|
|
// (With SkiaSharp 3.119, all platforms return null).
|
|
|
|
|
|
if (OperatingSystemEx.IsMacOS() |
|
|
|
|
|
&& skTypeface is not null |
|
|
|
|
|
&& skTypeface.FamilyName != familyName |
|
|
|
|
|
&& skTypeface.FamilyName == GetDefaultFontFamilyName()) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (skTypeface is null) |
|
|
if (skTypeface is null) |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
|