@ -89,7 +89,7 @@ namespace Avalonia.Skia
public Size Constraint = > _ constraint ;
public Size Constraint = > _ constraint ;
public Size Size = > _ size ;
public Rect Bounds = > _ bound s;
public IEnumerable < FormattedTextLine > GetLines ( )
public IEnumerable < FormattedTextLine > GetLines ( )
{
{
@ -135,7 +135,7 @@ namespace Avalonia.Skia
} ;
} ;
}
}
bool end = point . X > _ size . Width | | point . Y > _l ines . Sum ( l = > l . Height ) ;
bool end = point . X > _ bound s. Width | | point . Y > _l ines . Sum ( l = > l . Height ) ;
return new TextHitTestResult ( )
return new TextHitTestResult ( )
{
{
@ -323,7 +323,7 @@ namespace Avalonia.Skia
private Size _ constraint = new Size ( double . PositiveInfinity , double . PositiveInfinity ) ;
private Size _ constraint = new Size ( double . PositiveInfinity , double . PositiveInfinity ) ;
private float _l ineHeight = 0 ;
private float _l ineHeight = 0 ;
private float _l ineOffset = 0 ;
private float _l ineOffset = 0 ;
private Size _ size ;
private Rect _ bounds ;
private List < AvaloniaFormattedTextLine > _ skiaLines ;
private List < AvaloniaFormattedTextLine > _ skiaLines ;
private static void ApplyWrapperTo ( ref SKPaint current , DrawingContextImpl . PaintWrapper wrapper ,
private static void ApplyWrapperTo ( ref SKPaint current , DrawingContextImpl . PaintWrapper wrapper ,
@ -639,12 +639,26 @@ namespace Avalonia.Skia
if ( _ skiaLines . Count = = 0 )
if ( _ skiaLines . Count = = 0 )
{
{
_l ines . Add ( new FormattedTextLine ( 0 , _l ineHeight ) ) ;
_l ines . Add ( new FormattedTextLine ( 0 , _l ineHeight ) ) ;
_ size = new Size ( 0 , _l ineHeight ) ;
_ bound s = new Rect ( 0 , 0 , 0 , _l ineHeight ) ;
}
}
else
else
{
{
var lastLine = _ skiaLines [ _ skiaLines . Count - 1 ] ;
var lastLine = _ skiaLines [ _ skiaLines . Count - 1 ] ;
_ size = new Size ( maxX , lastLine . Top + lastLine . Height ) ;
_ bounds = new Rect ( 0 , 0 , maxX , lastLine . Top + lastLine . Height ) ;
switch ( _ paint . TextAlign )
{
case SKTextAlign . Center :
_ bounds = new Rect ( Constraint ) . CenterRect ( _ bounds ) ;
break ;
case SKTextAlign . Right :
_ bounds = new Rect (
Constraint . Width - _ bounds . Width ,
0 ,
_ bounds . Width ,
_ bounds . Height ) ;
break ;
}
}
}
}
}
@ -660,7 +674,7 @@ namespace Avalonia.Skia
{
{
double width = Constraint . Width > 0 & & ! double . IsPositiveInfinity ( Constraint . Width ) ?
double width = Constraint . Width > 0 & & ! double . IsPositiveInfinity ( Constraint . Width ) ?
Constraint . Width :
Constraint . Width :
_ size . Width ;
_ bound s. Width ;
switch ( align )
switch ( align )
{
{