[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 | |
---|
[8761] | 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. |
---|
[8761] | 19 | class Font : public Material /* TODO Material it should be */ |
---|
[5343] | 20 | { |
---|
[3245] | 21 | |
---|
[8751] | 22 | public: |
---|
[8761] | 23 | Font(); |
---|
| 24 | Font(const std::string& fontFile, unsigned int renderSize); |
---|
[8751] | 25 | Font(const std::string& imageFile); |
---|
| 26 | Font(char** xpmArray); |
---|
[8763] | 27 | Font(const Font& font); |
---|
[8751] | 28 | virtual ~Font(); |
---|
| 29 | |
---|
[8761] | 30 | Font& operator=(const Font& font); |
---|
| 31 | /** @brief compare two fonts @param font the comparator, @returns true if they match */ |
---|
| 32 | bool operator==(const Font& font) const { return this->data == font.data; }; |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | /// LOADING new Fonts |
---|
| 36 | bool loadFontFromTTF(const std::string& fontFile, unsigned int renderSize); |
---|
[8751] | 37 | bool loadFontFromSDL_Surface(SDL_Surface* surface); |
---|
[5343] | 38 | |
---|
[8751] | 39 | void setStyle(const std::string& renderStyle); |
---|
[5343] | 40 | |
---|
[8751] | 41 | /** @returns a Pointer to the Array of Glyphs */ |
---|
| 42 | inline Glyph** getGlyphArray() const { return this->data->getGlyphArray(); }; |
---|
| 43 | /** @returns the a pointer to the TTF */ |
---|
| 44 | inline TTF_Font* getTTF() const { return this->data->getTTF(); }; |
---|
[5343] | 45 | |
---|
[8751] | 46 | int getMaxHeight() const; |
---|
| 47 | int getMaxAscent() const; |
---|
| 48 | int getMaxDescent() const; |
---|
[7450] | 49 | |
---|
[8751] | 50 | void createAsciiImage(const std::string& fileName, unsigned int size) const; |
---|
[5343] | 51 | |
---|
[8761] | 52 | void debug() const; |
---|
[5343] | 53 | |
---|
[8751] | 54 | private: |
---|
| 55 | void init(); |
---|
[8761] | 56 | void initGlyphs(Uint16 from, Uint16 count); |
---|
[8751] | 57 | bool getGlyphMetrics(Glyph* glyph, Uint16 character); |
---|
[8761] | 58 | static void initDefaultFont(); |
---|
[5343] | 59 | |
---|
[8761] | 60 | int findOptimalFastTextureSize(); |
---|
[8751] | 61 | bool createFastTexture(); |
---|
[5343] | 62 | |
---|
[8761] | 63 | bool setTexture(GLuint texture); |
---|
[5343] | 64 | |
---|
| 65 | |
---|
[8751] | 66 | private: |
---|
[8763] | 67 | FontDataPointer data; //!< A Data-Pointer to a Font. |
---|
| 68 | |
---|
[8761] | 69 | static FontDataPointer defaultFontData; //!< a default font, that is used, if other fonts were unable to be loaded. |
---|
[1853] | 70 | }; |
---|
| 71 | |
---|
[5343] | 72 | #endif /* _FONT_H */ |
---|