nCine 2025.06.r503-ff15d8d
A cross-platform 2D game engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ncine::Font Class Reference

A class holding the font and glyphs information needed to render text. More...

#include <Font.h>

Inheritance diagram for ncine::Font:
Inheritance graph
[legend]
Collaboration diagram for ncine::Font:
Collaboration graph
[legend]

Public Types

enum  RenderMode { GLYPH_IN_ALPHA , GLYPH_IN_RED , GLYPH_SPRITE }
 The available modes for text nodes rendering. More...
 
- Public Types inherited from ncine::Object
enum class  ObjectType {
  BASE = 0 , TEXTURE , SHADER , SCENENODE ,
  SPRITE , MESH_SPRITE , ANIMATED_SPRITE , PARTICLE ,
  PARTICLE_SYSTEM , FONT , TEXTNODE , AUDIOBUFFER ,
  AUDIOBUFFER_PLAYER , AUDIOSTREAM_PLAYER
}
 Object types.
 

Public Member Functions

 Font ()
 Constructs an empty font object with no glyphs nor kerning pairs.
 
 Font (const char *fntBufferName, const unsigned char *fntBufferPtr, unsigned long int fntBufferSize, const char *texFilename)
 Constructs the object from an AngelCode's FNT memory buffer and a texture.
 
 Font (const char *fntBufferName, const unsigned char *fntBufferPtr, unsigned long int fntBufferSize, const char *texBufferName, const unsigned char *texBufferPtr, unsigned long int texBufferSize)
 Constructs the object from an AngelCode's FNT memory buffer and a texture memory buffer.
 
 Font (const char *fntBufferName, const unsigned char *fntBufferPtr, unsigned long int fntBufferSize, Texture *texture)
 Constructs the object from an AngelCode's FNT memory buffer and a shared texture object.
 
 Font (const char *fntFilename)
 Constructs the object from an AngelCode's FNT file.
 
 Font (const char *fntFilename, const char *texFilename)
 Constructs the object from an AngelCode's FNT file and a texture file.
 
 Font (const char *fntFilename, Texture *texture)
 Constructs the object from an AngelCode's FNT file and a shared texture object.
 
 Font (Font &&)
 Default move constructor.
 
Fontoperator= (Font &&)
 Default move assignment operator.
 
bool loadFromMemory (const char *fntBufferName, const unsigned char *fntBufferPtr, unsigned long int fntBufferSize, const char *texFilename)
 
bool loadFromMemory (const char *fntBufferName, const unsigned char *fntBufferPtr, unsigned long int fntBufferSize, const char *texBufferName, const unsigned char *texBufferPtr, unsigned long int texBufferSize)
 
bool loadFromMemory (const char *fntBufferName, const unsigned char *fntBufferPtr, unsigned long int fntBufferSize, Texture *texture)
 
bool loadFromFile (const char *fntFilename)
 
bool loadFromFile (const char *fntFilename, const char *texFilename)
 
bool loadFromFile (const char *fntFilename, Texture *texture)
 
const Texturetexture () const
 Returns the constant texture object in use by the font.
 
Texturetexture ()
 Returns the texture object in use by the font.
 
bool setTexture (Texture *texture)
 Sets a new shared texture object without modifying any glyphs or kerning data.
 
unsigned int lineHeight () const
 Returns the font line height.
 
unsigned int base () const
 Returns the font base.
 
Vector2i textureSize () const
 Returns the texture atlas size.
 
unsigned int numGlyphs () const
 Returns the number of glyphs.
 
unsigned int numKernings () const
 Returns the number of kerning pairs.
 
const FontGlyph * glyph (unsigned int glyphId) const
 Returns a constant pointer to a glyph.
 
RenderMode renderMode () const
 Returns the mode detected by the font to render text nodes.
 
- Public Member Functions inherited from ncine::Object
 Object (ObjectType type)
 Constructs an object with a specified type and adds it to the index.
 
 Object (ObjectType type, const char *name)
 Constructs an object with a specified type and name and adds it to the index.
 
virtual ~Object ()
 Removes an object from the index and then destroys it.
 
 Object (Object &&other)
 Move constructor.
 
Objectoperator= (Object &&other)
 Move assignment operator.
 
unsigned int id () const
 Returns the object identification number.
 
ObjectType type () const
 Returns the object type (RTTI)
 
const char * name () const
 Returns the object name.
 
void setName (const char *name)
 Sets the object name.
 

Static Public Member Functions

static ObjectType sType ()
 
- Static Public Member Functions inherited from ncine::Object
static ObjectType sType ()
 Static method to return class type.
 
template<class T >
static T * fromId (unsigned int id)
 Returns a casted pointer to the object with the specified id, if any exists.
 

Additional Inherited Members

- Static Public Attributes inherited from ncine::Object
static const unsigned int MaxNameLength = 128
 Maximum length for an object name.
 
- Protected Member Functions inherited from ncine::Object
 Object (const Object &other)
 Protected copy constructor used to clone objects.
 
- Protected Attributes inherited from ncine::Object
ObjectType type_
 Object type.
 

Detailed Description

A class holding the font and glyphs information needed to render text.

Member Enumeration Documentation

◆ RenderMode

The available modes for text nodes rendering.

Note
Depending on the glyph channel a different shader will be used.
Enumerator
GLYPH_IN_ALPHA 

Glyph data is in the alpha channel.

GLYPH_IN_RED 

Glyph data is in the red channel.

GLYPH_SPRITE 

Glyph data is in all four channels (glyphs are colored)

Constructor & Destructor Documentation

◆ Font() [1/6]

ncine::Font::Font ( const char *  fntBufferName,
const unsigned char *  fntBufferPtr,
unsigned long int  fntBufferSize,
const char *  texFilename 
)

Constructs the object from an AngelCode's FNT memory buffer and a texture.

Note
The specified texture will override the one in the FNT file

◆ Font() [2/6]

ncine::Font::Font ( const char *  fntBufferName,
const unsigned char *  fntBufferPtr,
unsigned long int  fntBufferSize,
const char *  texBufferName,
const unsigned char *  texBufferPtr,
unsigned long int  texBufferSize 
)

Constructs the object from an AngelCode's FNT memory buffer and a texture memory buffer.

Note
The specified texture will override the one in the FNT file

◆ Font() [3/6]

ncine::Font::Font ( const char *  fntBufferName,
const unsigned char *  fntBufferPtr,
unsigned long int  fntBufferSize,
Texture texture 
)

Constructs the object from an AngelCode's FNT memory buffer and a shared texture object.

Note
The specified texture will override the one in the FNT file

◆ Font() [4/6]

ncine::Font::Font ( const char *  fntFilename)
explicit

Constructs the object from an AngelCode's FNT file.

Note
The texture specified by the FNT file will be automatically loaded

◆ Font() [5/6]

ncine::Font::Font ( const char *  fntFilename,
const char *  texFilename 
)

Constructs the object from an AngelCode's FNT file and a texture file.

Note
The specified texture will override the one in the FNT file

◆ Font() [6/6]

ncine::Font::Font ( const char *  fntFilename,
Texture texture 
)

Constructs the object from an AngelCode's FNT file and a shared texture object.

Note
The specified texture will override the one in the FNT file

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