summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLeedehai <18319900+Leedehai@users.noreply.github.com>2024-07-17 04:19:08 -0400
committerGitHub <noreply@github.com>2024-07-17 08:19:08 +0000
commit993e7a45a9f5e2a18f12aed115d8d9f07557f524 (patch)
treedc2ec2263d6b45887920620eddd2b1a42b47963d /crates
parent09e0464e875fccecd6f2f686d462ad2c4a3b5ecd (diff)
Move the early exit inside `stretch_glyph()` upward (#4570)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/math/stretch.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/typst/src/math/stretch.rs b/crates/typst/src/math/stretch.rs
index cc71ced6..749773e3 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;