[][src]Trait ab_glyph::Font

pub trait Font {
    fn ascent_unscaled(&self) -> f32;
fn descent_unscaled(&self) -> f32;
fn line_gap_unscaled(&self) -> f32;
fn glyph_id(&self, c: char) -> GlyphId;
fn h_advance_unscaled(&self, id: GlyphId) -> f32;
fn h_side_bearing_unscaled(&self, id: GlyphId) -> f32;
fn v_advance_unscaled(&self, id: GlyphId) -> f32;
fn v_side_bearing_unscaled(&self, id: GlyphId) -> f32;
fn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32;
fn outline(&self, id: GlyphId) -> Option<Outline>;
fn glyph_count(&self) -> usize; fn height_unscaled(&self) -> f32 { ... }
fn glyph_bounds(&self, glyph: &Glyph) -> Rect
    where
        Self: Sized
, { ... }
fn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph>
    where
        Self: Sized
, { ... }
fn as_scaled<S: Into<PxScale>>(&self, scale: S) -> PxScaleFont<&Self>
    where
        Self: Sized
, { ... }
fn into_scaled<S: Into<PxScale>>(self, scale: S) -> PxScaleFont<Self>
    where
        Self: Sized
, { ... } }

Functionality required from font data.

See FontArc, FontRef & FontVec.

Required methods

fn ascent_unscaled(&self) -> f32

Unscaled glyph ascent.

Scaling can be done with as_scaled.

fn descent_unscaled(&self) -> f32

Unscaled glyph descent.

Scaling can be done with as_scaled.

fn line_gap_unscaled(&self) -> f32

Unscaled line gap.

Scaling can be done with as_scaled.

fn glyph_id(&self, c: char) -> GlyphId

Lookup a GlyphId matching a given char.

Scaling can be done with as_scaled.

fn h_advance_unscaled(&self, id: GlyphId) -> f32

Unscaled horizontal advance for a given glyph id.

Scaling can be done with as_scaled.

fn h_side_bearing_unscaled(&self, id: GlyphId) -> f32

Unscaled horizontal side bearing for a given glyph id.

Scaling can be done with as_scaled.

fn v_advance_unscaled(&self, id: GlyphId) -> f32

Unscaled vertical advance for a given glyph id.

Scaling can be done with as_scaled.

fn v_side_bearing_unscaled(&self, id: GlyphId) -> f32

Unscaled vertical side bearing for a given glyph id.

Scaling can be done with as_scaled.

fn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32

Returns additional unscaled kerning to apply for a particular pair of glyph ids.

Scaling can be done with as_scaled.

fn outline(&self, id: GlyphId) -> Option<Outline>

Compute unscaled glyph outline curves & bounding box.

fn glyph_count(&self) -> usize

The number of glyphs present in this font. Glyph identifiers for this font will always be in the range 0..self.glyph_count()

Loading content...

Provided methods

fn height_unscaled(&self) -> f32

Unscaled height ascent - descent.

Scaling can be done with as_scaled.

fn glyph_bounds(&self, glyph: &Glyph) -> Rect where
    Self: Sized

Returns the layout bounds of this glyph. These are different to the outline px_bounds().

Horizontally: Glyph position +/- h_advance/h_side_bearing. Vertically: Glyph position +/- ascent/descent.

fn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph> where
    Self: Sized

Compute glyph outline ready for drawing.

fn as_scaled<S: Into<PxScale>>(&self, scale: S) -> PxScaleFont<&Self> where
    Self: Sized

Construct a PxScaleFontRef by associating with the given pixel scale.

Example

let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;

assert_eq!(font.descent_unscaled(), -201.0);

assert_eq!(font.as_scaled(24.0).descent(), -4.02);
assert_eq!(font.as_scaled(50.0).descent(), -8.375);

fn into_scaled<S: Into<PxScale>>(self, scale: S) -> PxScaleFont<Self> where
    Self: Sized

Move into a PxScaleFont associated with the given pixel scale.

Loading content...

Implementations on Foreign Types

impl<'_, F: Font> Font for &'_ F[src]

Loading content...

Implementors

impl Font for FontArc[src]

impl Font for FontVec[src]

impl<'_> Font for FontRef<'_>[src]

Loading content...