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
impl OutlinedGlyph
sourcepub fn new(glyph: Glyph, outline: Outline, scale_factor: PxScaleFactor) -> Self
pub fn new(glyph: Glyph, outline: Outline, scale_factor: PxScaleFactor) -> Self
Constructs an OutlinedGlyph
from the source Glyph
, pixel bounds
& relatively positioned outline curves.
sourcepub fn px_bounds(&self) -> Rect
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.
sourcepub fn draw<O: FnMut(u32, u32, f32)>(&self, o: O)
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
impl AsRef<Glyph> for OutlinedGlyph
source§impl Clone for OutlinedGlyph
impl Clone for OutlinedGlyph
source§fn clone(&self) -> OutlinedGlyph
fn clone(&self) -> OutlinedGlyph
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more