Struct tfm::format::File

source ·
pub struct File {
Show 13 fields pub header: Header, pub smallest_char: Char, pub char_dimens: BTreeMap<Char, CharDimensions>, pub char_tags: BTreeMap<Char, CharTag>, pub unset_char_tags: BTreeMap<Char, u8>, pub widths: Vec<Number>, pub heights: Vec<Number>, pub depths: Vec<Number>, pub italic_corrections: Vec<Number>, pub lig_kern_program: Program, pub kerns: Vec<Number>, pub extensible_chars: Vec<ExtensibleRecipe>, pub params: Vec<Number>,
}
Expand description

Complete contents of a TeX font metric (.tfm) file.

The struct contain multiple vectors. In TeX and TFtoPL there is an optimization in which all of data in the vectors is stored in one large vector of 32-bit integers. The conversion from u32 to the specific types like Number are then done when the data is needed. This makes the memory footprint of this type much more compact, and such a change may be considered in the future.

In fact in TeX the font data for all fonts is stored in one contiguous piece of memory (font_info, defined in TeX82.2021.549). This is a little too unsafe to pull off though.

Fields§

§header: Header

Header.

§smallest_char: Char

Smallest character in the .tfm.

§char_dimens: BTreeMap<Char, CharDimensions>

Character dimensions.

§char_tags: BTreeMap<Char, CharTag>

Character tags.

Note there is no correlation between a character having a tag and a character having a dimension. All four combinations of (has or hasn’t dimensions) and (has or hasn’t a tag) are possible.

§unset_char_tags: BTreeMap<Char, u8>

Tags that have been unset, but whose discriminant is still written to a .tfm file by PLtoTF.

§widths: Vec<Number>

Character widths

§heights: Vec<Number>

Character heights

§depths: Vec<Number>

Character depths

§italic_corrections: Vec<Number>

Character italic corrections

§lig_kern_program: Program

Lig kern program.

§kerns: Vec<Number>

Kerns. These are referenced from inside the lig kern commands.

§extensible_chars: Vec<ExtensibleRecipe>

Extensible characters.

§params: Vec<Number>

Font parameters.

Implementations§

source§

impl File

source

pub fn from_raw_file(raw_file: &RawFile<'_>) -> Self

source

pub fn validate_and_fix(&mut self) -> Vec<ValidationWarning>

source

pub fn deserialize( b: &[u8] ) -> (Result<File, DeserializationError>, Vec<DeserializationWarning>)

source

pub fn serialize(&self) -> Vec<u8>

source

pub fn lig_kern_entrypoints(&self) -> HashMap<Char, u8>

Return a map from characters to the lig/kern entrypoint for that character. TODO: can probably return impl Iterator<Item=(Char, u8)>

source

pub fn checksum(&self) -> u32

Calculate the checksum of this .tfm file.

Trait Implementations§

source§

impl Clone for File

source§

fn clone(&self) -> File

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for File

source§

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

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

impl Default for File

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<File> for File

source§

fn from(pl_file: File) -> Self

Converts to this type from the input type.
source§

impl From<File> for File

source§

fn from(tfm_file: File) -> Self

Converts to this type from the input type.
source§

impl PartialEq<File> for File

source§

fn eq(&self, other: &File) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for File

source§

impl StructuralEq for File

source§

impl StructuralPartialEq for File

Auto Trait Implementations§

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.