| 1 | /*! | 
|---|
| 2 |  * @file font.h | 
|---|
| 3 |  * brief Definition of the FONT-loading class | 
|---|
| 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. | 
|---|
| 8 |  */ | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef _FONT_H | 
|---|
| 11 | #define _FONT_H | 
|---|
| 12 |  | 
|---|
| 13 | #include "material.h" | 
|---|
| 14 |  | 
|---|
| 15 | #include "font_data.h" | 
|---|
| 16 |  | 
|---|
| 17 |  | 
|---|
| 18 | //! A class to handle a Font of a certain ttf-File/image-file, Size. | 
|---|
| 19 | class Font : public Material | 
|---|
| 20 | { | 
|---|
| 21 |   ObjectListDeclaration(Font); | 
|---|
| 22 | public: | 
|---|
| 23 |   typedef FontData::Glyph Glyph; | 
|---|
| 24 | public: | 
|---|
| 25 |   Font(); | 
|---|
| 26 |   Font(const std::string& fontFile, unsigned int renderSize); | 
|---|
| 27 |   Font(const std::string& imageFile); | 
|---|
| 28 |   Font(char** xpmArray); | 
|---|
| 29 |   Font(const Font& font); | 
|---|
| 30 |   virtual ~Font(); | 
|---|
| 31 |  | 
|---|
| 32 |   Font& operator=(const Font& font); | 
|---|
| 33 |   /** @brief compare two fonts @param font the comparator, @returns true if they match */ | 
|---|
| 34 |   bool operator==(const Font& font) const { return this->data == font.data; }; | 
|---|
| 35 |  | 
|---|
| 36 |   /// LOADING new Fonts | 
|---|
| 37 |   bool loadFontFromTTF(const std::string& fontFile, unsigned int renderSize); | 
|---|
| 38 |   bool loadFontFromSDL_Surface(SDL_Surface* surface); | 
|---|
| 39 |  | 
|---|
| 40 |   void setStyle(const std::string& renderStyle); | 
|---|
| 41 |  | 
|---|
| 42 |   /** @returns a Pointer to the Array of Glyphs */ | 
|---|
| 43 |   inline const Glyph* const * const getGlyphArray() const { return this->data->getGlyphArray(); }; | 
|---|
| 44 |  | 
|---|
| 45 |   inline int getMaxHeight() const { return data->getMaxHeight(); }; | 
|---|
| 46 |   inline int getMaxAscent() const { return data->getMaxAscent(); }; | 
|---|
| 47 |   inline int getMaxDescent() const { return data->getMaxDescent(); }; | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 |   static void createAsciiImage(const std::string& ttfFile, const std::string& fileName, unsigned int size); | 
|---|
| 51 |  | 
|---|
| 52 |   void debug() const; | 
|---|
| 53 |  | 
|---|
| 54 |   void acquireData(const FontData::Pointer& data) { this->data = data; }; | 
|---|
| 55 |   const FontData::Pointer& dataPointer() const { return data; }; | 
|---|
| 56 | private: | 
|---|
| 57 |   void init(); | 
|---|
| 58 |   static void initDefaultFont(); | 
|---|
| 59 |  | 
|---|
| 60 |   void setTexture(const TextureData::Pointer& texDataPointer); | 
|---|
| 61 |  | 
|---|
| 62 | private: | 
|---|
| 63 |   FontData::Pointer         data;                //!< A Data-Pointer to a Font. | 
|---|
| 64 |  | 
|---|
| 65 |   static FontData::Pointer  defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded. | 
|---|
| 66 | }; | 
|---|
| 67 |  | 
|---|
| 68 | #endif /* _FONT_H */ | 
|---|