[4838] | 1 | /*! |
---|
[5343] | 2 | * @file font.h |
---|
| 3 | * brief Definition of the FONT-loading class |
---|
[5344] | 4 | * |
---|
| 5 | * !! IMPORTANT !! When using ttf fonts clear the license issues prior to |
---|
| 6 | * adding them to orxonox. This is really important, because we do not want |
---|
| 7 | * to offend anyone. |
---|
[5343] | 8 | */ |
---|
[1853] | 9 | |
---|
[5343] | 10 | #ifndef _FONT_H |
---|
| 11 | #define _FONT_H |
---|
[1853] | 12 | |
---|
[8755] | 13 | #include "material.h" |
---|
[1853] | 14 | |
---|
[8751] | 15 | #include "font_data.h" |
---|
[5343] | 16 | |
---|
| 17 | |
---|
[5347] | 18 | //! A class to handle a Font of a certain ttf-File/image-file, Size. |
---|
[8758] | 19 | class Font : public Material /* TODO Material it should be */ |
---|
[5343] | 20 | { |
---|
[3245] | 21 | |
---|
[8751] | 22 | public: |
---|
[8754] | 23 | Font(); |
---|
[8755] | 24 | Font(const std::string& fontFile, unsigned int renderSize); |
---|
[8751] | 25 | Font(const std::string& imageFile); |
---|
| 26 | Font(char** xpmArray); |
---|
| 27 | virtual ~Font(); |
---|
| 28 | |
---|
[8758] | 29 | Font& operator=(const Font& font); |
---|
[8754] | 30 | bool operator==(const Font& font) const { return this->data == font.data; }; |
---|
| 31 | |
---|
[8755] | 32 | |
---|
| 33 | /// LOADING new Fonts |
---|
[8756] | 34 | bool loadFontFromTTF(const std::string& fontFile, unsigned int renderSize); |
---|
[8751] | 35 | bool loadFontFromSDL_Surface(SDL_Surface* surface); |
---|
[5343] | 36 | |
---|
[8751] | 37 | void setStyle(const std::string& renderStyle); |
---|
[5343] | 38 | |
---|
[8751] | 39 | /** @returns a Pointer to the Array of Glyphs */ |
---|
| 40 | inline Glyph** getGlyphArray() const { return this->data->getGlyphArray(); }; |
---|
| 41 | /** @returns the a pointer to the TTF */ |
---|
| 42 | inline TTF_Font* getTTF() const { return this->data->getTTF(); }; |
---|
[5343] | 43 | |
---|
[8751] | 44 | int getMaxHeight() const; |
---|
| 45 | int getMaxAscent() const; |
---|
| 46 | int getMaxDescent() const; |
---|
[7450] | 47 | |
---|
[8751] | 48 | /** @returns the default Font */ |
---|
[8753] | 49 | //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; }; |
---|
[5768] | 50 | |
---|
[8758] | 51 | |
---|
[8751] | 52 | void createAsciiImage(const std::string& fileName, unsigned int size) const; |
---|
[5343] | 53 | |
---|
[8758] | 54 | void debug() const; |
---|
[8755] | 55 | |
---|
[8751] | 56 | private: |
---|
| 57 | void init(); |
---|
[8758] | 58 | void initGlyphs(Uint16 from, Uint16 count); |
---|
[8751] | 59 | bool getGlyphMetrics(Glyph* glyph, Uint16 character); |
---|
[8758] | 60 | static void initDefaultFont(); |
---|
[5343] | 61 | |
---|
[8758] | 62 | int findOptimalFastTextureSize(); |
---|
[8751] | 63 | bool createFastTexture(); |
---|
[5343] | 64 | |
---|
[8758] | 65 | bool setTexture(GLuint texture); |
---|
[5343] | 66 | |
---|
| 67 | |
---|
[8751] | 68 | private: |
---|
[8753] | 69 | static FontDataPointer defaultFontData; //!< a default font, that is used, if other fonts were unable to be loaded. |
---|
[8751] | 70 | |
---|
[8753] | 71 | FontDataPointer data; //!< A Data-Pointer to a Font. |
---|
[1853] | 72 | }; |
---|
| 73 | |
---|
[5343] | 74 | #endif /* _FONT_H */ |
---|