#include <th_gfx_font.h>
|
| | bitmap_font () |
| |
| void | set_sprite_sheet (sprite_sheet *pSpriteSheet, bitmap_font_character_set character_set) |
| | Set the character glyph sprite sheet.
|
| |
| void | set_scale_factor (int factor) |
| |
| sprite_sheet * | get_sprite_sheet () |
| |
| void | set_separation (int iCharSep, int iLineSep) |
| | Set the separation between characters and between lines.
|
| |
| text_layout | get_text_dimensions (const char *sMessage, size_t iMessageLength, int iMaxWidth=INT_MAX) const override |
| | Get the size of drawn text.
|
| |
| void | draw_text (render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY) const override |
| | Draw a single line of text.
|
| |
| text_layout | draw_text_wrapped (render_target *pCanvas, const char *sMessage, size_t iMessageLength, int iX, int iY, int iWidth, int iMaxRows=INT_MAX, int iSkipRows=0, text_alignment eAlign=text_alignment::left) const override |
| | Draw a single line of text, splitting it at word boundaries.
|
| |
| virtual | ~font ()=default |
| |
◆ bitmap_font()
| bitmap_font::bitmap_font |
( |
| ) |
|
|
default |
◆ draw_text()
Draw a single line of text.
- Parameters
-
| pCanvas | The render target to draw onto. |
| sMessage | A UTF-8 encoded string containing a single line of text to draw. |
| iMessageLength | The length, in bytes (not characters), of the string at sMessage. |
| iX | The X coordinate of the top-left corner of the bounding rectangle for the drawn text. |
| iY | The Y coordinate of the top-left corner of the bounding rectangle for the drawn text. |
Implements font.
◆ draw_text_wrapped()
Draw a single line of text, splitting it at word boundaries.
This function still only draws a single line of text (i.e. any line breaks like \r and \n in sMessage are ignored), but inserts line breaks between words so that no single line is wider than iWidth pixels. If iMaxRows is specified it will simply cut after that many rows.
- Parameters
-
| pCanvas | The canvas on which to draw. Can be nullptr, in which case nothing is drawn, but other calculations are still made. |
| sMessage | The line of text to draw, encoded in CP437. |
| iMessageLength | The length (in bytes) of sMessage. |
| iX | The X position to start drawing on the canvas. |
| iY | The Y position to start drawing on the canvas. |
| iWidth | The maximum width of each line of text. |
| iMaxRows | The maximum number of rows to draw. Default is INT_MAX. |
| iSkipRows | Start rendering text after skipping this many rows. |
| eAlign | How to align each line of text if the width of the line of text is smaller than iWidth. |
Implements font.
◆ get_sprite_sheet()
◆ get_text_dimensions()
Get the size of drawn text.
If iMaxWidth is specified the text will wrap, so that the height can span multiple rows. Otherwise gets the size of a single line of text.
- Parameters
-
| sMessage | A UTF-8 encoded string containing a single line of text to measure the width and height of. |
| iMessageLength | The length, in bytes (not characters), of the string at sMessage. |
| iMaxWidth | The maximum length, in pixels, that the text may occupy. Default is INT_MAX. |
Implements font.
◆ set_scale_factor()
| void bitmap_font::set_scale_factor |
( |
int |
factor | ) |
|
◆ set_separation()
| void bitmap_font::set_separation |
( |
int |
iCharSep, |
|
|
int |
iLineSep |
|
) |
| |
Set the separation between characters and between lines.
Generally, the sprite sheet glyphs will already include separation, and thus no extra separation is required (set iCharSep and iLineSep to 0).
◆ set_sprite_sheet()
Set the character glyph sprite sheet.
The sprite sheet should have the space character (ASCII 0x20) at sprite index 1, and other ASCII characters following on in simple order (i.e. '!' (ASCII 0x21) at index 2, 'A' (ASCII 0x41) at index 34, etc.)
- Parameters
-
| pSpriteSheet | The sprite sheet to use for the font. |
| character_set | The character set to use when mapping unicode to sprite indexes. |
The documentation for this class was generated from the following files: