Merge pull request #77 from notgull/early-div-zero
bugfix: Panic if a line height of zero is passed into Buffer
This commit is contained in:
commit
9a4d067f9d
1 changed files with 3 additions and 0 deletions
|
|
@ -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(),
|
||||
|
|
@ -491,6 +493,7 @@ impl<'a> Buffer<'a> {
|
|||
/// Set the current [`Metrics`]
|
||||
pub fn set_metrics(&mut self, metrics: Metrics) {
|
||||
if metrics != self.metrics {
|
||||
assert_ne!(metrics.font_size, 0, "font size cannot be 0");
|
||||
self.metrics = metrics;
|
||||
self.relayout();
|
||||
self.shape_until_scroll();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue