Enum ggez::graphics::Font
[−]
[src]
pub enum Font { TTFFont { font: Font<'static>, points: u32, scale: Scale, }, BitmapFontVariant(BitmapFont), }
A font that defines the shape of characters drawn on the screen. Can be created from a .ttf file or from an image (bitmap fonts).
Variants
TTFFont
A truetype font
Fields of TTFFont
font: Font<'static> | The actual font data |
points: u32 | The size of the font |
scale: Scale | Scale information for the font |
BitmapFontVariant(BitmapFont)
A bitmap font where letter widths are infered
Methods
impl Font
[src]
pub fn new<P>(context: &mut Context, path: P, points: u32) -> GameResult<Font> where
P: AsRef<Path> + Debug,
[src]
P: AsRef<Path> + Debug,
Load a new TTF font from the given file.
pub fn from_bytes(
name: &str,
bytes: &[u8],
points: u32,
dpi: (f32, f32)
) -> GameResult<Font>
[src]
name: &str,
bytes: &[u8],
points: u32,
dpi: (f32, f32)
) -> GameResult<Font>
Loads a new TTF font from data copied out of the given buffer.
pub fn new_bitmap<P: AsRef<Path>>(
context: &mut Context,
path: P,
glyphs: &str
) -> GameResult<Font>
[src]
context: &mut Context,
path: P,
glyphs: &str
) -> GameResult<Font>
Creates a bitmap font from a long image of its alphabet, specified by path
.
The width of each individual chars is assumed to be to be
image(path).width/glyphs.chars().count()
pub fn new_variable_width_bitmap_font<P: AsRef<Path>>(
context: &mut Context,
path: P,
glyphs: &str,
space_width: usize,
letter_separation: usize
) -> GameResult<Font>
[src]
context: &mut Context,
path: P,
glyphs: &str,
space_width: usize,
letter_separation: usize
) -> GameResult<Font>
Creates a bitmap font from a long image of its alphabet. Each letter must be separated from the last by a fully transparent column of pixels. The width of each letter is infered from these letter boundaries.
pub fn default_font() -> GameResult<Self>
[src]
Returns a baked-in default font: currently DejaVuSerif.ttf
Note it does create a new Font
object with every call.
pub fn get_height(&self) -> usize
[src]
Get the height of the Font in pixels.
The height of the font includes any spacing, it will be the total height a line needs.
pub fn get_width(&self, text: &str) -> usize
[src]
Returns the width a line of text needs, in pixels. Does not handle line-breaks.
pub fn get_wrap(&self, text: &str, wrap_limit: usize) -> (usize, Vec<String>)
[src]
Breaks the given text into lines that will not exceed wrap_limit
pixels
in length when drawn with the given font.
It accounts for newlines correctly but does not
try to break words or handle hyphenated words; it just breaks
at whitespace. (It also doesn't preserve whitespace.)
Returns a tuple of maximum line width and a Vec
of wrapped String
s.
Trait Implementations
impl Clone for Font
[src]
fn clone(&self) -> Font
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more