Cornell Cocos
Cornell Extensions to Cocos2d
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Friends | List of all members
TTFont Class Reference

#include <CUTTFont.h>

Inheritance diagram for TTFont:

Public Member Functions

const std::string & getName () const
 
const std::string & getSource () const
 
float getSize () const
 
const TTFConfig & getTTF () const
 
const FontAtlas * getAtlas () const
 
CC_CONSTRUCTOR_ACCESS _ident ("")
 
CC_CONSTRUCTOR_ACCESS _source ("")
 
CC_CONSTRUCTOR_ACCESS _atlas (nullptr)
 
 ~TTFont ()
 
bool init (std::string source, float size)
 

Static Public Member Functions

static TTFontcreate (std::string source, float size)
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: TTFont() : Ref()
 

Protected Attributes

std::string _ident
 
std::string _source
 
TTFConfig _config
 
FontAtlas * _atlas
 

Friends

class FontLoader
 

Detailed Description

Class provides a reference to a loaded font asset.

This class contains both the TTFConfig information and the associated FontAtlas, providing a uniform interface for all applications. Note that a True Type font asset is both the source file AND the font size. Because the font is converted to a texture for usage, different sizes are different fonts.

This class uses Cocos2d reference counting for memory management. The constructors are protected because only the FontLoader should construct fonts.

Constructor & Destructor Documentation

TTFont::~TTFont ( )
inline

Deletes this font object

The font should be unloaded before deletion.

Member Function Documentation

NS_CC_BEGIN TTFont * TTFont::create ( std::string  source,
float  size 
)
static

Creates a new font object for the given source file and size.

The font object must have a size in addition to its source file

Parameters
sourcethe source file for the font
sizethe font size
Returns
an autoreleased font object
const FontAtlas* TTFont::getAtlas ( ) const
inline

Returns the font atlas for this font.

The font atlas is the texture generated by FreeType for this font file and size. You generally do not need direct access to this.

Returns
the font atlas for this font.
const std::string& TTFont::getName ( ) const
inline

Returns the unique identifier for this font.

Because of how font textures are created, each size is considered a separate font. The identifier combines the source file and size.

Returns
the unique identifier for this font.
float TTFont::getSize ( ) const
inline

Returns the size of this font.

Because of how font textures are created, each size is considered a separate font.

Returns
the size of this font.
const std::string& TTFont::getSource ( ) const
inline

Returns the source file for this font.

Returns
the source file for this font.
const TTFConfig& TTFont::getTTF ( ) const
inline

Returns the font atlas for this font.

The font atlas is the texture generated by FreeType for this font file and size. You generally do not need direct access to this.

Returns
the font atlas for this font.
bool TTFont::init ( std::string  source,
float  size 
)

Initializes a new sound object for the given source file.

The font object must have a size in addition to its source file

Parameters
sourcethe source file for the font
sizethe font size
Returns
true if the font was initialized successfully

Friends And Related Function Documentation

friend class FontLoader
friend

Allow the font loader access to the constructors

Member Data Documentation

FontAtlas* TTFont::_atlas
protected

The font texture information

TTFConfig TTFont::_config
protected

The font information for constructing the atlas

std::string TTFont::_ident
protected

A unique identifier for this font (filre+size)

std::string TTFont::_source
protected

The source file for the font


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