summaryrefslogtreecommitdiff
path: root/crates/typst-render/src
diff options
context:
space:
mode:
authorMax <max@mkor.je>2025-06-10 14:44:38 +0000
committerGitHub <noreply@github.com>2025-06-10 14:44:38 +0000
commit44d410dd007569227e8eca41e39fde9a932f0d02 (patch)
tree4270d55c6cdea2024c381aec45ba74997f05f325 /crates/typst-render/src
parent7c7b962b98a09c1baabdd03ff4ccad8f6d817b37 (diff)
Use the shaper in math (#6336)
Diffstat (limited to 'crates/typst-render/src')
-rw-r--r--crates/typst-render/src/text.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/typst-render/src/text.rs b/crates/typst-render/src/text.rs
index 16490aff..55fe04b5 100644
--- a/crates/typst-render/src/text.rs
+++ b/crates/typst-render/src/text.rs
@@ -14,18 +14,20 @@ use crate::{shape, AbsExt, State};
/// Render a text run into the canvas.
pub fn render_text(canvas: &mut sk::Pixmap, state: State, text: &TextItem) {
let mut x = Abs::zero();
+ let mut y = Abs::zero();
for glyph in &text.glyphs {
let id = GlyphId(glyph.id);
- let offset = x + glyph.x_offset.at(text.size);
+ let x_offset = x + glyph.x_offset.at(text.size);
+ let y_offset = y + glyph.y_offset.at(text.size);
if should_outline(&text.font, glyph) {
- let state = state.pre_translate(Point::with_x(offset));
+ let state = state.pre_translate(Point::new(x_offset, -y_offset));
render_outline_glyph(canvas, state, text, id);
} else {
let upem = text.font.units_per_em();
let text_scale = text.size / upem;
let state = state
- .pre_translate(Point::new(offset, -text.size))
+ .pre_translate(Point::new(x_offset, -y_offset - text.size))
.pre_scale(Axes::new(text_scale, text_scale));
let (glyph_frame, _) = glyph_frame(&text.font, glyph.id);
@@ -33,6 +35,7 @@ pub fn render_text(canvas: &mut sk::Pixmap, state: State, text: &TextItem) {
}
x += glyph.x_advance.at(text.size);
+ y += glyph.y_advance.at(text.size);
}
}