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