From 94a5725a038c4b85572604900ee314b7472e836f Mon Sep 17 00:00:00 2001 From: FoggyFinder Date: Tue, 7 Apr 2020 12:21:02 +0300 Subject: [PATCH] apply transformation to x with alignment in case of empty text --- src/Skia/Avalonia.Skia/FormattedTextImpl.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs index 9612fa3d9b..d55af84b14 100644 --- a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs +++ b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs @@ -142,21 +142,16 @@ namespace Avalonia.Skia { var rects = GetRects(); - if (index < 0 || index >= rects.Count) - { - var r = rects.LastOrDefault(); - return new Rect(r.X + r.Width, r.Y, 0, _lineHeight); - } - if (rects.Count == 0) { - return new Rect(0, 0, 1, _lineHeight); + var x = TransformX(0, 0, _paint.TextAlign); + return new Rect(x, 0, 0, _lineHeight); } - if (index == rects.Count) + if (index < 0 || index >= rects.Count) { - var lr = rects[rects.Count - 1]; - return new Rect(new Point(lr.X + lr.Width, lr.Y), rects[index - 1].Size); + var r = rects.LastOrDefault(); + return new Rect(r.X + r.Width, r.Y, 0, _lineHeight); } return rects[index];