Gosu
|
Fonts are ideal for drawing short, dynamic strings. More...
Public Member Functions | |
Font (int height, const std::string &name=default_font_name(), unsigned flags=0) | |
Constructs a font that can be drawn onto the graphics object. More... | |
const std::string & | name () const |
Returns the name of the font that was used to create it. More... | |
int | height () const |
Returns the height of the font, in pixels. More... | |
unsigned | flags () const |
Returns the flags used to create the font characters. More... | |
double | text_width (const std::string &text) const |
Returns the width, in pixels, the given text would occupy if drawn. More... | |
double | markup_width (const std::string &markup) const |
Returns the width, in pixels, the given markup would occupy if drawn. More... | |
void | draw_text (const std::string &text, double x, double y, ZPos z, double scale_x=1, double scale_y=1, Color c=Color::WHITE, AlphaMode mode=AM_DEFAULT) const |
Draws text so the top left corner of the text is at (x; y). More... | |
void | draw_markup (const std::string &markup, double x, double y, ZPos z, double scale_x=1, double scale_y=1, Color c=Color::WHITE, AlphaMode mode=AM_DEFAULT) const |
Draws markup so the top left corner of the text is at (x; y). More... | |
void | draw_text_rel (const std::string &text, double x, double y, ZPos z, double rel_x, double rel_y, double scale_x=1, double scale_y=1, Color c=Color::WHITE, AlphaMode mode=AM_DEFAULT) const |
Draws text at a position relative to (x; y). More... | |
void | draw_markup_rel (const std::string &markup, double x, double y, ZPos z, double rel_x, double rel_y, double scale_x=1, double scale_y=1, Color c=Color::WHITE, AlphaMode mode=AM_DEFAULT) const |
Draws text at a position relative to (x; y). More... | |
void | set_image (std::string codepoint, unsigned font_flags, const Gosu::Image &image) |
Maps a letter to a specific image, instead of generating one using Gosu's built-in text rendering. More... | |
void | set_image (std::string codepoint, const Gosu::Image &image) |
A shortcut for mapping a character to an image regardless of font_flags. More... | |
Fonts are ideal for drawing short, dynamic strings.
For large, static texts you should use Gosu::layout_text and turn the result into an image.
Gosu::Font::Font | ( | int | height, |
const std::string & | name = default_font_name() , |
||
unsigned | flags = 0 |
||
) |
Constructs a font that can be drawn onto the graphics object.
font_name | Name of a system font, or a filename to a TTF file (must contain '/', does not work on Linux). |
font_height | Height of the font, in pixels. |
font_flags | Flags used to render individual characters of the font. |
void Gosu::Font::draw_markup | ( | const std::string & | markup, |
double | x, | ||
double | y, | ||
ZPos | z, | ||
double | scale_x = 1 , |
||
double | scale_y = 1 , |
||
Color | c = Color::WHITE , |
||
AlphaMode | mode = AM_DEFAULT |
||
) | const |
Draws markup so the top left corner of the text is at (x; y).
void Gosu::Font::draw_markup_rel | ( | const std::string & | markup, |
double | x, | ||
double | y, | ||
ZPos | z, | ||
double | rel_x, | ||
double | rel_y, | ||
double | scale_x = 1 , |
||
double | scale_y = 1 , |
||
Color | c = Color::WHITE , |
||
AlphaMode | mode = AM_DEFAULT |
||
) | const |
Draws text at a position relative to (x; y).
rel_x | Determines where the text is drawn horizontally. If rel_x is 0.0, the text will be to the right of x, if it is 1.0, the text will be to the left of x, if it is 0.5, it will be centered on x. All real numbers are possible values. |
rel_y | See rel_x. |
void Gosu::Font::draw_text | ( | const std::string & | text, |
double | x, | ||
double | y, | ||
ZPos | z, | ||
double | scale_x = 1 , |
||
double | scale_y = 1 , |
||
Color | c = Color::WHITE , |
||
AlphaMode | mode = AM_DEFAULT |
||
) | const |
Draws text so the top left corner of the text is at (x; y).
void Gosu::Font::draw_text_rel | ( | const std::string & | text, |
double | x, | ||
double | y, | ||
ZPos | z, | ||
double | rel_x, | ||
double | rel_y, | ||
double | scale_x = 1 , |
||
double | scale_y = 1 , |
||
Color | c = Color::WHITE , |
||
AlphaMode | mode = AM_DEFAULT |
||
) | const |
Draws text at a position relative to (x; y).
rel_x | Determines where the text is drawn horizontally. If rel_x is 0.0, the text will be to the right of x, if it is 1.0, the text will be to the left of x, if it is 0.5, it will be centered on x. All real numbers are possible values. |
rel_y | See rel_x. |
unsigned Gosu::Font::flags | ( | ) | const |
Returns the flags used to create the font characters.
int Gosu::Font::height | ( | ) | const |
Returns the height of the font, in pixels.
double Gosu::Font::markup_width | ( | const std::string & | markup | ) | const |
Returns the width, in pixels, the given markup would occupy if drawn.
const std::string& Gosu::Font::name | ( | ) | const |
Returns the name of the font that was used to create it.
void Gosu::Font::set_image | ( | std::string | codepoint, |
unsigned | font_flags, | ||
const Gosu::Image & | image | ||
) |
Maps a letter to a specific image, instead of generating one using Gosu's built-in text rendering.
void Gosu::Font::set_image | ( | std::string | codepoint, |
const Gosu::Image & | image | ||
) |
A shortcut for mapping a character to an image regardless of font_flags.
double Gosu::Font::text_width | ( | const std::string & | text | ) | const |
Returns the width, in pixels, the given text would occupy if drawn.