[chore:] logging for StableFontResolver.cs
This commit is contained in:
@@ -62,13 +62,15 @@ public class StableFontResolver : IFontResolver
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
// ignore resolver init errors
|
||||
Logger.Log($"Error while initializing FontResolver: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string NormalizeStyle(string s)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(s)) return "Regular";
|
||||
s = s.ToLowerInvariant();
|
||||
@@ -78,8 +80,17 @@ public class StableFontResolver : IFontResolver
|
||||
if (s.Contains("regular") || s == "r") return "Regular";
|
||||
return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(s);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while normalizing style: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If requested family exists, pick corresponding style if available
|
||||
string familyToUse = null;
|
||||
@@ -100,8 +111,17 @@ public class StableFontResolver : IFontResolver
|
||||
// Face name format: Family#Style
|
||||
return new FontResolverInfo($"{familyToUse}#{style}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while resolving typeface: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] GetFont(string faceName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(faceName)) return null;
|
||||
|
||||
@@ -133,4 +153,11 @@ public class StableFontResolver : IFontResolver
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while getting font: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user