Fix labels, lists and other tweaks

This commit is contained in:
2026-01-24 02:21:56 +00:00
parent 5415c71e9e
commit 7830356f24
10 changed files with 100 additions and 27 deletions

View File

@@ -711,10 +711,6 @@ public class SkiaLabel : SkiaView
if (needsMultiLine)
{
var textBoundsDbg = new SKRect();
paint.MeasureText(displayText, ref textBoundsDbg);
if (displayText.StartsWith("Full XAML") || displayText.StartsWith("Shell nav"))
Console.WriteLine($"[Label OnDraw] '{displayText.Substring(0, Math.Min(15, displayText.Length))}' textW={textBoundsDbg.Width:F0} boundsW={contentBounds.Width:F0} LineBreakMode={LineBreakMode}");
DrawMultiLineText(canvas, paint, font, contentBounds, displayText);
}
else
@@ -1126,6 +1122,15 @@ public class SkiaLabel : SkiaView
continue;
}
// Check if the entire paragraph fits on one line - no need to wrap
// Use small tolerance to account for floating point precision
float paragraphWidth = paint.MeasureText(paragraph);
if (paragraphWidth <= maxWidth + 1.0f)
{
lines.Add(paragraph);
continue;
}
if (LineBreakMode == LineBreakMode.CharacterWrap)
{
WrapByCharacter(paragraph, paint, maxWidth, lines);
@@ -1236,9 +1241,11 @@ public class SkiaLabel : SkiaView
}
else
{
// Use advance width (paint.MeasureText return value) not bounding box width
// This must match what WrapText uses for consistency
var textBounds = new SKRect();
paint.MeasureText(displayText, ref textBounds);
width = textBounds.Width;
width = paint.MeasureText(displayText); // Advance width, not textBounds.Width
height = textBounds.Height;
// Account for character spacing