pub struct FontTemplateDescriptor {
    pub weight: (FontWeight, FontWeight),
    pub stretch: (T, T),
    pub style: (T, T),
    pub unicode_range: Option<Vec<RangeInclusive<u32>>>,
}Expand description
Describes how to select a font from a given family. This is very basic at the moment and needs to be expanded or refactored when we support more of the font styling parameters.
NB: If you change this, you will need to update style::properties::compute_font_hash().
Fields§
§weight: (FontWeight, FontWeight)§stretch: (T, T)§style: (T, T)§unicode_range: Option<Vec<RangeInclusive<u32>>>Implementations§
Source§impl FontTemplateDescriptor
 
impl FontTemplateDescriptor
pub fn new(weight: FontWeight, stretch: FontStretch, style: FontStyle) -> Self
pub fn is_variation_font(&self) -> bool
Sourcefn distance_from(&self, target: &FontDescriptor) -> f32
 
fn distance_from(&self, target: &FontDescriptor) -> f32
Returns a score indicating how far apart visually the two font descriptors are. This is used for implmenting the CSS Font Matching algorithm: https://drafts.csswg.org/css-fonts/#font-matching-algorithm.
The smaller the score, the better the fonts match. 0 indicates an exact match. This must be commutative (distance(A, B) == distance(B, A)).
fn matches(&self, descriptor_to_match: &FontDescriptor) -> bool
pub fn override_values_with_css_font_template_descriptors( &mut self, css_font_template_descriptors: &CSSFontFaceDescriptors, )
Trait Implementations§
Source§impl Clone for FontTemplateDescriptor
 
impl Clone for FontTemplateDescriptor
Source§fn clone(&self) -> FontTemplateDescriptor
 
fn clone(&self) -> FontTemplateDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontTemplateDescriptor
 
impl Debug for FontTemplateDescriptor
Source§impl Default for FontTemplateDescriptor
 
impl Default for FontTemplateDescriptor
Source§impl<'de> Deserialize<'de> for FontTemplateDescriptor
 
impl<'de> Deserialize<'de> for FontTemplateDescriptor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
Source§impl Hash for FontTemplateDescriptor
 
impl Hash for FontTemplateDescriptor
Source§impl MallocSizeOf for FontTemplateDescriptor
 
impl MallocSizeOf for FontTemplateDescriptor
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
 
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Source§impl PartialEq for FontTemplateDescriptor
 
impl PartialEq for FontTemplateDescriptor
Source§impl Serialize for FontTemplateDescriptor
 
impl Serialize for FontTemplateDescriptor
impl Eq for FontTemplateDescriptor
FontTemplateDescriptor contains floats, which are not Eq because of NaN. However, we know they will never be NaN, so we can manually implement Eq.
impl StructuralPartialEq for FontTemplateDescriptor
Auto Trait Implementations§
impl Freeze for FontTemplateDescriptor
impl RefUnwindSafe for FontTemplateDescriptor
impl Send for FontTemplateDescriptor
impl Sync for FontTemplateDescriptor
impl Unpin for FontTemplateDescriptor
impl UnwindSafe for FontTemplateDescriptor
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<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.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