Skip to main content

complex_text/
complex_text.rs

1use impellers::*;
2mod common;
3
4fn main() {
5    let framework = common::SdlGlImpellerFrameWork::new();
6    // if you want to do any initialization before event loop,
7    // this is the place for that.
8    let dl = {
9        let mut builder = DisplayListBuilder::new(None);
10        let mut paint = Paint::default();
11        let paragraph = {
12            let ttx = TypographyContext::default(); // register any custom fonts if you want
13            let mut puilder = ParagraphBuilder::new(&ttx).unwrap();
14            let mut pstyle = ParagraphStyle::default();
15            // you can set a custom font family if you want, but lets just use the system fonts
16            pstyle.set_font_size(48.0);
17            pstyle.set_font_weight(FontWeight::ExtraBold);
18            paint.set_color(Color::BLUEBERRY);
19            pstyle.set_foreground(&paint);
20            puilder.push_style(&pstyle);
21            puilder.add_text("HELLO EVERYONE");
22            puilder.build(600.0).unwrap()
23        };
24
25        paint.set_color(Color::BLACK); // clear with black first
26        builder.draw_paint(&paint);
27        builder.draw_paragraph(&paragraph, Point::new(100.0, 100.0));
28        builder.build().unwrap()
29    };
30    framework.enter_event_loop(Some(dl), None);
31}