diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-10-28 18:02:16 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-10-28 18:02:16 +0200 |
| commit | c3b1e32d11c8485194070710431b081c52a64c45 (patch) | |
| tree | bbadd6b38e905a3adc13aaeb013ff717138e00b2 /crates | |
| parent | f78a8f5d4863260d05cbabe2711324489be47242 (diff) | |
Fix justified linebreaking without justifiables
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst-library/src/layout/par.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/typst-library/src/layout/par.rs b/crates/typst-library/src/layout/par.rs index 9b5f641b..ee47b579 100644 --- a/crates/typst-library/src/layout/par.rs +++ b/crates/typst-library/src/layout/par.rs @@ -1001,8 +1001,10 @@ fn linebreak_optimized<'a>(vt: &Vt, p: &'a Preparation<'a>, width: Abs) -> Vec<L ratio = 0.0; } if ratio > 1.0 { - // We should stretch the line above its stretchability. Now calculate the extra amount. - let extra_stretch = (delta - adjust) / attempt.justifiables() as f64; + // We should stretch the line above its stretchability. Now + // calculate the extra amount. Also, don't divide by zero. + let extra_stretch = + (delta - adjust) / attempt.justifiables().max(1) as f64; // Normalize the amount by half Em size. ratio = 1.0 + extra_stretch / (em / 2.0); } |
