raylib-cpp
C++ object-oriented wrapper library for raylib.
Public Member Functions | List of all members
raylib::Font Class Reference

Font type, includes texture and charSet array data. More...

Public Member Functions

 Font (const ::Font &font)
 
 Font (const ::Image &image, ::Color key, int firstChar)
 Loads a Font from the given image with a color key. More...
 
 Font (const Font &)=delete
 
 Font (const std::string &fileName)
 Loads a Font from the given file. More...
 
 Font (const std::string &fileName, int fontSize, int *fontChars, int charCount)
 Loads a Font from the given file, with generation parameters. More...
 
 Font (const std::string &fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount)
 Loads a font from memory, based on the given file type and file data. More...
 
 Font (Font &&other)
 
 Font (int baseSize, int glyphCount, int glyphPadding, ::Texture2D texture, ::Rectangle *recs=nullptr, ::GlyphInfo *glyphs=nullptr)
 
FontDrawText (const std::string &text, ::Vector2 position, ::Vector2 origin, float rotation, float fontSize, float spacing, ::Color tint=WHITE)
 
FontDrawText (const std::string &text, ::Vector2 position, float fontSize, float spacing, ::Color tint=WHITE)
 Draw text using font and additional parameters.
 
FontDrawText (int codepoint, ::Vector2 position, float fontSize, ::Color tint={ 255, 255, 255, 255 })
 Draw one character (codepoint)
 
int GetBaseSize () const
 Retrieves the baseSize value for the object. More...
 
int GetGlyphCount () const
 Retrieves the glyphCount value for the object. More...
 
int GetGlyphIndex (int character) const
 Get index position for a unicode character on font.
 
int GetGlyphPadding () const
 Retrieves the glyphPadding value for the object. More...
 
::GlyphInfo * GetGlyphs () const
 Retrieves the glyphs value for the object. More...
 
::RectangleGetRecs () const
 Retrieves the recs value for the object. More...
 
::Texture2D GetTexture () const
 Retrieves the texture value for the object. More...
 
inline ::Image ImageText (const std::string &text, float fontSize, float spacing, ::Color tint) const
 Create an image from text (custom sprite font)
 
bool Load (const ::Image &image, ::Color key, int firstChar)
 
bool Load (const std::string &fileName)
 Loads a font from a given file. More...
 
bool Load (const std::string &fileName, int fontSize, int *fontChars, int charCount)
 Loads a font from a given file with generation parameters. More...
 
bool Load (const std::string &fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount)
 
Vector2 MeasureText (const std::string &text, float fontSize, float spacing) const
 Measure string size for Font.
 
Fontoperator= (const ::Font &font)
 
Fontoperator= (const Font &)=delete
 
Fontoperator= (Font &&other)
 
void SetBaseSize (int value)
 Sets the baseSize value for the object. More...
 
void SetGlyphCount (int value)
 Sets the glyphCount value for the object. More...
 
void SetGlyphPadding (int value)
 Sets the glyphPadding value for the object. More...
 
void SetGlyphs (::GlyphInfo *value)
 Sets the glyphs value for the object. More...
 
void SetRecs (::Rectangle *value)
 Sets the recs value for the object. More...
 
void SetTexture (::Texture2D value)
 Sets the texture value for the object. More...
 
void Unload ()
 

Detailed Description

Font type, includes texture and charSet array data.

Definition at line 14 of file Font.hpp.

Constructor & Destructor Documentation

◆ Font() [1/4]

raylib::Font::Font ( const std::string &  fileName)
inline

Loads a Font from the given file.

Parameters
fileNameThe file name of the font to load.
Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.

Definition at line 40 of file Font.hpp.

References Load().

◆ Font() [2/4]

raylib::Font::Font ( const std::string &  fileName,
int  fontSize,
int *  fontChars,
int  charCount 
)
inline

Loads a Font from the given file, with generation parameters.

Parameters
fileNameThe file name of the font to load.
Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.
See also
::LoadFontEx

Definition at line 55 of file Font.hpp.

References Load().

◆ Font() [3/4]

