mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix unnecessary hyphenation (#5394)
This commit is contained in:
parent
7add9b459a
commit
cce744cf78
@ -543,7 +543,12 @@ fn raw_ratio(
|
|||||||
) -> f64 {
|
) -> f64 {
|
||||||
// Determine how much the line's spaces would need to be stretched
|
// Determine how much the line's spaces would need to be stretched
|
||||||
// to make it the desired width.
|
// 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.
|
// Determine how much stretch or shrink is natural.
|
||||||
let adjustability = if delta >= Abs::zero() { stretchability } else { shrinkability };
|
let adjustability = if delta >= Abs::zero() { stretchability } else { shrinkability };
|
||||||
|
BIN
tests/ref/issue-5360-unnecessary-hyphenation.png
Normal file
BIN
tests/ref/issue-5360-unnecessary-hyphenation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -172,3 +172,8 @@ int main() {
|
|||||||
// Test that overflow does not lead to bad bounds in paragraph optimization.
|
// Test that overflow does not lead to bad bounds in paragraph optimization.
|
||||||
#set par(justify: true)
|
#set par(justify: true)
|
||||||
#block(width: 0pt)[A B]
|
#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])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user