diff --git a/src/Controls/src/Core/FontExtensions.cs b/src/Controls/src/Core/FontExtensions.cs index 8e4899490d7e..538a78534fa7 100644 --- a/src/Controls/src/Core/FontExtensions.cs +++ b/src/Controls/src/Core/FontExtensions.cs @@ -26,7 +26,13 @@ public static FontAttributes GetFontAttributes(this Font font) return attributes; } - public static Font ToFont(this IFontElement element) => - Font.OfSize(element.FontFamily, element.FontSize, enableScaling: element.FontAutoScalingEnabled).WithAttributes(element.FontAttributes); + public static Font ToFont(this IFontElement element, double? defaultSize = null) + { + var size = element.FontSize; + if (defaultSize.HasValue && (size == 0 || size == double.NaN)) + size = defaultSize.Value; + + return Font.OfSize(element.FontFamily, size, enableScaling: element.FontAutoScalingEnabled).WithAttributes(element.FontAttributes); + } } } diff --git a/src/Controls/src/Core/Platform/Android/Extensions/FormattedStringExtensions.cs b/src/Controls/src/Core/Platform/Android/Extensions/FormattedStringExtensions.cs index c330b9868a5e..7e6b66d84b7c 100644 --- a/src/Controls/src/Core/Platform/Android/Extensions/FormattedStringExtensions.cs +++ b/src/Controls/src/Core/Platform/Android/Extensions/FormattedStringExtensions.cs @@ -22,6 +22,8 @@ public static SpannableString ToSpannableString(this FormattedString formattedSt if (formattedString == null) return new SpannableString(string.Empty); + var defaultFontSize = defaultFont?.Size ?? fontManager.DefaultFontSize; + var builder = new StringBuilder(); for (int i = 0; i < formattedString.Spans.Count; i++) { @@ -70,7 +72,7 @@ public static SpannableString ToSpannableString(this FormattedString formattedSt spannable.SetSpan(new LineHeightSpan(textPaint, lineHeight), start, end, SpanTypes.InclusiveExclusive); } - var font = span.ToFont(); + var font = span.ToFont(defaultFontSize); if (font.IsDefault && defaultFont.HasValue) font = defaultFont.Value;