19 #ifndef OPENXCOM_FONT_H
20 #define OPENXCOM_FONT_H
25 #include <yaml-cpp/yaml.h>
43 static std::wstring _index;
44 static SDL_Color _palette[6];
46 int _width, _height, _spacing;
47 std::map<wchar_t, SDL_Rect> _chars;
55 static inline bool isLinebreak(
wchar_t c) {
return (c == L
'\n' || c == L
'\x02'); }
57 static inline bool isSpace(
wchar_t c) {
return (c == L
' ' || c == L
'\xA0'); }
59 static inline bool isSeparator(
wchar_t c) {
return (c == L
'-' || c ==
'/'); }
63 static void setIndex(
const std::wstring &index);
65 void load(
const YAML::Node& node);
83 void fix(
const std::string &file,
int width);
Surface * getSurface() const
Gets the font's surface.
Definition: Font.cpp:255
static bool isNonBreakableSpace(wchar_t c)
Checks if a character is a non-breaking space.
Definition: Font.h:61
int getHeight() const
Gets the font's character height.
Definition: Font.cpp:205
static void setIndex(const std::wstring &index)
Sets the character index for every font.
Definition: Font.cpp:58
~Font()
Cleans up the font.
Definition: Font.cpp:48
int getWidth() const
Gets the font's character width.
Definition: Font.cpp:196
static bool isSeparator(wchar_t c)
Checks if a character is a word separator.
Definition: Font.h:59
void init()
Determines the size and position of each character in the font.
Definition: Font.cpp:115
static bool isSpace(wchar_t c)
Checks if a character is a blank space (includes non-breaking spaces).
Definition: Font.h:57
static bool isLinebreak(wchar_t c)
Checks if a character is a linebreak.
Definition: Font.h:55
void loadTerminal()
Generate the terminal font.
Definition: Font.cpp:87
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:40
Surface * getChar(wchar_t c)
Gets a particular character from the font, with its real size.
Definition: Font.cpp:180
int getSpacing() const
Gets the spacing between characters.
Definition: Font.cpp:216
SDL_Rect getCharSize(wchar_t c)
Gets the size of a particular character;.
Definition: Font.cpp:226
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
Font()
Creates a blank font.
Definition: Font.cpp:41
void load(const YAML::Node &node)
Loads the font from YAML.
Definition: Font.cpp:67