Closed CryZe closed 4 years ago
pub(crate) fn from_ptr(font: *const ffi::hb_font_t) -> &'static Font<'static> { unsafe { &*(font as *const Font) } }
This straight up transmutes a hb_font_t into a Font. However hb_font_t is not a Font, it's stored as a pointer in a Font. This causes a segfault here:
hb_font_t
Font
fn font_has_glyph(font: &Font, u: u32) -> bool { font.ttf_parser().glyph_index(char::try_from(u).unwrap()).is_some() }
where it then tries to access the ttf_parser() from the font, which doesn't exist, as it's not a Font, but a transmuted hb_font_t
ttf_parser()
font
Yes, this is a pretty bad one and there no easy way to fix it. We have to wait for a first pure Rust release.
PS: the current state of the library is pre-alpha.
The repo was reset, so this was kinda fixed.
This straight up transmutes a
hb_font_t
into aFont
. Howeverhb_font_t
is not aFont
, it's stored as a pointer in aFont
. This causes a segfault here:where it then tries to access the
ttf_parser()
from thefont
, which doesn't exist, as it's not aFont
, but a transmutedhb_font_t