From 83cb900c1c5818c305bf0c3dfc19d009b2a6cc60 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 7 May 2018 14:34:10 -0400 Subject: [PATCH] GlyphContext - return null if typeface does not have key for char (avoid KeyNotFoundException) --- src/client/spark/view/Utility/GlyphContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Utility/GlyphContext.cs b/src/client/spark/view/Utility/GlyphContext.cs index e89a49a36..79d7f2791 100644 --- a/src/client/spark/view/Utility/GlyphContext.cs +++ b/src/client/spark/view/Utility/GlyphContext.cs @@ -48,7 +48,8 @@ namespace mbts.ui.utility.text { var advance_widths = new double[text.Length]; double glyph_width = 0; for (int n = 0; n < text.Length; n++) { - var gc = _char_map[text[n]]; + if (!_char_map.TryGetValue(text[n], out (ushort index, double width) gc)) + return null; glyph_indices[n] = gc.index; double w = gc.width * font_size; advance_widths[n] = w;