#include <Font.hpp>
|
| Font ()=default |
|
virtual | ~Font ()=default |
|
int | pxWide (const std::string &string) const |
|
int | pxWide (const char *ch, float scale) const |
|
int | pxHeight (const std::string &string) const |
|
int | pxHeight (const char *ch, float scale) const |
|
std::tuple< float, float > | boundsY (const char *ch, float scale) const |
|
virtual std::tuple< float, float > | boundsY (const std::string &string, float scale) const =0 |
|
virtual float | pxWide (const std::string &string, float scale) const =0 |
|
virtual float | pxHeight (const std::string &string, float scale) const =0 |
|
virtual void | setMagFilter (ASGE::Texture2D::MagFilter mag_filter)=0 |
|
| NonCopyable (const NonCopyable &)=delete |
|
void | operator= (const NonCopyable &)=delete |
|
A font used to render text.
A font is used to store font related information. All fonts need a name, size and line height. This can be used by the renderer to ensure loaded fonts are being used correctly.
Usage:
renderer->loadFontFromMem(
"DroidSansMono", buffer.
as_unsigned_char(),
static_cast<unsigned int>(buffer.
length), 18);
renderer->loadFont("/data/fonts/DroidSansMono.ttf", 18);
A file stored locally on the machine.
IOBuffer read()
Reads the contents of the file.
bool open(const std::string &filename, IOMode mode=IOMode::READ)
Attempts to open a local file.
unsigned char * as_unsigned_char() noexcept
- See also
- Renderer
-
Text
Definition at line 50 of file Font.hpp.
◆ boundsY() [1/2]
std::tuple<float, float> ASGE::Font::boundsY |
( |
const char * |
ch, |
|
|
float |
scale |
|
) |
| const |
Returns the distance from the baseline in the y axis.
Font's use a baseline for positioning the main body of text. This function calculates the max distance on the Y axis required to render the text. It returns both the deviation in the -Y and deviation in the +Y axis. This can be used to create bounding boxes. It will also correctly parse new lines.
- Parameters
-
[in] | ch | The character used in the calculations. |
[in] | scale | Any scaling to apply. |
- Returns
- The number of pixels required in the Y axis to render the string.
◆ boundsY() [2/2]
virtual std::tuple<float, float> ASGE::Font::boundsY |
( |
const std::string & |
string, |
|
|
float |
scale |
|
) |
| const |
|
pure virtual |
Returns the distance from the baseline in the y axis.
Font's use a baseline for positioning the main body of text. This function calculates the max distance on the Y axis required to render the text. It returns both the deviation in the -Y and deviation in the +Y axis. This can be used to create bounding boxes. It will also correctly parse new lines.
- Parameters
-
[in] | str | The string used in the calculations. |
[in] | scale | Any scaling to apply. |
- Returns
- The number of pixels required in the Y axis to render the string.
◆ pxHeight() [1/3]
int ASGE::Font::pxHeight |
( |
const char * |
ch, |
|
|
float |
scale |
|
) |
| const |
Returns the distance in y pixels.
Sometimes it's useful to know how tall a string rendered on the screen will be, maybe for procedurally placing text etc. This function attempts to return the number of pixels the height of a string will take.
- Parameters
-
[in] | ch | The height of the character to calculate. |
[in] | scale | Any scaling to apply. |
- Returns
- The max number of pixels high needed to render the string.
◆ pxHeight() [2/3]
int ASGE::Font::pxHeight |
( |
const std::string & |
string | ) |
const |
Returns the distance in y pixels.
Sometimes it's useful to know how tall a string rendered on the screen will be, maybe for procedurally placing text etc. This function attempts to return the number of pixels the height of a string will take.
- Parameters
-
[in] | string | the length you want to calculate. |
- Returns
- The max number of pixels high needed to render the string.
◆ pxHeight() [3/3]
virtual float ASGE::Font::pxHeight |
( |
const std::string & |
string, |
|
|
float |
scale |
|
) |
| const |
|
pure virtual |
Returns the distance scaled in y pixels.
Sometimes it's useful to know how wide a string rendered on the screen will be, maybe for procedurally placing text etc. This function attempts to return the number of pixels a string will take vertically.
- Parameters
-
[in] | string | The length you want to calculate. |
[in] | scale | the scaled size you want to calculate. |
- Returns
- The max number of pixels wide needed to render the string.
◆ pxWide() [1/3]
int ASGE::Font::pxWide |
( |
const char * |
ch, |
|
|
float |
scale |
|
) |
| const |
Returns the distance in x pixels.
Sometimes it's useful to know how wide a string rendered on the screen will be, maybe for procedurally placing text etc. This function attempts to return the number of pixels a string will take.
- Parameters
-
[in] | ch | The character to check. |
[in] | scale | Any scaling to apply. |
- Returns
- The max number of pixels wide needed to render the string.
◆ pxWide() [2/3]
int ASGE::Font::pxWide |
( |
const std::string & |
string | ) |
const |
Returns the distance in x pixels.
Sometimes it's useful to know how wide a string rendered on the screen will be, maybe for procedurally placing text etc. This function attempts to return the number of pixels a string will take.
- Parameters
-
[in] | string | the length you want to calculate. |
- Returns
- The max number of pixels wide needed to render the string.
◆ pxWide() [3/3]
virtual float ASGE::Font::pxWide |
( |
const std::string & |
string, |
|
|
float |
scale |
|
) |
| const |
|
pure virtual |
Returns the distance scaled in x pixels.
Sometimes it's useful to know how wide a string placing text etc. This function attempts to return rendered on the screen will be, maybe for procedurally placing text etc. This function attempts to return the number of pixels a string will take.
- Parameters
-
[in] | string | The length you want to calculate. |
[in] | scale | The scaled size you want to calculate. |
- Returns
- The max number of pixels wide needed to render the string.
◆ setMagFilter()
Sets the filtering used for scaling the font upwards. The mag filter controls how a texture's sampling will operate when magnified. In general use, font's work well with linear sampling, but this allows the user to specify nearest neighbour instead which may lead to crisper results depending on the font face.
- Parameters
-
[in] | mag_filter | The magnification filter to use. |
The documentation for this struct was generated from the following file: