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§
Implementations§
source§impl 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 Freeze for Handle
impl RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnwindSafe for Handle
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)