Skip to main content

Font

Trait Font 

Source
pub trait Font: Clone + Debug {
    type Char: Character;
    type Dim: TeXDimen;
    type Int: TeXInt;
    type CS: CSName<Self::Char>;

Show 19 methods // Required methods fn get_at(&self) -> Self::Dim; fn has_at_set(&self) -> bool; fn set_at(&mut self, d: Self::Dim); fn name(&self) -> &Self::CS; fn filename(&self) -> &str; fn get_dim(&self, idx: u16) -> Self::Dim; fn set_dim(&mut self, idx: u16, d: Self::Dim); fn get_hyphenchar(&self) -> Self::Int; fn set_hyphenchar(&mut self, c: Self::Int); fn get_skewchar(&self) -> Self::Int; fn set_skewchar(&mut self, c: Self::Int); fn has_char(&self, c: Self::Char) -> bool; fn display<W: Write>( &self, i: &<Self::CS as CSName<Self::Char>>::Handler, w: W, ) -> Result; fn get_wd(&self, c: Self::Char) -> Self::Dim; fn get_ht(&self, c: Self::Char) -> Self::Dim; fn get_dp(&self, c: Self::Char) -> Self::Dim; fn get_ic(&self, c: Self::Char) -> Self::Dim; fn set_ic(&mut self, c: Self::Char, d: Self::Dim); fn ligature(&self, c1: Self::Char, c2: Self::Char) -> Option<Self::Char>;
}
Expand description

A font provides various information about Characters (or, rather, glyphs) in that font. Since in the Stomach every glyph in the output is directly associated with a Font, we clone them a lot, so they should be cheap to clone; e.g. using Rc or Arc is a good idea.

Required Associated Types§

Source

type Char: Character

The type of Characters used by this font.

Source

type Dim: TeXDimen

The type of TeXDimens used by this font, for e.g. \fontdimen, \fontcharwd etc.

Source

type Int: TeXInt

The type of TeXInts used by this font, for e.g. \skewchar, \hyphenchar etc. - these numbers may escape the actual character range of the font, so we use TeXInts instead of Characters.

Source

type CS: CSName<Self::Char>

The type of control sequences used to give a name to a font; returned by e.g. \the when followed by a font.

Required Methods§

Source

fn get_at(&self) -> Self::Dim

The size of the font; initially provided by the font itself, but can be set via e.g. \font\foo=cmr10 at 12pt.

Source

fn has_at_set(&self) -> bool

Returns whether the size of the font has been set via e.g. at ....

Source

fn set_at(&mut self, d: Self::Dim)

Sets the size of the font.

Source

fn name(&self) -> &Self::CS

Returns the name of the font as a CSName; used by e.g. \the\font.

Source

fn filename(&self) -> &str

Returns the filename of the font.

Source

fn get_dim(&self, idx: u16) -> Self::Dim

Returns the \fontdimen at the given index (-1); i.e. \fontdimen5 returns get_dim(4).

Source

fn set_dim(&mut self, idx: u16, d: Self::Dim)

Sets the \fontdimen at the given index (-1); i.e. \fontdimen5=... calls set_dim(4).

Source

fn get_hyphenchar(&self) -> Self::Int

Returns the \hyphenchar of this font.

Source

fn set_hyphenchar(&mut self, c: Self::Int)

Sets the \hyphenchar of this font.

Source

fn get_skewchar(&self) -> Self::Int

Returns the \skewchar of this font.

Source

fn set_skewchar(&mut self, c: Self::Int)

Sets the \skewchar of this font.

Source

fn has_char(&self, c: Self::Char) -> bool

Returns whether this font has a glyph for the given Character.

Source

fn display<W: Write>( &self, i: &<Self::CS as CSName<Self::Char>>::Handler, w: W, ) -> Result

Writes a human-readable representation of this font to the given std::fmt::Writer

Source

fn get_wd(&self, c: Self::Char) -> Self::Dim

Returns the width the given Character in this font.

Source

fn get_ht(&self, c: Self::Char) -> Self::Dim

Returns the height the given Character in this font.

Source

fn get_dp(&self, c: Self::Char) -> Self::Dim

Returns the depth the given Character in this font.

Source

fn get_ic(&self, c: Self::Char) -> Self::Dim

Returns the litalic correction of the given Character in this font.

Source

fn set_ic(&mut self, c: Self::Char, d: Self::Dim)

Sets the litalic correction of the given Character in this font.

Source

fn ligature(&self, c1: Self::Char, c2: Self::Char) -> Option<Self::Char>

Returns the ligature of the given Characters in this font, if any; e.g. most fonts combine - and - into an endash.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<I: TeXInt, D: TeXDimen + Numeric<I>, CS: CSName<u8>> Font for TfmFont<I, D, CS>

Source§

type Char = u8

Source§

type CS = CS

Source§

type Int = I

Source§

type Dim = D