Make Family::DynamicName(String) (or edit Family::Name to be Cow<'static, str>) (or make the lifetime generic))

I want the user to be able to configure what font they want to use - I hate when applcations don’t let you configure the font.

The problem is that Font::with_name accepts &'static str. I’ve had to mess with string leaks and mutexes to get this working therefore it’s pretty unclean. I think I am going to just transmute a reference to the font name. But unsafe code should be used when it’s really really necessary.

A solution would be simple - Either make a new enum variant Family::DynamicName that contains a String or edit the Family::Name to accept a Cow<'static, str> (Though I think first option is better as it prevents breaking changes). Then make Font::with_name accept Into<Cow<'static, str>>

An alternative would be to make the lifetime generic

2 Likes

Related issues on github have been closed but I agree that this needs a discussion.