Skip to content

Commit 3938b06

Browse files
committed
Merge PR #213 into next
2 parents 4ecba49 + fa61731 commit 3938b06

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ usize_conversions = "0.2.0"
1717
x86_64 = { version = "0.14.8" }
1818
xmas-elf = "0.8.0"
1919

20-
[dependencies.font8x8]
21-
version = "0.3.1"
20+
[dependencies.noto-sans-mono-bitmap]
21+
version = "0.1.2"
2222
default-features = false
23-
features = ["unicode"]
23+
features = ["regular", "size_14"]

common/src/logger.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::{
44
fmt::{self, Write},
55
ptr,
66
};
7-
use font8x8::UnicodeFonts;
7+
use noto_sans_mono_bitmap::{get_bitmap, get_bitmap_width, BitmapChar, BitmapHeight, FontWeight};
88
use spinning_top::Spinlock;
99

1010
/// The global logger instance used for the `log` crate.
@@ -68,7 +68,7 @@ impl Logger {
6868
}
6969

7070
fn newline(&mut self) {
71-
self.y_pos += 8 + LINE_SPACING;
71+
self.y_pos += 14 + LINE_SPACING;
7272
self.carriage_return()
7373
}
7474

@@ -103,25 +103,24 @@ impl Logger {
103103
if self.x_pos >= self.width() {
104104
self.newline();
105105
}
106-
if self.y_pos >= (self.height() - 8) {
106+
const BITMAP_LETTER_WIDTH: usize =
107+
get_bitmap_width(FontWeight::Regular, BitmapHeight::Size14);
108+
if self.y_pos >= (self.height() - BITMAP_LETTER_WIDTH) {
107109
self.clear();
108110
}
109-
let rendered = font8x8::BASIC_FONTS
110-
.get(c)
111-
.expect("character not found in basic font");
112-
self.write_rendered_char(rendered);
111+
let bitmap_char = get_bitmap(c, FontWeight::Regular, BitmapHeight::Size14).unwrap();
112+
self.write_rendered_char(bitmap_char);
113113
}
114114
}
115115
}
116116

117-
fn write_rendered_char(&mut self, rendered_char: [u8; 8]) {
118-
for (y, byte) in rendered_char.iter().enumerate() {
119-
for (x, bit) in (0..8).enumerate() {
120-
let alpha = if *byte & (1 << bit) == 0 { 0 } else { 255 };
121-
self.write_pixel(self.x_pos + x, self.y_pos + y, alpha);
117+
fn write_rendered_char(&mut self, rendered_char: BitmapChar) {
118+
for (y, row) in rendered_char.bitmap().iter().enumerate() {
119+
for (x, byte) in row.iter().enumerate() {
120+
self.write_pixel(self.x_pos + x, self.y_pos + y, *byte);
122121
}
123122
}
124-
self.x_pos += 8;
123+
self.x_pos += rendered_char.width();
125124
}
126125

127126
fn write_pixel(&mut self, x: usize, y: usize, intensity: u8) {

0 commit comments

Comments
 (0)