mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
fixed GetSelfWidth receiving the default and custom font inconsistently
This commit is contained in:
parent
066ed9f8f7
commit
f0b65daf68
1 changed files with 6 additions and 10 deletions
|
@ -162,17 +162,13 @@ namespace MLEM.Formatting {
|
||||||
for (var t = 0; t < this.Tokens.Length; t++) {
|
for (var t = 0; t < this.Tokens.Length; t++) {
|
||||||
var token = this.Tokens[t];
|
var token = this.Tokens[t];
|
||||||
var drawFont = token.GetFont(font);
|
var drawFont = token.GetFont(font);
|
||||||
var selfWidth = token.GetSelfWidth(drawFont);
|
|
||||||
var drawColor = token.GetColor(color);
|
var drawColor = token.GetColor(color);
|
||||||
|
|
||||||
|
token.DrawSelf(time, batch, pos + innerOffset, drawFont, drawColor, scale, depth);
|
||||||
|
innerOffset.X += token.GetSelfWidth(drawFont) * scale;
|
||||||
|
|
||||||
var indexInToken = 0;
|
var indexInToken = 0;
|
||||||
for (var l = 0; l < token.SplitDisplayString.Length; l++) {
|
for (var l = 0; l < token.SplitDisplayString.Length; l++) {
|
||||||
// only draw self at the start of the first line of the token!
|
|
||||||
if (indexInToken == 0) {
|
|
||||||
token.DrawSelf(time, batch, pos + innerOffset, drawFont, color, scale, depth);
|
|
||||||
innerOffset.X += selfWidth * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
var charIndex = 0;
|
var charIndex = 0;
|
||||||
var line = new CodePointSource(token.SplitDisplayString[l]);
|
var line = new CodePointSource(token.SplitDisplayString[l]);
|
||||||
while (charIndex < line.Length) {
|
while (charIndex < line.Length) {
|
||||||
|
@ -242,8 +238,8 @@ namespace MLEM.Formatting {
|
||||||
if (endsLater) {
|
if (endsLater) {
|
||||||
for (var i = tokenIndex + 1; i < this.Tokens.Length; i++) {
|
for (var i = tokenIndex + 1; i < this.Tokens.Length; i++) {
|
||||||
var other = this.Tokens[i];
|
var other = this.Tokens[i];
|
||||||
var otherWidth = other.GetSelfWidth(defaultFont);
|
var otherFont = other.GetFont(defaultFont);
|
||||||
restOfLine += other.GetFont(defaultFont).MeasureString(other.SplitDisplayString[0], !this.EndsLater(i, 0)).X + otherWidth;
|
restOfLine += otherFont.MeasureString(other.SplitDisplayString[0], !this.EndsLater(i, 0)).X + other.GetSelfWidth(otherFont);
|
||||||
// if the token's split display string has multiple lines, then the line ends in it, which means we can stop
|
// 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)
|
if (other.SplitDisplayString.Length > 1)
|
||||||
break;
|
break;
|
||||||
|
@ -268,7 +264,7 @@ namespace MLEM.Formatting {
|
||||||
private float GetSelfWidthForIndex(GenericFont font, int index) {
|
private float GetSelfWidthForIndex(GenericFont font, int index) {
|
||||||
foreach (var token in this.Tokens) {
|
foreach (var token in this.Tokens) {
|
||||||
if (index == token.Index)
|
if (index == token.Index)
|
||||||
return token.GetSelfWidth(font);
|
return token.GetSelfWidth(token.GetFont(font));
|
||||||
// if we're already beyond this token, any later tokens definitely won't match
|
// if we're already beyond this token, any later tokens definitely won't match
|
||||||
if (token.Index > index)
|
if (token.Index > index)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue