1 | #ifndef DEFAULTFONT_H_ |
1 | #ifndef DEFAULTFONT_H_ |
2 | #define DEFAULTFONT_H_ |
2 | #define DEFAULTFONT_H_ |
|
|
3 | |
|
|
4 | #include <X11/Xlib.h> |
|
|
5 | #if XFT |
|
|
6 | # include <X11/Xft/Xft.h> |
|
|
7 | #endif |
3 | |
8 | |
4 | #ifdef HAVE_XSETLOCALE |
9 | #ifdef HAVE_XSETLOCALE |
5 | # define X_LOCALE |
10 | # define X_LOCALE |
6 | # include <X11/Xlocale.h> |
11 | # include <X11/Xlocale.h> |
7 | #else |
12 | #else |
… | |
… | |
26 | }; |
31 | }; |
27 | int width, height; |
32 | int width, height; |
28 | int weight, slant; |
33 | int weight, slant; |
29 | }; |
34 | }; |
30 | |
35 | |
|
|
36 | struct rxvt_drawable { |
|
|
37 | rxvt_display *display; |
|
|
38 | Drawable drawable; |
|
|
39 | #if XFT |
|
|
40 | XftDraw *xftdrawable; |
|
|
41 | operator XftDraw *(); |
|
|
42 | #endif |
|
|
43 | |
|
|
44 | rxvt_drawable (rxvt_display *display, Drawable drawable) |
|
|
45 | : display(display), |
|
|
46 | #if XFT |
|
|
47 | xftdrawable(0), |
|
|
48 | #endif |
|
|
49 | drawable(drawable) |
|
|
50 | { } |
|
|
51 | |
|
|
52 | #if XFT |
|
|
53 | ~rxvt_drawable (); |
|
|
54 | #endif |
|
|
55 | |
|
|
56 | operator Drawable() { return drawable; } |
|
|
57 | }; |
|
|
58 | |
31 | struct rxvt_font { |
59 | struct rxvt_font { |
|
|
60 | struct rxvt_fontset *fs; |
32 | // managed by the fontset |
61 | // managed by the fontset |
33 | rxvt_t r; |
62 | rxvt_t r; |
34 | void set_term (rxvt_t r) { this->r = r; } |
63 | void set_term (rxvt_t r) { this->r = r; } |
35 | |
64 | |
36 | char *name; |
65 | char *name; |
… | |
… | |
49 | } |
78 | } |
50 | |
79 | |
51 | rxvt_font () { name = 0; } |
80 | rxvt_font () { name = 0; } |
52 | ~rxvt_font () { free (name); }; |
81 | ~rxvt_font () { free (name); }; |
53 | |
82 | |
54 | void clear_rect (int x, int y, int w, int h, int color); |
83 | void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color); |
55 | |
84 | |
56 | virtual void clear () { }; |
85 | virtual void clear () { }; |
57 | |
86 | |
58 | virtual rxvt_fontprop properties () = 0; |
87 | virtual rxvt_fontprop properties () = 0; |
59 | |
88 | |
60 | virtual bool load (const rxvt_fontprop &prop) = 0; |
89 | virtual bool load (const rxvt_fontprop &prop) = 0; |
61 | virtual bool has_codepoint (uint32_t unicode) = 0; |
90 | virtual bool has_codepoint (uint32_t unicode) = 0; |
62 | |
91 | |
63 | virtual void draw (int x, int y, |
92 | virtual void draw (rxvt_drawable &d, |
|
|
93 | int x, int y, |
64 | const text_t *text, int len, |
94 | const text_t *text, int len, |
65 | int fg, int bg) = 0; |
95 | int fg, int bg) = 0; |
66 | }; |
96 | }; |
67 | |
97 | |
68 | #define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0) |
98 | #define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0) |