pub enum Handle {
Path {
path: PathBuf,
font_index: u32,
},
Memory {
bytes: Arc<Vec<u8>>,
font_index: u32,
},
}Expand description
Encapsulates the information needed to locate and open a font.
This is either the path to the font or the raw in-memory font data.
To open the font referenced by a handle, use a loader.
Variants
Path
Fields
path: PathBufThe path to the font.
font_index: u32The index of the font, if the path refers to a collection.
If the path refers to a single font, this value will be 0.
A font on disk referenced by a path.
Memory
Fields
font_index: u32The index of the font, if the memory consists of a collection.
If the memory consists of a single font, this value will be 0.
A font in memory.
Implementations
sourceimpl Handle
impl Handle
sourcepub fn from_path(path: PathBuf, font_index: u32) -> Handle
pub fn from_path(path: PathBuf, font_index: u32) -> Handle
Creates a new handle from a path.
font_index specifies the index of the font to choose if the path points to a font
collection. If the path points to a single font file, pass 0.
sourcepub fn from_memory(bytes: Arc<Vec<u8>>, font_index: u32) -> Handle
pub fn from_memory(bytes: Arc<Vec<u8>>, font_index: u32) -> Handle
Creates a new handle from raw TTF/OTF/etc. data in memory.
font_index specifies the index of the font to choose if the memory represents a font
collection. If the memory represents a single font file, pass 0.
sourcepub fn load(&self) -> Result<Font, FontLoadingError>
pub fn load(&self) -> Result<Font, FontLoadingError>
A convenience method to load this handle with the default loader, producing a Font.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnwindSafe for Handle
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
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