Struct fonts::FontTemplateDescriptor
source · 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(crate) 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§fn eq(&self, other: &FontTemplateDescriptor) -> bool
fn eq(&self, other: &FontTemplateDescriptor) -> bool
self
and other
values to be equal, and is used
by ==
.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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> 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 moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.