jrmuizel / raqote

Rust 2D graphics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to draw text with \n character causes panic.

jonatino opened this issue · comments

OS: Windows 11
raqote v0.8.3

Example I'm trying to draw this string

        let script_status = format!(
            "Status: {status}\n{actions_label}: {actions_completed} ({actions_per_hr}/hr) - Session: {session_length} {break_text}\n{xp_per_hr_string}");

        println!("{script_status}");

        dt.draw_text(
            font,
            16.,
            script_status.as_str(),
            Point::new((status_bounds.x1 + 4) as f32, y),
            &Source::Solid(SolidSource::from_unpremultiplied_argb(255, 255, 255, 255)),
            &DrawOptions::default(),
        );

When you try to draw a string that has \n characters in it (only tested on windows), code panics failed to unwrap at the following line:

https://github.com/jrmuizel/raqote/blob/master/src/draw_target.rs#L789