diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-10-18 15:10:22 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-10-18 16:21:08 +0200 |
| commit | 242a16e77a867dabc538a767fcd46a38b8b23a2e (patch) | |
| tree | 82320bc071e23a41c0d4d858beda1ab687a2c86c | |
| parent | 0774943f1d877a3146817f6dc9fec3549537edd3 (diff) | |
Fix optimized linebreaks without justification (#5236)
| -rw-r--r-- | crates/typst/src/layout/inline/linebreak.rs | 2 | ||||
| -rw-r--r-- | tests/ref/issue-5235-linebreak-optimized-without-justify.png | bin | 0 -> 5821 bytes | |||
| -rw-r--r-- | tests/suite/layout/inline/linebreak.typ | 16 |
3 files changed, 17 insertions, 1 deletions
diff --git a/crates/typst/src/layout/inline/linebreak.rs b/crates/typst/src/layout/inline/linebreak.rs index f5048aae..aa62d487 100644 --- a/crates/typst/src/layout/inline/linebreak.rs +++ b/crates/typst/src/layout/inline/linebreak.rs @@ -597,7 +597,7 @@ fn raw_cost( let badness = if ratio < metrics.min_ratio(approx) { // Overfull line always has maximum cost. 1_000_000.0 - } else if justify || ratio < 0.0 { + } else if breakpoint != Breakpoint::Mandatory || justify || ratio < 0.0 { // If the line shall be justified or needs shrinking, it has normal // badness with cost 100|ratio|^3. We limit the ratio to 10 as to not // get to close to our maximum cost. diff --git a/tests/ref/issue-5235-linebreak-optimized-without-justify.png b/tests/ref/issue-5235-linebreak-optimized-without-justify.png Binary files differnew file mode 100644 index 00000000..b36dc406 --- /dev/null +++ b/tests/ref/issue-5235-linebreak-optimized-without-justify.png diff --git a/tests/suite/layout/inline/linebreak.typ b/tests/suite/layout/inline/linebreak.typ index 8371d76e..e4b04b24 100644 --- a/tests/suite/layout/inline/linebreak.typ +++ b/tests/suite/layout/inline/linebreak.typ @@ -123,3 +123,19 @@ For info see #link("https://myhost.tld"). // - shaping that results in multiple glyphs in the same cluster #set text(font: "Noto Sans Thai") #h(85pt) งบิก + +--- issue-5235-linebreak-optimized-without-justify --- +#set page(width: 207pt, margin: 15pt) +#set text(11pt) + +#set par(linebreaks: "simple") +Some texts feature many longer +words. Those are often exceedingly +challenging to break in a visually +pleasing way. + +#set par(linebreaks: "optimized") +Some texts feature many longer +words. Those are often exceedingly +challenging to break in a visually +pleasing way. |
