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

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

#include <Font.hpp>

Public Member Functions

 Font ()
 Retrieves the default Font.
 
 Font (const ::Font &font)
 
 Font (const ::Image &image, ::Color key, int firstChar)
 Loads a Font from the given image with a color key.
 
 Font (const Font &)=delete
 
 Font (const std::string &fileName)
 Loads a Font from the given file.
 
 Font (const std::string &fileName, int fontSize, const int *codepoints=nullptr, int codepointCount=0)
 Loads a Font from the given file, with generation parameters.
 
 Font (const std::string &fileType, const unsigned char *fileData, int dataSize, int fontSize, const int *codepoints, int codepointCount)
 Loads a font from memory, based on the given file type and file data.
 
 Font (Font &&other) noexcept
 
 Font (int baseSize, int glyphCount, int glyphPadding, ::Texture2D texture, ::Rectangle *recs=nullptr, ::GlyphInfo *glyphs=nullptr)
 
void DrawText (const char *text, ::Vector2 position, ::Vector2 origin, float rotation, float fontSize, float spacing, ::Color tint=WHITE) const
 
void DrawText (const char *text, ::Vector2 position, float fontSize, float spacing, ::Color tint=WHITE) const
 Draw text using font and additional parameters.
 
void DrawText (const char *text, int posX, int posY, float fontSize, float spacing, ::Color tint=WHITE) const
 Draw text using font and additional parameters.
 
void DrawText (const int *codepoints, int count, ::Vector2 position, float fontSize, float spacing, ::Color tint={255, 255, 255, 255}) const
 Draw multiple character (codepoint)
 
void DrawText (const std::string &text, ::Vector2 position, ::Vector2 origin, float rotation, float fontSize, float spacing, ::Color tint=WHITE) const
 
void DrawText (const std::string &text, ::Vector2 position, float fontSize, float spacing, ::Color tint=WHITE) const
 Draw text using font and additional parameters.
 
void DrawText (const std::string &text, int posX, int posY, float fontSize, float spacing, ::Color tint=WHITE) const
 Draw text using font and additional parameters.
 
void DrawText (int codepoint, ::Vector2 position, float fontSize, ::Color tint={255, 255, 255, 255}) const
 Draw one character (codepoint)
 
int GetBaseSize () const
 Retrieves the baseSize value for the object.
 
int GetGlyphCount () const
 Retrieves the glyphCount value for the object.
 
int GetGlyphIndex (int character) const
 Get index position for a unicode character on font.
 
int GetGlyphPadding () const
 Retrieves the glyphPadding value for the object.
 
::GlyphInfo * GetGlyphs () const
 Retrieves the glyphs value for the object.
 
::Rectangle * GetRecs () const
 Retrieves the recs value for the object.
 
TextureUnmanaged GetTexture ()
 Get the texture atlas containing the glyphs.
 
::Image ImageText (const char *text, float fontSize, float spacing, ::Color tint) const
 Create an image from text (custom sprite font)
 
::Image ImageText (const std::string &text, float fontSize, float spacing, ::Color tint) const
 Create an image from text (custom sprite font)
 
bool IsValid () const
 Returns if the font is ready to be used.
 
void Load (const ::Image &image, ::Color key, int firstChar)
 
void Load (const std::string &fileName)
 Loads a font from a given file.
 
void Load (const std::string &fileName, int fontSize, const int *codepoints=nullptr, int codepointCount=0)
 Loads a font from a given file with generation parameters.
 
void Load (const std::string &fileType, const unsigned char *fileData, int dataSize, int fontSize, const int *codepoints, int codepointCount)
 
Vector2 MeasureText (const char *text, float fontSize, float spacing) const
 Measure string size for Font.
 
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) noexcept
 
void SetTexture (const ::Texture &newTexture)
 Set the texture atlas containing the glyphs.
 
void Unload ()
 

Protected Member Functions

void set (const ::Font &font)
 

Detailed Description

Font type, includes texture and charSet array data.

Definition at line 15 of file Font.hpp.

Constructor & Destructor Documentation

◆ Font() [1/8]

raylib::Font::Font ( int  baseSize,
int  glyphCount,
int  glyphPadding,
::Texture2D  texture,
::Rectangle *  recs = nullptr,
::GlyphInfo *  glyphs = nullptr 
)
inline

Definition at line 17 of file Font.hpp.

◆ Font() [2/8]

raylib::Font::Font ( )
inline

Retrieves the default Font.

Definition at line 31 of file Font.hpp.

◆ Font() [3/8]

raylib::Font::Font ( const ::Font &  font)
inline

Definition at line 33 of file Font.hpp.

◆ Font() [4/8]

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 42 of file Font.hpp.

References Load().

◆ Font() [5/8]

raylib::Font::Font ( const std::string &  fileName,
int  fontSize,
const int *  codepoints = nullptr,
int  codepointCount = 0 
)
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 53 of file Font.hpp.

References Load().

◆ Font() [6/8]

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 66 of file Font.hpp.

References Load().

◆ Font() [7/8]

raylib::Font::Font ( const std::string &  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
const int *  codepoints,
int  codepointCount 
)
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 75 of file Font.hpp.

References Load().

◆ Font() [8/8]

raylib::Font::Font ( Font &&  other)
inlinenoexcept

Definition at line 87 of file Font.hpp.

◆ ~Font()

raylib::Font::~Font ( )
inline

Definition at line 98 of file Font.hpp.

Member Function Documentation