raylib::Font::Font ( const ::Image image,
::Color  key,
int  firstChar 
)
inline

Loads a Font from the given image with a color key.

Parameters
imageThe image to load the fond from.
Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.
See also
::LoadFontFromImage()

Definition at line 70 of file Font.hpp.

References Load().

◆ Font() [4/4]

raylib::Font::Font ( const std::string &  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
int *  fontChars,
int  charsCount 
)
inline

Loads a font from memory, based on the given file type and file data.

Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.
See also
::LoadFontFromMemory()

Definition at line 83 of file Font.hpp.

References Load().

Member Function Documentation

◆ GetBaseSize()

int raylib::Font::GetBaseSize ( ) const
inline

Retrieves the baseSize value for the object.

Returns
The baseSize value of the object.

Definition at line 111 of file Font.hpp.

◆ GetGlyphCount()

int raylib::Font::GetGlyphCount ( ) const
inline

Retrieves the glyphCount value for the object.

Returns
The glyphCount value of the object.

Definition at line 112 of file Font.hpp.

◆ GetGlyphPadding()

int raylib::Font::GetGlyphPadding ( ) const
inline

Retrieves the glyphPadding value for the object.

Returns
The glyphPadding value of the object.

Definition at line 113 of file Font.hpp.

◆ GetGlyphs()

::GlyphInfo* raylib::Font::GetGlyphs ( ) const
inline

Retrieves the glyphs value for the object.

Returns
The glyphs value of the object.

Definition at line 116 of file Font.hpp.

◆ GetRecs()

::Rectangle* raylib::Font::GetRecs ( ) const
inline

Retrieves the recs value for the object.

Returns
The recs value of the object.

Definition at line 115 of file Font.hpp.

◆ GetTexture()

::Texture2D raylib::Font::GetTexture ( ) const
inline

Retrieves the texture value for the object.

Returns
The texture value of the object.

Definition at line 114 of file Font.hpp.

◆ Load() [1/2]

bool raylib::Font::Load ( const std::string &  fileName)
inline

Loads a font from a given file.

Parameters
fileNameThe filename of the font to load.
Returns
True of false depending on if the font loaded successfully.
See also
::LoadFont()

Definition at line 152 of file Font.hpp.

Referenced by Font().

◆ Load() [2/2]

bool raylib::Font::Load ( const std::string &  fileName,
int  fontSize,
int *  fontChars,
int  charCount 
)
inline

Loads a font from a given file with generation parameters.

Parameters
fileNameThe filename of the font to load.
fontSizeThe desired size of the font.
Returns
True of false depending on if the font loaded successfully.
See also
::LoadFontEx()

Definition at line 167 of file Font.hpp.

◆ SetBaseSize()

void raylib::Font::SetBaseSize ( int  value)
inline

Sets the baseSize value for the object.

Parameters
valueThe value of which to set baseSize to.

Definition at line 111 of file Font.hpp.

◆ SetGlyphCount()

void raylib::Font::SetGlyphCount ( int  value)
inline

Sets the glyphCount value for the object.

Parameters
valueThe value of which to set glyphCount to.

Definition at line 112 of file Font.hpp.

◆ SetGlyphPadding()

void raylib::Font::SetGlyphPadding ( int  value)
inline

Sets the glyphPadding value for the object.

Parameters
valueThe value of which to set glyphPadding to.

Definition at line 113 of file Font.hpp.

◆ SetGlyphs()

void raylib::Font::SetGlyphs ( ::GlyphInfo *  value)
inline

Sets the glyphs value for the object.

Parameters
valueThe value of which to set glyphs to.

Definition at line 116 of file Font.hpp.

◆ SetRecs()

void raylib::Font::SetRecs ( ::Rectangle value)
inline

Sets the recs value for the object.

Parameters
valueThe value of which to set recs to.

Definition at line 115 of file Font.hpp.

◆ SetTexture()

void raylib::Font::SetTexture ( ::Texture2D  value)
inline

Sets the texture value for the object.

Parameters
valueThe value of which to set texture to.

Definition at line 114 of file Font.hpp.