Prevent overfull inline math from overlapping words
This commit is contained in:
1 parent
d248a84764
commit
5d4920eb29
3 files changed
+11
-3
No files matched your search
@@ -893,7 +893,11 @@ impl InlineMathItem {
|
||||
Self::Text { width, .. } => *width,
|
||||
Self::Formula(layout) => layout.size.width,
|
||||
Self::MathSpacing(glue) => glue.width,
|
||||
Self::Kern(width) | Self::Glue(width) => *width,
|
||||
Self::Kern(width) => *width,
|
||||
// Overfull inline-math lines can produce a negative shrink glue.
|
||||
// Painting with a negative advance would put the following word on
|
||||
// top of the current one, so clamp the space at zero.
|
||||
Self::Glue(width) => (*width).max(Mm::from(0.6)),
|
||||
Self::ExplicitGlue(glue) => mm_from_scaled(glue.width),
|
||||
Self::BreakPenalty(_) => Mm::from(0.0),
|
||||
}
|
||||
|
||||
@@ -1838,7 +1838,10 @@ fn paragraph_glue_width(glue: &Glue, order: common::GlueOrder, ratio: f64) -> Sc
|
||||
let adjustment = if ratio > 0.0 && glue.stretch_order == order {
|
||||
f64::from(glue.stretch.0) * ratio
|
||||
} else if ratio < 0.0 && glue.shrink_order == order {
|
||||
f64::from(glue.shrink.0) * ratio
|
||||
// Never shrink a space past its declared shrink amount: a TeX
|
||||
// overfull line may report ratio < -1, which would make the space
|
||||
// negative and paint adjacent words on top of each other.
|
||||
f64::from(glue.shrink.0) * ratio.max(-1.0)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
@@ -1296,7 +1296,8 @@ fn measure_positioned_lines(
|
||||
.map(|(line_index, (height_mm, element))| {
|
||||
let height =
|
||||
i64::from(scaled_points(f64::from(height_mm) * PDF_POINTS_PER_INCH / 25.4).0)
|
||||
.saturating_add(1);
|
||||
.saturating_add(1)
|
||||
.max(baseline_skip_scaled(font_size));
|
||||
let ascent = millimeters_to_scaled(f64::from(element.baseline())).min(height);
|
||||
let pre_display_size = element
|
||||
.pre_display_size()
|
||||
|
||||
Reference in new issue
Block a user