Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Friz64 committed Dec 16, 2023
1 parent e8d1860 commit 4ce6e34
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/title/ab_glyph_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ impl AbGlyphTitleText {

let glyphs = self.layout(&font);
let last_glyph = glyphs.last()?;
// + 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;

Expand All @@ -97,6 +99,7 @@ impl AbGlyphTitleText {
// same as 1.0. For our purposes, we need to contrain this value.
let c = c.min(1.0);

// 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);
Expand Down

0 comments on commit 4ce6e34

Please sign in to comment.