From c4ee3ba64e9b9da71d3b224446795d3bb81d65a0 Mon Sep 17 00:00:00 2001 From: notgull Date: Sat, 18 Feb 2023 17:59:30 -0800 Subject: [PATCH] Early panic on divide by zero --- src/buffer.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/buffer.rs b/src/buffer.rs index 9b243d3..ad3bde1 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -306,6 +306,8 @@ pub struct Buffer<'a> { impl<'a> Buffer<'a> { /// Create a new [`Buffer`] with the provided [`FontSystem`] and [`Metrics`] pub fn new(font_system: &'a FontSystem, metrics: Metrics) -> Self { + assert_ne!(metrics.line_height, 0, "line height cannot be 0"); + let mut buffer = Self { font_system, lines: Vec::new(),