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