Skip to content

Commit

Permalink
Merge pull request #5853 from Gillibald/fixes/TextBlockHorizontalAlig…
Browse files Browse the repository at this point in the history
…nment

Fix TextAlignment for TextBlock when HorizontalAlignment is used.
# Conflicts:
#	src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs
  • Loading branch information
Gillibald authored and Dan Walmsley committed Apr 30, 2021
1 parent 60ab70a commit cb24755
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ public void Draw(DrawingContext context)
/// <param name="height">The current height.</param>
private static void UpdateBounds(TextLine textLine, ref double width, ref double height)
{
if (width < textLine.LineMetrics.Size.Width)
var lineWidth = textLine.Width + textLine.Start * 2;

if (width < lineWidth)
{
width = textLine.LineMetrics.Size.Width;
width = lineWidth;
}

height += textLine.LineMetrics.Size.Height;
Expand Down

0 comments on commit cb24755

Please sign in to comment.