Enum ggez::graphics::Font [−][src]
pub enum Font { TTFFont { font: Font<'static>, points: u32, scale: Scale, }, BitmapFontVariant(BitmapFont), GlyphFont(FontId), }
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
GlyphFont(FontId)
A TrueType font stored in GraphicsContext::glyph_brush
Methods
impl Font
[src]
impl Font
pub fn new<P>(context: &mut Context, path: P, points: u32) -> GameResult<Font> where
P: AsRef<Path> + Debug,
[src]
pub fn new<P>(context: &mut Context, path: P, points: u32) -> GameResult<Font> where
P: AsRef<Path> + Debug,
Load a new TTF font from the given file.
pub fn new_px<P>(
context: &mut Context,
path: P,
pixels: u32
) -> GameResult<Font> where
P: AsRef<Path> + Debug,
[src]
pub fn new_px<P>(
context: &mut Context,
path: P,
pixels: u32
) -> GameResult<Font> where
P: AsRef<Path> + Debug,
Load a new TTF font from the given file, returning a font that draws lines that are the given number of pixels high.
pub fn from_bytes(
name: &str,
bytes: &[u8],
points: u32,
dpi: (f32, f32)
) -> GameResult<Font>
[src]
pub fn from_bytes(
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 from_bytes_px(name: &str, bytes: &[u8], pixels: u32) -> GameResult<Font>
[src]
pub fn from_bytes_px(name: &str, bytes: &[u8], pixels: u32) -> GameResult<Font>
Loads a new TTF font from data copied out of the given buffer, taking font size in pixels
pub fn new_bitmap<P: AsRef<Path>>(
context: &mut Context,
path: P,
glyphs: &str
) -> GameResult<Font>
[src]
pub fn new_bitmap<P: AsRef<Path>>(
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]
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>
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 new_glyph_font<P>(context: &mut Context, path: P) -> GameResult<Self> where
P: AsRef<Path> + Debug,
[src]
pub fn new_glyph_font<P>(context: &mut Context, path: P) -> GameResult<Self> where
P: AsRef<Path> + Debug,
Loads a new TrueType font from given file and into GraphicsContext::glyph_brush
.
pub fn get_glyph_font_by_id(
context: &mut Context,
font_id: FontId
) -> GameResult<Self>
[src]
pub fn get_glyph_font_by_id(
context: &mut Context,
font_id: FontId
) -> GameResult<Self>
Retrieves a loaded font from GraphicsContext::glyph_brush
.
pub fn default_font() -> GameResult<Self>
[src]
pub fn default_font() -> GameResult<Self>
Returns baked-in default font (currently DejaVuSerif.ttf).
Note it does create a new Font
object with every call;
although the actual data should be shared.
pub fn get_height(&self) -> usize
[src]
pub fn get_height(&self) -> usize
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]
pub fn get_width(&self, text: &str) -> usize
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]
pub fn get_wrap(&self, text: &str, wrap_limit: usize) -> (usize, Vec<String>)
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]
impl Clone for Font
fn clone(&self) -> Font
[src]
fn clone(&self) -> Font
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Font
[src]
impl Debug for Font
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Into<FontId> for Font
[src]
impl Into<FontId> for Font