From cce744cf780dd730f1638e17a0e106faeb38de22 Mon Sep 17 00:00:00 2001 From: wznmickey Date: Sun, 17 Nov 2024 04:04:07 -0500 Subject: Fix unnecessary hyphenation (#5394) --- crates/typst-layout/src/inline/linebreak.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crates/typst-layout') diff --git a/crates/typst-layout/src/inline/linebreak.rs b/crates/typst-layout/src/inline/linebreak.rs index 26621cd7..236d6892 100644 --- a/crates/typst-layout/src/inline/linebreak.rs +++ b/crates/typst-layout/src/inline/linebreak.rs @@ -543,7 +543,12 @@ fn raw_ratio( ) -> f64 { // Determine how much the line's spaces would need to be stretched // to make it the desired width. - let delta = available_width - line_width; + let mut delta = available_width - line_width; + + // Avoid possible floating point errors in previous calculation. + if delta.approx_eq(Abs::zero()) { + delta = Abs::zero(); + } // Determine how much stretch or shrink is natural. let adjustability = if delta >= Abs::zero() { stretchability } else { shrinkability }; -- cgit v1.2.3