Struct TableWriter

Source
pub struct TableWriter { /* private fields */ }
Expand description

An object that manages a collection of serialized tables.

This handles deduplicating objects and tracking offsets.

Implementations§

Source§

impl TableWriter

Source

pub fn write_slice(&mut self, bytes: &[u8])

Write raw bytes into this table.

The caller is responsible for ensuring bytes are in big-endian order.

Source

pub fn write_offset(&mut self, obj: &dyn FontWrite, width: usize)

Create an offset to another table.

The width argument is the size in bytes of the offset, e.g. 2 for an Offset16, and 4 for an Offset32.

The provided table will be serialized immediately, and the position of the offset within the current table will be recorded. Offsets are resolved when the root table object is serialized, at which point we overwrite each recorded offset position with the final offset of the appropriate table.

Source

pub fn pad_to_2byte_aligned(&mut self)

Add a padding byte of necessary to ensure the table length is an even number.

This is necessary for things like the glyph table, which require offsets to be aligned on 2-byte boundaries.

Trait Implementations§

Source§

impl Debug for TableWriter

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TableWriter

Source§

fn default() -> Self

Returns the “default value” for a type. 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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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.