elmesque icon indicating copy to clipboard operation
elmesque copied to clipboard

How do I embed a font?

Open quadrupleslap opened this issue 9 years ago • 0 comments

Sorry if this is a stupid question, but how would I embed a font into my app? As far as I can tell the text object needs a filepath, so is it possible?

Edit: Right now I'm using env::temp_dir() and writing to a temporary path with include_bytes!, but hopefully there's a way that's less hacky than that.

let mut font_path = env::temp_dir();
font_path.set_file_name("inconsolata.otf");
File::create(&font_path).unwrap().write(include_bytes!("../assets/inconsolata.otf")).unwrap();

quadrupleslap avatar Dec 06 '15 10:12 quadrupleslap