Skip to content

Commit 86646c8

Browse files
committed
MauiFontLoader.Load: use fontName as fallback if GetFont fails (on iOS)
* and mirror the same behavior on MacCatalyst * as suggested by Copilot
1 parent cc4b097 commit 86646c8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Source/OxyPlot.Maui.Skia/Platforms/MacCatalyst/MauiFontLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public Stream Load(string fontName)
1212
if (fontRegistrar == null)
1313
fontRegistrar = IPlatformApplication.Current.Services.GetRequiredService<IFontRegistrar>();
1414

15-
fontName = fontRegistrar.GetFont(fontName);
16-
if (File.Exists(fontName))
17-
{
15+
fontName = fontRegistrar.GetFont(fontName) ?? fontName;
16+
if (fontName == null)
17+
return null;
18+
else if (File.Exists(fontName))
1819
return File.OpenRead(fontName);
19-
}
2020

2121
try
2222
{

Source/OxyPlot.Maui.Skia/Platforms/iOS/MauiFontLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public Stream Load(string fontName)
1212
if (fontRegistrar == null)
1313
fontRegistrar = IPlatformApplication.Current.Services.GetRequiredService<IFontRegistrar>();
1414

15-
fontName = fontRegistrar.GetFont(fontName);
15+
fontName = fontRegistrar.GetFont(fontName) ?? fontName;
1616
if (fontName == null)
1717
return null;
1818
else if (File.Exists(fontName))

0 commit comments

Comments
 (0)