Skip to content

Commit f2ae2ce

Browse files
committed
don't panic when an invalid font instance key is supplied
1 parent 400ae87 commit f2ae2ce

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

webrender/src/frame.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,22 @@ impl Frame {
567567
info.image_rendering);
568568
}
569569
SpecificDisplayItem::Text(ref text_info) => {
570-
let instance = context.resource_cache.get_font_instance(text_info.font_key).unwrap();
571-
context.builder.add_text(clip_and_scroll,
572-
reference_frame_relative_offset,
573-
item_rect_with_offset,
574-
&clip_with_offset,
575-
instance,
576-
&text_info.color,
577-
item.glyphs(),
578-
item.display_list().get(item.glyphs()).count(),
579-
text_info.glyph_options);
570+
match context.resource_cache.get_font_instance(text_info.font_key) {
571+
Some(instance) => {
572+
context.builder.add_text(clip_and_scroll,
573+
reference_frame_relative_offset,
574+
item_rect_with_offset,
575+
&clip_with_offset,
576+
instance,
577+
&text_info.color,
578+
item.glyphs(),
579+
item.display_list().get(item.glyphs()).count(),
580+
text_info.glyph_options);
581+
}
582+
None => {
583+
warn!("Unknown font instance key: {:?}", text_info.font_key);
584+
}
585+
}
580586
}
581587
SpecificDisplayItem::Rectangle(ref info) => {
582588
if !self.try_to_add_rectangle_splitting_on_clip(context,

0 commit comments

Comments
 (0)