From 993e7a45a9f5e2a18f12aed115d8d9f07557f524 Mon Sep 17 00:00:00 2001 From: Leedehai <18319900+Leedehai@users.noreply.github.com> Date: Wed, 17 Jul 2024 04:19:08 -0400 Subject: [PATCH] Move the early exit inside `stretch_glyph()` upward (#4570) Co-authored-by: Laurenz --- crates/typst/src/math/stretch.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/typst/src/math/stretch.rs b/crates/typst/src/math/stretch.rs index cc71ced6d..749773e3c 100644 --- a/crates/typst/src/math/stretch.rs +++ b/crates/typst/src/math/stretch.rs @@ -39,7 +39,13 @@ fn stretch_glyph( short_fall: Abs, horizontal: bool, ) -> VariantFragment { + // If the base glyph is good enough, use it. + let advance = if horizontal { base.width } else { base.height() }; let short_target = target - short_fall; + if short_target <= advance { + return base.into_variant(); + } + let mut min_overlap = Abs::zero(); let construction = ctx .table @@ -55,12 +61,6 @@ fn stretch_glyph( }) .unwrap_or(GlyphConstruction { assembly: None, variants: LazyArray16::new(&[]) }); - // If the base glyph is good enough, use it. - let advance = if horizontal { base.width } else { base.height() }; - if short_target <= advance { - return base.into_variant(); - } - // Search for a pre-made variant with a good advance. let mut best_id = base.id; let mut best_advance = base.width;