summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAna Gelez <ana@gelez.xyz>2024-06-03 12:17:04 +0200
committerGitHub <noreply@github.com>2024-06-03 10:17:04 +0000
commit9afd2475346a90019800fa7f524d42d7cfb1bf15 (patch)
tree9881cfe5318d8662857ac68bfd88022f40e29212
parenta9b3273a2b49c0df7e1223bfddc98f2df3cee515 (diff)
Fix emoji advance in PDF export (#4325)
-rw-r--r--crates/typst-pdf/src/color_font.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/typst-pdf/src/color_font.rs b/crates/typst-pdf/src/color_font.rs
index 641fe156..f4621ca0 100644
--- a/crates/typst-pdf/src/color_font.rs
+++ b/crates/typst-pdf/src/color_font.rs
@@ -69,7 +69,8 @@ pub fn write_color_fonts(
.font
.advance(color_glyph.gid)
.unwrap_or(Em::new(0.0))
- .to_font_units();
+ .get() as f32
+ * scale_factor;
widths.push(width);
chunk
.stream(
@@ -239,8 +240,10 @@ impl ColorFontMap<()> {
}
let frame = frame_for_glyph(font, gid);
- let width = font.advance(gid).unwrap_or(Em::new(0.0)).to_font_units();
- let instructions = content::build(&mut self.resources, &frame, Some(width));
+ let width =
+ font.advance(gid).unwrap_or(Em::new(0.0)).get() * font.units_per_em();
+ let instructions =
+ content::build(&mut self.resources, &frame, Some(width as f32));
color_font.glyphs.push(ColorGlyph { gid, instructions });
color_font.glyph_indices.insert(gid, index);