_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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
gcn::Font Class Referenceabstract

#include <font.h>

Inheritance diagram for gcn::Font:
CFont gcn::DefaultFont gcn::ImageFont

Public Member Functions

virtual ~Font ()
 
virtual int getWidth (const std::string &text) const =0
 
virtual int getHeight () const =0
 
virtual int getStringIndexAt (const std::string &text, int x)
 
virtual void drawString (Graphics *graphics, const std::string &text, int x, int y, bool is_normal=true)=0
 

Detailed Description

Holder of a font. Fonts should inherit from this class and implements it's functions.

See also
ImageFont

Constructor & Destructor Documentation

◆ ~Font()

virtual gcn::Font::~Font ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ drawString()

virtual void gcn::Font::drawString ( Graphics graphics,
const std::string &  text,
int  x,
int  y,
bool  is_normal = true 
)
pure 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.

Implemented in gcn::ImageFont, gcn::DefaultFont, and CFont.

◆ getHeight()

virtual int gcn::Font::getHeight ( ) const
pure virtual

Gets the height of the glyphs in the font.

Returns
the height of the glyphs int the font.

Implemented in gcn::ImageFont, gcn::DefaultFont, and CFont.

◆ getStringIndexAt()

int gcn::Font::getStringIndexAt ( const std::string &  text,
int  x 
)
virtual

Gets a string index in a string providing an x coordinate. Used to retrive a string index (for a character in a string) at a certain x position. It is especially useful when a mouse clicks in a TextField and you want to know which character was clicked.

Returns
a string index in a string providing an x coordinate.

Reimplemented in gcn::ImageFont, and gcn::DefaultFont.

◆ getWidth()

virtual int gcn::Font::getWidth ( const std::string &  text) const
pure 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
textthe string to return the width of.
Returns
the width of a string.

Implemented in gcn::ImageFont, gcn::DefaultFont, and CFont.


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.