Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | Static Public Member Functions | List of all members
jop::Font Class Reference

#include <Font.hpp>

Inheritance diagram for jop::Font:
jop::Resource jop::SafeReferenceable< Resource > jop::SerializeInfo

Public Member Functions

 Font (const std::string &name)
 Constructor. More...
 
 ~Font () override
 Destructor. More...
 
bool load (const std::string &path, const int fontSize)
 Load from file. More...
 
bool load (const void *ptr, const uint32 size, const int fontSize)
 Loads a font from memory. More...
 
float getKerning (const uint32 left, const uint32 right) const
 Returns the necessary kerning advancement between two characters. More...
 
const GlyphgetGlyph (const uint32 codepoint) const
 Returns a single glyph from given codepoint. More...
 
float getLineSpacing () const
 Return the spacing between two rows in the font. More...
 
const Texture2DgetTexture () const
 Return the texture that contains all loaded glyphs. More...
 
int getSize () const
 Returns pixel size of the font. More...
 
- Public Member Functions inherited from jop::Resource
 Resource (const std::string &name)
 Constructor. More...
 
virtual ~Resource ()=0
 Virtual destructor. More...
 
const std::string & getName () const
 Get the name of this resource. More...
 
void setPersistence (const unsigned short level)
 Set the persistence level. More...
 
unsigned short getPersistence () const
 Get the persistence level. More...
 
- Public Member Functions inherited from jop::SafeReferenceable< Resource >
WeakReference< ResourcegetReference () const
 Get a weak reference to the bound object. More...
 
- Public Member Functions inherited from jop::SerializeInfo
 SerializeInfo ()
 
void setSerializePackage (const uint16 package)
 
uint16 getSerializePackage () const
 
void setShouldSerialize (const bool set)
 
bool shouldSerialize () const
 
void setLightSerializeable (const bool set)
 
bool isLightSerializeable () const
 

Static Public Member Functions

static FontgetDefault ()
 Get the default font. More...
 

Additional Inherited Members

- Protected Member Functions inherited from jop::Resource
 Resource (const Resource &other, const std::string &newName)
 Copy constructor. More...
 
- Protected Member Functions inherited from jop::SafeReferenceable< Resource >
 SafeReferenceable (Resource *ref)
 Constructor. More...
 
 SafeReferenceable (SafeReferenceable< Resource > &&other)
 Move constructor. More...
 
SafeReferenceableoperator= (SafeReferenceable< Resource > &&other)
 Move assignment operator. More...
 
 ~SafeReferenceable ()
 Protected destructor. More...
 

Detailed Description

Font manager class, which loads fonts from file and packs them to textures. Supports .ttf format.

Definition at line 43 of file Font.hpp.

Constructor & Destructor Documentation

jop::Font::Font ( const std::string &  name)

Constructor.

Parameters
nameName of the resource
jop::Font::~Font ( )
override

Destructor.

Member Function Documentation

static Font& jop::Font::getDefault ( )
static

Get the default font.

Returns
Reference to the font
const Glyph& jop::Font::getGlyph ( const uint32  codepoint) const

Returns a single glyph from given codepoint.

If glyph with the given codepoint does not exist yet calls packGlyph() to create and pack it.

Parameters
codepointUnicode codepoint of a character
Returns
Reference to the glyph
float jop::Font::getKerning ( const uint32  left,
const uint32  right 
) const

Returns the necessary kerning advancement between two characters.

Parameters
leftCode point value pointing to the desired character
rightCode point value pointing to the next character
Warning
Every font does NOT have support for this!
Returns
True if successful
float jop::Font::getLineSpacing ( ) const

Return the spacing between two rows in the font.

Returns
The line spacing
int jop::Font::getSize ( ) const

Returns pixel size of the font.

Returns
The font pixel size
const Texture2D& jop::Font::getTexture ( ) const

Return the texture that contains all loaded glyphs.

Returns
Reference to the font texture
bool jop::Font::load ( const std::string &  path,
const int  fontSize 
)

Load from file.

Parameters
pathPath to desired .ttf font file
fontSizeGlyph size in texture
Returns
True if successful
bool jop::Font::load ( const void *  ptr,
const uint32  size,
const int  fontSize 
)

Loads a font from memory.

The memory will be copied.

Parameters
ptrPointer to memory
sizeAmount of bytes to read
fontSizeGlyph size in texture
Returns
True if successful

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