1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 04:53:29 +01:00

Fixed formatting codes at the start of strings not being added to the AllCodes collection

Closes #26
This commit is contained in:
Ell 2024-09-29 12:17:47 +02:00
parent f35730ee7c
commit 4c378f7cd9
3 changed files with 10 additions and 4 deletions

View file

@ -18,6 +18,10 @@ Jump to version:
## 7.1.2 (In Development)
### MLEM
Fixes
- Fixed formatting codes at the start of strings not being added to the AllCodes collection
### MLEM.Ui
Additions
- Added Panel.IsVisible method to check if a child element is visible

View file

@ -160,8 +160,10 @@ namespace MLEM.Formatting {
var allCodes = new List<Code>();
// add the formatting code right at the start of the string
var firstCode = this.GetNextCode(s, 0, 0);
if (firstCode != null)
if (firstCode != null) {
allCodes.Add(firstCode);
applied.Add(firstCode);
}
var index = 0;
var rawIndex = 0;
while (rawIndex < s.Length) {

View file

@ -118,11 +118,11 @@ public class FontTests {
[Test]
public void TestFormatting() {
this.formatter.AddImage("Test", new TextureRegion((Texture2D) null, 0, 8, 24, 24));
const string strg = "Lorem Ipsum <i Test> is simply dummy text of the <i Test> printing and typesetting <i Test> industry. Lorem Ipsum has been the industry's standard dummy text <i Test> ever since the <i Test> 1500s, when <i Test><i Test><i Test><i Test><i Test><i Test><i Test> an unknown printer took a galley of type and scrambled it to make a type specimen book.";
const string strg = "<b>Lorem</b> Ipsum <i Test> is simply dummy text of the <i Test> printing and typesetting <i Test> industry. Lorem Ipsum has been the industry's standard dummy text <i Test> ever since the <i Test> 1500s, when <i Test><i Test><i Test><i Test><i Test><i Test><i Test> an unknown printer took a galley of type and scrambled it to make a type specimen <b></b>book.";
var ret = this.formatter.Tokenize(this.font, strg);
Assert.AreEqual(ret.Tokens.Length, 13);
Assert.AreEqual(ret.Tokens.Length, 16);
Assert.AreEqual(ret.DisplayString, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.");
Assert.AreEqual(ret.AllCodes.Length, 12);
Assert.AreEqual(ret.AllCodes.Length, 16);
}
[Test]