1 | /* |
|
|
2 | * $Id: defaultfont.h,v 1.8 2003/12/24 09:07:01 pcg Exp $ |
|
|
3 | */ |
|
|
4 | |
|
|
5 | #ifndef _DEFAULTFONT_H_ |
1 | #ifndef DEFAULTFONT_H_ |
6 | #define _DEFAULTFONT_H_ |
2 | #define DEFAULTFONT_H_ |
7 | |
3 | |
8 | #ifdef HAVE_XSETLOCALE |
4 | #ifdef HAVE_XSETLOCALE |
9 | # define X_LOCALE |
5 | # define X_LOCALE |
10 | # include <X11/Xlocale.h> |
6 | # include <X11/Xlocale.h> |
11 | #else |
7 | #else |
… | |
… | |
19 | #endif |
15 | #endif |
20 | |
16 | |
21 | #include "rxvtlib.h" |
17 | #include "rxvtlib.h" |
22 | #include "feature.h" |
18 | #include "feature.h" |
23 | #include "encoding.h" |
19 | #include "encoding.h" |
24 | #include "rxvtvec.h" |
20 | #include "rxvtstl.h" |
25 | |
21 | |
26 | struct rxvt_fontprop { |
22 | struct rxvt_fontprop { |
27 | enum { |
23 | enum { |
28 | medium = 100, bold = 200, |
24 | medium = 100, bold = 200, |
29 | roman = 0, italic = 100, |
25 | roman = 0, italic = 100, |
… | |
… | |
51 | if (this->name) free (this->name); // let the compiler optimize |
47 | if (this->name) free (this->name); // let the compiler optimize |
52 | this->name = name; |
48 | this->name = name; |
53 | } |
49 | } |
54 | |
50 | |
55 | rxvt_font () { name = 0; } |
51 | rxvt_font () { name = 0; } |
56 | ~rxvt_font () { free (name); clear (); }; |
52 | ~rxvt_font () { free (name); }; |
57 | |
53 | |
58 | void clear_rect (int x, int y, int w, int h, int color); |
54 | void clear_rect (int x, int y, int w, int h, int color); |
59 | |
55 | |
60 | virtual void clear () { }; |
56 | virtual void clear () { }; |
61 | |
57 | |
… | |
… | |
67 | virtual void draw (int x, int y, |
63 | virtual void draw (int x, int y, |
68 | const text_t *text, int len, |
64 | const text_t *text, int len, |
69 | int fg, int bg) = 0; |
65 | int fg, int bg) = 0; |
70 | }; |
66 | }; |
71 | |
67 | |
72 | //#define FONT_REF(obj) (obj)->refcnt++ |
68 | #define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0) |
73 | //#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj) |
|
|
74 | #define FONT_UNREF(f) delete f |
|
|
75 | |
69 | |
76 | struct rxvt_fallback_font; |
70 | struct rxvt_fallback_font; |
77 | |
71 | |
78 | struct rxvt_fontset { |
72 | struct rxvt_fontset { |
79 | rxvt_fontset (rxvt_t r); |
73 | rxvt_fontset (rxvt_t r); |
80 | ~rxvt_fontset (); |
74 | ~rxvt_fontset (); |
81 | |
75 | |
82 | rxvt_font *new_font (const char *name, codeset cs); |
76 | rxvt_font *new_font (const char *name, codeset cs); |
83 | |
77 | |
84 | void populate (const char *desc); |
78 | bool populate (const char *desc); |
85 | int find_font (uint32_t unicode); |
79 | int find_font (uint32_t unicode); |
86 | |
80 | |
87 | rxvt_font *operator [](int id) const |
81 | rxvt_font *operator [] (int id) const |
88 | { |
82 | { |
89 | return fonts[id]; |
83 | return fonts[id]; |
90 | } |
84 | } |
91 | |
85 | |
92 | rxvt_font *base_font () const |
86 | rxvt_font *base_font () const |