mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
also apply the newline fix to bitmap fonts
This commit is contained in:
parent
e1baacdb0d
commit
404e95c8f2
1 changed files with 10 additions and 7 deletions
|
@ -8,15 +8,18 @@ namespace MLEM.Extended.Extensions {
|
||||||
|
|
||||||
public static IEnumerable<string> SplitString(this BitmapFont font, string text, float width, float scale) {
|
public static IEnumerable<string> SplitString(this BitmapFont font, string text, float width, float scale) {
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
foreach (var word in text.Split(' ')) {
|
foreach (var line in text.Split('\n')) {
|
||||||
builder.Append(word).Append(' ');
|
foreach (var word in line.Split(' ')) {
|
||||||
if (font.MeasureString(builder).Width * scale >= width) {
|
builder.Append(word).Append(' ');
|
||||||
var len = builder.Length - word.Length - 1;
|
if (font.MeasureString(builder).Width * scale >= width) {
|
||||||
yield return builder.ToString(0, len - 1);
|
var len = builder.Length - word.Length - 1;
|
||||||
builder.Remove(0, len);
|
yield return builder.ToString(0, len - 1);
|
||||||
|
builder.Remove(0, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
yield return builder.ToString(0, builder.Length - 1);
|
||||||
|
builder.Clear();
|
||||||
}
|
}
|
||||||
yield return builder.ToString(0, builder.Length - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue