Skip to main content

ShapingResultC

Struct ShapingResultC 

Source
#[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

  • glyphs may be null if glyph_count is 0
  • Always check glyph_count before dereferencing glyphs

Fields§

§glyphs: *mut PositionedGlyphC

Pointer to array of positioned glyphs (owned)

§glyph_count: u32

Number of glyphs in the array

§advance_width: f32

Total horizontal advance width

§advance_height: f32

Total vertical advance height

§direction: DirectionC

Text direction

§_reserved: [u8; 3]

Reserved for future use (padding)

Implementations§

Source§

impl ShapingResultC

Source

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().

Source

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()
Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ShapingResultC

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.