Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/fontdata/src/lib/graphics/text_engine/font.h @ 8758

Last change on this file since 8758 was 8758, checked in by bensch, 18 years ago

font is a Material now

File size: 2.0 KB
Line 
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.
19class Font : public Material /* TODO Material it should be */
20{
21
22public:
23  Font();
24  Font(const std::string& fontFile, unsigned int renderSize);
25  Font(const std::string& imageFile);
26  Font(char** xpmArray);
27  virtual ~Font();
28
29  Font& operator=(const Font& font);
30  bool operator==(const Font& font) const { return this->data == font.data; };
31
32
33  /// LOADING new Fonts
34  bool loadFontFromTTF(const std::string& fontFile, unsigned int renderSize);
35  bool loadFontFromSDL_Surface(SDL_Surface* surface);
36
37  void setStyle(const std::string& renderStyle);
38
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(); };
43
44  int getMaxHeight() const;
45  int getMaxAscent() const;
46  int getMaxDescent() const;
47
48  /** @returns the default Font */
49  //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
50
51
52  void createAsciiImage(const std::string& fileName, unsigned int size) const;
53
54  void debug() const;
55
56private:
57  void init();
58  void initGlyphs(Uint16 from, Uint16 count);
59  bool getGlyphMetrics(Glyph* glyph, Uint16 character);
60  static void initDefaultFont();
61
62  int findOptimalFastTextureSize();
63  bool createFastTexture();
64
65  bool setTexture(GLuint texture);
66
67
68private:
69  static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
70
71  FontDataPointer           data;                //!< A Data-Pointer to a Font.
72};
73
74#endif /* _FONT_H */
Note: See TracBrowser for help on using the repository browser.