____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

CFont Class Reference

Font definition. More...

#include <font.h>

Inheritance diagram for CFont:

gcn::Font

List of all members.

Public Member Functions

virtual ~CFont ()
int Height () const
int Width (const std::string &text) const
bool IsLoaded () const
virtual int getHeight () const
virtual int getWidth (const std::string &text) const
virtual void drawString (gcn::Graphics *graphics, const std::string &text, int x, int y)
void MeasureWidths ()

Static Public Member Functions

static CFontNew (const std::string &ident, CGraphic *g)
static CFontGet (const std::string &ident)

Public Attributes

std::string Ident
 Ident of the font.
char * CharWidth
 Real font width (starting with ' ').
CGraphicG
 Graphic object used to draw.


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.

Definition at line 71 of file include/font.h.


Constructor & Destructor Documentation

CFont::~CFont (  )  [virtual]

Definition at line 303 of file font.cpp.

References CharWidth, CGraphic::Free(), and G.


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

Definition at line 814 of file font.cpp.

References AllFonts, Fonts, CGraphic::Free(), and G.

Referenced by tolua_stratagus_CFont_New00().

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

Get a font

Parameters:
ident Font identifier
Returns:
The font

Definition at line 838 of file font.cpp.

References _C_, DebugPrint, and Fonts.

Referenced by CclDefineButtonStyle(), CclSetTitleScreens(), LoadFonts(), and tolua_stratagus_CFont_Get00().

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.

Definition at line 226 of file font.cpp.

References CharWidth, and GetUTF8().

Referenced by MessagesDisplay::AddMessage(), DrawDecoration(), DrawMenuButton(), DrawPopup(), getWidth(), ShowInput(), ShowTitleImage(), and VideoDrawTextCentered().

bool CFont::IsLoaded (  )  const

Definition at line 90 of file font.cpp.

References G, and CGraphic::IsLoaded().

Referenced by ShowLoadProgress().

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.

Definition at line 86 of file include/font.h.

References Height().

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.

Definition at line 87 of file include/font.h.

References Width().

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.

Definition at line 95 of file font.cpp.

References gcn::Graphics::getCurrentClipArea(), CVideo::Height, gcn::Rectangle::height, PopClipping(), PushClipping(), SetClipping(), Video, VideoDrawTextClip(), CVideo::Width, gcn::Rectangle::width, gcn::Rectangle::x, gcn::ClipRectangle::xOffset, gcn::Rectangle::y, and gcn::ClipRectangle::yOffset.

void CFont::MeasureWidths (  ) 

Calculate the width of each character

Definition at line 666 of file font.cpp.

References CharWidth, G, CGraphic::GraphicHeight, CGraphic::GraphicWidth, CGraphic::Height, CGraphic::Surface, CGraphic::Width, and y.


Member Data Documentation

std::string CFont::Ident

Ident of the font.

Definition at line 94 of file include/font.h.

Real font width (starting with ' ').

Definition at line 95 of file include/font.h.

Referenced by DoDrawText(), MeasureWidths(), Width(), and ~CFont().

Graphic object used to draw.

Definition at line 96 of file include/font.h.

Referenced by DoDrawText(), FreeOpenGLFonts(), Height(), IsLoaded(), LoadFonts(), MakeFontColorTextures(), MeasureWidths(), New(), ReloadFonts(), and ~CFont().


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

Generated on Sat Feb 21 00:28:23 2009 for Bos Wars by  doxygen 1.5.6