Gamedev Framework (gf)  0.11.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::BasicText Class Reference

#include <gf/BasicText.h>

Public Member Functions

 BasicText ()
 Default constructor. More...
 
 BasicText (std::string string, Font &font, unsigned characterSize=30)
 Construct the text from a string, font and size. More...
 
void setString (std::string string)
 Set the text's string. More...
 
const std::string & getString () const
 Get the text's string. More...
 
void setCharacterSize (unsigned characterSize)
 Set the character size. More...
 
unsigned getCharacterSize () const
 Get the character size. More...
 
void setFont (Font &font)
 Set the text's font. More...
 
const FontgetFont () const
 Get the text's font. More...
 
const AlphaTexturegetFontTexture ()
 
void setOutlineThickness (float thickness)
 Set the thickness of the text's outline. More...
 
float getOutlineThickness ()
 Get the outline thickness of the text. More...
 
void setLineSpacing (float spacingFactor)
 Set the line spacing factor. More...
 
float getLineSpacing () const
 Get the size of the line spacing factor. More...
 
void setLetterSpacing (float spacingFactor)
 Set the letter spacing factor. More...
 
float getLetterSpacing () const
 Get the size of the letter spacing factor. More...
 
void setParagraphWidth (float paragraphWidth)
 Set the paragraph width for aligned text. More...
 
float getParagraphWidth () const
 Get the paragraph width. More...
 
void setAlignment (Alignment align)
 Set the alignement of the text. More...
 
Alignment getAlignment () const
 Get the alignment of the text. More...
 
RectF getLocalBounds () const
 Get the local bounding rectangle of the entity. More...
 
void updateGeometry (VertexArray &vertices, VertexArray &outlineVertices)
 

Detailed Description

See also
gf::Text

Constructor & Destructor Documentation

◆ BasicText() [1/2]

gf::BasicText::BasicText ( )

Default constructor.

Creates an empty text.

◆ BasicText() [2/2]

gf::BasicText::BasicText ( std::string  string,
Font font,
unsigned  characterSize = 30 
)

Construct the text from a string, font and size.

Parameters
stringText assigned to the string in UTF-8 format
fontFont used to draw the string
characterSizeBase size of characters, in pixels

Member Function Documentation

◆ getAlignment()

Alignment gf::BasicText::getAlignment ( ) const
inline

Get the alignment of the text.

Returns
Current alignment of the text
See also
setAlignment()

◆ getCharacterSize()

unsigned gf::BasicText::getCharacterSize ( ) const
inline

Get the character size.

Returns
Size of the characters, in pixels
See also
setCharacterSize()

◆ getFont()

const Font* gf::BasicText::getFont ( ) const
inline

Get the text's font.

If the text has no font attached, a nullptr pointer is returned. The returned pointer is const, which means that you cannot modify the font when you get it from this function.

Returns
Pointer to the text's font
See also
setFont()

◆ getFontTexture()

const AlphaTexture* gf::BasicText::getFontTexture ( )

◆ getLetterSpacing()

float gf::BasicText::getLetterSpacing ( ) const
inline

Get the size of the letter spacing factor.

Returns
The size of the letter spacing factor
See also
setLetterSpacing()

◆ getLineSpacing()

float gf::BasicText::getLineSpacing ( ) const
inline

Get the size of the line spacing factor.

Returns
The size of the line spacing factor
See also
setLineSpacing

◆ getLocalBounds()

RectF gf::BasicText::getLocalBounds ( ) const
inline

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity

◆ getOutlineThickness()

float gf::BasicText::getOutlineThickness ( )
inline

Get the outline thickness of the text.

Returns
Outline thickness of the text, in pixels
See also
setOutlineThickness()

◆ getParagraphWidth()

float gf::BasicText::getParagraphWidth ( ) const
inline

Get the paragraph width.

Returns
Paragraph width in pixels
See also
setParagraphWidth()

◆ getString()

const std::string& gf::BasicText::getString ( ) const
inline

Get the text's string.

The text string is in UTF-8 format.

Returns
Text's string
See also
setString()

◆ setAlignment()

void gf::BasicText::setAlignment ( Alignment  align)

Set the alignement of the text.

By default, the text is not aligned.

Parameters
alignNew alignement
See also
getAlignment()

◆ setCharacterSize()

void gf::BasicText::setCharacterSize ( unsigned  characterSize)

Set the character size.

The default size is 30.

Parameters
characterSizeNew character size, in pixels
See also
getCharacterSize()

◆ setFont()

void gf::BasicText::setFont ( Font font)

Set the text's font.

The font argument refers to a font that must exist as long as the text uses it. Indeed, the text doesn't store its own copy of the font, but rather keeps a pointer to the one that you passed to this function. If the font is destroyed and the text tries to use it, the behavior is undefined.

Parameters
fontNew font
See also
getFont()

◆ setLetterSpacing()

void gf::BasicText::setLetterSpacing ( float  spacingFactor)

Set the letter spacing factor.

The default spacing between letters is defined by the font. This factor doesn't directly apply to the existing spacing between each character, it rather adds a fixed space between them which is calculated from the font metrics and the character size. Note that factors below 1 (including negative numbers) bring characters closer to each other. By default the letter spacing factor is 1.

Parameters
spacingFactorNew letter spacing factor
See also
getLetterSpacing()

◆ setLineSpacing()

void gf::BasicText::setLineSpacing ( float  spacingFactor)

Set the line spacing factor.

The default spacing between lines is defined by the font. This method enables you to set a factor for the spacing between lines. By default the line spacing factor is 1.

Parameters
spacingFactorNew line spacing factor
See also
getLineSpacing()

◆ setOutlineThickness()

void gf::BasicText::setOutlineThickness ( float  thickness)

Set the thickness of the text's outline.

By default, the outline thickness is 0.

Parameters
thicknessNew outline thickness, in pixels
See also
getOutlineThickness()

◆ setParagraphWidth()

void gf::BasicText::setParagraphWidth ( float  paragraphWidth)

Set the paragraph width for aligned text.

By default, the paragraph width is 0.

Parameters
paragraphWidthNew paragraph width in pixels
See also
getParagraphWidth()

◆ setString()

void gf::BasicText::setString ( std::string  string)

Set the text's string.

The text string is in UTF-8 format. A text's string is empty by default.

Parameters
stringNew string in UTF-8 format
See also
getString()

◆ updateGeometry()

void gf::BasicText::updateGeometry ( VertexArray vertices,
VertexArray outlineVertices 
)