From e2f9a8ff5d2d5a9ae51bfd9c0a0e4fb9e85e5766 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 6 Sep 2019 11:25:31 +0200 Subject: [PATCH] fixed a splitstring crash with specific string lengths and font sizes --- MLEM/Extensions/SpriteFontExtensions.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MLEM/Extensions/SpriteFontExtensions.cs b/MLEM/Extensions/SpriteFontExtensions.cs index bc914d8..8b55de2 100644 --- a/MLEM/Extensions/SpriteFontExtensions.cs +++ b/MLEM/Extensions/SpriteFontExtensions.cs @@ -37,8 +37,10 @@ namespace MLEM.Extensions { curr.Append(word).Append(' '); if (widthFunc(curr) * scale >= width) { var len = curr.Length - word.Length - 1; - total.Append(curr.ToString(0, len - 1)).Append('\n'); - curr.Remove(0, len); + if (len > 0) { + total.Append(curr.ToString(0, len - 1)).Append('\n'); + curr.Remove(0, len); + } } } total.Append(curr.ToString(0, curr.Length - 1)).Append('\n');