/// <summary> /// Initializes a new instance of the <see cref="TextLayout" /> class. /// </summary> /// <param name="text">The text.</param> /// <param name="typeface">The typeface.</param> /// <param name="fontSize">Size of the font.</param> /// <param name="foreground">The foreground.</param> /// <param name="textAlignment">The text alignment.</param> /// <param name="textWrapping">The text wrapping.</param> /// <param name="textTrimming">The text trimming.</param> /// <param name="textDecorations">The text decorations.</param> /// <param name="maxWidth">The maximum width.</param> /// <param name="maxHeight">The maximum height.</param> /// <param name="maxLines">The maximum number of text lines.</param> /// <param name="textStyleOverrides">The text style overrides.</param> public TextLayout( string text, Typeface typeface, double fontSize, IBrush foreground, TextAlignment textAlignment = TextAlignment.Left, TextWrapping textWrapping = TextWrapping.NoWrap, TextTrimming textTrimming = TextTrimming.None, TextDecorationCollection textDecorations = null, double maxWidth = double.PositiveInfinity, double maxHeight = double.PositiveInfinity, int maxLines = 0, IReadOnlyList <TextStyleRun> textStyleOverrides = null) { _text = string.IsNullOrEmpty(text) ? new ReadOnlySlice <char>() : new ReadOnlySlice <char>(text.AsMemory()); _paragraphProperties = CreateTextParagraphProperties(typeface, fontSize, foreground, textAlignment, textWrapping, textTrimming, textDecorations?.ToImmutable()); _textStyleOverrides = textStyleOverrides; MaxWidth = maxWidth; MaxHeight = maxHeight; MaxLines = maxLines; UpdateLayout(); }