pub struct FontVec(_);
Expand description
Implementations§
§impl FontVec
impl FontVec
pub fn try_from_vec(data: Vec<u8, Global>) -> Result<FontVec, InvalidFont>
pub fn try_from_vec(data: Vec<u8, Global>) -> Result<FontVec, InvalidFont>
Creates an FontVec
from owned data.
For font collections see
FontVec::try_from_vec_and_index
.
Example
let font = FontVec::try_from_vec(owned_font_data)?;
pub fn try_from_vec_and_index(
data: Vec<u8, Global>,
index: u32
) -> Result<FontVec, InvalidFont>
pub fn try_from_vec_and_index( data: Vec<u8, Global>, index: u32 ) -> Result<FontVec, InvalidFont>
Creates an FontVec
from owned data.
You can set index for font collections. For simple fonts use 0
or
FontVec::try_from_vec
.
Example
let font = FontVec::try_from_vec_and_index(owned_font_data, 0)?;
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Extracts a slice containing the data passed into e.g. FontVec::try_from_vec
.
Example
let font_data_clone = owned_font_data.clone();
let font = FontVec::try_from_vec(owned_font_data)?;
assert_eq!(font.as_slice(), font_data_clone);
Trait Implementations§
§impl Font for FontVec
impl Font for FontVec
§fn units_per_em(&self) -> Option<f32>
fn units_per_em(&self) -> Option<f32>
Get the size of the font unit Read more
§fn ascent_unscaled(&self) -> f32
fn ascent_unscaled(&self) -> f32
Unscaled glyph ascent. Read more
§fn descent_unscaled(&self) -> f32
fn descent_unscaled(&self) -> f32
Unscaled glyph descent. Read more
§fn line_gap_unscaled(&self) -> f32
fn line_gap_unscaled(&self) -> f32
Unscaled line gap. Read more
§fn 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
§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. Read more
§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
§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
§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
§fn outline(&self, id: GlyphId) -> Option<Outline>
fn outline(&self, id: GlyphId) -> Option<Outline>
Compute unscaled glyph outline curves & bounding box.
§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()
§fn codepoint_ids<'a>(&'a self) -> CodepointIdIter<'a> ⓘ
fn codepoint_ids<'a>(&'a self) -> CodepointIdIter<'a> ⓘ
Returns an iterator of all distinct
(GlyphId, char)
pairs. Not ordered. Read more§fn 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
§fn height_unscaled(&self) -> f32
fn height_unscaled(&self) -> f32
Unscaled height
ascent - descent
. Read more§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. These are different to the outline
px_bounds()
. Read more§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.
§fn into_scaled<S>(self, scale: S) -> PxScaleFont<Self>where
S: Into<PxScale>,
Self: Sized,
fn into_scaled<S>(self, scale: S) -> PxScaleFont<Self>where S: Into<PxScale>, Self: Sized,
Move into a
PxScaleFont
associated with the
given pixel scale
.§impl VariableFont for FontVec
impl VariableFont for FontVec
§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
§fn variations(&self) -> Vec<VariationAxis, Global>
fn variations(&self) -> Vec<VariationAxis, Global>
Returns variation axes. Read more