Public Types | Public Member Functions

Tiny2D::Font Class Reference

Font resource handle. More...

#include <Tiny2D.h>

List of all members.

Public Types

enum  Flags { Flags_Bold = 1 << 0, Flags_Italic = 1 << 1, Flags_Underlined = 1 << 2, Flags_StrikeThrough = 1 << 3 }
 

Font flags.

More...

Public Member Functions

 Font ()
 Creates an empty font.
 Font (const Font &other)
 Copy constructor; internally only increases reference count of the font resource.
 ~Font ()
 Destroys the font.
ResourceState GetState () const
 Gets resource state.
void operator= (const Font &other)
 Copy operator; internally only increases reference count of the font resource.
bool Create (const std::string &path, int size, unsigned int flags=0, bool immediate=true)
 Creates font from TTF file; 'size' indicates font size in pixels.
void Destroy ()
 Destroys the font.
void CacheGlyphs (const std::string &text)
 Caches glyphs from given text, so that consecutive calls to Draw() are faster.
void CacheGlyphsFromFile (const std::string &path)
 Caches glyphs from given text file, so that consecutive calls to Draw() are faster.
void Draw (const Text::DrawParams *params)
 Draws text.
void Draw (const char *text, const Vec2 &position, const Color &color=Color::White)
 Draws text.
void CalculateSize (const Text::DrawParams *params, float &width, float &height)
 Calculates text size.

Detailed Description

Font resource handle.


Member Enumeration Documentation

Font flags.

Enumerator:
Flags_Bold 

Bold font.

Flags_Italic 

Italic font.

Flags_Underlined 

Font with underline.

Flags_StrikeThrough 

Font with strike-through effect.


Constructor & Destructor Documentation

Tiny2D::Font::Font (  )

Creates an empty font.

Tiny2D::Font::Font ( const Font other )

Copy constructor; internally only increases reference count of the font resource.

Tiny2D::Font::~Font (  )

Destroys the font.


Member Function Documentation

void Tiny2D::Font::CacheGlyphs ( const std::string &  text )

Caches glyphs from given text, so that consecutive calls to Draw() are faster.

void Tiny2D::Font::CacheGlyphsFromFile ( const std::string &  path )

Caches glyphs from given text file, so that consecutive calls to Draw() are faster.

void Tiny2D::Font::CalculateSize ( const Text::DrawParams params,
float &  width,
float &  height 
)

Calculates text size.

bool Tiny2D::Font::Create ( const std::string &  path,
int  size,
unsigned int  flags = 0,
bool  immediate = true 
)

Creates font from TTF file; 'size' indicates font size in pixels.

See also:
enum Flags; 'immediate' set to true indicates to load it synchronously
void Tiny2D::Font::Destroy (  )

Destroys the font.

void Tiny2D::Font::Draw ( const Text::DrawParams params )

Draws text.

void Tiny2D::Font::Draw ( const char *  text,
const Vec2 position,
const Color color = Color::White 
)

Draws text.

ResourceState Tiny2D::Font::GetState (  ) const

Gets resource state.

void Tiny2D::Font::operator= ( const Font other )

Copy operator; internally only increases reference count of the font resource.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines