pub struct FontRef<'font>(PreParsedSubtables<'font, Face<'font>>);
Expand description
Tuple Fields§
§0: PreParsedSubtables<'font, Face<'font>>
Implementations§
source§impl<'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§
source§impl Font for FontRef<'_>
impl Font for FontRef<'_>
source§fn ascent_unscaled(&self) -> f32
fn ascent_unscaled(&self) -> f32
Unscaled glyph ascent. See glyph layout concepts. Read more
source§fn descent_unscaled(&self) -> f32
fn descent_unscaled(&self) -> f32
Unscaled glyph descent. See glyph layout concepts. Read more
source§fn line_gap_unscaled(&self) -> f32
fn line_gap_unscaled(&self) -> f32
Unscaled line gap. See glyph layout concepts. Read more
source§fn h_advance_unscaled(&self, id: GlyphId) -> f32
fn h_advance_unscaled(&self, id: GlyphId) -> f32
Unscaled horizontal advance for a given glyph id.
See glyph layout concepts. Read more
source§fn 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.
See glyph layout concepts. Read more
source§fn 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
source§fn 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
source§fn 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
source§fn outline(&self, id: GlyphId) -> Option<Outline>
fn outline(&self, id: GlyphId) -> Option<Outline>
Compute unscaled glyph outline curves & bounding box.
source§fn 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()
source§fn codepoint_ids(&self) -> CodepointIdIter<'_> ⓘ
fn codepoint_ids(&self) -> CodepointIdIter<'_> ⓘ
Returns an iterator of all distinct
(GlyphId, char)
pairs. Not ordered. Read moresource§fn glyph_raster_image2(&self, id: GlyphId, size: u16) -> Option<GlyphImage<'_>>
fn glyph_raster_image2(&self, id: GlyphId, size: u16) -> Option<GlyphImage<'_>>
Returns a pre-rendered image of the glyph. Read more
source§fn glyph_svg_image(&self, id: GlyphId) -> Option<GlyphSvg<'_>>
fn glyph_svg_image(&self, id: GlyphId) -> Option<GlyphSvg<'_>>
Returns raw SVG data of a range of glyphs which includes this one. Read more
source§fn font_data(&self) -> &[u8] ⓘ
fn font_data(&self) -> &[u8] ⓘ
Extracts a slice containing the data passed into e.g.
FontArc::try_from_slice
. Read moresource§fn height_unscaled(&self) -> f32
fn height_unscaled(&self) -> f32
source§fn glyph_raster_image(
&self,
id: GlyphId,
pixel_size: u16,
) -> Option<GlyphImage<'_>>
fn glyph_raster_image( &self, id: GlyphId, pixel_size: u16, ) -> Option<GlyphImage<'_>>
👎Deprecated since 0.2.22: Deprecated in favor of
glyph_raster_image2
Returns a pre-rendered image of the glyph. Read more
source§fn glyph_bounds(&self, glyph: &Glyph) -> Rectwhere
Self: Sized,
fn glyph_bounds(&self, glyph: &Glyph) -> Rectwhere
Self: Sized,
Returns the layout bounds of this glyph. Read more
source§fn 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.
source§fn 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
.source§impl VariableFont for FontRef<'_>
impl VariableFont for FontRef<'_>
source§fn set_variation(&mut self, axis: &[u8; 4], value: f32) -> bool
fn set_variation(&mut self, axis: &[u8; 4], value: f32) -> bool
Sets a variation axis coordinate value by it’s tag. Read more
source§fn variations(&self) -> Vec<VariationAxis>
fn variations(&self) -> Vec<VariationAxis>
Returns variation axes. Read more
Auto Trait Implementations§
impl<'font> Freeze for FontRef<'font>
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§
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