mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
Fixed some TokenizedString tokens starting with a line break not being split correctly
This commit is contained in:
parent
0fe4c940d7
commit
023233a062
2 changed files with 4 additions and 9 deletions
|
@ -21,6 +21,7 @@ Improvements
|
|||
|
||||
Fixes
|
||||
- Fixed TokenizedString handling trailing spaces incorrectly in the last line of non-left aligned text
|
||||
- Fixed some TokenizedString tokens starting with a line break not being split correctly
|
||||
|
||||
### MLEM.Ui
|
||||
Additions
|
||||
|
|
|
@ -229,16 +229,10 @@ namespace MLEM.Formatting {
|
|||
if (endsLater) {
|
||||
for (var i = tokenIndex + 1; i < this.Tokens.Length; i++) {
|
||||
var other = this.Tokens[i];
|
||||
var otherFont = other.GetFont(defaultFont);
|
||||
if (other.SplitDisplayString.Length > 1) {
|
||||
// the line ends in this token (so we also ignore trailing whitespaces)
|
||||
restOfLine += otherFont.MeasureString(other.SplitDisplayString[0], true).X;
|
||||
restOfLine += other.GetFont(defaultFont).MeasureString(other.SplitDisplayString[0], true).X;
|
||||
// if the token's split display string has multiple lines, then the line ends in it, which means we can stop
|
||||
if (other.SplitDisplayString.Length > 1)
|
||||
break;
|
||||
} else {
|
||||
// the line doesn't end in this token (or it's the last token), so add it fully
|
||||
var lastToken = i >= this.Tokens.Length - 1;
|
||||
restOfLine += otherFont.MeasureString(other.DisplayString, lastToken).X;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (alignment == TextAlignment.Center)
|
||||
|
|
Loading…
Reference in a new issue