#[repr(C)]pub struct ShapingResultC {
pub glyphs: *mut PositionedGlyphC,
pub glyph_count: u32,
pub advance_width: f32,
pub advance_height: f32,
pub direction: DirectionC,
pub _reserved: [u8; 3],
}Expand description
C-ABI compatible shaping result.
Contains a pointer to an array of positioned glyphs plus metadata.
§Memory Ownership
When returned from FFI functions, the caller owns the memory and must call
typf_shaping_result_free() to release it. The glyphs pointer is valid
until freed.
§Null Safety
glyphsmay be null ifglyph_countis 0- Always check
glyph_countbefore dereferencingglyphs
Fields§
§glyphs: *mut PositionedGlyphCPointer to array of positioned glyphs (owned)
glyph_count: u32Number of glyphs in the array
advance_width: f32Total horizontal advance width
advance_height: f32Total vertical advance height
direction: DirectionCText direction
_reserved: [u8; 3]Reserved for future use (padding)
Implementations§
Source§impl ShapingResultC
impl ShapingResultC
Sourcepub fn from_rust(result: &ShapingResult) -> Self
pub fn from_rust(result: &ShapingResult) -> Self
Creates a new ShapingResultC by converting from a Rust ShapingResult.
This allocates a new array for the glyphs. The caller is responsible
for freeing it via free().
Sourcepub unsafe fn free(&mut self)
pub unsafe fn free(&mut self)
Frees the memory allocated for glyphs.
§Safety
- Must only be called once per ShapingResultC
- The glyphs pointer must have been allocated by
from_rust()
Sourcepub unsafe fn glyphs_slice(&self) -> &[PositionedGlyphC]
pub unsafe fn glyphs_slice(&self) -> &[PositionedGlyphC]
Returns a slice view of the glyphs.
§Safety
The returned slice is valid only while this ShapingResultC is valid and has not been freed.
Sourcepub unsafe fn to_rust(&self) -> ShapingResult
pub unsafe fn to_rust(&self) -> ShapingResult
Converts back to a Rust ShapingResult.
This creates a new owned Vec, leaving this ShapingResultC unchanged.
§Safety
The glyphs pointer must be valid.