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

CFont Class Reference

Font definition. More...

#include <font.h>

Inheritance diagram for CFont:

gcn::Font

List of all members.


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)
void Load ()
void Reload () const
void FreeOpenGL ()
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)

Public Member Functions

virtual int getHeight () const
virtual int getWidth (const std::string &text) const

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 (  )  [virtual]


Member Function Documentation

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

Create a new font

Parameters:
ident Font identifier
g Graphic
Returns:
New font

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

Get a font

Parameters:
ident Font identifier
Returns:
The font

int CFont::Height (  )  const

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

Returns the pixel width of text.

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

int CFont::Width ( const int  number  )  const

Returns the pixel width of text.

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

bool CFont::IsLoaded (  )  const

virtual int CFont::getHeight (  )  const [inline, virtual]

Gets the height of the glyphs in the font.

Returns:
the height of the glyphs int the font.

Implements gcn::Font.

virtual int CFont::getWidth ( const std::string &  text  )  const [inline, virtual]

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:
text the string to return the width of.
Returns:
the width of a string.

Implements gcn::Font.

void CFont::drawString ( gcn::Graphics graphics,
const std::string &  text,
int  x,
int  y 
) [virtual]

Draws a string.

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

Parameters:
graphics a Graphics object to use for drawing.
text the string to draw.
x the x coordinate where to draw the string.
y the y coordinate where to draw the string.

Implements gcn::Font.

void CFont::Load (  ) 

void CFont::Reload (  )  const

void CFont::FreeOpenGL (  ) 

void CFont::Clean (  ) 

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

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

void CFont::DynamicLoad (  )  const


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