Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/render_gif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,13 @@ fn rasterize_raw_frame(
continue;
}
let px = pen_x as i32 + bm.offset_x + gx as i32;
let py = pen_y_baseline + bm.offset_y + gy as i32;
let mut py = pen_y_baseline + bm.offset_y + gy as i32;
if is_box_drawing(ch) {
// Center the stretched bitmap within the cell vertically.
let cell_center_y = y as i32 + (cell_h as i32) / 2;
let box_center_y = pen_y_baseline + bm.offset_y + (bm.height as i32) / 2;
py += cell_center_y - box_center_y;
}
if px < 0 || py < 0 {
continue;
}
Expand Down
8 changes: 5 additions & 3 deletions src/render_svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,12 @@ fn emit_frame_body(s: &mut String, frame: &RawFrame, cfg: ViewportConfig, font_s
let transform = if scale_y > 1.0 {
// SVG text coordinates are roughly on the baseline. Scaling by Y will stretch the ascent and descent.
// To keep the character centered vertically in the cell, we scale it relative to its vertical center.
let cy = y as f32 - (font_size * 0.3); // Approximate vertical center of the character, closer to baseline
let cell_center_y = (y as f32 - baseline as f32) + (cell_h as f32 / 2.0);
let char_center_y = y as f32 - (font_size * 0.3); // Approximate vertical center of the character, closer to baseline
format!(
r#" transform="translate(0, {cy}) scale(1, {scale_y}) translate(0, -{cy})""#,
cy = cy,
r#" transform="translate(0, {cy}) scale(1, {scale_y}) translate(0, -{char_center_y})""#,
cy = cell_center_y,
char_center_y = char_center_y,
scale_y = scale_y
)
} else {
Expand Down
Loading