00001 #ifndef FT_FONTWRAPPER_H
00002 #define FT_FONTWRAPPER_H
00003
00004 #ifdef USE_TILE
00005 #ifdef USE_FT
00006
00007 #include "tilefont.h"
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 class FTFontWrapper : public FontWrapper
00018 {
00019 public:
00020 FTFontWrapper();
00021 virtual ~FTFontWrapper();
00022
00023
00024 virtual bool load_font(const char *font_name, unsigned int font_size,
00025 bool outline);
00026
00027
00028 virtual void render_textblock(unsigned int x, unsigned int y,
00029 unsigned char *chars, unsigned char *colours,
00030 unsigned int width, unsigned int height,
00031 bool drop_shadow = false);
00032
00033
00034 virtual void render_string(unsigned int x, unsigned int y,
00035 const char *text, const coord_def &min_pos,
00036 const coord_def &max_pos,
00037 unsigned char font_colour,
00038 bool drop_shadow = false,
00039 unsigned char box_alpha = 0,
00040 unsigned char box_colour = 0,
00041 unsigned int outline = 0,
00042 bool tooltip = false);
00043
00044
00045 virtual void store(FontBuffer &buf, float &x, float &y,
00046 const std::string &s, const VColour &c);
00047 virtual void store(FontBuffer &buf, float &x, float &y,
00048 const formatted_string &fs);
00049 virtual void store(FontBuffer &buf, float &x, float &y, unsigned char c,
00050 const VColour &col);
00051
00052 virtual unsigned int char_width() const;
00053 virtual unsigned int char_height() const;
00054
00055 virtual unsigned int string_width(const char *text) const;
00056 virtual unsigned int string_width(const formatted_string &str) const;
00057 virtual unsigned int string_height(const char *text) const;
00058 virtual unsigned int string_height(const formatted_string &str) const;
00059
00060
00061 virtual formatted_string split(const formatted_string &str,
00062 unsigned int max_width,
00063 unsigned int max_height);
00064
00065 virtual const GenericTexture *font_tex() const;
00066
00067 protected:
00068 void store(FontBuffer &buf, float &x, float &y,
00069 const std::string &s, const VColour &c, float orig_x);
00070 void store(FontBuffer &buf, float &x, float &y, const formatted_string &fs,
00071 float orig_x);
00072
00073 int find_index_before_width(const char *str, int max_width);
00074
00075 struct GlyphInfo
00076 {
00077
00078 char offset;
00079
00080
00081 char advance;
00082
00083
00084 char width;
00085
00086 bool renderable;
00087 };
00088 GlyphInfo *m_glyphs;
00089
00090
00091 coord_def m_max_advance;
00092
00093
00094 int m_min_offset;
00095
00096 GenericTexture m_tex;
00097 GLShapeBuffer *m_buf;
00098 };
00099
00100 #endif // USE_FT
00101 #endif // USE_TILE
00102 #endif // include guard