pub struct FontRef<'font>(_);
Expand description
Implementations
sourceimpl<'font> FontRef<'font>
impl<'font> FontRef<'font>
sourcepub fn try_from_slice(data: &'font [u8]) -> Result<Self, InvalidFont>
pub fn try_from_slice(data: &'font [u8]) -> Result<Self, InvalidFont>
Creates an FontRef
from a byte-slice.
For font collections see
FontRef::try_from_slice_and_index
.
Example
let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;
sourcepub fn try_from_slice_and_index(
data: &'font [u8],
index: u32
) -> Result<Self, InvalidFont>
pub fn try_from_slice_and_index(
data: &'font [u8],
index: u32
) -> Result<Self, InvalidFont>
Creates an FontRef
from byte-slice.
You can set index for font collections. For simple fonts use 0
or
FontRef::try_from_slice
.
Example
let font =
FontRef::try_from_slice_and_index(include_bytes!("../../dev/fonts/Exo2-Light.otf"), 0)?;
Trait Implementations
sourceimpl Font for FontRef<'_>
impl Font for FontRef<'_>
sourcefn units_per_em(&self) -> Option<f32>
fn units_per_em(&self) -> Option<f32>
Get the size of the font unit Read more
sourcefn ascent_unscaled(&self) -> f32
fn ascent_unscaled(&self) -> f32
Unscaled glyph ascent. Read more
sourcefn descent_unscaled(&self) -> f32
fn descent_unscaled(&self) -> f32
Unscaled glyph descent. Read more
sourcefn line_gap_unscaled(&self) -> f32
fn line_gap_unscaled(&self) -> f32
Unscaled line gap. Read more
sourcefn h_advance_unscaled(&self, id: GlyphId) -> f32
fn h_advance_unscaled(&self, id: GlyphId) -> f32
Unscaled horizontal advance for a given glyph id. Read more
sourcefn h_side_bearing_unscaled(&self, id: GlyphId) -> f32
fn h_side_bearing_unscaled(&self, id: GlyphId) -> f32
Unscaled horizontal side bearing for a given glyph id. Read more
sourcefn v_advance_unscaled(&self, id: GlyphId) -> f32
fn v_advance_unscaled(&self, id: GlyphId) -> f32
Unscaled vertical advance for a given glyph id. Read more
sourcefn v_side_bearing_unscaled(&self, id: GlyphId) -> f32
fn v_side_bearing_unscaled(&self, id: GlyphId) -> f32
Unscaled vertical side bearing for a given glyph id. Read more
sourcefn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32
fn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32
Returns additional unscaled kerning to apply for a particular pair of glyph ids. Read more
sourcefn outline(&self, id: GlyphId) -> Option<Outline>
fn outline(&self, id: GlyphId) -> Option<Outline>
Compute unscaled glyph outline curves & bounding box.
sourcefn glyph_count(&self) -> usize
fn glyph_count(&self) -> usize
The number of glyphs present in this font. Glyph identifiers for this
font will always be in the range 0..self.glyph_count()
Read more
sourcefn codepoint_ids<'a>(&'a self) -> CodepointIdIter<'a>ⓘNotable traits for CodepointIdIter<'a>impl<'a> Iterator for CodepointIdIter<'a> type Item = (GlyphId, char);
fn codepoint_ids<'a>(&'a self) -> CodepointIdIter<'a>ⓘNotable traits for CodepointIdIter<'a>impl<'a> Iterator for CodepointIdIter<'a> type Item = (GlyphId, char);
Returns an iterator of all distinct (GlyphId, char)
pairs. Not ordered. Read more
sourcefn glyph_raster_image(&self, id: GlyphId, size: u16) -> Option<GlyphImage<'_>>
fn glyph_raster_image(&self, id: GlyphId, size: u16) -> Option<GlyphImage<'_>>
Returns a pre-rendered image of the glyph. Read more
sourcefn height_unscaled(&self) -> f32
fn height_unscaled(&self) -> f32
Unscaled height ascent - descent
. Read more
sourcefn glyph_bounds(&self, glyph: &Glyph) -> Rect where
Self: Sized,
fn glyph_bounds(&self, glyph: &Glyph) -> Rect where
Self: Sized,
Returns the layout bounds of this glyph. These are different to the outline px_bounds()
. Read more
sourcefn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph> where
Self: Sized,
fn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph> where
Self: Sized,
Compute glyph outline ready for drawing.
sourcefn as_scaled<S: Into<PxScale>>(&self, scale: S) -> PxScaleFont<&Self> where
Self: Sized,
fn as_scaled<S: Into<PxScale>>(&self, scale: S) -> PxScaleFont<&Self> where
Self: Sized,
Construct a PxScaleFontRef
by associating with the
given pixel scale
. Read more
sourcefn into_scaled<S: Into<PxScale>>(self, scale: S) -> PxScaleFont<Self> where
Self: Sized,
fn into_scaled<S: Into<PxScale>>(self, scale: S) -> PxScaleFont<Self> where
Self: Sized,
Move into a PxScaleFont
associated with the
given pixel scale
. Read more
Auto Trait Implementations
impl<'font> RefUnwindSafe for FontRef<'font>
impl<'font> Send for FontRef<'font>
impl<'font> Sync for FontRef<'font>
impl<'font> Unpin for FontRef<'font>
impl<'font> UnwindSafe for FontRef<'font>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more