Fix unnecessary hyphenation (#5394)

This commit is contained in:
wznmickey 2024-11-17 04:04:07 -05:00 committed by GitHub
parent 7add9b459a
commit cce744cf78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -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 };

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -172,3 +172,8 @@ int main() {
// Test that overflow does not lead to bad bounds in paragraph optimization.
#set par(justify: true)
#block(width: 0pt)[A B]
--- issue-5360-unnecessary-hyphenation ---
// Test whether `Formal` would be in one line.
#set par(justify: true)
#table(columns: 1, [Formal])