#[repr(C)]pub struct FontRef {
pub parsed: *const c_void,
pub copies: *const AtomicUsize,
pub id: u64,
pub run_destructor: bool,
pub parsed_destructor: FontRefDestructorCallbackType,
}Expand description
FontRef is a reference-counted pointer to a parsed font.
It holds a *const c_void that points to the actual parsed font data
(typically a ParsedFont from the layout crate).
The parsed data is managed via atomic reference counting, allowing safe sharing across threads without duplicating the font data.
Fields§
§parsed: *const c_voidPointer to the parsed font data (e.g., ParsedFont)
copies: *const AtomicUsizeReference counter for memory management
id: u64Process-unique, monotonically-assigned identity of this parsed font.
Shared by shallow clones (same font), fresh for each new. Used for
Eq/Ord/Hash instead of the parsed pointer so that freeing a
font and reusing its heap address can’t forge identity — the same
aliasing fix applied to ImageRef. (Content-level dedup still uses the
separate content hash via font_ref_get_hash.)
run_destructor: boolWhether to run the destructor on drop
parsed_destructor: FontRefDestructorCallbackTypeDestructor function for the parsed data
Implementations§
Source§impl FontRef
impl FontRef
Sourcepub fn new(
parsed: *const c_void,
destructor: FontRefDestructorCallbackType,
) -> Self
pub fn new( parsed: *const c_void, destructor: FontRefDestructorCallbackType, ) -> Self
Create a new FontRef from parsed font data
§Arguments
parsed- Pointer to parsed font data (e.g.,Arc::into_raw(Arc::new(ParsedFont)))destructor- Function to clean up the parsed data
Sourcepub const fn get_parsed(&self) -> *const c_void
pub const fn get_parsed(&self) -> *const c_void
Get a raw pointer to the parsed font data