_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Member Functions | List of all members
CFont Class Reference

Font definition. More...

#include <font.h>

Inheritance diagram for CFont:
gcn::Font

Public Member Functions

virtual int getHeight () const
 
virtual int getWidth (const std::string &text) const
 
- Public Member Functions inherited from gcn::Font
virtual ~Font ()
 
virtual int getStringIndexAt (const std::string &text, int x)
 

font.cpp - The color fonts.

virtual ~CFont ()
 
int Height () const
 
int Width (const std::string &text) const
 
int Width (const int number) const
 
bool IsLoaded () const
 
virtual void drawString (gcn::Graphics *graphics, const std::string &text, int x, int y, bool is_normal=true)
 
void Load ()
 
void Reload () const
 
void Clean ()
 
CGraphicGetFontColorGraphic (const CFontColor &fontColor) const
 
template<bool CLIP>
unsigned int DrawChar (CGraphic &g, int utf8, int x, int y, const CFontColor &fc) const
 
void DynamicLoad () const
 
static CFontNew (const std::string &ident, CGraphic *g)
 
static CFontGet (const std::string &ident)
 

Detailed Description

Font definition.

#include "font.h"

Defines the fonts used in the Stratagus engine. We support proportional multicolor fonts of 9 colors. (Currently the fonts aren't packed)

CFont::CharWidth[]

The width of each font glyph in pixels. The index 0 is the width of the SPACE (' ', 0x20).

CFont::G

Contains the graphics of the font, Only 9 colors are supported.

Constructor & Destructor Documentation

◆ ~CFont()

CFont::~CFont ( )
virtual

Member Function Documentation

◆ Clean()

void CFont::Clean ( )

◆ DrawChar()

template<bool CLIP>
unsigned int CFont::DrawChar ( CGraphic g,
int  utf8,
int  x,
int  y,
const CFontColor fc 
) const

◆ drawString()

void CFont::drawString ( gcn::Graphics graphics,
const std::string &  text,
int  x,
int  y,
bool  is_normal = true 
)
virtual

Draws a string.

NOTE: You normally won't use this function to draw text since Graphics contains better functions for drawing text.

Parameters
graphicsa Graphics object to use for drawing.
textthe string to draw.
xthe x coordinate where to draw the string.
ythe y coordinate where to draw the string.

Implements gcn::Font.

◆ DynamicLoad()

void CFont::DynamicLoad ( ) const

◆ Get()

CFont * CFont::Get ( const std::string &  ident)
static

Get a font

Parameters
identFont identifier
Returns
The font

◆ GetFontColorGraphic()

CGraphic * CFont::GetFontColorGraphic ( const CFontColor fontColor) const

◆ getHeight()

virtual int CFont::getHeight ( ) const
inlinevirtual

Gets the height of the glyphs in the font.

Returns
the height of the glyphs int the font.

Implements gcn::Font.

◆ getWidth()

virtual int CFont::getWidth ( const std::string &  text) const
inlinevirtual

Gets the width of a string. The width of a string is not necesserily the sum of all the widths of it's glyphs.

Parameters
textthe string to return the width of.
Returns
the width of a string.

Implements gcn::Font.

◆ Height()

int CFont::Height ( ) const

◆ IsLoaded()

bool CFont::IsLoaded ( ) const

◆ Load()

void CFont::Load ( )

◆ New()

CFont * CFont::New ( const std::string &  ident,
CGraphic g 
)
static

Create a new font

Parameters
identFont identifier
gGraphic
Returns
New font

◆ Reload()

void CFont::Reload ( ) const

◆ Width() [1/2]

int CFont::Width ( const int  number) const

Returns the pixel width of text. This is intimately tied to FormatNumber

Parameters
numbernumber to calculate the width of.
Returns
The width in pixels of the text.

◆ Width() [2/2]

int CFont::Width ( const std::string &  text) const

Returns the pixel width of text.

Parameters
textText to calculate the width of.
Returns
The width in pixels of the text.

The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.