pub struct Font(/* private fields */);Expand description
A sized font face.
A sized font can be requested from a FontFace.
This type is a shared reference to the loaded font data, cloning it is cheap.
Implementations§
Source§impl Font
impl Font
Sourcepub fn space_index(&self) -> u32
pub fn space_index(&self) -> u32
Glyph index for the space ' ' character.
Sourcepub fn space_x_advance(&self) -> Px
pub fn space_x_advance(&self) -> Px
Returns the horizontal advance of the space ' ' character.
Sourcepub fn shape_text(
&self,
text: &SegmentedText,
config: &TextShapingArgs,
) -> ShapedText
pub fn shape_text( &self, text: &SegmentedText, config: &TextShapingArgs, ) -> ShapedText
Calculates a ShapedText.
Sourcepub fn outline(
&self,
glyph_id: u32,
sink: &mut impl OutlineSink,
) -> Option<Rect<Px, Px>>
pub fn outline( &self, glyph_id: u32, sink: &mut impl OutlineSink, ) -> Option<Rect<Px, Px>>
Sends the sized vector path for a glyph to sink.
Returns the glyph bounds if a full outline was sent to the sink.
Sourcepub fn h_line_hits(
&self,
glyph_id: u32,
line_y_range: (f32, f32),
) -> Option<(f32, f32)>
pub fn h_line_hits( &self, glyph_id: u32, line_y_range: (f32, f32), ) -> Option<(f32, f32)>
Ray cast an horizontal line across the glyph and returns the entry and exit hits.
The line_y_range are two vertical offsets relative to the baseline, the offsets define
the start and inclusive end of the horizontal line, that is, (underline, underline + thickness), note
that positions under the baseline are negative so a 2px underline set 1px under the baseline becomes (-1.0, -3.0).
Returns Ok(Some(x_enter, x_exit)) where the two values are x-advances, returns None if there is no hit.
The first x-advance is from the left typographic border to the first hit on the outline,
the second x-advance is from the first across the outline to the exit hit.
Source§impl Font
impl Font
Sourcepub fn variations(&self) -> &Vec<Variation>
pub fn variations(&self) -> &Vec<Variation>
Custom font variations.
Sourcepub fn metrics(&self) -> &FontMetrics
pub fn metrics(&self) -> &FontMetrics
Sized font metrics.
Sourcepub fn ligature_caret_offsets(
&self,
lig: u32,
) -> impl ExactSizeIterator + DoubleEndedIterator
pub fn ligature_caret_offsets( &self, lig: u32, ) -> impl ExactSizeIterator + DoubleEndedIterator
Iterate over pixel offsets relative to lig glyph start that represents the
caret offset for each cluster that is covered by the ligature, after the first.
The caret offset for the first cluster is the glyph offset and is not yielded in the iterator. The yielded offsets are relative to the glyph position.
Trait Implementations§
Source§impl Font for Font
impl Font for Font
Source§fn is_empty_fallback(&self) -> bool
fn is_empty_fallback(&self) -> bool
Source§fn renderer_id(
&self,
renderer: &ViewRenderer,
synthesis: FontSynthesis,
) -> FontId
fn renderer_id( &self, renderer: &ViewRenderer, synthesis: FontSynthesis, ) -> FontId
renderer namespace. Read moreimpl Eq for Font
Auto Trait Implementations§
impl Freeze for Font
impl !RefUnwindSafe for Font
impl Send for Font
impl Sync for Font
impl Unpin for Font
impl !UnwindSafe for Font
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more