Apply short fall consistently in math when stretching (#6377)
@ -46,7 +46,7 @@ pub fn layout_accent(
|
||||
// wide in many case.
|
||||
let width = elem.size(styles).relative_to(base.width());
|
||||
let short_fall = ACCENT_SHORT_FALL.at(glyph.font_size);
|
||||
let variant = glyph.stretch_horizontal(ctx, width, short_fall);
|
||||
let variant = glyph.stretch_horizontal(ctx, width - short_fall);
|
||||
let accent = variant.frame;
|
||||
let accent_attach = variant.accent_attach.0;
|
||||
|
||||
|
@ -110,12 +110,12 @@ fn layout_frac_like(
|
||||
|
||||
if binom {
|
||||
let mut left = GlyphFragment::new(ctx, styles, '(', span)
|
||||
.stretch_vertical(ctx, height, short_fall);
|
||||
.stretch_vertical(ctx, height - short_fall);
|
||||
left.center_on_axis(ctx);
|
||||
ctx.push(left);
|
||||
ctx.push(FrameFragment::new(styles, frame));
|
||||
let mut right = GlyphFragment::new(ctx, styles, ')', span)
|
||||
.stretch_vertical(ctx, height, short_fall);
|
||||
.stretch_vertical(ctx, height - short_fall);
|
||||
right.center_on_axis(ctx);
|
||||
ctx.push(right);
|
||||
} else {
|
||||
|
@ -435,13 +435,8 @@ impl GlyphFragment {
|
||||
}
|
||||
|
||||
/// Try to stretch a glyph to a desired height.
|
||||
pub fn stretch_vertical(
|
||||
self,
|
||||
ctx: &mut MathContext,
|
||||
height: Abs,
|
||||
short_fall: Abs,
|
||||
) -> VariantFragment {
|
||||
stretch_glyph(ctx, self, height, short_fall, Axis::Y)
|
||||
pub fn stretch_vertical(self, ctx: &mut MathContext, height: Abs) -> VariantFragment {
|
||||
stretch_glyph(ctx, self, height, Axis::Y)
|
||||
}
|
||||
|
||||
/// Try to stretch a glyph to a desired width.
|
||||
@ -449,9 +444,8 @@ impl GlyphFragment {
|
||||
self,
|
||||
ctx: &mut MathContext,
|
||||
width: Abs,
|
||||
short_fall: Abs,
|
||||
) -> VariantFragment {
|
||||
stretch_glyph(ctx, self, width, short_fall, Axis::X)
|
||||
stretch_glyph(ctx, self, width, Axis::X)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ fn layout_delimiters(
|
||||
|
||||
if let Some(left) = left {
|
||||
let mut left = GlyphFragment::new(ctx, styles, left, span)
|
||||
.stretch_vertical(ctx, target, short_fall);
|
||||
.stretch_vertical(ctx, target - short_fall);
|
||||
left.align_on_axis(ctx, delimiter_alignment(left.c));
|
||||
ctx.push(left);
|
||||
}
|
||||
@ -323,7 +323,7 @@ fn layout_delimiters(
|
||||
|
||||
if let Some(right) = right {
|
||||
let mut right = GlyphFragment::new(ctx, styles, right, span)
|
||||
.stretch_vertical(ctx, target, short_fall);
|
||||
.stretch_vertical(ctx, target - short_fall);
|
||||
right.align_on_axis(ctx, delimiter_alignment(right.c));
|
||||
ctx.push(right);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ pub fn layout_root(
|
||||
// Layout root symbol.
|
||||
let target = radicand.height() + thickness + gap;
|
||||
let sqrt = GlyphFragment::new(ctx, styles, '√', span)
|
||||
.stretch_vertical(ctx, target, Abs::zero())
|
||||
.stretch_vertical(ctx, target)
|
||||
.frame;
|
||||
|
||||
// Layout the index.
|
||||
|
@ -67,8 +67,7 @@ pub fn stretch_fragment(
|
||||
let mut variant = stretch_glyph(
|
||||
ctx,
|
||||
glyph,
|
||||
stretch.relative_to(relative_to_size),
|
||||
short_fall,
|
||||
stretch.relative_to(relative_to_size) - short_fall,
|
||||
axis,
|
||||
);
|
||||
|
||||
@ -120,7 +119,6 @@ pub fn stretch_glyph(
|
||||
ctx: &mut MathContext,
|
||||
mut base: GlyphFragment,
|
||||
target: Abs,
|
||||
short_fall: Abs,
|
||||
axis: Axis,
|
||||
) -> VariantFragment {
|
||||
// If the base glyph is good enough, use it.
|
||||
@ -128,8 +126,7 @@ pub fn stretch_glyph(
|
||||
Axis::X => base.width,
|
||||
Axis::Y => base.height(),
|
||||
};
|
||||
let short_target = target - short_fall;
|
||||
if short_target <= advance {
|
||||
if target <= advance {
|
||||
return base.into_variant();
|
||||
}
|
||||
|
||||
@ -153,13 +150,13 @@ pub fn stretch_glyph(
|
||||
for variant in construction.variants {
|
||||
best_id = variant.variant_glyph;
|
||||
best_advance = base.font.to_em(variant.advance_measurement).at(base.font_size);
|
||||
if short_target <= best_advance {
|
||||
if target <= best_advance {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This is either good or the best we've got.
|
||||
if short_target <= best_advance || construction.assembly.is_none() {
|
||||
if target <= best_advance || construction.assembly.is_none() {
|
||||
base.set_id(ctx, best_id);
|
||||
return base.into_variant();
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ fn layout_glyph(
|
||||
let mut variant = if math_size == MathSize::Display {
|
||||
let height = scaled!(ctx, styles, display_operator_min_height)
|
||||
.max(SQRT_2 * glyph.height());
|
||||
glyph.stretch_vertical(ctx, height, Abs::zero())
|
||||
glyph.stretch_vertical(ctx, height)
|
||||
} else {
|
||||
glyph.into_variant()
|
||||
};
|
||||
|
@ -286,7 +286,7 @@ fn layout_underoverspreader(
|
||||
let body_class = body.class();
|
||||
let body = body.into_fragment(styles);
|
||||
let glyph = GlyphFragment::new(ctx, styles, c, span);
|
||||
let stretched = glyph.stretch_horizontal(ctx, body.width(), Abs::zero());
|
||||
let stretched = glyph.stretch_horizontal(ctx, body.width());
|
||||
|
||||
let mut rows = vec![];
|
||||
let baseline = match position {
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 567 B |
Before Width: | Height: | Size: 359 B After Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 510 B After Width: | Height: | Size: 506 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 492 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 927 B |
Before Width: | Height: | Size: 989 B After Width: | Height: | Size: 903 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 976 B After Width: | Height: | Size: 875 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 954 B |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 816 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 651 B After Width: | Height: | Size: 648 B |
Before Width: | Height: | Size: 882 B After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 927 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 436 B |
Before Width: | Height: | Size: 651 B After Width: | Height: | Size: 648 B |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 630 B |