1 |
/* |
2 |
* $Id: defaultfont.h,v 1.7 2003/12/18 04:14:30 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_fontprop { |
27 |
enum { |
28 |
medium = 100, bold = 200, |
29 |
roman = 0, italic = 100, |
30 |
}; |
31 |
int width, height; |
32 |
int weight, slant; |
33 |
}; |
34 |
|
35 |
struct rxvt_font { |
36 |
// managed by the fontset |
37 |
rxvt_t r; |
38 |
void set_term (rxvt_t r) { this->r = r; } |
39 |
|
40 |
char *name; |
41 |
codeset cs; |
42 |
bool loaded; // wether we tried loading it before (not wether it's loaded) |
43 |
|
44 |
// managed by the font object |
45 |
bool slow; // wether this is a proportional font or has other funny characteristics |
46 |
int ascent, descent, |
47 |
width, height; |
48 |
|
49 |
void set_name (char *name) |
50 |
{ |
51 |
if (this->name) free (this->name); // let the compiler optimize |
52 |
this->name = name; |
53 |
} |
54 |
|
55 |
rxvt_font () { name = 0; } |
56 |
~rxvt_font () { free (name); clear (); }; |
57 |
|
58 |
void clear_rect (int x, int y, int w, int h, int color); |
59 |
|
60 |
virtual void clear () { }; |
61 |
|
62 |
virtual rxvt_fontprop properties () = 0; |
63 |
|
64 |
virtual bool load (const rxvt_fontprop &prop) = 0; |
65 |
virtual bool has_codepoint (uint32_t unicode) = 0; |
66 |
|
67 |
virtual void draw (int x, int y, |
68 |
const text_t *text, int len, |
69 |
int fg, int bg) = 0; |
70 |
}; |
71 |
|
72 |
//#define FONT_REF(obj) (obj)->refcnt++ |
73 |
//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj) |
74 |
#define FONT_UNREF(f) delete f |
75 |
|
76 |
struct rxvt_fallback_font; |
77 |
|
78 |
struct rxvt_fontset { |
79 |
rxvt_fontset (rxvt_t r); |
80 |
~rxvt_fontset (); |
81 |
|
82 |
rxvt_font *new_font (const char *name, codeset cs); |
83 |
|
84 |
void populate (const char *desc); |
85 |
int find_font (uint32_t unicode); |
86 |
|
87 |
rxvt_font *operator [](int id) const |
88 |
{ |
89 |
return fonts[id]; |
90 |
} |
91 |
|
92 |
rxvt_font *base_font () const |
93 |
{ |
94 |
return fonts[base_id]; |
95 |
} |
96 |
|
97 |
private: |
98 |
rxvt_t r; |
99 |
simplevec<rxvt_font *> fonts; |
100 |
const rxvt_fallback_font *fallback; |
101 |
|
102 |
rxvt_fontprop base_prop; |
103 |
int base_id; |
104 |
|
105 |
bool realize_font (int i); |
106 |
void add_fonts (const char *desc); |
107 |
void clear (); |
108 |
}; |
109 |
|
110 |
#endif /* _DEFAULTFONT_H_ */ |
111 |
|