Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surround the ab_glyph pixmap with a 1px border #55

Merged
merged 3 commits into from
Dec 17, 2023
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
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;
Friz64 marked this conversation as resolved.
Show resolved Hide resolved
// + 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
Loading