pub struct SurfaceRenderer {
pub fg_color: Color,
pub bg_color: Color,
pub scale: u32,
pub bold: bool,
pub italic: bool,
/* private fields */
}
Expand description
Storage class for rendering settings.
Fields§
§fg_color: Color
The colour to use to draw text.
bg_color: Color
The colour to use to fill the surface before drawing text.
scale: u32
Integer scale multiplier, since Unifont is a raster font.
bold: bool
Whether or not to make text bold. Uses XTerm-style bolding, where the text is just drawn twice on the x-axis, one pixel apart.
italic: bool
Whether or not to make text italicised. Simply shifts pixels to the right by one additional pixel, every two vertical pixels.
Implementations§
Source§impl SurfaceRenderer
impl SurfaceRenderer
Sourcepub fn new(fg_color: Color, bg_color: Color) -> SurfaceRenderer
pub fn new(fg_color: Color, bg_color: Color) -> SurfaceRenderer
Creates a new Unifont renderer which renders text to new SDL surfaces.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Returns the renderer to the state it was in when it was first created (i.e. the foreground and background colours are reset to the values given to the constructor, and all other fields are reset).
Sourcepub fn draw(&self, text: &str) -> Result<Surface<'_>, String>
pub fn draw(&self, text: &str) -> Result<Surface<'_>, String>
Draws the supplied text to a new surface, which has been sized to fit
the text exactly, using the renderer’s style settings. Returns an Err
result if a character was found which is not in the font, or the font
could not be initialised.