1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 06:28:35 +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 System.Text;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@ -68,10 +69,16 @@ namespace MLEM.Font {
} }
private static SpriteFont SetDefaults(SpriteFont font) { private static SpriteFont SetDefaults(SpriteFont font) {
// so that missing character behavior is in line with MG.Extended's // we copy the font here to set the default character to a space
// bitmap fonts, we draw nothing as the default character return new SpriteFont(
font.DefaultCharacter = ' '; font.Texture,
return font; 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(),
' ');
} }
} }