I noticed that the format of the pixmap doesn't really seem to match what I usually expect. There seems to be no pixel since dimensions of the pixmap are not always multiples of 4.
I am probably missing something. Am I using fontdue correctly?
let mut index = ((x + (y * width as u32)) * 4) as usize;
let font = include_bytes!("/home/bryan/.local/share/fonts/TerminusTTF-Bold.ttf") as &[u8];
// Parse it into the font type.
let font = fontdue::Font::from_bytes(font, fontdue::FontSettings::default()).unwrap();
for c in self.text.chars() {
let (metrics, bitmap) = font.rasterize(c, self.font_size);
for i in (0..metrics.width * metrics.height).into_iter().step_by(metrics.width) {
if index >= canvas.len() {
break;
} else {
let mut writer = &mut canvas[index..];
writer.write(&bitmap[i..i+metrics.width]).unwrap();
writer.flush().unwrap();
index += width as usize * 4;
}
}
}
I noticed that the format of the pixmap doesn't really seem to match what I usually expect. There seems to be no pixel since dimensions of the pixmap are not always multiples of 4.
I am probably missing something. Am I using fontdue correctly?
This is supposed to be the letter 'm'.