I’m using “Arial Bold” 20pt SpriteFont:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<FontName>Arial Bold</FontName>
<Size>20</Size>
<Spacing>0</Spacing>
<UseKerning>true</UseKerning>
<Style>Regular</Style>
<DefaultCharacter>*</DefaultCharacter>
<CharacterRegions>
<CharacterRegion>
<Start> </Start>
<End>~</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
And the following code to draw a simple string:
_spriteBatch.Begin();
_spriteBatch.DrawString(SF, "Sample Text Test: tl", new Vector2(100, 100), Color.Black);
_spriteBatch.End();
I have 2 MonoGame projects and they’re giving me very different results on the same .spritefont.
My first project references these packages:
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
and gives me this result:
My second project references these packages:
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.1.303" />
and gives me this result:
Why does the result from my first project look so… bad? It looks like the kerning is incorrect, especially between the ‘t’ and ‘l’ at the end of the string.
If I copy over the .xnb file built from my second project into the first project’s bin\Content folder, then running the first project gives the desired rendering. So I assume it must be something different between whatever’s creating the .xnb files. But I opened my Content.mgcb in both projects and they appear to have the exact same settings for my SpriteFont.
Edit: Ok I’m pretty sure the difference has nothing to do with using MonoGame.Framework.DesktopGL vs MonoGame.Framework.WindowsDX. I downgraded MonoGame.Content.Build.Task from 3.8.1.303 down to 3.8.0.1641 and I’m getting the desired kerning results now. So I guess there’s a bug in the latest version of MonoGame.Content.Build.Task.
The settings I was using on my spritefont in the MonoGame Pipeline Tool was:
Build Action: Build
Importer: Sprite Font Importer - MonoGame
Processor: Sprite Font Description - MonoGame
PremultiplyAlpha: True
TextureFormat: Color (I originally had this set to ‘Compressed’ and was still having the problem)