pub struct Font<'ttf_module, 'rwops> { /* private fields */ }
Expand description
A loaded TTF font.
Implementations§
source§impl<'ttf, 'r> Font<'ttf, 'r>
impl<'ttf, 'r> Font<'ttf, 'r>
sourcepub fn render<'a, 'b>(&'a self, text: &'b str) -> PartialRendering<'a, 'b>
pub fn render<'a, 'b>(&'a self, text: &'b str) -> PartialRendering<'a, 'b>
Starts specifying a rendering of the given UTF-8-encoded text.
sourcepub fn render_latin1<'a, 'b>(
&'a self,
text: &'b [u8],
) -> PartialRendering<'a, 'b>
pub fn render_latin1<'a, 'b>( &'a self, text: &'b [u8], ) -> PartialRendering<'a, 'b>
Starts specifying a rendering of the given Latin-1-encoded text.
sourcepub fn render_char(&self, ch: char) -> PartialRendering<'_, 'static>
pub fn render_char(&self, ch: char) -> PartialRendering<'_, 'static>
Starts specifying a rendering of the given UTF-8-encoded character.
sourcepub fn size_of(&self, text: &str) -> FontResult<(u32, u32)>
pub fn size_of(&self, text: &str) -> FontResult<(u32, u32)>
Returns the width and height of the given text when rendered using this font.
sourcepub fn size_of_latin1(&self, text: &[u8]) -> FontResult<(u32, u32)>
pub fn size_of_latin1(&self, text: &[u8]) -> FontResult<(u32, u32)>
Returns the width and height of the given text when rendered using this font.
sourcepub fn size_of_char(&self, ch: char) -> FontResult<(u32, u32)>
pub fn size_of_char(&self, ch: char) -> FontResult<(u32, u32)>
Returns the width and height of the given text when rendered using this font.
sourcepub fn get_outline_width(&self) -> u16
pub fn get_outline_width(&self) -> u16
Returns the width of the font’s outline.
sourcepub fn set_outline_width(&mut self, width: u16)
pub fn set_outline_width(&mut self, width: u16)
Sets the width of the font’s outline.
sourcepub fn get_hinting(&self) -> Hinting
pub fn get_hinting(&self) -> Hinting
Returns the font’s freetype hints.
sourcepub fn set_hinting(&mut self, hinting: Hinting)
pub fn set_hinting(&mut self, hinting: Hinting)
Sets the font’s freetype hints.
sourcepub fn get_kerning(&self) -> bool
pub fn get_kerning(&self) -> bool
Returns whether the font is kerning.
sourcepub fn set_kerning(&mut self, kerning: bool)
pub fn set_kerning(&mut self, kerning: bool)
Sets whether the font should use kerning.
sourcepub fn descent(&self) -> i32
pub fn descent(&self) -> i32
Returns the font’s lowest descent (height below base). This is a negative number.
sourcepub fn recommended_line_spacing(&self) -> i32
pub fn recommended_line_spacing(&self) -> i32
Returns the recommended line spacing for text rendered with this font.
sourcepub fn face_count(&self) -> u16
pub fn face_count(&self) -> u16
Returns the number of faces in this font.
sourcepub fn face_is_fixed_width(&self) -> bool
pub fn face_is_fixed_width(&self) -> bool
Returns whether the font is monospaced.
sourcepub fn face_family_name_borrowed(&self) -> Option<&'ttf CStr>
pub fn face_family_name_borrowed(&self) -> Option<&'ttf CStr>
Returns the family name of the current font face without doing any heap allocations.
sourcepub fn face_family_name(&self) -> Option<String>
pub fn face_family_name(&self) -> Option<String>
Returns the family name of the current font face.
sourcepub fn face_style_name_borrowed(&self) -> Option<&'ttf CStr>
pub fn face_style_name_borrowed(&self) -> Option<&'ttf CStr>
Returns the name of the current font face without doing any heap allocations.
sourcepub fn face_style_name(&self) -> Option<String>
pub fn face_style_name(&self) -> Option<String>
Returns the name of the current font face.
sourcepub fn find_glyph(&self, ch: char) -> Option<u16>
pub fn find_glyph(&self, ch: char) -> Option<u16>
Returns the index of the given character in this font face.
sourcepub fn find_glyph_metrics(&self, ch: char) -> Option<GlyphMetrics>
pub fn find_glyph_metrics(&self, ch: char) -> Option<GlyphMetrics>
Returns the glyph metrics of the given character in this font face.