Skip to main content

Buffers

Struct Buffers 

Source
pub struct Buffers<'a, S: Scale> {
    pub points: &'a mut [Point<S::Coord>],
    pub flags: &'a mut [PointFlags],
    pub contours: &'a mut [u16],
    pub unscaled: &'a mut [Point<i32>],
    pub deltas: &'a mut [Point<S::Delta>],
    pub iup: &'a mut [Point<S::Delta>],
    pub composite_deltas: &'a mut [Point<S::Delta>],
}
Expand description

Scratch space for OutlinePlan::load.

Every buffer comes from the caller. Size them with OutlinePlan::buffer_lengths; a buffer shorter than that is reported as Error::InsufficientMemory, not overrun.

Fields§

§points: &'a mut [Point<S::Coord>]

Receives the loaded points.

§flags: &'a mut [PointFlags]

Receives the point flags.

§contours: &'a mut [u16]

Receives the contour end point indices.

§unscaled: &'a mut [Point<i32>]

Font unit coordinates. Read only when Scale::NEEDS_UNSCALED, and may be empty otherwise.

§deltas: &'a mut [Point<S::Delta>]

Variation delta scratch. May be empty for a static instance.

§iup: &'a mut [Point<S::Delta>]

Delta interpolation scratch. May be empty for a static instance.

§composite_deltas: &'a mut [Point<S::Delta>]

Per-component delta stack. May be empty for a static instance.

Implementations§

Source§

impl<'a, S: Scale> Buffers<'a, S>

Source

pub fn from_bytes( bytes: &'a mut [u8], lengths: &BufferLengths, ) -> Result<Self, Error>

Carves all seven buffers out of one block of bytes.

For a caller with its own allocator, or one that prefers a single allocation per draw. bytes must be at least BufferLengths::packed_len long and need not be aligned.

use read_fonts::{
    tables::glyf::outline::{
        Buffers, OutlinePlan, OutlineTables, Scale26Dot6,
    },
    types::GlyphId,
    FontRef,
};

let font = FontRef::new(font_test_data::COLRV0V1_VARIABLE)?;
let tables = OutlineTables::new(&font)?;
let plan = OutlinePlan::new(&tables, GlyphId::new(1))?;

let lengths = plan.buffer_lengths::<Scale26Dot6>();
let mut block = vec![0u8; lengths.packed_len::<Scale26Dot6>()];
let buffers = Buffers::from_bytes(&mut block, &lengths)?;

let scale = Scale26Dot6::new(Some(16.0), tables.units_per_em);
let outline = plan.load(&tables, &scale, buffers, None)?;
assert_eq!(outline.points().len(), outline.flags().len());

Auto Trait Implementations§

§

impl<'a, S> !UnwindSafe for Buffers<'a, S>

§

impl<'a, S> Freeze for Buffers<'a, S>

§

impl<'a, S> RefUnwindSafe for Buffers<'a, S>
where <S as Scale>::Coord: RefUnwindSafe, <S as Scale>::Delta: RefUnwindSafe,

§

impl<'a, S> Send for Buffers<'a, S>
where <S as Scale>::Coord: Send, <S as Scale>::Delta: Send,

§

impl<'a, S> Sync for Buffers<'a, S>
where <S as Scale>::Coord: Sync, <S as Scale>::Delta: Sync,

§

impl<'a, S> Unpin for Buffers<'a, S>

§

impl<'a, S> UnsafeUnpin for Buffers<'a, S>

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> ErasedDestructor for T
where T: 'static,

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, 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.