فهرست منبع

Don't attempt to render glyphs we don't have

Thomas Dy 7 سال پیش
والد
کامیت
4bf78e33ed
1فایلهای تغییر یافته به همراه13 افزوده شده و 12 حذف شده
  1. 13 12
      src/ui/font.rs

+ 13 - 12
src/ui/font.rs

@@ -221,18 +221,19 @@ impl FontLoader {
         let mut id = 0;
         let mut width = 0;
         for (i, charcode) in string.char_indices() {
-            let (this_id, char_width) = self.glyphset_and_width_for_char(charcode).unwrap();
-            width += char_width;
-            if i == 0 {
-                id = this_id;
-            }
-            else if id != this_id {
-                ret.push(TextGroup {
-                    text: &string[prev..i],
-                    glyphset: id
-                });
-                id = this_id;
-                prev = i;
+            if let Some((this_id, char_width)) = self.glyphset_and_width_for_char(charcode) {
+                width += char_width;
+                if i == 0 {
+                    id = this_id;
+                }
+                else if id != this_id {
+                    ret.push(TextGroup {
+                        text: &string[prev..i],
+                        glyphset: id
+                    });
+                    id = this_id;
+                    prev = i;
+                }
             }
         }
         ret.push(TextGroup {