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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
font.cpp File Reference
#include "stratagus.h"
#include "font.h"
#include "intern_video.h"
#include "video.h"
#include <vector>
#include <map>

font.cpp - The color fonts.

typedef std::map< std::string,
CFont * > 
FontMap
 
typedef std::map< std::string,
CFontColor * > 
FontColorMap
 Font mappings. More...
 
typedef std::map< const
CFontColor *, CGraphic * > 
FontColorGraphicMap
 Default reverse color index. More...
 
static FontMap Fonts
 
static FontColorMap FontColors
 
static CFontColorFontColor
 Map of ident to font color. More...
 
static const CFontColorLastTextColor
 Current font color. More...
 
static CFontColorDefaultTextColor
 Last text color. More...
 
static CFontColorReverseTextColor
 Default text color. More...
 
static std::string DefaultNormalColorIndex
 Reverse text color. More...
 
static std::string DefaultReverseColorIndex
 Default normal color index. More...
 
static std::map< const CFont
*, FontColorGraphicMap
FontColorGraphics
 
static CFontSmallFont
 
static CFontGameFont
 Small font used in stats. More...
 
static int FormatNumber (int number, char *buf)
 Normal font used in game. More...
 
CFontGetSmallFont ()
 
bool IsGameFontReady ()
 Normal font used in game. More...
 
CFontGetGameFont ()
 Small font used in stats. More...
 
static void VideoDrawChar (const CGraphic &g, int gx, int gy, int w, int h, int x, int y, const CFontColor &fc)
 
void SetDefaultTextColors (const std::string &normal, const std::string &reverse)
 true when GameFont is provided More...
 
void GetDefaultTextColors (std::string &normalp, std::string &reversep)
 Get the default text colors for normal and reverse text. More...
 
static bool GetUTF8 (const std::string &text, size_t &pos, int &utf8)
 
static bool GetUTF8 (const char text[], const size_t len, size_t &pos, int &utf8)
 
int convertKey (const char *key)
 
int GetHotKey (const std::string &text)
 Get the hot key from a string. More...
 
static void VideoDrawCharClip (const CGraphic &g, int gx, int gy, int w, int h, int x, int y, const CFontColor &fc)
 
static int strchrlen (const std::string &s, char c, unsigned int maxlen, const CFont *font)
 
std::string GetLineFont (unsigned int line, const std::string &s, unsigned int maxlen, const CFont *font)
 Return the 'line' line of the string 's'. More...
 
void LoadFonts ()
 Load and initialize the fonts. More...
 
void FreeOpenGLFonts ()
 Free OpenGL fonts. More...
 
void ReloadFonts ()
 Reload OpenGL fonts. More...
 
void CleanFonts ()
 Cleanup the font module. More...
 

Typedef Documentation

typedef std::map<const CFontColor *, CGraphic *> FontColorGraphicMap

Default reverse color index.

Font color graphics Usage: FontColorGraphics[CFont *font][CFontColor *color]

typedef std::map<std::string, CFontColor *> FontColorMap

Font mappings.

typedef std::map<std::string, CFont *> FontMap

Function Documentation

void CleanFonts ( )

Cleanup the font module.

Clean up the font module.

int convertKey ( const char *  key)
static int FormatNumber ( int  number,
char *  buf 
)
static

Normal font used in game.

Format a number using commas

Parameters
numberNumber to be formatted
bufBuffer to save the formatted number to
Returns
The real length of the Formated Number.
void FreeOpenGLFonts ( )

Free OpenGL fonts.

Free OpenGL fonts

void GetDefaultTextColors ( std::string &  normalp,
std::string &  reversep 
)

Get the default text colors for normal and reverse text.

Get the default text colors.

Parameters
normalpNormal text color pointer.
reversepReverse text color pointer.
CFont& GetGameFont ( )

Small font used in stats.

int GetHotKey ( const std::string &  text)

Get the hot key from a string.

Get the hot key from a string

std::string GetLineFont ( unsigned int  line,
const std::string &  s,
unsigned int  maxlen,
const CFont font 
)

Return the 'line' line of the string 's'.

Return the 'line' line of the string 's'.

Parameters
lineline number.
smultiline string.
maxlenmax length of the string (0 : unlimited) (in char if font == NULL else in pixels).
fontif specified use font->Width() instead of strlen.
Returns
computed value.
CFont& GetSmallFont ( )

Font selector for the font functions. FIXME: should be moved to lua

static bool GetUTF8 ( const std::string &  text,
size_t &  pos,
int &  utf8 
)
static

Get the next utf8 character from a string

static bool GetUTF8 ( const char  text[],
const size_t  len,
size_t &  pos,
int &  utf8 
)
static

Get the next utf8 character from an array of chars

bool IsGameFontReady ( )

Normal font used in game.

void LoadFonts ( )

Load and initialize the fonts.

Load all fonts.

void ReloadFonts ( )

Reload OpenGL fonts.

Reload OpenGL fonts

void SetDefaultTextColors ( const std::string &  normal,
const std::string &  reverse 
)

true when GameFont is provided

Set the default text colors.

Parameters
normalNormal text color.
reverseReverse text color.
static int strchrlen ( const std::string &  s,
char  c,
unsigned int  maxlen,
const CFont font 
)
static

Return the index of first occurrence of c in [s- s + maxlen]

Parameters
soriginal string.
ccharacter to find.
maxlensize limit of the search. (0 means unlimited). (in char if font == NULL else in pixels).
fontif specified use font->Width() instead of strlen.
Returns
computed value.
static void VideoDrawChar ( const CGraphic g,
int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
const CFontColor fc 
)
static

Draw character with current color.

Parameters
gPointer to object
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX screen position
yY screen position
static void VideoDrawCharClip ( const CGraphic g,
int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
const CFontColor fc 
)
static

Draw character with current color clipped into 8 bit framebuffer.

Parameters
gPointer to object
gxX offset into object
gyY offset into object
wwidth to display
hheight to display
xX screen position
yY screen position

Variable Documentation

std::string DefaultNormalColorIndex
static

Reverse text color.

std::string DefaultReverseColorIndex
static

Default normal color index.

CFontColor* DefaultTextColor
static

Last text color.

CFontColor* FontColor
static

Map of ident to font color.

std::map<const CFont *, FontColorGraphicMap> FontColorGraphics
static
FontColorMap FontColors
static
FontMap Fonts
static
CFont* GameFont
static

Small font used in stats.

const CFontColor* LastTextColor
static

Current font color.

CFontColor* ReverseTextColor
static

Default text color.

CFont* SmallFont
static
(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.