1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-29 15:58:33 +01:00

fixed a splitstring crash with specific string lengths and font sizes

This commit is contained in:
Ellpeck 2019-09-06 11:25:31 +02:00
parent af98526d47
commit e2f9a8ff5d

View file

@ -37,10 +37,12 @@ namespace MLEM.Extensions {
curr.Append(word).Append(' '); curr.Append(word).Append(' ');
if (widthFunc(curr) * scale >= width) { if (widthFunc(curr) * scale >= width) {
var len = curr.Length - word.Length - 1; var len = curr.Length - word.Length - 1;
if (len > 0) {
total.Append(curr.ToString(0, len - 1)).Append('\n'); total.Append(curr.ToString(0, len - 1)).Append('\n');
curr.Remove(0, len); curr.Remove(0, len);
} }
} }
}
total.Append(curr.ToString(0, curr.Length - 1)).Append('\n'); total.Append(curr.ToString(0, curr.Length - 1)).Append('\n');
} }
return total.ToString(0, total.Length - 1); return total.ToString(0, total.Length - 1);