diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index e194a17a63..f246fdae64 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -19,6 +19,9 @@ namespace OpenRA.Graphics { public class SpriteFont { + static Library library = new Library(); + static SheetBuilder builder; + int size; string name; @@ -30,8 +33,7 @@ namespace OpenRA.Graphics face = new Face(library, name); face.SetPixelSizes((uint)size, (uint)size); - glyphs = new Cache, GlyphInfo>(CreateGlyph, - Pair.EqualityComparer); + glyphs = new Cache, GlyphInfo>(CreateGlyph, Pair.EqualityComparer); // setup a SheetBuilder for our private use // TODO: SheetBuilder state is leaked between mod switches @@ -92,7 +94,7 @@ namespace OpenRA.Graphics return new int2((int)Math.Ceiling(lines.Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance))), lines.Length * size); } - Cache, GlyphInfo> glyphs; + Cache, GlyphInfo> glyphs; Face face; GlyphInfo CreateGlyph(Pair c) @@ -112,6 +114,7 @@ namespace OpenRA.Graphics // A new bitmap is generated each time this property is accessed, so we do need to dispose it. using (var bitmap = face.Glyph.Bitmap) + { unsafe { var p = (byte*)bitmap.Buffer; @@ -133,13 +136,12 @@ namespace OpenRA.Graphics p += bitmap.Pitch; } } + } + s.sheet.CommitData(); return g; } - - static Library library = new Library(); - static SheetBuilder builder; } class GlyphInfo