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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
BIN
tests/ref/bugs/linebreak-no-justifiables.png
Normal file
BIN
tests/ref/bugs/linebreak-no-justifiables.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
5
tests/typ/bugs/linebreak-no-justifiables.typ
Normal file
5
tests/typ/bugs/linebreak-no-justifiables.typ
Normal file
@ -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
Block a user