1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-27 02:29:23 +01:00

copy SpriteFont in GenericSpriteFont so that we don't modify the passed fonts' default character

This commit is contained in:
Ell 2020-09-28 02:52:51 +02:00
parent aa064812fc
commit bd43c14a33

View file

@ -1,3 +1,4 @@
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@ -68,10 +69,16 @@ namespace MLEM.Font {
}
private static SpriteFont SetDefaults(SpriteFont font) {
// so that missing character behavior is in line with MG.Extended's
// bitmap fonts, we draw nothing as the default character
font.DefaultCharacter = ' ';
return font;
// we copy the font here to set the default character to a space
return new SpriteFont(
font.Texture,
font.Glyphs.Select(g => g.BoundsInTexture).ToList(),
font.Glyphs.Select(g => g.Cropping).ToList(),
font.Characters.ToList(),
font.LineSpacing,
font.Spacing,
font.Glyphs.Select(g => new Vector3(g.LeftSideBearing, g.Width, g.RightSideBearing)).ToList(),
' ');
}
}