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>
impl<'a, S: Scale> Buffers<'a, S>
Sourcepub fn from_bytes(
bytes: &'a mut [u8],
lengths: &BufferLengths,
) -> Result<Self, Error>
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());