Enum tfm::format::DeserializationError
source · pub enum DeserializationError {
FileIsEmpty,
FileHasOneByte(u8),
InternalFileLengthIsZero,
InternalFileLengthIsNegative(i16),
InternalFileLengthIsTooBig(i16, usize),
InternalFileLengthIsTooSmall(i16, usize),
SubFileSizeIsNegative(SubFileSizes),
HeaderLengthIsTooSmall(i16),
InvalidCharacterRange(i16, i16),
IncompleteSubFiles(SubFileSizes),
TooManyExtensibleCharacters(i16),
InconsistentSubFileSizes(SubFileSizes),
}
Variants§
FileIsEmpty
The TFM file is empty (i.e., 0 bytes).
Knuth’s TFToPL doesn’t handle this case explicitly.
Providing an empty file to the TFtoPL always returns an error.
However, the error message is non-deterministic
and depends on the initial value of a specific byte of memory (tfm[0]
).
If that byte is greater than 127 the message for DeserializationError::InternalFileLengthIsNegative
is printed; otherwise the message for DeserializationError::FileHasOneByte
is printed.
FileHasOneByte(u8)
The TFM file consists of a single byte.
InternalFileLengthIsZero
The file length specified inside the TFM file is invalid because it is zero.
InternalFileLengthIsNegative(i16)
The file length specified inside the TFM file is invalid because it is negative.
The variant payload is the invalid length in this file.
InternalFileLengthIsTooBig(i16, usize)
The file length specified inside the TFM file is invalid because the file is smaller than it claims.
The variant payload is the invalid length of this file (in words) and the actual file size (in bytes). One word is 4 bytes.
InternalFileLengthIsTooSmall(i16, usize)
The file length specified inside the TFM file is invalid because it is too small.
TFM files must contain at least 24 bytes of data: the 16-bit file size and the 11 16-bit numbers in the sub file sizes section.
Knuth’s TFToPL doesn’t handle this case explicitly. When this buggy input is provided, a DeserializationError::SubFileSizeIsNegative error is thrown in some cases, and a DeserializationError::HeaderLengthIsTooSmall in other cases. Although the result is deterministic, there seems to be undefined behavior here because it seems to depend on the value of uninitialized memory.
SubFileSizeIsNegative(SubFileSizes)
One of the sub file sizes is negative.
HeaderLengthIsTooSmall(i16)
The header length is too small (either 0 or 1).
InvalidCharacterRange(i16, i16)
The character range is invalid.
This means either that the lower bound of the range (the smallest character) is not smaller than the upper bound of the range (the largest character), or the upper bound is bigger than 255.
IncompleteSubFiles(SubFileSizes)
The character dimension sub-files are incomplete.
This means the sub-file for either widths, heights, depths or italic corrections is empty.
TooManyExtensibleCharacters(i16)
There are more than 256 extensible characters.
InconsistentSubFileSizes(SubFileSizes)
The sub-file sizes are inconsistent.
Implementations§
source§impl DeserializationError
impl DeserializationError
sourcepub fn tftopl_message(&self) -> String
pub fn tftopl_message(&self) -> String
Returns the error message the TFtoPL program prints for this kind of error.
sourcepub fn tftopl_section(&self) -> usize
pub fn tftopl_section(&self) -> usize
Returns the section in Knuth’s TFtoPL (version 2014) in which this error occurs.
Trait Implementations§
source§impl Debug for DeserializationError
impl Debug for DeserializationError
source§impl PartialEq<DeserializationError> for DeserializationError
impl PartialEq<DeserializationError> for DeserializationError
source§fn eq(&self, other: &DeserializationError) -> bool
fn eq(&self, other: &DeserializationError) -> bool
self
and other
values to be equal, and is used
by ==
.