Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
Minor fixes and checks for overruns
  • Loading branch information
vonderborch committed Apr 6, 2021
1 parent 57274bf commit 77e72a3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions Velentr.Font.Core/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void Draw(SpriteBatch spriteBatch, string text, Color color, Rectangle bo
}

// Markdown rules
if (applyMarkdown && text[i] == '[')
if (applyMarkdown && text[i] == '[' && (i > 0 && text[i - 1] != '\\'))
{
var results = ApplyMarkdownCommands(text, color, i);
i = results.Item1;
Expand Down Expand Up @@ -339,7 +339,7 @@ public void Draw(SpriteBatch spriteBatch, string text, Color color, Rectangle bo
}

// Markdown rules
if (applyMarkdown && text[i] == '[')
if (applyMarkdown && text[i] == '[' && (i > 0 && text[i - 1] != '\\'))
{
var results = ApplyMarkdownCommands(text, color, i);
i = results.Item1;
Expand Down Expand Up @@ -440,7 +440,7 @@ public Text MakeText(string text, bool applyMarkdown = false)
}

// Markdown rules
if (applyMarkdown && text[i] == '[')
if (applyMarkdown && text[i] == '[' && (i > 0 && text[i - 1] != '\\'))
{
var results = ApplyMarkdownCommands(text, Color.White, i);
i = results.Item1;
Expand Down Expand Up @@ -542,7 +542,7 @@ public Vector2 MeasureText(string text)
}

// Markdown rules
if (text[i] == '[')
if (text[i] == '[' && (i > 0 && text[i - 1] != '\\'))
{
var results = ApplyMarkdownCommands(text, Color.White, i);
i = results.Item1;
Expand Down Expand Up @@ -759,6 +759,13 @@ private bool TryGetGlyph(char character, out Internal.Glyph glyph)
int finalIIndex;
int endIndex;
var finalColor = defaultColor;

// exit early if we're at the end of the string
if (text.Length <= currentIndex + 1)
{
return (currentIndex, finalColor);
}

switch (text[currentIndex + 1])
{
// invalid markdown, we'll skip this markdown...
Expand Down
2 changes: 1 addition & 1 deletion Velentr.Font.Core/Velentr.Font.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU</Platforms>
<RootNamespace>Velentr.Font</RootNamespace>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Velentr.Font.FNA/Velentr.Font.FNA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageProjectUrl>https://github.com/vonderborch/Velentr.Font</PackageProjectUrl>
<Description>An alternative solution for Monogame/FNA/XNA-derived frameworks that utilizes SharpFont to draw text rather than the traditional SpriteFont approach.</Description>
<PackageTags>SharpFont, FNA, SpriteFont, Font</PackageTags>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
2 changes: 1 addition & 1 deletion Velentr.Font.Monogame/Velentr.Font.Monogame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageProjectUrl>https://github.com/vonderborch/Velentr.Font</PackageProjectUrl>
<Description>An alternative solution for Monogame/FNA/XNA-derived frameworks that utilizes SharpFont to draw text rather than the traditional SpriteFont approach.</Description>
<PackageTags>SharpFont, Monogame, SpriteFont, Font</PackageTags>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down

0 comments on commit 77e72a3

Please sign in to comment.