pub struct Font { /* private fields */ }
Expand description
A parsed font, with access to its glyphs and stored strings
Implementations§
Source§impl Font
impl Font
Sourcepub fn new(font_data: &[u8]) -> ParseResult<Self>
pub fn new(font_data: &[u8]) -> ParseResult<Self>
Creates a new font from the given font data
§Errors
Returns an error if the font data is invalid or cannot be parsed
Sourcepub fn from_file(path: impl AsRef<Path>) -> ParseResult<Self>
pub fn from_file(path: impl AsRef<Path>) -> ParseResult<Self>
Creates a new font from the font file at the specified path
§Errors
Returns an error if the font data is invalid or cannot be parsed
Sourcepub fn string(&self, kind: StringKind) -> Option<&str>
pub fn string(&self, kind: StringKind) -> Option<&str>
Returns the string with the specified kind, if it exists
Sourcepub fn strings(&self) -> &HashMap<StringKind, String>
pub fn strings(&self) -> &HashMap<StringKind, String>
Returns all the strings in the font
Sourcepub fn glyph(&self, codepoint: u32) -> Option<&Glyph>
pub fn glyph(&self, codepoint: u32) -> Option<&Glyph>
Returns the glyph with the specified unicode codepoint, if it exists
Sourcepub fn glyph_named(&self, name: &str) -> Option<&Glyph>
pub fn glyph_named(&self, name: &str) -> Option<&Glyph>
Returns the glyph with the specified postscript name, if it exists
Trait Implementations§
Source§impl From<TrueTypeFont> for Font
impl From<TrueTypeFont> for Font
Source§fn from(value: TrueTypeFont) -> Self
fn from(value: TrueTypeFont) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Font
impl RefUnwindSafe for Font
impl Send for Font
impl Sync for Font
impl Unpin for Font
impl UnwindSafe for Font
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