From b1d9519fe7b491f130556356aab8317f1f3d8d87 Mon Sep 17 00:00:00 2001 From: Malo <57839069+MDLC01@users.noreply.github.com> Date: Sun, 29 Jun 2025 15:30:14 +0100 Subject: [PATCH] Safer conversion from `Length` to `Em` --- crates/typst-library/src/layout/length.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/typst-library/src/layout/length.rs b/crates/typst-library/src/layout/length.rs index 4c98ec789..60991295f 100644 --- a/crates/typst-library/src/layout/length.rs +++ b/crates/typst-library/src/layout/length.rs @@ -77,8 +77,8 @@ impl Length { } /// Expresses this length in em's of the provided outer text size. - pub fn to_em(&self, text_size: Abs) -> Em { - self.em + Em::new(self.abs / text_size) + pub fn to_em(&self, font_size: Abs) -> Em { + self.em + Em::from_length(self.abs, font_size) } /// Fails with an error if the length has a non-zero font-relative part.