diff --git a/MLEM.Ui/Elements/TextField.cs b/MLEM.Ui/Elements/TextField.cs
index 14ce61a..332fbd7 100644
--- a/MLEM.Ui/Elements/TextField.cs
+++ b/MLEM.Ui/Elements/TextField.cs
@@ -423,7 +423,7 @@ namespace MLEM.Ui.Elements {
var maxWidth = this.DisplayArea.Width / this.Scale - this.TextOffsetX * 2;
if (this.Multiline) {
// soft wrap if we're multiline
- this.splitText = this.Font.Value.SplitStringSeparate(this.text.ToString(), maxWidth, this.TextScale).ToArray();
+ this.splitText = this.Font.Value.SplitStringSeparate(this.text, maxWidth, this.TextScale).ToArray();
this.displayedText = string.Join("\n", this.splitText);
this.UpdateCaretData();
@@ -466,7 +466,7 @@ namespace MLEM.Ui.Elements {
}
} else {
// not multiline, so scroll horizontally based on caret position
- if (this.Font.Value.MeasureString(this.text.ToString()).X * this.TextScale > maxWidth) {
+ if (this.Font.Value.MeasureString(this.text).X * this.TextScale > maxWidth) {
if (this.textOffset > this.CaretPos) {
// if we're moving the caret to the left
this.textOffset = this.CaretPos;
diff --git a/MLEM/Font/GenericFont.cs b/MLEM/Font/GenericFont.cs
index fa060a6..6961637 100644
--- a/MLEM/Font/GenericFont.cs
+++ b/MLEM/Font/GenericFont.cs
@@ -110,6 +110,11 @@ namespace MLEM.Font {
return this.MeasureString(new CharSource(text), ignoreTrailingSpaces, null);
}
+ ///
+ public Vector2 MeasureString(StringBuilder text, bool ignoreTrailingSpaces = false) {
+ return this.MeasureString(new CharSource(text), ignoreTrailingSpaces, null);
+ }
+
///
/// Truncates a string to a given width. If the string's displayed area is larger than the maximum width, the string is cut off.
/// Optionally, the string can be cut off a bit sooner, adding the at the end instead.