Skip to content

Commit

Permalink
Surround the ab_glyph pixmap with a 1px border (PolyMeilex#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Friz64 authored Dec 17, 2023
1 parent cc33bd2 commit 1ceb573
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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<CompositorState>` as an argument
- **Breaking:** `AdwaitaFrame::new` now takes `Arc<CompositorState>` as an argument
- Fix leftmost title pixel sometimes being cut off (#45)
- Fix transparency in ab_glyph renderer (#44)
- Extended resize corners (#47)
Expand Down
9 changes: 6 additions & 3 deletions src/title/ab_glyph_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand All @@ -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(
Expand Down

0 comments on commit 1ceb573

Please sign in to comment.