pub struct Font { /* private fields */ }
Expand description
Font, font texture and GlyphInfo array data
Implementations§
Source§impl Font
impl Font
Sourcepub fn glyph_count(&self) -> usize
pub fn glyph_count(&self) -> usize
Number of glyph characters
Sourcepub fn glyph_padding(&self) -> u32
pub fn glyph_padding(&self) -> u32
Padding around the glyph characters
Sourcepub fn from_file_ex(
file_name: &str,
font_size: u32,
chars: &[char],
) -> Option<Self>
pub fn from_file_ex( file_name: &str, font_size: u32, chars: &[char], ) -> Option<Self>
Load font from file with extended parameters
Sourcepub fn from_image(
image: &Image,
key_color: Color,
first_char: char,
) -> Option<Self>
pub fn from_image( image: &Image, key_color: Color, first_char: char, ) -> Option<Self>
Load font from Image (XNA style)
Sourcepub fn from_memory(
file_type: &str,
file_data: &[u8],
font_size: u32,
chars: &[char],
) -> Option<Self>
pub fn from_memory( file_type: &str, file_data: &[u8], font_size: u32, chars: &[char], ) -> Option<Self>
Load font from memory buffer, fileType refers to extension: i.e. ‘.ttf’
Sourcepub fn export_as_code(&self, file_name: &str) -> bool
pub fn export_as_code(&self, file_name: &str) -> bool
Export font as code file, returns true on success
Sourcepub fn measure_text(text: &str, font_size: u32) -> u32
pub fn measure_text(text: &str, font_size: u32) -> u32
Measure string width for default font
Sourcepub fn measure_text_ex(
&self,
text: &str,
font_size: f32,
spacing: f32,
) -> Vector2
pub fn measure_text_ex( &self, text: &str, font_size: f32, spacing: f32, ) -> Vector2
Measure string size for Font
Sourcepub fn get_glyph_index(&self, codepoint: char) -> usize
pub fn get_glyph_index(&self, codepoint: char) -> usize
Get glyph index position in font for a codepoint (unicode character), fallback to ‘?’ if not found
Sourcepub fn get_glyph_atlas_rect(&self, codepoint: char) -> Rectangle
pub fn get_glyph_atlas_rect(&self, codepoint: char) -> Rectangle
Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to ‘?’ if not found
Sourcepub fn get_glyph_info(&self, codepoint: char) -> GlyphInfo
pub fn get_glyph_info(&self, codepoint: char) -> GlyphInfo
Get glyph font info data for a codepoint (unicode character), fallback to ‘?’ if not found
Sourcepub fn as_raw(&self) -> &Font
pub fn as_raw(&self) -> &Font
Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original
Sourcepub fn as_raw_mut(&mut self) -> &mut Font
pub fn as_raw_mut(&mut self) -> &mut Font
Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original