mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00
Fix figlet centering possibly throwing due to negative size (#1302)
This commit is contained in:
parent
f7befacd79
commit
037e109699
@ -67,8 +67,8 @@ public sealed class FigletText : Renderable, IHasJustification
|
|||||||
}
|
}
|
||||||
else if (alignment == Console.Justify.Center)
|
else if (alignment == Console.Justify.Center)
|
||||||
{
|
{
|
||||||
var left = (maxWidth - lineWidth) / 2;
|
var left = Math.Max(0, maxWidth - lineWidth) / 2;
|
||||||
var right = left + ((maxWidth - lineWidth) % 2);
|
var right = left + (Math.Max(0, maxWidth - lineWidth) % 2);
|
||||||
|
|
||||||
yield return Segment.Padding(left);
|
yield return Segment.Padding(left);
|
||||||
yield return line;
|
yield return line;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user