diff options
author | Ixtli <cg@325i.org> | 2010-03-14 20:40:54 +0900 |
---|---|---|
committer | Enne Walker <ennewalker@users.sourceforge.net> | 2010-04-24 10:19:45 -0400 |
commit | 149c76283904371235ea6d564037900edb8b07af (patch) | |
tree | 6bcde02f7acf2485f7e557bb4c64f74d3abefa9d /crawl-ref/source/tilefont.h | |
parent | bab61331e9e1287ae14afe2644b68f4c49ff09d8 (diff) | |
download | crawl-ref-149c76283904371235ea6d564037900edb8b07af.tar.gz crawl-ref-149c76283904371235ea6d564037900edb8b07af.zip |
Created FontWrapper, and made FT flag in makefile.
Diffstat (limited to 'crawl-ref/source/tilefont.h')
-rw-r--r-- | crawl-ref/source/tilefont.h | 95 |
1 files changed, 37 insertions, 58 deletions
diff --git a/crawl-ref/source/tilefont.h b/crawl-ref/source/tilefont.h index fb25dff5aa..8fc77cd158 100644 --- a/crawl-ref/source/tilefont.h +++ b/crawl-ref/source/tilefont.h @@ -25,78 +25,57 @@ class FontBuffer; class VColour; class formatted_string; -class FTFont +class FontWrapper { public: - FTFont(); - virtual ~FTFont(); + // static creation functions + static FontWrapper *create(); + + virtual ~FontWrapper() {}; - bool load_font(const char *font_name, unsigned int font_size, bool outline); + // font loading + virtual bool load_font( const char *font_name, unsigned int font_size, + bool outline) = 0; // render just text - void render_textblock(unsigned int x, unsigned int y, - unsigned char *chars, unsigned char *colours, - unsigned int width, unsigned int height, - bool drop_shadow = false); + virtual void render_textblock( unsigned int x, unsigned int y, + unsigned char *chars, unsigned char *colours, + unsigned int width, unsigned int height, + bool drop_shadow = false) = 0; // render text + background box - void render_string(unsigned int x, unsigned int y, const char *text, - const coord_def &min_pos, const coord_def &max_pos, - unsigned char font_colour, bool drop_shadow = false, - unsigned char box_alpha = 0, - unsigned char box_colour = 0, unsigned int outline = 0, - bool tooltip = false); + virtual void render_string( unsigned int x, unsigned int y, + const char *text, const coord_def &min_pos, + const coord_def &max_pos, + unsigned char font_colour, + bool drop_shadow = false, + unsigned char box_alpha = 0, + unsigned char box_colour = 0, + unsigned int outline = 0, + bool tooltip = false) = 0; // FontBuffer helper functions - void store(FontBuffer &buf, float &x, float &y, - const std::string &s, const VColour &c); - void store(FontBuffer &buf, float &x, float &y, const formatted_string &fs); - void store(FontBuffer &buf, float &x, float &y, unsigned char c, const VColour &col); + virtual void store(FontBuffer &buf, float &x, float &y, + const std::string &s, const VColour &c) = 0; + virtual void store(FontBuffer &buf, float &x, float &y, + const formatted_string &fs) = 0; + virtual void store(FontBuffer &buf, float &x, float &y, unsigned char c, + const VColour &col) = 0; - unsigned int char_width() const { return m_max_advance.x; } - unsigned int char_height() const { return m_max_advance.y; } + virtual unsigned int char_width() = 0; + virtual unsigned int char_height() = 0; - unsigned int string_width(const char *text); - unsigned int string_width(const formatted_string &str); - unsigned int string_height(const char *text); - unsigned int string_height(const formatted_string &str); + virtual unsigned int string_width(const char *text) = 0; + virtual unsigned int string_width(const formatted_string &str) = 0; + virtual unsigned int string_height(const char *text) = 0; + virtual unsigned int string_height(const formatted_string &str) = 0; // Try to split this string to fit in w x h pixel area. - formatted_string split(const formatted_string &str, unsigned int max_width, - unsigned int max_height); + virtual formatted_string split( const formatted_string &str, + unsigned int max_width, + unsigned int max_height) = 0; - const GenericTexture *font_tex() const { return &m_tex; } - -protected: - void store(FontBuffer &buf, float &x, float &y, - const std::string &s, const VColour &c, float orig_x); - void store(FontBuffer &buf, float &x, float &y, const formatted_string &fs, - float orig_x); - - int find_index_before_width(const char *str, int max_width); - - struct GlyphInfo - { - // offset before drawing glyph; can be negative - char offset; - - // per-glyph horizontal advance - char advance; - - // per-glyph width - char width; - - bool renderable; - }; - GlyphInfo *m_glyphs; - - // cached value of the maximum advance from m_advance - coord_def m_max_advance; - - // minimum offset (likely negative) - int m_min_offset; - - GenericTexture m_tex; + virtual const GenericTexture *font_tex() = 0; }; #endif |