gamnit: fix crash on character missing from font
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 14 Sep 2017 17:48:19 +0000 (13:48 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 25 Sep 2017 15:11:11 +0000 (11:11 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/bmfont.nit

index c2c8be5..a7afc56 100644 (file)
@@ -477,6 +477,13 @@ class BMFontAsset
                                                var w = text[wi]
 
                                                if w == '\n' or w == pld or w == plu or w.is_whitespace or (in_link and w == ']') then break
+
+                                               if not desc.chars.keys.has(w) then
+                                                       var rc = replacement_char
+                                                       if rc == null then continue
+                                                       w = rc
+                                               end
+
                                                word_len += advance(prev_w, w) * scale
                                                prev_w = w
                                        end