StringBuilder PrepareFormattingString(StringBuilder _formattingString) { if (!ForegroundColor.IsDefault) { _formattingString.AppendFormat("color={0} ", ForegroundColor.ToHex()); } if (!BackgroundColor.IsDefault) { _formattingString.AppendFormat("backing_color={0} backing=on ", BackgroundColor.ToHex()); } if (!string.IsNullOrEmpty(FontFamily)) { _formattingString.AppendFormat("font={0} ", FontFamily); } if (FontSize != -1) { _formattingString.AppendFormat("font_size={0} ", System.Maui.Maui.ConvertToEflFontPoint(FontSize)); } if ((FontAttributes & FontAttributes.Bold) != 0) { _formattingString.Append("font_weight=Bold "); } else { // FontWeight is only available in case of FontAttributes.Bold is not used. if (FontWeight != Specific.FontWeight.None) { _formattingString.AppendFormat("font_weight={0} ", FontWeight); } } if ((FontAttributes & FontAttributes.Italic) != 0) { _formattingString.Append("font_style=italic "); } if (Underline) { _formattingString.AppendFormat("underline=on underline_color={0} ", ForegroundColor.IsDefault ? s_defaultLineColor.ToHex() : ForegroundColor.ToHex()); } if (Strikethrough) { _formattingString.AppendFormat("strikethrough=on strikethrough_color={0} ", ForegroundColor.IsDefault ? s_defaultLineColor.ToHex() : ForegroundColor.ToHex()); } switch (HorizontalTextAlignment) { case TextAlignment.Auto: _formattingString.Append("align=auto "); break; case TextAlignment.Start: _formattingString.Append("align=left "); break; case TextAlignment.End: _formattingString.Append("align=right "); break; case TextAlignment.Center: _formattingString.Append("align=center "); break; case TextAlignment.None: break; } if (LineHeight != -1.0d) { _formattingString.Append($"linerelsize={(int)(LineHeight * 100)}%"); } switch (LineBreakMode) { case LineBreakMode.HeadTruncation: _formattingString.Append("ellipsis=0.0"); break; case LineBreakMode.MiddleTruncation: _formattingString.Append("ellipsis=0.5"); break; case LineBreakMode.TailTruncation: _formattingString.Append("ellipsis=1.0"); break; case LineBreakMode.None: break; } return(_formattingString); }