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 Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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.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