diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd1c07..16137c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ ## [Unreleased] +- Fix `ab_glyph` renderer panicking with integer scale factor 3 (#50) - Improved roundness of headerbar (#51) ## 0.8.0 -- **Braking:** `AdwaitaFrame::new` now takes `Arc` as an argument +- **Breaking:** `AdwaitaFrame::new` now takes `Arc` as an argument - Fix leftmost title pixel sometimes being cut off (#45) - Fix transparency in ab_glyph renderer (#44) - Extended resize corners (#47) diff --git a/src/title/ab_glyph_renderer.rs b/src/title/ab_glyph_renderer.rs index e049359..e78920d 100644 --- a/src/title/ab_glyph_renderer.rs +++ b/src/title/ab_glyph_renderer.rs @@ -80,8 +80,10 @@ impl AbGlyphTitleText { let glyphs = self.layout(&font); let last_glyph = glyphs.last()?; - let width = (last_glyph.position.x + font.h_advance(last_glyph.id)).ceil() as u32; - let height = font.height().ceil() as u32; + // + 2 because ab_glyph likes to draw outside of its area, + // so we add 1px border around the pixmap + let width = (last_glyph.position.x + font.h_advance(last_glyph.id)).ceil() as u32 + 2; + let height = font.height().ceil() as u32 + 2; let mut pixmap = Pixmap::new(width, height)?; @@ -97,7 +99,8 @@ impl AbGlyphTitleText { // same as 1.0. For our purposes, we need to contrain this value. let c = c.min(1.0); - let p_idx = (top + y) * width + (left + x); + // offset the index by 1, so it is in the center of the pixmap + let p_idx = (top + y + 1) * width + (left + x + 1); let old_alpha_u8 = pixels[p_idx as usize].alpha(); let new_alpha = c + (old_alpha_u8 as f32 / 255.0); if let Some(px) = PremultipliedColorU8::from_rgba(