diff --git a/Cargo.toml b/Cargo.toml index 3766102..3d6359a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fontkit" -version = "0.6.0-beta.7" +version = "0.6.0-beta.8" edition = "2021" authors = ["Zimon Dai "] description = "A simple library for font loading and indexing" diff --git a/src/metrics.rs b/src/metrics.rs index 366eef1..91560a3 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -285,6 +285,9 @@ impl TextMetrics { } pub(crate) fn width_until(&self, font_size: f32, letter_spacing: f32, index: usize) -> f32 { + if self.units == 0 { + return 0.0; + } let factor = font_size / self.units as f32; let positions = self.positions.read().unwrap(); positions.iter().take(index).fold(0.0, |current, p| {