Changeset 5343 in orxonox.OLD for trunk/src/lib/graphics/text_engine/font.h
- Timestamp:
- Oct 10, 2005, 12:16:19 AM (19 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/font.h
r5330 r5343 1 1 /*! 2 * @file proto_class.h3 * @brief Definition of ...4 */2 * @file font.h 3 * brief Definition of the FONT-loading class 4 */ 5 5 6 #ifndef _ PROTO_CLASS_H7 #define _ PROTO_CLASS_H6 #ifndef _FONT_H 7 #define _FONT_H 8 8 9 9 #include "base_object.h" 10 10 11 #include "glincl.h" 12 13 14 #ifdef HAVE_SDL_TTF_H 15 #include <SDL_ttf.h> 16 #else 17 #include <SDL/SDL_ttf.h> 18 #endif 19 20 /* some default values */ 21 #define FONT_NUM_COLORS 256 //!< number of colors. 22 23 #define FONT_HIGHEST_KNOWN_CHAR 128 //!< The highest character known to the textEngine. 24 11 25 // FORWARD DECLARATION 12 26 27 //! A struct for handling glyphs 28 /** 29 a Glyph is one letter of a certain font 30 */ 31 struct Glyph 32 { 33 // Glyph-specific (size and so on) 34 Uint16 character; //!< The character 35 int minX; //!< The minimum distance from the origin in X 36 int maxX; //!< The maximum distance from the origin in X 37 int minY; //!< The minimum distance from the origin in Y 38 int maxY; //!< The maximum distance from the origin in Y 39 int width; //!< The width of the Glyph 40 int height; //!< The height of the Glyph 41 int bearingX; //!< How much is right of the Origin 42 int bearingY; //!< How much is above the Origin 43 int advance; //!< How big a Glyph would be in monospace-mode 44 45 // OpenGL-specific 46 // TexCoord texCoord; //!< A Texture Coordinate for this glyph. 47 GLuint displayList; //!< DiplayList to render this Glyph. 48 }; 13 49 14 50 15 //! A class for ... 16 class ProtoClass : public BaseObject { 51 //////////// 52 /// FONT /// 53 //////////// 54 //! A class to handle a Font of a certain ttf-File, Size and Color. 55 class Font : public BaseObject 56 { 57 friend class Text; 17 58 18 public: 19 ProtoClass(); 20 virtual ~ProtoClass(); 59 public: 60 Font(const char* fontFile, 61 unsigned int fontSize); 62 Font(char** xpmArray); 63 virtual ~Font(); 21 64 65 void init(); 22 66 23 private: 67 // font 68 bool loadFont(const char* fontFile); 69 bool loadFontFromSDL_Surface(SDL_Surface* surface); 24 70 71 void setSize(unsigned int fontSize); 72 void setStyle(const char* renderStyle); 73 74 /** @returns a Pointer to the Array of Glyphs */ 75 inline Glyph** getGlyphArray() const { return this->glyphArray; }; 76 /** @returns the texture to the fast-texture */ 77 inline GLuint getFastTextureID() const { return this->fastTextureID; }; 78 /** @returns the default Font */ 79 inline static Font* getDefaultFont() { return Font::defaultFont; }; 80 81 void createAsciiImage(const char* fileName); 82 static void initDefaultFont(); 83 static void removeDefaultFont(); 84 85 private: 86 int getMaxHeight(); 87 int getMaxAscent(); 88 int getMaxDescent(); 89 Glyph* getGlyphMetrics(Uint16 character); 90 91 GLuint createFastTexture(); 92 93 void initGlyphs(Uint16 from, Uint16 count); 94 int findOptimalFastTextureSize(); 95 96 void debug(); 97 98 private: 99 static Font* defaultFont; //!< a default font, that is used, if other fonts were unable to be loaded. 100 // information about the Font 101 TTF_Font* font; //!< The font we use for this. 102 unsigned int fontSize; //!< The size of the font in pixels. each Font has one size. 103 int renderStyle; //!< The Renderstyle 104 105 Glyph** glyphArray; //!< An Array of all the Glyphs stored in the Array of Glyphs. 106 GLuint fastTextureID; //!< The fast textureID. 25 107 }; 26 108 27 #endif /* _ PROTO_CLASS_H */109 #endif /* _FONT_H */
Note: See TracChangeset
for help on using the changeset viewer.