Native.FormattedString nativeString = new Native.FormattedString();
- foreach (var element in formattedString.Spans)
+ foreach (var span in formattedString.Spans)
{
- Native.Span span = new Native.Span();
- span.FormattedText = element.Text;
- span.FontAttributes = element.FontAttributes;
- span.FontFamily = element.FontFamily;
- span.FontSize = element.FontSize;
- span.ForegroundColor = element.ForegroundColor.IsDefault ? s_defaultForegroundColor : element.ForegroundColor.ToNative();
- span.BackgroundColor = element.BackgroundColor.IsDefault ? s_defaultBackgroundColor : element.BackgroundColor.ToNative();
-
- nativeString.Spans.Add(span);
+ Native.Span nativeSpan = new Native.Span();
+ nativeSpan.FormattedText = span.Text;
+ nativeSpan.FontAttributes = span.FontAttributes == FontAttributes.None ? Element.FontAttributes : span.FontAttributes;
+ nativeSpan.FontFamily = span.FontFamily == null ? Element.FontFamily : span.FontFamily;
+ nativeSpan.FontSize = span.FontSize == Device.GetNamedSize(NamedSize.Default, typeof(Label), true) ? Element.FontSize : span.FontSize;
+
+ if (span.ForegroundColor.IsDefault)
+ nativeSpan.ForegroundColor = Element.TextColor.IsDefault ? s_defaultForegroundColor : Element.TextColor.ToNative();
+ else
+ nativeSpan.ForegroundColor = span.ForegroundColor.ToNative();
+
+ if (span.BackgroundColor.IsDefault)
+ nativeSpan.BackgroundColor = Element.BackgroundColor.IsDefault ? s_defaultBackgroundColor : Element.BackgroundColor.ToNative();
+ else
+ nativeSpan.BackgroundColor = span.BackgroundColor.ToNative();
+
+ nativeString.Spans.Add(nativeSpan);
}
return nativeString;