Skip to content

Commit

Permalink
Fix Issue #17
Browse files Browse the repository at this point in the history
Fixes Issue #17 - correction to positioning matrix.
  • Loading branch information
vonderborch committed Oct 22, 2021
1 parent 8b6cd2b commit 0bfa5a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion Velentr.Font.DevEnv/Game1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,25 @@ protected override void Update(GameTime gameTime)

protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
GraphicsDevice.Clear(Color.Red);

_spriteBatch.Begin();

//_spriteBatch.DrawString(font1, testString, new Vector2(0, -15), Color.Blue);
/*
_spriteBatch.DrawStringWithMarkdown(font1, testString3, new Vector2(0, -15), Color.Black);
_spriteBatch.DrawString(font1, testString, new Vector2(150, -15), Color.Pink, 0.1f, Vector2.Zero, new Vector2(.5f, .5f), SpriteEffects.None, 1f);
_spriteBatch.DrawString(text2, new Vector2(50, 150), Color.Red);
_spriteBatch.DrawString(text1, new Vector2(150, 300), Color.Black, 0.1f, Vector2.Zero, new Vector2(.5f, .5f), SpriteEffects.None, 1f);
_spriteBatch.DrawString(text1, new Vector2(150, 350), Color.Black, 0.1f, new Vector2(50, 50), new Vector2(.5f, .5f), SpriteEffects.FlipVertically, 1f);
*/

var text = "cake";
var text2 = font1.MakeText(text);
//_spriteBatch.DrawString(font1, text, (new Vector2(75, 75) - (font1.MeasureText(text) / 2)), Color.Blue);
//_spriteBatch.DrawString(font1, text, (new Vector2(75, 75) - (font1.MeasureText(text) / 2)), Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.5F);

_spriteBatch.DrawString(text2, (new Vector2(75, 75) - (font1.MeasureText(text) / 2)), Color.Blue);

_spriteBatch.End();

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 @@ -10,7 +10,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.2.7</Version>
<Version>1.2.8</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
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 @@ -10,7 +10,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.2.7</Version>
<Version>1.2.8</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>..\release\Monogame\Velentr.Font.Monogame.xml</DocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion Velentr.Font/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public void Draw(SpriteBatch spriteBatch, string text, Color color, Rectangle bo
underrun = 0;
}

var characterPosition = new Vector2(boundaries.X + offsetX, boundaries.Y + offsetY);
var characterPosition = new Vector2(offsetX, offsetY);
Vector2.Transform(ref characterPosition, ref transformation, out characterPosition);
spriteBatch.Draw(cachedCharacter.GlyphCache.Texture, characterPosition, cachedCharacter.Boundary, currentColor, rotation, origin, scale, effects, layerDepth);
offsetX += cachedCharacter.Boundary.Width;
Expand Down

0 comments on commit 0bfa5a8

Please sign in to comment.