|
| Font () |
| Default constructor Creates an empty font instance.
|
|
| Font (const Font &font) |
| Copy constructor. More...
|
|
void | AddGlyph (const Glyph &glyph) |
| Adds a glyph to the font. More...
|
|
void | AddGlyph (Ui32 codepoint, Si32 xadvance, Sprite sprite) |
| Adds a glyph to the font. More...
|
|
void | CreateEmpty (Si32 base_to_top, Si32 line_height) |
| Creates an empty font with no glyphs. More...
|
|
void | Draw (const char *text, const Si32 x, const Si32 y, const TextOrigin origin, const TextAlignment alignment, const DrawBlendingMode blending_mode, const DrawFilterMode filter_mode, const std::vector< Rgba > &palete) |
| Draws a UTF-8 string containing one or more lines of text to the backbuffer (directly to the screen) using a color palette. More...
|
|
void | Draw (const char *text, const Si32 x, const Si32 y, const TextOrigin origin=kTextOriginBottom, const TextAlignment alignment=kTextAlignmentLeft, const DrawBlendingMode blending_mode=kDrawBlendingModeAlphaBlend, const DrawFilterMode filter_mode=kFilterNearest, const Rgba color=Rgba(0xffffffff)) |
| Draws a UTF-8 string containing one or more lines of text to the backbuffer (directly to the screen) More...
|
|
void | Draw (Sprite to_sprite, const char *text, const Si32 x, const Si32 y, const TextOrigin origin, const TextAlignment alignment, const DrawBlendingMode blending_mode, const DrawFilterMode filter_mode, const std::vector< Rgba > &palete) |
| Draws a UTF-8 string containing one or more lines of text to the destination sprite. More...
|
|
void | Draw (Sprite to_sprite, const char *text, const Si32 x, const Si32 y, const TextOrigin origin=kTextOriginBottom, const TextAlignment alignment=kTextAlignmentLeft, const DrawBlendingMode blending_mode=kDrawBlendingModeAlphaBlend, const DrawFilterMode filter_mode=kFilterNearest, const Rgba color=Rgba(0xffffffff)) |
| Draws a UTF-8 string containing one or more lines of text to the destination sprite. More...
|
|
Vec2Si32 | EvaluateSize (const char *text, bool do_keep_xadvance) |
|
const std::shared_ptr< FontInstance > & | FontInstance () const |
| Gets the internal font instance. More...
|
|
Si32 | GetOutlineSize () |
| Returns outline size in pixels. Outline*2 is counted towards size.
|
|
bool | IsEmpty () const |
| Checks if the font is empty (has no codepoints) More...
|
|
void | Load (const char *file_name) |
| Loads the font from file. More...
|
|
void | LoadAsciiSquare (const char *file_name, bool is_dense) |
| Loads an ASCII square font from a file. More...
|
|
void | LoadBinaryFnt (const char *file_name) |
| Loads a binary BMFont file. More...
|
|
void | LoadHorizontalStripe (Sprite sprite, const char *utf8_letters, Si32 base_to_top, Si32 line_height, Si32 space_width) |
| Loads a font from a horizontal stripe of glyphs. More...
|
|
void | LoadLetterBits (Letter *in_letters, Si32 base_to_top, Si32 line_height) |
|
void | LoadTable (Sprite sprite, const char *utf8_letters, Si32 cell_width, Si32 cell_height, Si32 base_to_top, Si32 line_height, Si32 space_width, Si32 left_offset) |
| Loads a font from a table of glyphs. More...
|
|
void | LoadXml (const char *file_name) |
| Loads a font from an XML file. More...
|
|
Class representing a font for text rendering.
The Font class provides functionality for loading and rendering text in your game. It supports various text origins, alignments, blending modes, and colors.
Basic Usage
- Create a Font instance:
Class representing a font for text rendering.
Definition: font.h:462
- Load a font file (BMFont format):
gameFont.
Load(
"data/arctic_one_bmf.fnt");
void Load(const char *file_name)
Loads the font from file.
Definition: font.h:536
- Draw text to the screen:
void Draw(Sprite to_sprite, const char *text, const Si32 x, const Si32 y, const TextOrigin origin=kTextOriginBottom, const TextAlignment alignment=kTextAlignmentLeft, const DrawBlendingMode blending_mode=kDrawBlendingModeAlphaBlend, const DrawFilterMode filter_mode=kFilterNearest, const Rgba color=Rgba(0xffffffff))
Draws a UTF-8 string containing one or more lines of text to the destination sprite.
Definition: font.h:630
@ kFilterNearest
Nearest neighbor filter.
Definition: easy_sprite.h:56
@ kTextOriginTop
The top of the first text line.
Definition: font.h:190
@ kDrawBlendingModeColorize
Colorize.
Definition: easy_sprite.h:48
Represents a color in RGBA format.
Definition: rgba.h:39
Font Format Requirements
The Arctic Engine font system ONLY supports bitmap fonts in the following formats:
- BMFont binary format (.fnt)
- BMFont XML format (.xml)
- ASCII square font format (16x16 grid)
- Horizontal stripe font format
- Table font format
TTF (TrueType Font) files are NOT supported. You must convert your TTF fonts to one of the supported bitmap formats using tools like BMFont (https://www.angelcode.com/products/bmfont/) before using them with the Arctic Engine.
Blending Modes
The Font class supports several blending modes for text rendering:
- kDrawBlendingModeColorize: Applies the specified color to the text while preserving its shape and transparency. Works best with black and white fonts. This is the recommended mode for text output.
- kDrawBlendingModeSolidColor: Replaces all colors of the font with the specified color. This may work with a pre-colored font file.
Text Origins
The origin determines the reference point for positioning text:
- kTextOriginTop: The top of the text is at the specified y-coordinate
- kTextOriginFirstBase: The baseline of the first line is at the specified y-coordinate
- kTextOriginBottom: The bottom of the text is at the specified y-coordinate
- kTextOriginCenter: The center of the text is at the specified y-coordinate
Text Alignment
The alignment determines how text is positioned horizontally:
- kTextAlignmentLeft: Text is aligned to the left of the specified x-coordinate
- kTextAlignmentCenter: Text is centered at the specified x-coordinate
- kTextAlignmentRight: Text is aligned to the right of the specified x-coordinate