Skip to content

Commit

Permalink
Fix Bounding Box Calculation
Browse files Browse the repository at this point in the history
At some point when changing our text engine, we introduced a scale value
for each individual glyph, possibly during the transition to
`cosmic-text`. This is correctly being used when rendering the text, but
not when calculating the bounding box of the text. This meant that for
certain fonts the dirty region of the image, that is cleared on each
frame was not calculated correctly and thus the previous text was still
visible.
  • Loading branch information
CryZe committed Jan 17, 2025
1 parent 654b373 commit 9fb0229
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rendering/software.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,10 @@ fn calculate_bounds(layer: &[Entity<SkiaPath, SkiaImage, SkiaLabel>]) -> [f32; 2
Entity::Label(label, _, transform) => {
for glyph in label.read().unwrap().glyphs() {
if let Some(path) = &glyph.path {
let transform = transform.pre_translate(glyph.x, glyph.y);
let transform = transform
.pre_translate(glyph.x, glyph.y)
.pre_scale(glyph.scale, glyph.scale);

let bounds = path.bounds();
for y in [bounds.top(), bounds.bottom()] {
let transformed_y = transform.transform_y(y);
Expand Down

0 comments on commit 9fb0229

Please sign in to comment.