Struct ab_glyph::outlined::OutlinedGlyph

source ·
pub struct OutlinedGlyph {
    glyph: Glyph,
    px_bounds: Rect,
    scale_factor: PxScaleFactor,
    outline: Outline,
}
Expand description

A glyph that has been outlined at a scale & position.

Fields§

§glyph: Glyph§px_bounds: Rect§scale_factor: PxScaleFactor§outline: Outline

Implementations§

source§

impl OutlinedGlyph

source

pub fn new(glyph: Glyph, outline: Outline, scale_factor: PxScaleFactor) -> Self

Constructs an OutlinedGlyph from the source Glyph, pixel bounds & relatively positioned outline curves.

source

pub fn glyph(&self) -> &Glyph

Glyph info.

source

pub fn px_bounds(&self) -> Rect

Conservative whole number pixel bounding box for this glyph outline. The returned rect is exactly large enough to Self::draw into.

The rect holds bounding coordinates in the same coordinate space as the Glyph::position.

Note: These bounds depend on the glyph outline. That outline is not necessarily bound by the layout/glyph_bounds() bounds.

  • The min.x bound may be greater or smaller than the Glyph::position x. E.g. if a glyph at position x=0 has an outline going off to the left a bit, min.x will be negative.
  • The max.x bound may be greater/smaller than the position.x + h_advance.
  • The min.y bound may be greater/smaller than the position.y - ascent.
  • The max.y bound may be greater/smaller than the position.y - descent.

Pixel bounds coordinates should not be used for layout logic.

source

pub fn draw<O: FnMut(u32, u32, f32)>(&self, o: O)

Draw this glyph outline using a pixel & coverage handling function.

The callback will be called for each (x, y) pixel coordinate inside the bounds with a coverage value indicating how much the glyph covered that pixel.

A coverage value of 0.0 means the pixel is totally uncoverred by the glyph. A value of 1.0 or greater means fully covered.

Trait Implementations§

source§

impl AsRef<Glyph> for OutlinedGlyph

source§

fn as_ref(&self) -> &Glyph

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for OutlinedGlyph

source§

fn clone(&self) -> OutlinedGlyph

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 OutlinedGlyph

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.