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.