Font Crash gracious fallback

This commit is contained in:
Andrii Yukhymchak
2017-10-18 22:37:52 +03:00
committed by abcdefg30
parent 6a750d7a65
commit 636a9a74a1

View File

@@ -84,6 +84,7 @@ namespace OpenRA.Graphics
}
var g = glyphs[Pair.New(s, c)];
if (g.Sprite != null)
Game.Renderer.RgbaSpriteRenderer.DrawSprite(g.Sprite,
new float2(
(int)Math.Round(p.X * deviceScale + g.Offset.X, 0) / deviceScale,
@@ -135,8 +136,21 @@ namespace OpenRA.Graphics
}
GlyphInfo CreateGlyph(Pair<char, Color> c)
{
try
{
face.LoadChar(c.First, LoadFlags.Default, LoadTarget.Normal);
}
catch (FreeTypeException)
{
return new GlyphInfo
{
Sprite = null,
Advance = 0,
Offset = int2.Zero
};
}
face.Glyph.RenderGlyph(RenderMode.Normal);
var size = new Size((int)face.Glyph.Metrics.Width, (int)face.Glyph.Metrics.Height);