-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load Font From Memory (make better documentation) #107
Comments
I have found that forking |
You need to write the file type as |
Here's an actually working example for anybody who stumbles upon this: let fontfile = include_bytes!("./Ubuntu-Regular.ttf");
let fontfile_size = fontfile.len();
let fontfile_type = CString::new(".ttf").unwrap();
let chars = null_mut();
let font = unsafe {
Font::from_raw(LoadFontFromMemory(
fontfile_type.as_ptr(),
fontfile.as_ptr(),
fontfile_size.try_into().unwrap(),
256,
chars,
100,
))
};
``` |
I wouldn't consider this closed. This is a less then ideal situation and I think this should be implemented as a safe function. That said, this repo is severely dormant. This should maybe be reopened/PR'd in the fork mentioned in the resdme. |
|
This repo also isn't maintained anymore. I'll open up a PR in the fork that is maintained. |
UPDATE: It has been merged. It's actually been accepted into the master of that branch meaning you do not even need to upgrade to 5.0. (In fact, you shouldn't, because it has not been merged to the other branches yet). |
Hello,
I have problems loading a TTF font from the buffer. Since I don't want to load the font file as such from disk, I would like to use the LoadFontFromMemory function, but this doesn't seem to have a wrapper. I also tried to use the FFI binding but the raw FFI font struct is not readily compatible with the API and the constructor of the wrapped struct seems private.
So I need help loading a font from a [u8]. My sample code:
The text was updated successfully, but these errors were encountered: