Trait allsorts_no_std::binary::write::WriteBinaryDep [−][src]
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
.
Required methods
fn write_dep<C: WriteContext>(
ctxt: &mut C,
val: HostType,
args: Self::Args
) -> Result<Self::Output, WriteError>
[src]
ctxt: &mut C,
val: HostType,
args: Self::Args
) -> Result<Self::Output, WriteError>
Write the binary representation of Self to ctxt
.
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]
ctxt: &mut C,
table: GlyfTable<'a>,
index_to_loc_format: IndexToLocFormat
) -> Result<Self::Output, WriteError>
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
fn write_dep<C: WriteContext>(
ctxt: &mut C,
loca: LocaTable,
index_to_loc_format: Self::Args
) -> Result<(), WriteError>
[src]
ctxt: &mut C,
loca: LocaTable,
index_to_loc_format: Self::Args
) -> Result<(), WriteError>
impl<T> WriteBinaryDep<&'_ Dict<T>> for Dict<T> where
T: DictDefault,
[src]
T: DictDefault,
type Args = DictDelta
type Output = usize
fn write_dep<C: WriteContext>(
ctxt: &mut C,
dict: &Dict<T>,
delta: DictDelta
) -> Result<Self::Output, WriteError>
[src]
ctxt: &mut C,
dict: &Dict<T>,
delta: DictDelta
) -> Result<Self::Output, WriteError>
impl<T, HostType> WriteBinaryDep<HostType> for T where
T: WriteBinary<HostType>,
[src]
T: WriteBinary<HostType>,