Struct zng::font::FontFaceMetrics
source · pub struct FontFaceMetrics {
pub units_per_em: u32,
pub ascent: f32,
pub descent: f32,
pub line_gap: f32,
pub underline_position: f32,
pub underline_thickness: f32,
pub cap_height: f32,
pub x_height: f32,
pub bounds: Rect<f32, ()>,
}
Expand description
Various metrics that apply to the entire FontFace
.
For OpenType fonts, these mostly come from the OS/2
table.
See the FreeType Glyph Metrics
documentation for an explanation of the various metrics.
Fields§
§units_per_em: u32
The number of font units per em.
Font sizes are usually expressed in pixels per em; e.g. 12px
means 12 pixels per em.
ascent: f32
The maximum amount the font rises above the baseline, in font units.
descent: f32
The maximum amount the font descends below the baseline, in font units.
This is typically a negative value to match the definition of sTypoDescender
in the
OS/2
table in the OpenType specification. If you are used to using Windows or Mac APIs,
beware, as the sign is reversed from what those APIs return.
line_gap: f32
Distance between baselines, in font units.
underline_position: f32
The suggested distance of the top of the underline from the baseline (negative values indicate below baseline), in font units.
underline_thickness: f32
A suggested value for the underline thickness, in font units.
cap_height: f32
The approximate amount that uppercase letters rise above the baseline, in font units.
x_height: f32
The approximate amount that non-ascending lowercase letters rise above the baseline, in font units.
bounds: Rect<f32, ()>
A rectangle that surrounds all bounding boxes of all glyphs, in font units.
This corresponds to the xMin
/xMax
/yMin
/yMax
values in the OpenType head
table.
Implementations§
source§impl FontFaceMetrics
impl FontFaceMetrics
sourcepub fn sized(&self, font_size_px: Px) -> FontMetrics
pub fn sized(&self, font_size_px: Px) -> FontMetrics
Compute FontMetrics
given a font size in pixels.
Trait Implementations§
source§impl Clone for FontFaceMetrics
impl Clone for FontFaceMetrics
source§fn clone(&self) -> FontFaceMetrics
fn clone(&self) -> FontFaceMetrics
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FontFaceMetrics
impl Debug for FontFaceMetrics
source§impl<'de> Deserialize<'de> for FontFaceMetrics
impl<'de> Deserialize<'de> for FontFaceMetrics
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FontFaceMetrics, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FontFaceMetrics, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<'a> From<Face<'a>> for FontFaceMetrics
impl<'a> From<Face<'a>> for FontFaceMetrics
source§fn from(f: Face<'a>) -> FontFaceMetrics
fn from(f: Face<'a>) -> FontFaceMetrics
source§impl Serialize for FontFaceMetrics
impl Serialize for FontFaceMetrics
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for FontFaceMetrics
impl RefUnwindSafe for FontFaceMetrics
impl Send for FontFaceMetrics
impl Sync for FontFaceMetrics
impl Unpin for FontFaceMetrics
impl UnwindSafe for FontFaceMetrics
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more