Skip to content

Commit 087ed72

Browse files
committed
[libgui] Label renders TrueType fonts
1 parent eedc4eb commit 087ed72

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

rust_programs/libgui/src/label.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,27 @@ impl Drawable for Label {
8383
}
8484

8585
fn draw(&self) -> Vec<Rect> {
86+
/*
87+
println!("\nLabel::draw()");
88+
println!("\nLabel frame: {}", self.frame());
89+
*/
8690
let onto = &mut self.get_slice();
87-
let font_size = Size::new(8, 10);
91+
//println!("\nOnto frame: {}", onto.frame());
8892
let mut cursor = Point::zero();
8993
for ch in self.text.borrow().chars() {
90-
draw_char(onto, ch, &cursor, self.color, &font_size);
91-
cursor.x += font_size.width;
94+
/*
95+
draw_char(onto, ch, &cursor, self.color, &self.font_size);
96+
cursor.x += self.font_size.width;
97+
*/
98+
let mut drawn_ch = DrawnCharacter::new(cursor, self.color, ch, self.font_size);
99+
let (bounding_box, glyph_metrics) =
100+
draw_char_with_font_onto(&mut drawn_ch, &self.font, onto);
101+
//let scaled_glyph_metrics = scaled_metrics_for_codepoint(&self.font, self.font_size, ch);
102+
//let scaled_glyph_metrics = scaled_metrics_for_codepoint(&self.font, self.font_size, ch);
103+
//cursor.x += scaled_glyph_metrics.advance_width as isize;
104+
cursor.x += glyph_metrics.advance_width as isize;
105+
//cursor.x += bounding_box.width();
106+
//cursor.x += scaled_glyph_metrics.advance_width as isize;
92107
}
93108
// TODO: Damages
94109
vec![]

0 commit comments

Comments
 (0)