Fix justified linebreaking without justifiables
This commit is contained in:
parent
f78a8f5d48
commit
c3b1e32d11
|
|
@ -1001,8 +1001,10 @@ fn linebreak_optimized<'a>(vt: &Vt, p: &'a Preparation<'a>, width: Abs) -> Vec<L
|
||||||
ratio = 0.0;
|
ratio = 0.0;
|
||||||
}
|
}
|
||||||
if ratio > 1.0 {
|
if ratio > 1.0 {
|
||||||
// We should stretch the line above its stretchability. Now calculate the extra amount.
|
// We should stretch the line above its stretchability. Now
|
||||||
let extra_stretch = (delta - adjust) / attempt.justifiables() as f64;
|
// 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.
|
// Normalize the amount by half Em size.
|
||||||
ratio = 1.0 + extra_stretch / (em / 2.0);
|
ratio = 1.0 + extra_stretch / (em / 2.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -0,0 +1,5 @@
|
||||||
|
// Test breaking a line without justifiables.
|
||||||
|
|
||||||
|
---
|
||||||
|
#set par(justify: true)
|
||||||
|
#block(width: 1cm, fill: aqua, lorem(2))
|
||||||
Loading…
Reference in New Issue