Trait allsorts_no_std::binary::write::WriteBinaryDep[][src]

pub trait WriteBinaryDep<HostType = Self> {
    type Args;
    type Output;
    fn write_dep<C: WriteContext>(
        ctxt: &mut C,
        val: HostType,
        args: Self::Args
    ) -> Result<Self::Output, WriteError>; }

Trait that describes a type that can be written to a WriteContext in binary form with dependent arguments.

Associated Types

type Args[src]

The type of the arguments supplied to write_dep.

type Output[src]

The type of the value returned by write_dep.

Loading content...

Required methods

fn write_dep<C: WriteContext>(
    ctxt: &mut C,
    val: HostType,
    args: Self::Args
) -> Result<Self::Output, WriteError>
[src]

Write the binary representation of Self to ctxt.

Loading content...

Implementors

impl<'a> WriteBinaryDep<GlyfTable<'a>> for GlyfTable<'a>[src]

type Output = LocaTable

type Args = IndexToLocFormat

fn write_dep<C: WriteContext>(
    ctxt: &mut C,
    table: GlyfTable<'a>,
    index_to_loc_format: IndexToLocFormat
) -> Result<Self::Output, WriteError>
[src]

Write this glyf table into ctxt.

A Note About Padding

On the loca table documentation at the bottom it states:

Note that the local offsets should be 32-bit aligned. Offsets which are not 32-bit aligned may seriously degrade performance of some processors.

On the Recommendations for OpenType Fonts page it states:

We recommend that local offsets should be 16-bit aligned, in both the short and long formats of this table.

On Apple’s loca documentation it says:

The glyph data is always word aligned.

Elsewhere in the Apple docs they refer to long as 32-bits, so assuming word here means 16-bits.

An issue was raised against Microsoft’s docs regarding this. Behdad Esfahbod commented:

All the requirements should be removed since 2019.

In reality, in the short format, you are forced to do 16-bit alignment because of how offsets are stored. In the long format, use alignment 1. We’ve been doing that in fonttools for years and never ever heard a complaint whatsoever.

So with this in mind we implement 16-bit alignment when index_to_loc_format is 0, and no alignment/padding otherwise.

impl<'a> WriteBinaryDep<LocaTable> for LocaTable[src]

type Output = ()

type Args = IndexToLocFormat

impl<T> WriteBinaryDep<&'_ Dict<T>> for Dict<T> where
    T: DictDefault
[src]

type Args = DictDelta

type Output = usize

impl<T, HostType> WriteBinaryDep<HostType> for T where
    T: WriteBinary<HostType>, 
[src]

type Args = ()

type Output = T::Output

Loading content...