Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ishere committed Feb 1, 2024
1 parent 71ab96d commit 98fe5da
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/render/pff2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,37 @@ impl Glyph {
let index = y * self.width + x;
let byte_index = index / 8;
let bit_index = 7 - (index % 8);
let mask =1 << bit_index;
let mask = 1 << bit_index;

Some((self.bitmap[byte_index] & mask) != 0)
}
}

#[cfg(test)]
mod tests {
use crate::parser::pff2::Glyph;

#[test_case(
8, 1, &[0b00000001],
7, 0 => 1;
"right bit one line"
)]
#[test_case(
8, 1, &[0b10000000],
0, 0 => 1;
"left bit one line"
)]
fn foo(width: usize, height: usize, bitmap: &[u8], x: usize, y: usize) -> u8 {
let glyph = Glyph {
width,
height,
bitmap: bitmap.into(),
..Default::default()
};

glyph.pixel(x, y).unwrap() as u8
#[allow(non_snake_case)]
mod Glyph {
use crate::parser::pff2::Glyph;

#[test_case(
8, 1, &[0b00000001],
7, 0 => 1;
"right bit one line"
)]
#[test_case(
8, 1, &[0b10000000],
0, 0 => 1;
"left bit one line"
)]
fn pixel(width: usize, height: usize, bitmap: &[u8], x: usize, y: usize) -> u8 {
let glyph = Glyph {
width,
height,
bitmap: bitmap.into(),
..Default::default()
};

glyph.pixel(x, y).unwrap() as u8
}
}
}

0 comments on commit 98fe5da

Please sign in to comment.