_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
#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 CFontColor * | FontColor |
| Map of ident to font color. More... | |
| static const CFontColor * | LastTextColor |
| Current font color. More... | |
| static CFontColor * | DefaultTextColor |
| Last text color. More... | |
| static CFontColor * | ReverseTextColor |
| 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 CFont * | SmallFont |
| static CFont * | GameFont |
| Small font used in stats. More... | |
| static const unsigned char | codepoint_to_cp437 [] |
| static const unsigned char | codepoint_to_cp1252 [] |
| static const unsigned char | codepoint_to_cp866 [] |
| static const char * | codepoint_from_0xa0_to_ascii [] |
| static const char * | codepoint_from_0x400_to_ascii [] |
| int | FontCodePage = 437 |
| true when GameFont is provided More... | |
| static std::string | FormatNumber (const int number) |
| Normal font used in game. More... | |
| CFont & | GetSmallFont () |
| bool | IsGameFontReady () |
| Normal font used in game. More... | |
| CFont & | GetGameFont () |
| 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) |
| Set the default text colors for normal and reverse text. More... | |
| void | GetDefaultTextColors (std::string &normalp, std::string &reversep) |
| Get the default text colors for normal and reverse text. More... | |
| static unsigned char | codepoint_to_codepage_index (int codepoint, const char **subst) |
| static int | CodepageIndexFromUTF8 (const char text[], const size_t len, size_t &pos, size_t &subpos) |
| static int | CodepageIndexFromUTF8 (const std::string &text, size_t &pos, size_t &subpos) |
| 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 | ReloadFonts () |
| void | CleanFonts () |
| Cleanup the font module. More... | |
| 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.
| void CleanFonts | ( | ) |
Cleanup the font module.
Clean up the font module.
|
static |
Get the next codepage index to render from a utf8 encoded string. This maps utf8 encoded unicode codepoints into the codepage index of the active FontCodePage. If no mapping into the codepage exists, this may offer a single- or multi-char replacement string. The subpos out-parameter is used to communicate at which position in a multi-char replacement string we are. Callers should pass in the same pos and subpos arguments while iterating over a loop. When the subpos is 0 after a call, the utf8 character was completely processed, otherwise more codepoint indices are needed to substitute the utf8 char.
|
static |
Get the next codepage index to render from a utf8 encoded string
|
static |
Convert a Unicode codepoint to a codepage index, based on the convert table to work with Stratagus char. This maps Unicode codepoints into codepages commonly used for DOS and early Windows games; currently CP437, CP1251, and CP866. More can be added. The games need to ensure that the font graphic represents the appropriate codepage.
| codepoint | the char to convert |
| subst | out variable for a char pointer with a substitution string if the codepage doesn't support the char |
| int convertKey | ( | const char * | key | ) |
|
static |
Normal font used in game.
@brief Format a number using commas
This is closely tied to CFont::Width(int number).
@param number Number to be formatted @return The formatted number as a string
| void GetDefaultTextColors | ( | std::string & | normalp, |
| std::string & | reversep | ||
| ) |
Get the default text colors for normal and reverse text.
Get the default text colors.
| normalp | Normal text color pointer. |
| reversep | Reverse 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'.
| line | line number. |
| s | multiline string. |
| maxlen | max length of the string (0 : unlimited) (in char if font == NULL else in pixels). |
| font | if specified use font->Width() instead of strlen. |
| CFont& GetSmallFont | ( | ) |
Font selector for the font functions. FIXME: should be moved to lua
| bool IsGameFontReady | ( | ) |
Normal font used in game.
| void LoadFonts | ( | ) |
Load and initialize the fonts.
Load all fonts.
| void ReloadFonts | ( | ) |
Reload fonts
| void SetDefaultTextColors | ( | const std::string & | normal, |
| const std::string & | reverse | ||
| ) |
Set the default text colors for normal and reverse text.
Set the default text colors.
| normal | Normal text color. |
| reverse | Reverse text color. |
|
static |
Return the index of first occurrence of c in [s- s + maxlen]
| s | original string. |
| c | character to find. |
| maxlen | size limit of the search. (0 means unlimited). (in char if font == NULL else in pixels). |
| font | if specified use font->Width() instead of strlen. |
|
static |
Draw character with current color.
| g | Pointer to object |
| gx | X offset into object |
| gy | Y offset into object |
| w | width to display |
| h | height to display |
| x | X screen position |
| y | Y screen position |
|
static |
Draw character with current color clipped into 8 bit framebuffer.
| g | Pointer to object |
| gx | X offset into object |
| gy | Y offset into object |
| w | width to display |
| h | height to display |
| x | X screen position |
| y | Y screen position |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Reverse text color.
|
static |
Default normal color index.
|
static |
Last text color.
| int FontCodePage = 437 |
true when GameFont is provided
|
static |
Map of ident to font color.
|
static |
|
static |
|
static |
|
static |
Small font used in stats.
|
static |
Current font color.
|
static |
Default text color.
|
static |
1.8.17
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.