1 |
/* |
2 |
* $Id: defaultfont.h,v 1.4 2003/11/25 11:52:42 pcg Exp $ |
3 |
*/ |
4 |
|
5 |
#ifndef _DEFAULTFONT_H_ |
6 |
#define _DEFAULTFONT_H_ |
7 |
|
8 |
#ifdef HAVE_XSETLOCALE |
9 |
# define X_LOCALE |
10 |
# include <X11/Xlocale.h> |
11 |
#else |
12 |
# ifdef HAVE_SETLOCALE |
13 |
# include <locale.h> |
14 |
# endif |
15 |
#endif /* HAVE_XLOCALE */ |
16 |
|
17 |
#ifdef HAVE_NL_LANGINFO |
18 |
# include <langinfo.h> |
19 |
#endif |
20 |
|
21 |
#include "rxvtlib.h" |
22 |
#include "feature.h" |
23 |
#include "encoding.h" |
24 |
#include "rxvtvec.h" |
25 |
|
26 |
struct rxvt_font { |
27 |
// managed by the fontset |
28 |
rxvt_t r; |
29 |
void set_term (rxvt_t r) { this->r = r; } |
30 |
|
31 |
char *name; |
32 |
codeset cs; |
33 |
bool loaded; |
34 |
|
35 |
// managed by the font object |
36 |
bool prop; // wether this is a proportional font or has other funny characteristics |
37 |
int ascent, descent, |
38 |
width, height; |
39 |
|
40 |
void set_name (char *name) |
41 |
{ |
42 |
if (this->name) free (this->name); // let the compiler optimize |
43 |
this->name = name; |
44 |
} |
45 |
|
46 |
rxvt_font () { name = 0; } |
47 |
~rxvt_font () { free (name); clear (); }; |
48 |
|
49 |
void clear_rect (int x, int y, int w, int h, int color); |
50 |
|
51 |
virtual void clear () { }; |
52 |
|
53 |
virtual bool load (int maxheight) = 0; |
54 |
virtual bool has_codepoint (uint32_t unicode) = 0; |
55 |
|
56 |
virtual void draw (int x, int y, |
57 |
const text_t *text, int len, |
58 |
int fg, int bg) = 0; |
59 |
}; |
60 |
|
61 |
//#define FONT_REF(obj) (obj)->refcnt++ |
62 |
//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj) |
63 |
#define FONT_UNREF(f) delete f |
64 |
|
65 |
struct rxvt_fallback_font; |
66 |
|
67 |
struct rxvt_fontset { |
68 |
rxvt_fontset (rxvt_t r); |
69 |
~rxvt_fontset (); |
70 |
|
71 |
rxvt_font *new_font (const char *name, codeset cs); |
72 |
|
73 |
void populate (const char *desc); |
74 |
int find_font (uint32_t unicode); |
75 |
|
76 |
rxvt_font *operator [](int id) const |
77 |
{ |
78 |
return fonts[id]; |
79 |
} |
80 |
|
81 |
rxvt_font *base_font () const |
82 |
{ |
83 |
return fonts[base_id]; |
84 |
} |
85 |
|
86 |
private: |
87 |
rxvt_t r; |
88 |
simplevec<rxvt_font *> fonts; |
89 |
const rxvt_fallback_font *fallback; |
90 |
|
91 |
int height; |
92 |
int base_id; |
93 |
|
94 |
bool realize_font (int i); |
95 |
void add_fonts (const char *desc); |
96 |
void clear (); |
97 |
}; |
98 |
|
99 |
#endif /* _DEFAULTFONT_H_ */ |
100 |
|