Move the early exit inside stretch_glyph() upward (#4570)

Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
Leedehai 2024-07-17 04:19:08 -04:00 committed by GitHub
parent 09e0464e87
commit 993e7a45a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;