pub struct FontSelector {
pub family: FamilySelector,
pub weight: FontWeight,
pub width: FontWidth,
pub style: FontStyle,
}Expand description
A font face selection tool
This tool selects a font according to the given criteria from available system fonts. Selection criteria are based on CSS.
This can be converted from a FamilySelector, selecting the
default styles.
Fields§
§family: FamilySelectorFamily selector
weight: FontWeightWeight
width: FontWidthWidth
style: FontStyleItalic / oblique style
Implementations§
Source§impl FontSelector
impl FontSelector
Sourcepub fn new() -> Self
pub fn new() -> Self
Synonym for default
Without further parametrization, this will select a generic sans-serif font which should be suitable for most uses.
Sourcepub fn format_css(&self) -> Option<String>
pub fn format_css(&self) -> Option<String>
Format CSS-style
This is similar to the CSS font property, though it does not support
size or variant or using relative or global values. Examples:
system-uiitalic bold expanded sans-serifoblique 10deg 500 175% monospace300 cursive
Weight, width and style will be omitted if normal. Family is required and must be a single generic name.
Will return None if Self::family is not one of the generic
families supported by FamilySelector.
Sourcepub fn parse_css(s: &str) -> Option<Self>
pub fn parse_css(s: &str) -> Option<Self>
Parse a CSS-style selector
Format support is similar to Self::format_css.
Does not (yet) support non-generic font families. TODO: write a nicer parser with real error detection!
Trait Implementations§
Source§impl Clone for FontSelector
impl Clone for FontSelector
Source§fn clone(&self) -> FontSelector
fn clone(&self) -> FontSelector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontSelector
impl Debug for FontSelector
Source§impl Default for FontSelector
impl Default for FontSelector
Source§fn default() -> FontSelector
fn default() -> FontSelector
Source§impl<'de> Deserialize<'de> for FontSelector
impl<'de> Deserialize<'de> for FontSelector
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<FontSelector, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<FontSelector, D::Error>
Source§impl From<FamilySelector> for FontSelector
impl From<FamilySelector> for FontSelector
Source§fn from(family: FamilySelector) -> Self
fn from(family: FamilySelector) -> Self
Source§impl Hash for FontSelector
impl Hash for FontSelector
Source§impl PartialEq for FontSelector
impl PartialEq for FontSelector
Source§impl Serialize for FontSelector
impl Serialize for FontSelector
impl Copy for FontSelector
impl Eq for FontSelector
impl StructuralPartialEq for FontSelector
Auto Trait Implementations§
impl Freeze for FontSelector
impl RefUnwindSafe for FontSelector
impl Send for FontSelector
impl Sync for FontSelector
impl Unpin for FontSelector
impl UnwindSafe for FontSelector
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<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.