Struct glow_glyph::ab_glyph::FontArc
[−]pub struct FontArc(_);
Expand description
Font
implementor that wraps another concrete Font + 'static
type storing in an Arc
.
Provides convenient type erasure & cheap clones (particularly for FontVec
).
Example
use ab_glyph::{Font, FontArc};
let font = FontArc::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;
assert_eq!(font.glyph_id('s'), ab_glyph::GlyphId(56));
Implementations
impl FontArc
impl FontArc
pub fn new<F>(font: F) -> FontArc where
F: 'static + Font + Send + Sync,
pub fn new<F>(font: F) -> FontArc where
F: 'static + Font + Send + Sync,
Example
let font_arc = FontArc::new(font_vec);
pub fn try_from_vec(data: Vec<u8, Global>) -> Result<FontArc, InvalidFont>
pub fn try_from_vec(data: Vec<u8, Global>) -> Result<FontArc, InvalidFont>
pub fn try_from_slice(data: &'static [u8]) -> Result<FontArc, InvalidFont>
pub fn try_from_slice(data: &'static [u8]) -> Result<FontArc, InvalidFont>
Creates an FontArc
from a byte-slice.
Example
let font = FontArc::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;
Trait Implementations
impl Font for FontArc
impl Font for FontArc
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, glyph: GlyphId) -> Option<Outline>
fn outline(&self, glyph: 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()
Read more
fn codepoint_ids(&self) -> CodepointIdIter<'_>ⓘNotable traits for CodepointIdIter<'a>impl<'a> Iterator for CodepointIdIter<'a> type Item = (GlyphId, char);
fn codepoint_ids(&self) -> CodepointIdIter<'_>ⓘ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
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) -> Rect
fn glyph_bounds(&self, glyph: &Glyph) -> Rect
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>
fn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph>
Compute glyph outline ready for drawing.
fn as_scaled<S>(&self, scale: S) -> PxScaleFont<&Self> where
S: Into<PxScale>,
fn as_scaled<S>(&self, scale: S) -> PxScaleFont<&Self> where
S: Into<PxScale>,
Construct a PxScaleFontRef
by associating with the
given pixel scale
. Read more
fn into_scaled<S>(self, scale: S) -> PxScaleFont<Self> where
S: Into<PxScale>,
fn into_scaled<S>(self, scale: S) -> PxScaleFont<Self> where
S: Into<PxScale>,
Move into a PxScaleFont
associated with the
given pixel scale
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for FontArc
impl Send for FontArc
impl Sync for FontArc
impl Unpin for FontArc
impl !UnwindSafe for FontArc
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more