Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.73k stars 468 forks source link

Is there a way to have unsafe_fonts like unsafe_textures? #929

Open louiidev opened 4 years ago

louiidev commented 4 years ago

I'm really struggling to design my app with some of the limitations of lifetimes related to font's.

I basically have a struct that gets initialised on my app start and doesn't get dropped.

it looks like this:

pub struct Context {
    pub canvas: Canvas<sdl2::video::Window>,
    pub texture_creator: TextureCreator<sdl2::video::WindowContext>,
    pub input: Input,
    pub tff: Sdl2TtfContext,
}

I was able to get around the texture lifecycle issue with unsafe_textures is there a way I can do something similar with font's?

Cobrand commented 4 years ago

There isn't at the moment... But feel free to create a PR for that! I can't guarantee this won't be a small amount of work though, I took quite a bit of time myself to create the unsafe_textures feature...

louiidev commented 4 years ago

There isn't at the moment... But feel free to create a PR for that! I can't guarantee this won't be a small amount of work though, I took quite a bit of time myself to create the unsafe_textures feature...

No worries, I'll dive into the code and see if I make a PR for it :)