mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix wrong drop order for self-referential struct (#5306)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
parent
ead6c03a98
commit
83927686d9
@ -29,10 +29,6 @@ pub struct Font(Arc<Repr>);
|
||||
|
||||
/// The internal representation of a font.
|
||||
struct Repr {
|
||||
/// The raw font data, possibly shared with other fonts from the same
|
||||
/// collection. The vector's allocation must not move, because `ttf` points
|
||||
/// into it using unsafe code.
|
||||
data: Bytes,
|
||||
/// The font's index in the buffer.
|
||||
index: u32,
|
||||
/// Metadata about the font.
|
||||
@ -43,6 +39,14 @@ struct Repr {
|
||||
ttf: ttf_parser::Face<'static>,
|
||||
/// The underlying rustybuzz face.
|
||||
rusty: rustybuzz::Face<'static>,
|
||||
// NOTE: `ttf` and `rusty` reference `data`, so it's important for `data`
|
||||
// to be dropped after them or they will be left dangling while they're
|
||||
// dropped. Fields are dropped in declaration order, so `data` needs to be
|
||||
// declared after `ttf` and `rusty`.
|
||||
/// The raw font data, possibly shared with other fonts from the same
|
||||
/// collection. The vector's allocation must not move, because `ttf` points
|
||||
/// into it using unsafe code.
|
||||
data: Bytes,
|
||||
}
|
||||
|
||||
impl Font {
|
||||
|
Loading…
x
Reference in New Issue
Block a user