Skip to content

Commit

Permalink
[libgui - Rust] TextView can be initialized with a Font explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Feb 7, 2024
1 parent cb8f91d commit 82436d7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions rust_programs/libgui/src/text_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@ impl TextView {
)
}

pub fn new_with_font<F: 'static + Fn(&View, Size) -> Rect>(
_background_color: Color,
font: Font,
font_size: Size,
text_insets: RectInsets,
sizer: F,
pixel_byte_layout: PixelByteLayout,
) -> Rc<Self> {
let view = ScrollView::new_ext(sizer, pixel_byte_layout);
Rc::new(Self {
view,
font,
font_size,
text_insets,
text: RefCell::new(vec![]),
cursor_pos: RefCell::new(CursorPos(0, Point::zero())),
})
}

pub fn font_size(&self) -> Size {
self.font_size
}
Expand Down

0 comments on commit 82436d7

Please sign in to comment.