Browse Source

Merge pull request #5853 from Gillibald/fixes/TextBlockHorizontalAlignment

Fix TextAlignment for TextBlock when HorizontalAlignment is used.
Benedikt Stebner 4 years ago
parent
commit
9305b2b6ea
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs

+ 4 - 2
src/Avalonia.Visuals/Media/TextFormatting/TextLayout.cs

@@ -305,9 +305,11 @@ namespace Avalonia.Media.TextFormatting
         /// <param name="height">The current height.</param>
         private static void UpdateBounds(TextLine textLine, ref double width, ref double height)
         {
-            if (width < textLine.Width)
+            var lineWidth = textLine.Width + textLine.Start * 2;
+            
+            if (width < lineWidth)
             {
-                width = textLine.Width;
+                width = lineWidth;
             }
 
             height += textLine.Height;