#include <sprite_font.hpp>
◆ SpriteFont() [1/3]
Constructs a sprite font.
- Parameters
-
[in,out] | device | A reference to the device. |
[in] | fname | The filename (the globally unique identifier). |
[in] | desc | A reference to the sprite font descriptor. |
- Exceptions
-
Exception | Failed to initialize the sprite font. |
◆ SpriteFont() [2/3]
mage::rendering::SpriteFont::SpriteFont |
( |
const SpriteFont & |
font | ) |
|
|
delete |
Constructs a sprite font from the given sprite font.
- Parameters
-
[in] | font | A reference to the sprite font to copy. |
◆ SpriteFont() [3/3]
mage::rendering::SpriteFont::SpriteFont |
( |
SpriteFont && |
font | ) |
|
|
defaultnoexcept |
Constructs a sprite font by moving the given sprite font.
- Parameters
-
[in] | font | A reference to the sprite font to move. |
◆ ~SpriteFont()
mage::rendering::SpriteFont::~SpriteFont |
( |
| ) |
|
|
virtualdefault |
Destructs this sprite font.
◆ ContainsCharacter()
bool mage::rendering::SpriteFont::ContainsCharacter |
( |
wchar_t |
character | ) |
const |
Checks whether this sprite font contains a glyp matching the given character.
- Parameters
-
[in] | character | The character. |
- Returns
true
if this sprite font contains a glyph corresponding to the given character. false
otherwise.
◆ DrawText()
Draws the given text with this sprite font using the given sprite batch.
- Parameters
-
[in,out] | sprite_batch | A reference to the sprite batch used for rendering the given text with this sprite font. |
[in] | strings | The strings of the text. |
[in] | transform | A reference to the sprite transform. |
[in] | effects | The sprite effects to apply. |
[in] | color | A pointer to the (linear) color. If this pointer is equal to nullptr , each string will be drawn in its own color. Otherwise, each string is drawn in this color. |
◆ empty()
bool mage::rendering::SpriteFont::empty |
( |
| ) |
const |
|
noexcept |
Checks whether this sprite font is empty.
- Returns
true
if this sprite font is empty. false
otherwise.
◆ Get()
ID3D11ShaderResourceView* mage::rendering::SpriteFont::Get |
( |
| ) |
const |
|
noexcept |
Returns a pointer to the shader resource view of the texture of this sprite font.
- Returns
- A pointer to the shader resource view of the texture of this sprite font.
◆ GetDefaultCharacter()
wchar_t mage::rendering::SpriteFont::GetDefaultCharacter |
( |
| ) |
const |
|
noexcept |
Returns the default character of this sprite font.
If this sprite font has no default glyph, L'0'
is returned.
- Returns
- The default character of this sprite font.
◆ GetGlyph()
const Glyph * mage::rendering::SpriteFont::GetGlyph |
( |
wchar_t |
character | ) |
const |
Returns the glyph of this sprite font corresponding to the given character.
- Parameters
-
[in] | character | The character. |
- Returns
- A pointer to the default glyph of this sprite font if the given character does not match any glyphs of this sprite font and if this sprite font has a default character.
-
A pointer to the glyph of this sprite font corresponding to the given character.
- Exceptions
-
Exception | If the given character does not match any glyphs of this sprite font and if this sprite font has not a default character. |
◆ GetLineSpacing()
F32 mage::rendering::SpriteFont::GetLineSpacing |
( |
| ) |
const |
|
noexcept |
Returns the line spacing of this sprite font.
- Returns
- The line spacing of this sprite font.
◆ InitializeSpriteFont()
void mage::rendering::SpriteFont::InitializeSpriteFont |
( |
const SpriteFontOutput & |
output | ) |
|
|
private |
Initializes this sprite font with the given sprite font output.
- Parameters
-
[in] | output | A reference to the sprite font output. |
- Exceptions
-
Exception | The sprite font glyphs of the given sprite font output are not sorted. |
◆ MeasureDrawBounds()
const RECT mage::rendering::SpriteFont::MeasureDrawBounds |
( |
gsl::span< const ColorString > |
strings, |
|
|
const F32x2 & |
top_left |
|
) |
| const |
Returns a rectangle bounding the given text with this sprite font.
- Parameters
-
[in] | strings | The strings of the text. |
[in] | top_left | The top-left position of the text. |
- Returns
- A
RECT
bounding the given text with this sprite font.
◆ MeasureText()
const XMVECTOR XM_CALLCONV mage::rendering::SpriteFont::MeasureText |
( |
gsl::span< const ColorString > |
strings | ) |
const |
Returns the size of the given text with this sprite font (in pixels).
- Parameters
-
[in] | strings | The strings of the text. |
- Returns
- A XMVECTOR containing the pixel width as first coordinate and pixel height as second coordinate.
- Note
- The text size is computed from the origin to the rightmost pixel rendered by any character glyph. This has the effect of ignoring 'trailing spaces'.
◆ operator=() [1/2]
Copies the given sprite font to this sprite font.
- Parameters
-
[in] | font | A reference to the sprite font to copy. |
- Returns
- A reference to the copy of the given sprite font (i.e. this sprite font).
◆ operator=() [2/2]
Moves the given sprite font to this sprite font.
- Parameters
-
[in] | font | A reference to the sprite font to move. |
- Returns
- A reference to the moved sprite font (i.e. this sprite font).
◆ SetDefaultCharacter()
void mage::rendering::SpriteFont::SetDefaultCharacter |
( |
wchar_t |
character | ) |
|
Sets the default character of this sprite font to the given character.
If character is equal to 0
, the default glyph of this sprite font is set to nullptr
.
- Parameters
-
[in] | character | The character. |
- Exceptions
-
Exception | If the given character does not match any glyphs of this sprite font and if this sprite font has not a default character. |
◆ SetLineSpacing()
void mage::rendering::SpriteFont::SetLineSpacing |
( |
F32 |
spacing | ) |
|
|
noexcept |
Sets the line spacing of this sprite font to the given spacing value.
- Parameters
-
[in] | spacing | The line spacing. |
◆ size()
std::size_t mage::rendering::SpriteFont::size |
( |
| ) |
const |
|
noexcept |
Returns the number of characters in this sprite font.
- Returns
- The number of characters in this sprite font.
◆ m_default_glyph
const Glyph* mage::rendering::SpriteFont::m_default_glyph |
|
private |
A pointer to the default glyph of this sprite font.
◆ m_glyphs
std::vector< Glyph > mage::rendering::SpriteFont::m_glyphs |
|
private |
A vector containing the glyphs of this sprite font.
◆ m_line_spacing
F32 mage::rendering::SpriteFont::m_line_spacing |
|
private |
The (extra) line spacing of this sprite font.
◆ m_texture_srv
ComPtr< ID3D11ShaderResourceView > mage::rendering::SpriteFont::m_texture_srv |
|
private |
A pointer to the texture of this sprite font.