diff --git a/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs b/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs index 57cba5e..f87d3b9 100644 --- a/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs +++ b/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs @@ -45,7 +45,12 @@ namespace SlatedGameToolkit.Framework.Graphics.Text public unsafe BitmapFont(byte[] data, GLContext glContext = null, int cacheSize = 1024, int textures = 2, uint textureSizes = 512) { info = new StbTrueType.stbtt_fontinfo(); fixed(byte* dataPtr = &data[0]) { - StbTrueType.stbtt_InitFont(info, dataPtr, 0); + int offset = StbTrueType.stbtt_GetFontOffsetForIndex(dataPtr, 0); + if (offset != -1) { + StbTrueType.stbtt_InitFont(info, dataPtr, offset); + } else { + throw new FrameworkUsageException("Could not load ttf file."); + } } this.glyphIndices = new LRUCache(cacheSize); @@ -90,6 +95,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Text int textureChanges = 0; foreach (char c in characters) { + if (c == ' ') continue; if (!glyphTexLocations.ContainsKey((c, scale)) || !textures[glyphTexLocations[(c, scale)]].ContainsChar(c, scale)) { glyphTexLocations.Remove((c, scale)); if (!textures[drawingTo].Upload(scale, c)) {