diff options
| author | Peng Guanwen <pg999w@outlook.com> | 2023-04-18 00:20:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-17 18:20:59 +0200 |
| commit | 480ad7670b19457a3163d59e948bfac5eacd9472 (patch) | |
| tree | 1927ca2b08d5bfa249ceb7a344a2aa2ac915c70d /library/src/layout | |
| parent | 9bdc4a7de0fb685fa2b8d02280e70aa0b5d92bf9 (diff) | |
More Chinese punctuation adjustment (#836)
and also general linebreak improvements
Diffstat (limited to 'library/src/layout')
| -rw-r--r-- | library/src/layout/par.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs index 5d33de40..29a82a01 100644 --- a/library/src/layout/par.rs +++ b/library/src/layout/par.rs @@ -906,7 +906,7 @@ fn linebreak_optimized<'a>(vt: &Vt, p: &'a Preparation<'a>, width: Abs) -> Vec<L } // Determine the cost of the line. - let min_ratio = if attempt.justify { MIN_RATIO } else { 0.0 }; + let min_ratio = if p.justify { MIN_RATIO } else { 0.0 }; let mut cost = if ratio < min_ratio { // The line is overfull. This is the case if // - justification is on, but we'd need to shrink too much @@ -920,7 +920,9 @@ fn linebreak_optimized<'a>(vt: &Vt, p: &'a Preparation<'a>, width: Abs) -> Vec<L // all breakpoints before this one become inactive since no line // can span above the mandatory break. active = k; - if attempt.justify { + // If ratio > 0, we need to stretch the line only when justify is needed. + // If ratio < 0, we always need to shrink the line. + if (ratio > 0.0 && attempt.justify) || ratio < 0.0 { ratio.powi(3).abs() } else { 0.0 |