◆ DrawText() [1/8]

void raylib::Font::DrawText ( const char *  text,
::Vector2  position,
::Vector2  origin,
float  rotation,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
) const
inline

Definition at line 244 of file Font.hpp.

◆ DrawText() [2/8]

void raylib::Font::DrawText ( const char *  text,
::Vector2  position,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
) const
inline

Draw text using font and additional parameters.

Definition at line 211 of file Font.hpp.

References raylib::DrawTextEx().

◆ DrawText() [3/8]

void raylib::Font::DrawText ( const char *  text,
int  posX,
int  posY,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
) const
inline

Draw text using font and additional parameters.

Definition at line 226 of file Font.hpp.

References raylib::DrawTextEx().

◆ DrawText() [4/8]

void raylib::Font::DrawText ( const int *  codepoints,
int  count,
::Vector2  position,
float  fontSize,
float  spacing,
::Color  tint = {255, 255, 255, 255} 
) const
inline

Draw multiple character (codepoint)

Definition at line 276 of file Font.hpp.

◆ DrawText() [5/8]

void raylib::Font::DrawText ( const std::string &  text,
::Vector2  position,
::Vector2  origin,
float  rotation,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
) const
inline

Definition at line 255 of file Font.hpp.

◆ DrawText() [6/8]

void raylib::Font::DrawText ( const std::string &  text,
::Vector2  position,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
) const
inline

Draw text using font and additional parameters.

Definition at line 219 of file Font.hpp.

References raylib::DrawTextEx().

◆ DrawText() [7/8]

void raylib::Font::DrawText ( const std::string &  text,
int  posX,
int  posY,
float  fontSize,
float  spacing,
::Color  tint = WHITE 
) const
inline

Draw text using font and additional parameters.

Definition at line 234 of file Font.hpp.

References raylib::DrawTextEx().

◆ DrawText() [8/8]

void raylib::Font::DrawText ( int  codepoint,
::Vector2  position,
float  fontSize,
::Color  tint = {255, 255, 255, 255} 
) const
inline

Draw one character (codepoint)

Definition at line 269 of file Font.hpp.

◆ GetBaseSize()

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

Retrieves the baseSize value for the object.

Returns
The baseSize value of the object.

Definition at line 108 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 109 of file Font.hpp.

◆ GetGlyphIndex()

int raylib::Font::GetGlyphIndex ( int  character) const
inline

Get index position for a unicode character on font.

Definition at line 303 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 110 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 112 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 111 of file Font.hpp.

◆ GetTexture()

TextureUnmanaged raylib::Font::GetTexture ( )
inline

Get the texture atlas containing the glyphs.

Definition at line 117 of file Font.hpp.

◆ ImageText() [1/2]

::Image raylib::Font::ImageText ( const char *  text,
float  fontSize,
float  spacing,
::Color  tint 
) const
inline

Create an image from text (custom sprite font)

Definition at line 308 of file Font.hpp.

◆ ImageText() [2/2]

::Image raylib::Font::ImageText ( const std::string &  text,
float  fontSize,
float  spacing,
::Color  tint 
) const
inline

Create an image from text (custom sprite font)

Definition at line 315 of file Font.hpp.

◆ IsValid()

bool raylib::Font::IsValid ( ) const
inline

Returns if the font is ready to be used.

Definition at line 206 of file Font.hpp.

Referenced by Load(), and Load().

◆ Load() [1/4]

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

Definition at line 183 of file Font.hpp.

◆ Load() [2/4]

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

Loads a font from a given file.

Parameters
fileNameThe filename of the font to load.
Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.
See also
LoadFont()

Definition at line 159 of file Font.hpp.

References IsValid(), and raylib::LoadFont().

Referenced by Font(), Font(), Font(), and Font().

◆ Load() [3/4]

void raylib::Font::Load ( const std::string &  fileName,
int  fontSize,
const int *  codepoints = nullptr,
int  codepointCount = 0 
)
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.
Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.
See also
LoadFontEx()

Definition at line 176 of file Font.hpp.

References IsValid(), and raylib::LoadFontEx().

◆ Load() [4/4]

void raylib::Font::Load ( const std::string &  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
const int *  codepoints,
int  codepointCount 
)
inline

Definition at line 190 of file Font.hpp.

◆ MeasureText() [1/2]

Vector2 raylib::Font::MeasureText ( const char *  text,
float  fontSize,
float  spacing 
) const
inline

Measure string size for Font.

Definition at line 289 of file Font.hpp.

◆ MeasureText() [2/2]

Vector2 raylib::Font::MeasureText ( const std::string &  text,
float  fontSize,
float  spacing 
) const
inline

Measure string size for Font.

Definition at line 296 of file Font.hpp.

◆ operator=() [1/2]

Font & raylib::Font::operator= ( const ::Font &  font)
inline

Definition at line 124 of file Font.hpp.

◆ operator=() [2/2]

Font & raylib::Font::operator= ( Font &&  other)
inlinenoexcept

Definition at line 132 of file Font.hpp.

◆ set()

void raylib::Font::set ( const ::Font &  font)
inlineprotected

Definition at line 319 of file Font.hpp.

◆ SetTexture()

void raylib::Font::SetTexture ( const ::Texture &  newTexture)
inline

Set the texture atlas containing the glyphs.

Definition at line 122 of file Font.hpp.

◆ Unload()

void raylib::Font::Unload ( )
inline

Definition at line 100 of file Font.hpp.