pub struct Font { /* private fields */ }Expand description
A font used for writing on a Layer.
Use Font::builder() to create a new font from a registered system font or
a local file. The Font::from_file() is a shortcut to achieve the latter.
In addition to the usual properties of a font, radiant also assigns a fixed size
to each font object. Instead of modifying this value, you can clone a new font
with a different size using Font::with_size().
Implementations§
Source§impl Font
impl Font
Sourcepub fn builder(context: &RenderContext) -> FontBuilder<'_>
pub fn builder(context: &RenderContext) -> FontBuilder<'_>
Returns a font builder for font construction.
§Examples
let my_font = Font::builder(&rendercontext).family("Arial").size(16.0).build().unwrap();Sourcepub fn from_file(context: &RenderContext, file: &str) -> Result<Font>
pub fn from_file(context: &RenderContext, file: &str) -> Result<Font>
Creates a font instance from a file.
Sourcepub fn query() -> FontQueryBuilder
pub fn query() -> FontQueryBuilder
Returns a query builder to retrieve the names of all available system fonts with the given properties (e.g. monospace).
§Examples
let monospace_fonts = Font::query().monospace().italic().fetch();Sourcepub fn clone_with_size(&self, size: f32) -> Font
pub fn clone_with_size(&self, size: f32) -> Font
Returns a new font instance with given size.
Sourcepub fn write<T>(
&self,
layer: &Layer,
text: &str,
position: T,
color: Color,
) -> &Font
pub fn write<T>( &self, layer: &Layer, text: &str, position: T, color: Color, ) -> &Font
Write to given layer.
Sourcepub fn write_wrapped<T>(
&self,
layer: &Layer,
text: &str,
position: T,
color: Color,
max_width: f32,
) -> &Font
pub fn write_wrapped<T>( &self, layer: &Layer, text: &str, position: T, color: Color, max_width: f32, ) -> &Font
Write to given layer. Breaks lines after max_width pixels.
Trait Implementations§
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§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford method by default
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
Converts
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>
Converts
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