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:
parent
f35730ee7c
commit
4c378f7cd9
3 changed files with 10 additions and 4 deletions
|
@ -18,6 +18,10 @@ Jump to version:
|
||||||
|
|
||||||
## 7.1.2 (In Development)
|
## 7.1.2 (In Development)
|
||||||
|
|
||||||
|
### MLEM
|
||||||
|
Fixes
|
||||||
|
- Fixed formatting codes at the start of strings not being added to the AllCodes collection
|
||||||
|
|
||||||
### MLEM.Ui
|
### MLEM.Ui
|
||||||
Additions
|
Additions
|
||||||
- Added Panel.IsVisible method to check if a child element is visible
|
- Added Panel.IsVisible method to check if a child element is visible
|
||||||
|
|
|
@ -160,8 +160,10 @@ namespace MLEM.Formatting {
|
||||||
var allCodes = new List<Code>();
|
var allCodes = new List<Code>();
|
||||||
// add the formatting code right at the start of the string
|
// add the formatting code right at the start of the string
|
||||||
var firstCode = this.GetNextCode(s, 0, 0);
|
var firstCode = this.GetNextCode(s, 0, 0);
|
||||||
if (firstCode != null)
|
if (firstCode != null) {
|
||||||
|
allCodes.Add(firstCode);
|
||||||
applied.Add(firstCode);
|
applied.Add(firstCode);
|
||||||
|
}
|
||||||
var index = 0;
|
var index = 0;
|
||||||
var rawIndex = 0;
|
var rawIndex = 0;
|
||||||
while (rawIndex < s.Length) {
|
while (rawIndex < s.Length) {
|
||||||
|
|
|
@ -118,11 +118,11 @@ public class FontTests {
|
||||||
[Test]
|
[Test]
|
||||||
public void TestFormatting() {
|
public void TestFormatting() {
|
||||||
this.formatter.AddImage("Test", new TextureRegion((Texture2D) null, 0, 8, 24, 24));
|
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);
|
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.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]
|
[Test]
|
||||||
|
|
Loading…
Reference in a new issue