[−][src]Struct ab_glyph::FontRef
Font data handle stored as a &[u8]
+ parsed data.
See Font
for more methods.
Also see the owned version FontVec
.
Example
use ab_glyph::{Font, FontRef}; let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?; assert_eq!(font.glyph_id('s'), ab_glyph::GlyphId(56));
Implementations
impl<'font> FontRef<'font>
[src]
pub fn try_from_slice(data: &'font [u8]) -> Result<Self, InvalidFont>
[src]
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"))?;
pub fn try_from_slice_and_index(
data: &'font [u8],
index: u32
) -> Result<Self, InvalidFont>
[src]
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
impl<'font> Clone for FontRef<'font>
[src]
impl<'_> Debug for FontRef<'_>
[src]
impl<'_> Font for FontRef<'_>
[src]
fn ascent_unscaled(&self) -> f32
[src]
fn descent_unscaled(&self) -> f32
[src]
fn line_gap_unscaled(&self) -> f32
[src]
fn glyph_id(&self, c: char) -> GlyphId
[src]
fn h_advance_unscaled(&self, id: GlyphId) -> f32
[src]
fn h_side_bearing_unscaled(&self, id: GlyphId) -> f32
[src]
fn v_advance_unscaled(&self, id: GlyphId) -> f32
[src]
fn v_side_bearing_unscaled(&self, id: GlyphId) -> f32
[src]
fn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32
[src]
fn outline(&self, id: GlyphId) -> Option<Outline>
[src]
fn glyph_count(&self) -> usize
[src]
fn height_unscaled(&self) -> f32
[src]
fn glyph_bounds(&self, glyph: &Glyph) -> Rect where
Self: Sized,
[src]
Self: Sized,
fn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph> where
Self: Sized,
[src]
Self: Sized,
fn as_scaled<S: Into<PxScale>>(&self, scale: S) -> PxScaleFont<&Self> where
Self: Sized,
[src]
Self: Sized,
fn into_scaled<S: Into<PxScale>>(self, scale: S) -> PxScaleFont<Self> where
Self: Sized,
[src]
Self: Sized,
impl From<FontRef<'static>> for FontArc
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,