diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 1ee0b364136c..6f7667378dca 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -2171,12 +2171,15 @@ impl Context { self.write(|ctx| { let tessellation_options = ctx.memory.options.tessellation_options; - let texture_atlas = ctx - .fonts - .get(&pixels_per_point.into()) - .expect("tessellate called with a different pixels_per_point than the font atlas was created with. \ - You should use egui::FullOutput::pixels_per_point when tessellating.") - .texture_atlas(); + let texture_atlas = match ctx.fonts.get(&pixels_per_point.into()) { + Some(fonts) => fonts.texture_atlas(), + None => { + ctx.fonts.iter().next() + .expect("tessellate called with a different pixels_per_point than the font atlas was created with. \ + You should use egui::FullOutput::pixels_per_point when tessellating.") + .1.texture_atlas() + } + }; let (font_tex_size, prepared_discs) = { let atlas = texture_atlas.lock(); (atlas.size(), atlas.prepared_discs()) diff --git a/crates/egui/src/layers.rs b/crates/egui/src/layers.rs index b9b1fb5a5c38..f73880b4fbdb 100644 --- a/crates/egui/src/layers.rs +++ b/crates/egui/src/layers.rs @@ -149,6 +149,10 @@ impl PaintList { /// and then later setting it using `paint_list.set(idx, cr, frame);`. #[inline(always)] pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) { + if self.0.len() <= idx.0 { + self.add(clip_rect, Shape::Noop); + } + self.0[idx.0] = ClippedShape { clip_rect, shape }; }