diff --git a/CHANGELOG.md b/CHANGELOG.md index e29bfd4..cb6ffd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ Improvements Fixes - Fixed StaticSpriteBatch handling rotated sprites incorrectly +Removals +- Renamed GenericFont.OneEmSpace to Emsp (and marked OneEmSpace as obsolete) + ### MLEM.Ui Additions - Added Element.OnStyleInit event diff --git a/MLEM/Font/GenericFont.cs b/MLEM/Font/GenericFont.cs index fa55078..4b82973 100644 --- a/MLEM/Font/GenericFont.cs +++ b/MLEM/Font/GenericFont.cs @@ -18,7 +18,10 @@ namespace MLEM.Font { /// This is a character that isn't drawn, but has the same width as . /// Whereas a regular would have to explicitly support this character for width calculations, generic fonts implicitly support it in . /// - public const char OneEmSpace = '\u2003'; + public const char Emsp = '\u2003'; + /// + [Obsolete("Use the Emsp field instead.")] + public const char OneEmSpace = Emsp; /// /// This field holds the unicode representation of a non-breaking space. /// Whereas a regular would have to explicitly support this character for width calculations, generic fonts implicitly support it in . @@ -48,7 +51,7 @@ namespace MLEM.Font { /// /// Measures the width of the given character with the default scale for use in . - /// Note that this method does not support , and for most generic fonts, which is why should be used even for single characters. + /// Note that this method does not support , and for most generic fonts, which is why should be used even for single characters. /// /// The character whose width to calculate /// The width of the given character with the default scale @@ -100,7 +103,7 @@ namespace MLEM.Font { /// /// Measures the width of the given string when drawn with this font's underlying font. - /// This method uses internally to calculate the size of known characters and calculates additional characters like , and . + /// This method uses internally to calculate the size of known characters and calculates additional characters like , and . /// If the text contains newline characters (\n), the size returned will represent a rectangle that encompasses the width of the longest line and the string's full height. /// /// The text whose size to calculate @@ -182,7 +185,7 @@ namespace MLEM.Font { xOffset = 0; size.Y += this.LineHeight; break; - case OneEmSpace: + case Emsp: xOffset += this.LineHeight; break; case Nbsp: @@ -249,7 +252,7 @@ namespace MLEM.Font { } else { var font = fontFunction?.Invoke(i) ?? this; var cWidth = font.MeasureString(c.ToCachedString()).X * scale; - if (c == ' ' || c == OneEmSpace || c == Zwsp) { + if (c == ' ' || c == Emsp || c == Zwsp) { // remember the location of this (breaking!) space lastSpaceIndex = curr.Length; widthSinceLastSpace = 0; diff --git a/MLEM/Formatting/Codes/ImageCode.cs b/MLEM/Formatting/Codes/ImageCode.cs index 5a7fe34..aef7616 100644 --- a/MLEM/Formatting/Codes/ImageCode.cs +++ b/MLEM/Formatting/Codes/ImageCode.cs @@ -27,7 +27,7 @@ namespace MLEM.Formatting.Codes { /// public override string GetReplacementString(GenericFont font) { - return GenericFont.OneEmSpace.ToCachedString(); + return GenericFont.Emsp.ToCachedString(); } /// diff --git a/Tests/FontTests.cs b/Tests/FontTests.cs index 3ab2998..674e32c 100644 --- a/Tests/FontTests.cs +++ b/Tests/FontTests.cs @@ -147,10 +147,10 @@ namespace Tests { } CompareSizes($"This is a very simple{GenericFont.Nbsp}test string"); - CompareSizes($"This is a very simple{GenericFont.OneEmSpace}test string"); + CompareSizes($"This is a very simple{GenericFont.Emsp}test string"); CompareSizes($"This is a very simple{GenericFont.Zwsp}test string"); - Assert.AreEqual(new Vector2(this.font.LineHeight, this.font.LineHeight), this.font.MeasureString(GenericFont.OneEmSpace.ToCachedString())); + Assert.AreEqual(new Vector2(this.font.LineHeight, this.font.LineHeight), this.font.MeasureString(GenericFont.Emsp.ToCachedString())); Assert.AreEqual(new Vector2(0, this.font.LineHeight), this.font.MeasureString(GenericFont.Zwsp.ToCachedString())); }