summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilefont.h
blob: 8197c9d412e552cccfc6b1616b9a64e88da8a003 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef TILEFONT_H
#define TILEFONT_H

#include "defines.h"
#include "glwrapper.h"

extern const VColour term_colours[MAX_TERM_COLOUR];

class FontBuffer;
class formatted_string;
class GenericTexture;

class FontWrapper
{
public:
    // Static creation functions.
    // Implementation-specific files (e.g. fontwrapper-ft.cc) should
    // contain their own version of this factory function.
    static FontWrapper *create();

    virtual ~FontWrapper() {}

    // font loading
    virtual bool load_font(const char *font_name, unsigned int font_size,
                           bool outline) = 0;

    // render just text
    virtual void render_textblock(unsigned int x, unsigned int y,
                                  ucs_t *chars, uint8_t *colours,
                                  unsigned int width, unsigned int height,
                                  bool drop_shadow = false) = 0;

    // render text + background box
    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
    virtual void store(FontBuffer &buf, float &x, float &y,
                       const 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, ucs_t c,
                       const VColour &col) = 0;

    virtual unsigned int char_width() const = 0;
    virtual unsigned int char_height() const = 0;

    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) const = 0;
    virtual unsigned int string_height(const formatted_string &str) const = 0;

    // Try to split this string to fit in w x h pixel area.
    virtual formatted_string split(const formatted_string &str,
                                   unsigned int max_width,
                                   unsigned int max_height) = 0;

   virtual const GenericTexture *font_tex() const = 0;
};

#endif