@ -162,7 +162,7 @@ namespace Avalonia.Controls
nameof ( Inlines ) , t = > t . Inlines , ( t , v ) = > t . Inlines = v ) ;
nameof ( Inlines ) , t = > t . Inlines , ( t , v ) = > t . Inlines = v ) ;
private TextLayout ? _ textLayout ;
private TextLayout ? _ textLayout ;
protected Size _ constraint = Size . Infinity ;
protected Size _ constraint = new ( double . NaN , double . NaN ) ;
protected IReadOnlyList < TextRun > ? _ textRuns ;
protected IReadOnlyList < TextRun > ? _ textRuns ;
private InlineCollection ? _ inlines ;
private InlineCollection ? _ inlines ;
@ -366,6 +366,13 @@ namespace Avalonia.Controls
internal bool HasComplexContent = > Inlines ! = null & & Inlines . Count > 0 ;
internal bool HasComplexContent = > Inlines ! = null & & Inlines . Count > 0 ;
private protected Size GetMaxSizeFromConstraint ( )
{
var maxWidth = double . IsNaN ( _ constraint . Width ) ? 0.0 : _ constraint . Width ;
var maxHeight = double . IsNaN ( _ constraint . Height ) ? 0.0 : _ constraint . Height ;
return new Size ( maxWidth , maxHeight ) ;
}
/// <summary>
/// <summary>
/// The BaselineOffset property provides an adjustment to baseline offset
/// The BaselineOffset property provides an adjustment to baseline offset
/// </summary>
/// </summary>
@ -670,12 +677,14 @@ namespace Avalonia.Controls
textSource = new SimpleTextSource ( text ? ? "" , defaultProperties ) ;
textSource = new SimpleTextSource ( text ? ? "" , defaultProperties ) ;
}
}
var maxSize = GetMaxSizeFromConstraint ( ) ;
return new TextLayout (
return new TextLayout (
textSource ,
textSource ,
paragraphProperties ,
paragraphProperties ,
TextTrimming ,
TextTrimming ,
_ constraint . Width ,
maxSize . Width ,
_ constraint . Height ,
maxSize . Height ,
MaxLines ) ;
MaxLines ) ;
}
}