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