pub struct FontContext { /* private fields */ }Expand description
A font manager for maycoon applications.
Can be used to load and access in-memory fonts or by system source.
If the default include-noto-sans feature is enabled, the default font is set to Noto Sans.
Implementations§
Source§impl FontContext
impl FontContext
Sourcepub fn new(default: impl ToString) -> Self
pub fn new(default: impl ToString) -> Self
Create a new font context with the given default font name.
Make sure to load the default font via FontContext::load, before passing this context to the application runner.
Sourcepub fn load(self, name: impl ToString, font: FontData) -> Option<Self>
pub fn load(self, name: impl ToString, font: FontData) -> Option<Self>
Loads a font with a custom name into the font context and return itself.
If the font with the same name already exists, None is returned.
Sourcepub fn set_default_font(&mut self, name: impl ToString)
pub fn set_default_font(&mut self, name: impl ToString)
Set the default font.
NOTE: The font must be loaded before usage with FontContext::load.
Sourcepub fn get(&self, name: impl ToString) -> Option<FontData>
pub fn get(&self, name: impl ToString) -> Option<FontData>
Get a font by a specified name. Returns None if the font could not be found.
Sourcepub fn remove(self, name: impl AsRef<str>) -> Option<Self>
pub fn remove(self, name: impl AsRef<str>) -> Option<Self>
Removes a font by the given name and returns it or None if the font could not be found.
Sourcepub fn default_font(&self) -> &FontData
pub fn default_font(&self) -> &FontData
Returns the default font. Roboto by default.
Trait Implementations§
Source§impl Clone for FontContext
impl Clone for FontContext
Source§fn clone(&self) -> FontContext
fn clone(&self) -> FontContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontContext
impl Debug for FontContext
Auto Trait Implementations§
impl Freeze for FontContext
impl !RefUnwindSafe for FontContext
impl !Send for FontContext
impl !Sync for FontContext
impl Unpin for FontContext
impl !UnwindSafe for FontContext
Blanket Implementations§
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§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>
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>
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)
&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)
&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> 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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.