Struct gfx::font_template::FontTemplateDescriptor
source · pub struct FontTemplateDescriptor {
pub weight: FontWeight,
pub stretch: T,
pub style: T,
}
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
§stretch: T
§style: T
Implementations§
source§impl FontTemplateDescriptor
impl FontTemplateDescriptor
pub fn new(weight: FontWeight, stretch: FontStretch, style: FontStyle) -> Self
sourcefn distance_from(&self, other: &FontTemplateDescriptor) -> f32
fn distance_from(&self, other: &FontTemplateDescriptor) -> f32
Returns a score indicating how far apart visually the two font descriptors are. This is used for fuzzy font selection.
The smaller the score, the better the fonts match. 0 indicates an exact match. This must be commutative (distance(A, B) == distance(B, A)).
The policy is to care most about differences in italicness, then weight, then stretch
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<'a> From<&'a Font> for FontTemplateDescriptor
impl<'a> From<&'a Font> for FontTemplateDescriptor
source§fn from(style: &'a FontStyleStruct) -> Self
fn from(style: &'a FontStyleStruct) -> Self
source§impl Hash for FontTemplateDescriptor
impl Hash for FontTemplateDescriptor
source§impl PartialEq<FontTemplateDescriptor> for FontTemplateDescriptor
impl PartialEq<FontTemplateDescriptor> 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 Copy 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 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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
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>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,
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, Global>> for T
impl<T> MaybeBoxed<Box<T, Global>> for T
source§fn maybe_boxed(self) -> Box<T, Global>
fn maybe_boxed(self) -> Box<T, Global>
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 Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
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()
.