Oficina Framework  1.3
Games Framework
OficinaFramework::RenderingSystem::Font Class Reference

Represents a Font, a texture with monospace characters to be used to draw text onscreen. More...

#include <RenderingSystem.hpp>

Public Member Functions

 Font (Texture *t, vec2dw CharacterSize, vec2b PaddingSize)
 Constructs a font. More...
 
 ~Font ()
 Disposes font accordingly. More...
 
vec2dw GetCharacterSize () const
 Gets the size of a single character. More...
 
vec2b GetPaddingSize () const
 Gets the size of the padding around a single character. More...
 
void DrawString (vec2 Position, std::string Text, float magnification, Color4 tint, float transparency)
 Draws a specific string in a region. More...
 
void DrawString (vec2 Position, std::string Text, float magnification)
 Draws a specific string in a region. More...
 
void DrawString (vec2 Position, std::string Text)
 Draws a specific string in a region. More...
 
vec2 MeasureString (std::string Text, float magnification) const
 Calculates the total area consumed by the text on screen. More...
 

Detailed Description

Represents a Font, a texture with monospace characters to be used to draw text onscreen.

Warning
The characters font range must be 31 ~ 126 in ASCII table.

Constructor & Destructor Documentation

◆ Font()

OficinaFramework::RenderingSystem::Font::Font ( Texture t,
vec2dw  CharacterSize,
vec2b  PaddingSize 
)

Constructs a font.

Parameters
tTexture to be used as source for characters.
Warning
The texture must contain monospace ASCII characters ranging from 31 (before white space) to '~'.
DO NOT dispose the texture by yourself. The system will take care of it, once you delete the font pointer.
Parameters
CharacterSizeSize occupied by each character on the texture.
PaddingSizeThickness of the padding around each character of the atlas. x specifies left and right boundaries, y specifies up and down boundaries.

◆ ~Font()

OficinaFramework::RenderingSystem::Font::~Font ( )

Disposes font accordingly.

Member Function Documentation

◆ DrawString() [1/3]

void OficinaFramework::RenderingSystem::Font::DrawString ( vec2  Position,
std::string  Text,
float  magnification,
Color4  tint,
float  transparency 
)

Draws a specific string in a region.

Warning
The text included must be ASCII characters ranging from 31~126.
Parameters
PositionPosition on screen in which the text will be drawn.
TextText that must be rendered. Only ASCII text is valid.
magnificationSize for the text to be multiplied by. Defaults to 1.
tintColor to tint the font. Defaults to White (1.0f, 1.0f, 1.0f, 1.0f). The alpha factor will be used to measure intensity of tinting.
transparencyTransparency of the text. 1 is opaque, 0 is completely transparent.

◆ DrawString() [2/3]

void OficinaFramework::RenderingSystem::Font::DrawString ( vec2  Position,
std::string  Text,
float  magnification 
)

Draws a specific string in a region.

Warning
The text included must be ASCII characters ranging from 31~126.
Parameters
PositionPosition on screen in which the text will be drawn.
TextText that must be rendered. Only ASCII text is valid.
magnificationSize for the text to be multiplied by. Defaults to 1.

◆ DrawString() [3/3]

void OficinaFramework::RenderingSystem::Font::DrawString ( vec2  Position,
std::string  Text 
)

Draws a specific string in a region.

Warning
The text included must be ASCII characters ranging from 31~126.
Parameters
PositionPosition on screen in which the text will be drawn.
TextText that must be rendered. Only ASCII text is valid.

◆ GetCharacterSize()

vec2dw OficinaFramework::RenderingSystem::Font::GetCharacterSize ( ) const

Gets the size of a single character.

Returns
A vec2 with dword precision showing the size of a character.

◆ GetPaddingSize()

vec2b OficinaFramework::RenderingSystem::Font::GetPaddingSize ( ) const

Gets the size of the padding around a single character.

Returns
A vec2 with byte precision showing the thickness of the padding border.

◆ MeasureString()

vec2 OficinaFramework::RenderingSystem::Font::MeasureString ( std::string  Text,
float  magnification 
) const

Calculates the total area consumed by the text on screen.

Parameters
TextRendered text to have its space calculated.
magnificationSize for the text to be multiplied by. Defaults to 1.
Returns
A vec2, with float precision, showing the total occupied size by the string.

The documentation for this class was generated from the following file: