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

Protected Member Functions

void set (const ::Font &font)
 

Detailed Description

Font type, includes texture and charSet array data.

Definition at line 18 of file Font.hpp.

Constructor & Destructor Documentation

◆ Font() [1/11]

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

Definition at line 20 of file Font.hpp.

◆ Font() [2/11]

raylib::Font::Font ( int  baseSize,
int  glyphPadding,
::Texture2D  texture,
std::span<::Rectangle >  recs = {},
std::span<::GlyphInfo >  glyphs = {} 
)
inline

Definition at line 29 of file Font.hpp.

◆ Font() [3/11]

raylib::Font::Font ( )
inline

Retrieves the default Font.

Definition at line 40 of file Font.hpp.

◆ Font() [4/11]

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

Definition at line 44 of file Font.hpp.

◆ Font() [5/11]

raylib::Font::Font ( const std::string_view  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 55 of file Font.hpp.

References Load().

◆ Font() [6/11]

raylib::Font::Font ( const std::string_view  fileName,
int  fontSize,
int *  fontChars = 0,
int  charCount = 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 68 of file Font.hpp.

References Load().

◆ Font() [7/11]

raylib::Font::Font ( const std::string_view  fileName,
int  fontSize,
std::span< int >  fontChars 
)
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 81 of file Font.hpp.

References Load().

◆ Font() [8/11]

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

References Load().

◆ Font() [9/11]

raylib::Font::Font ( const std::string_view  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 105 of file Font.hpp.

References Load().

◆ Font() [10/11]

raylib::Font::Font ( const std::string_view  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
std::span< int >  fontChars 
)
inline

Definition at line 110 of file Font.hpp.

◆ Font() [11/11]

raylib::Font::Font ( Font &&  other)
inline

Definition at line 117 of file Font.hpp.

◆ ~Font()

raylib::Font::~Font ( )
inline

Definition at line 128 of file Font.hpp.

Member Function Documentation

◆ DrawText() [1/9]

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

Definition at line 312 of file Font.hpp.

◆ DrawText() [2/9]

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

◆ DrawText() [3/9]

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

◆ DrawText() [4/9]

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

◆ DrawText() [5/9]

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

Definition at line 326 of file Font.hpp.

◆ DrawText() [6/9]

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

Draw text using font and additional parameters.

Definition at line 287 of file Font.hpp.

◆ DrawText() [7/9]

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

Draw text using font and additional parameters.

Definition at line 305 of file Font.hpp.

◆ DrawText() [8/9]

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

◆ DrawText() [9/9]

void raylib::Font::DrawText ( std::span< const int >  codepoints,
::Vector2  position,
float  fontSize,
float  spacing,
::Color  tint = { 255, 255, 255, 255 } 
) const
inline

Draw multiple character (codepoint)

Definition at line 366 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 140 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 141 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 392 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 142 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 144 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 143 of file Font.hpp.

◆ GetTexture()

TextureUnmanaged raylib::Font::GetTexture ( )
inline

Get the texture atlas containing the glyphs.

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

◆ ImageText() [2/2]

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

Create an image from text (custom sprite font)

Definition at line 407 of file Font.hpp.

◆ IsReady()

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

Returns if the font is ready to be used.

Definition at line 272 of file Font.hpp.

Referenced by Load().

◆ Load() [1/8]

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

Definition at line 226 of file Font.hpp.

◆ Load() [2/8]

void raylib::Font::Load ( const std::string_view  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 195 of file Font.hpp.

References IsReady().

Referenced by Font().

◆ Load() [3/8]

void raylib::Font::Load ( const std::string_view  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.
Exceptions
raylib::RaylibExceptionThrows if the given font failed to initialize.
See also
LoadFontEx()

Definition at line 212 of file Font.hpp.

References IsReady().

◆ Load() [4/8]

void raylib::Font::Load ( const std::string_view  fileName,
int  fontSize,
std::span< int >  fontChars 
)
inline

Definition at line 219 of file Font.hpp.

◆ Load() [5/8]

void raylib::Font::Load ( const std::string_view  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
int *  fontChars,
int  charsCount 
)
inline

Definition at line 233 of file Font.hpp.

◆ Load() [6/8]

void raylib::Font::Load ( const std::string_view  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
std::span< int >  fontChars 
)
inline

Definition at line 242 of file Font.hpp.

◆ Load() [7/8]

void raylib::Font::Load ( const std::string_view  fileType,
std::span< unsigned char >  fileData,
int  fontSize,
int *  fontChars,
int  charsCount 
)
inline

Definition at line 251 of file Font.hpp.

◆ Load() [8/8]

void raylib::Font::Load ( const std::string_view  fileType,
std::span< unsigned char >  fileData,
int  fontSize,
std::span< int >  fontChars 
)
inline

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

◆ MeasureText() [2/2]

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

Measure string size for Font.

Definition at line 385 of file Font.hpp.

◆ operator=() [1/2]

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

Definition at line 160 of file Font.hpp.

◆ operator=() [2/2]

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

Definition at line 168 of file Font.hpp.

◆ set()

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

Definition at line 413 of file Font.hpp.

◆ SetTexture()

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

Set the texture atlas containing the glyphs.

Definition at line 156 of file Font.hpp.

◆ Unload()

void raylib::Font::Unload ( )
inline

Definition at line 132 of file Font.hpp.