pub struct FontInfo {
pub name: String,
pub family: FontFamily,
pub weight: FontWeight,
pub italic: bool,
pub is_base14: bool,
pub ascender: f32,
pub descender: f32,
pub line_gap: f32,
pub cap_height: f32,
pub x_height: f32,
/* private fields */
}Expand description
Information about a font.
Fields§
§name: StringFont name (e.g., “Helvetica-Bold”)
family: FontFamilyFont family
weight: FontWeightFont weight
italic: boolWhether the font is italic/oblique
is_base14: boolWhether this is a Base-14 font
ascender: f32Ascender height (above baseline)
descender: f32Descender depth (below baseline, negative)
line_gap: f32Line gap (extra space between lines)
cap_height: f32Cap height (height of capital letters)
x_height: f32x-height (height of lowercase x)
Implementations§
Source§impl FontInfo
impl FontInfo
Sourcepub fn text_width(&self, text: &str, font_size: f32) -> f32
pub fn text_width(&self, text: &str, font_size: f32) -> f32
Calculate the width of text in this font.
Returns width in points for the given font size.
Sourcepub fn char_width(&self, ch: char) -> f32
pub fn char_width(&self, ch: char) -> f32
Get the width of a single character in font units (1/1000 of em).
Sourcepub fn line_height(&self, font_size: f32) -> f32
pub fn line_height(&self, font_size: f32) -> f32
Get the line height for this font at the given size.
Sourcepub fn line_spacing_factor(&self) -> f32
pub fn line_spacing_factor(&self) -> f32
Get recommended line spacing multiplier.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FontInfo
impl RefUnwindSafe for FontInfo
impl Send for FontInfo
impl Sync for FontInfo
impl Unpin for FontInfo
impl UnsafeUnpin for FontInfo
impl UnwindSafe for FontInfo
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.