Struct ab_glyph::FontArc[][src]

pub struct FontArc(_);
Expand description

Font implementor that wraps another concrete Font + 'static type storing in an Arc.

Provides convenient type erasure & cheap clones (particularly for FontVec).

Example

use ab_glyph::{Font, FontArc};

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

assert_eq!(font.glyph_id('s'), ab_glyph::GlyphId(56));

Implementations

impl FontArc[src]

pub fn new<F: Font + Send + Sync + 'static>(font: F) -> Self[src]

Example

let font_arc = FontArc::new(font_vec);

pub fn try_from_vec(data: Vec<u8>) -> Result<Self, InvalidFont>[src]

Creates an FontArc from owned data.

Example

let font = FontArc::try_from_vec(owned_font_data)?;

pub fn try_from_slice(data: &'static [u8]) -> Result<Self, InvalidFont>[src]

Creates an FontArc from a byte-slice.

Example

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

Trait Implementations

impl Clone for FontArc[src]

fn clone(&self) -> FontArc[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for FontArc[src]

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

Formats the value using the given formatter. Read more

impl Font for FontArc[src]

fn units_per_em(&self) -> Option<f32>[src]

Get the size of the font unit Read more

fn ascent_unscaled(&self) -> f32[src]

Unscaled glyph ascent. Read more

fn descent_unscaled(&self) -> f32[src]

Unscaled glyph descent. Read more

fn line_gap_unscaled(&self) -> f32[src]

Unscaled line gap. Read more

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

Lookup a GlyphId matching a given char. Read more

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

Unscaled horizontal advance for a given glyph id. Read more

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

Unscaled horizontal side bearing for a given glyph id. Read more

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

Unscaled vertical advance for a given glyph id. Read more

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

Unscaled vertical side bearing for a given glyph id. Read more

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

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

fn outline(&self, glyph: GlyphId) -> Option<Outline>[src]

Compute unscaled glyph outline curves & bounding box.

fn glyph_count(&self) -> usize[src]

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

fn codepoint_ids(&self) -> CodepointIdIter<'_>

Notable traits for CodepointIdIter<'a>

impl<'a> Iterator for CodepointIdIter<'a> type Item = (GlyphId, char);
[src]

Returns an iterator of all distinct (GlyphId, char) pairs. Not ordered. Read more

fn glyph_raster_image(&self, id: GlyphId, size: u16) -> Option<GlyphImage<'_>>[src]

Returns a pre-rendered image of the glyph. Read more

fn height_unscaled(&self) -> f32[src]

Unscaled height ascent - descent. Read more

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

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

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

Compute glyph outline ready for drawing.

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

Construct a PxScaleFontRef by associating with the given pixel scale. Read more

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

Move into a PxScaleFont associated with the given pixel scale. Read more

impl From<Arc<dyn Font + 'static + Sync + Send>> for FontArc[src]

fn from(font: Arc<dyn Font + Send + Sync + 'static>) -> Self[src]

Performs the conversion.

impl From<FontRef<'static>> for FontArc[src]

fn from(font: FontRef<'static>) -> Self[src]

Performs the conversion.

impl From<FontVec> for FontArc[src]

fn from(font: FontVec) -> Self[src]

Performs the conversion.

Auto Trait Implementations

impl !RefUnwindSafe for FontArc

impl Send for FontArc

impl Sync for FontArc

impl Unpin for FontArc

impl !UnwindSafe for FontArc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.