pub enum Handle {
Path {
path: PathBuf,
font_index: u32,
},
Memory {
bytes: Arc<Vec<u8>>,
font_index: u32,
},
Native {
inner: Arc<dyn Any + Sync + Send>,
},
}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
A font on disk referenced by a path.
Fields
Memory
A font in memory.
Fields
Native
An already-loaded font.
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 from_native<T: Loader>(inner: &T) -> Self
pub fn from_native<T: Loader>(inner: &T) -> Self
Creates a new handle from a system handle.
Sourcepub fn native_as<T: 'static>(&self) -> Option<&T>
pub fn native_as<T: 'static>(&self) -> Option<&T>
Retrieves a handle to the font object.
May return None if inner object is not of type T or if this handle does not contain a native font object.
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.