Skip to content

Commit eedc4eb

Browse files
committed
[libgui] Label accepts a Font
1 parent e4688ae commit eedc4eb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rust_programs/libgui/src/label.rs

+9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use alloc::{
88
vec,
99
vec::Vec,
1010
};
11+
use ttf_renderer::Font;
1112

13+
use crate::font::{draw_char_with_font_onto, load_font, scaled_metrics_for_codepoint};
14+
use crate::text_view::DrawnCharacter;
15+
use crate::view::View;
1216
use crate::{font::draw_char, ui_elements::UIElement};
1317

1418
pub struct Label {
@@ -17,16 +21,21 @@ pub struct Label {
1721
container: RefCell<Option<RefCell<Weak<dyn NestedLayerSlice>>>>,
1822
frame: RefCell<Rect>,
1923
pub text: RefCell<String>,
24+
font: Font,
25+
font_size: Size,
2026
color: Color,
2127
}
2228

2329
impl Label {
2430
pub fn new<F: 'static + Fn(&Label, Size) -> Rect>(text: &str, color: Color, sizer: F) -> Self {
31+
let font = load_font("/fonts/sf_pro.ttf");
2532
Self {
2633
sizer: RefCell::new(Box::new(sizer)),
2734
container: RefCell::new(None),
2835
frame: RefCell::new(Rect::zero()),
2936
text: RefCell::new(text.to_string()),
37+
font,
38+
font_size: Size::new(18, 18),
3039
color,
3140
}
3241
}

0 commit comments

Comments
 (0)