Runtime Font Loading #1329
lylythechosenone
started this conversation in
General
Replies: 1 comment
-
For the time being, I've resorted to memory leaks. fn load_font(name: &'static str) -> Result<Self, Self::Err> {
let font = SystemSource::new()
.select_by_postscript_name(name)
.unwrap()
.load()?;
let bytes = font.copy_font_data().unwrap();
let bytes = (*bytes).clone();
let bytes = bytes.leak();
Ok(Self::External { name, bytes })
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there an existing issue for this?
Is this issue related to iced?
What happened?
Fonts require
&'static
parameters for external fonts. This makes it impossible to load fonts in runtime without running into lifetime issues.What is the expected behavior?
It should be possible to load fonts in runtime. In my case, I am trying to write a rich text editor widget using
text::Renderer
, but I can't render fonts because the fonts are specific to the document, and can't be loaded in compile-time.Version
0.3.0
Operative System
macOS
Do you have any log output?
No response
Beta Was this translation helpful? Give feedback.
All reactions