pub fn fonts() -> Vec<String>
Expand description
Gets a Vector<String>
of loaded fonts, unless get_font_names() or load_system_fonts() is called,
this will return a Vec with a String representation of the default Fonts shipped by FLTK, which is the same as the enums::Font
.
Examples found in repository?
examples/system_fonts.rs (line 31)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
fn main() {
let app = app::App::default().load_system_fonts();
// To load a font by path, check the App::load_font() method
let fonts = app::fonts();
// println!("{:?}", fonts);
let mut wind = window::Window::default().with_size(400, 300);
let mut frame = frame::Frame::default().size_of(&wind);
frame.set_label_size(30);
wind.set_color(enums::Color::White);
wind.end();
wind.show();
println!("The system has {} fonts!\nStarting slideshow!", fonts.len());
let mut i = 0;
while app.wait() {
if i == fonts.len() {
i = 0;
}
frame.set_label(&format!("[{}]", fonts[i]));
frame.set_label_font(enums::Font::by_index(i));
app::sleep(0.5);
i += 1;
}
}