Function safe_read_array_to_end

Source
pub(crate) fn safe_read_array_to_end<'a, T: AnyBitPattern + FixedSize>(
    data: &FontData<'a>,
    offset: usize,
) -> Result<&'a [T], ReadError>
Expand description

Reads an array of T from the given FontData, ensuring that the byte length is a multiple of the size of T.

Many of the morx subtables have arrays without associated lengths so we simply read to the end of the available data. The FontData::read_array method will fail if the byte range provided is not exact so this helper allows us to force the lengths to an acceptable value.