mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Store font data more compressed
This commit is contained in:
parent
1b71ef6473
commit
fb197d3e79
|
@ -33,10 +33,24 @@ pub fn load_font(font_data: &[u8], pixels_per_em: f32) -> TokenStream {
|
|||
let width = metrics.width;
|
||||
let height = metrics.height;
|
||||
|
||||
let rendered = bitmap
|
||||
.chunks(8)
|
||||
.map(|chunk| {
|
||||
let mut output = 0u8;
|
||||
for (i, &value) in chunk.iter().enumerate() {
|
||||
if value > 100 {
|
||||
output |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
||||
output
|
||||
})
|
||||
.collect();
|
||||
|
||||
LetterData {
|
||||
width,
|
||||
height,
|
||||
rendered: bitmap,
|
||||
rendered,
|
||||
xmin: metrics.xmin,
|
||||
ymin: metrics.ymin,
|
||||
advance_width: metrics.advance_width,
|
||||
|
|
|
@ -154,9 +154,11 @@ impl<'a> TextRenderer<'a> {
|
|||
|
||||
for letter_x in letter_x_start..letter_x_end {
|
||||
let x = letter_x - letter_offset_x;
|
||||
let px = letter.data[(x + y * letter.width as i32) as usize];
|
||||
let pos = x + y * letter.width as i32;
|
||||
let px_line = letter.data[(pos / 8) as usize];
|
||||
let px = (px_line >> (pos & 7)) & 1;
|
||||
|
||||
if px > 100 {
|
||||
if px != 0 {
|
||||
masks[(letter_y & 7) as usize] |=
|
||||
(foreground_colour as u32) << ((letter_x & 7) * 4);
|
||||
zero = false;
|
||||
|
|
Loading…
Reference in a new issue