1 |
root |
1.1 |
#ifndef DEFAULTFONT_H_ |
2 |
|
|
#define DEFAULTFONT_H_ |
3 |
|
|
|
4 |
|
|
#include <X11/Xlib.h> |
5 |
|
|
#if XFT |
6 |
|
|
# include <X11/Xft/Xft.h> |
7 |
|
|
#endif |
8 |
|
|
|
9 |
|
|
#include <inttypes.h> |
10 |
|
|
|
11 |
|
|
#include "encoding.h" |
12 |
|
|
#include "rxvtutil.h" |
13 |
root |
1.12 |
#include "rxvttoolkit.h" |
14 |
|
|
|
15 |
|
|
struct rxvt_term; |
16 |
root |
1.1 |
|
17 |
root |
1.25 |
struct rxvt_fontprop |
18 |
|
|
{ |
19 |
root |
1.1 |
enum { |
20 |
root |
1.12 |
unset = -1, |
21 |
root |
1.1 |
medium = 100, bold = 200, |
22 |
|
|
roman = 0, italic = 100, |
23 |
|
|
}; |
24 |
root |
1.17 |
int width, height, ascent; |
25 |
root |
1.1 |
int weight, slant; |
26 |
|
|
}; |
27 |
|
|
|
28 |
root |
1.25 |
struct rxvt_font |
29 |
|
|
{ |
30 |
root |
1.1 |
// managed by the fontset |
31 |
root |
1.18 |
rxvt_term *term; |
32 |
|
|
void set_term (rxvt_term *term) { this->term = term; } |
33 |
root |
1.1 |
|
34 |
|
|
char *name; |
35 |
|
|
codeset cs; |
36 |
sf-exg |
1.31 |
bool loaded; // whether we tried loading it before (not whether it's loaded) |
37 |
root |
1.1 |
|
38 |
|
|
// managed by the font object |
39 |
|
|
int ascent, descent, |
40 |
|
|
width, height; |
41 |
|
|
|
42 |
root |
1.26 |
void set_name (char *name_); |
43 |
root |
1.1 |
|
44 |
root |
1.20 |
rxvt_font (); |
45 |
root |
1.12 |
virtual ~rxvt_font () { free (name); }; |
46 |
|
|
|
47 |
|
|
virtual void clear () { }; |
48 |
root |
1.1 |
|
49 |
root |
1.18 |
void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const; |
50 |
root |
1.1 |
|
51 |
|
|
virtual rxvt_fontprop properties () = 0; |
52 |
|
|
|
53 |
root |
1.22 |
virtual bool load (const rxvt_fontprop &morph, bool force_prop) = 0; |
54 |
root |
1.18 |
virtual bool has_char (uint32_t unicode, const rxvt_fontprop *prop, bool &careful) const = 0; |
55 |
root |
1.1 |
|
56 |
|
|
virtual void draw (rxvt_drawable &d, |
57 |
|
|
int x, int y, |
58 |
|
|
const text_t *text, int len, |
59 |
|
|
int fg, int bg) = 0; |
60 |
root |
1.37 |
|
61 |
|
|
void unref () |
62 |
|
|
{ |
63 |
|
|
clear (); |
64 |
|
|
delete this; |
65 |
|
|
} |
66 |
root |
1.1 |
}; |
67 |
|
|
|
68 |
|
|
struct rxvt_fallback_font; |
69 |
|
|
|
70 |
root |
1.25 |
struct rxvt_fontset |
71 |
|
|
{ |
72 |
root |
1.1 |
char *fontdesc; |
73 |
|
|
|
74 |
root |
1.39 |
// must be power-of-two - 1, also has to match RS_fontMask in rxvt.h |
75 |
|
|
#if USE_256_COLORS |
76 |
|
|
enum { fontCount = 7 }; // 4 extra colors bits, 4 fewer fontcount bits |
77 |
|
|
#else |
78 |
|
|
enum { fontCount = 127 }; |
79 |
|
|
#endif |
80 |
|
|
|
81 |
|
|
// index of first font in set |
82 |
|
|
enum { firstFont = 2 }; |
83 |
root |
1.27 |
|
84 |
root |
1.18 |
rxvt_fontset (rxvt_term *term); |
85 |
root |
1.1 |
~rxvt_fontset (); |
86 |
|
|
|
87 |
root |
1.13 |
bool populate (const char *desc); |
88 |
root |
1.22 |
void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; } |
89 |
sf-exg |
1.32 |
int find_font_idx (uint32_t unicode); |
90 |
root |
1.1 |
int find_font (const char *name) const; |
91 |
root |
1.12 |
bool realize_font (int i); |
92 |
root |
1.1 |
|
93 |
root |
1.30 |
rxvt_font *operator [] (int id) const |
94 |
root |
1.1 |
{ |
95 |
root |
1.33 |
return fonts[id >> 1]; |
96 |
root |
1.1 |
} |
97 |
|
|
|
98 |
root |
1.34 |
int |
99 |
|
|
find_font (unicode_t unicode) |
100 |
|
|
{ |
101 |
|
|
return min<int> ((fontCount << 1) | 1, find_font_idx (unicode)); |
102 |
|
|
} |
103 |
|
|
|
104 |
root |
1.1 |
private: |
105 |
root |
1.18 |
rxvt_term *term; |
106 |
root |
1.13 |
rxvt_fontprop prop; |
107 |
root |
1.22 |
bool force_prop; |
108 |
root |
1.1 |
simplevec<rxvt_font *> fonts; |
109 |
|
|
const rxvt_fallback_font *fallback; |
110 |
|
|
|
111 |
root |
1.12 |
typedef unsigned char pagemap[256]; |
112 |
|
|
vector<pagemap *> fmap; |
113 |
root |
1.1 |
|
114 |
root |
1.13 |
void clear (); |
115 |
|
|
rxvt_font *new_font (const char *name, codeset cs); |
116 |
root |
1.34 |
void prepare_font (rxvt_font *font, codeset cs); |
117 |
root |
1.1 |
void add_fonts (const char *desc); |
118 |
root |
1.34 |
void push_font (rxvt_font *font); |
119 |
root |
1.1 |
}; |
120 |
|
|
|
121 |
|
|
#endif /* _DEFAULTFONT_H_ */ |
122 |
|
|
|