1 | /* |
|
|
2 | * $Id: defaultfont.h,v 1.2 2003/11/24 17:31:27 pcg Exp $ |
|
|
3 | */ |
|
|
4 | |
|
|
5 | #ifndef _DEFAULTFONT_H_ |
1 | #ifndef DEFAULTFONT_H_ |
6 | #define _DEFAULTFONT_H_ |
2 | #define DEFAULTFONT_H_ |
7 | |
3 | |
8 | #ifdef HAVE_XSETLOCALE |
4 | #ifdef HAVE_XSETLOCALE |
9 | # define X_LOCALE |
5 | # define X_LOCALE |
10 | # include <X11/Xlocale.h> |
6 | # include <X11/Xlocale.h> |
11 | #else |
7 | #else |
… | |
… | |
19 | #endif |
15 | #endif |
20 | |
16 | |
21 | #include "rxvtlib.h" |
17 | #include "rxvtlib.h" |
22 | #include "feature.h" |
18 | #include "feature.h" |
23 | #include "encoding.h" |
19 | #include "encoding.h" |
24 | #include "rxvtvec.h" |
20 | #include "rxvtstl.h" |
25 | |
21 | |
26 | #include "defaultfont.intpro" /* PROTOS for internal routines */ |
22 | struct rxvt_fontprop { |
27 | |
23 | enum { |
28 | typedef struct rxvt_vars rxvt_t; |
24 | medium = 100, bold = 200, |
|
|
25 | roman = 0, italic = 100, |
|
|
26 | }; |
|
|
27 | int width, height; |
|
|
28 | int weight, slant; |
|
|
29 | }; |
29 | |
30 | |
30 | struct rxvt_font { |
31 | struct rxvt_font { |
31 | // managed by the fontset |
32 | // managed by the fontset |
32 | #if EXPLICIT_CONTEXT |
33 | rxvt_t r; |
33 | rxvt_t *rxvt_term; |
34 | void set_term (rxvt_t r) { this->r = r; } |
34 | void set_term (pR) { this->rxvt_term = R; } |
35 | |
35 | #else |
|
|
36 | void set_term (pR) { } |
|
|
37 | #endif |
|
|
38 | char *name; |
36 | char *name; |
39 | codeset cs; |
37 | codeset cs; |
40 | bool loaded; |
38 | bool loaded; // wether we tried loading it before (not wether it's loaded) |
41 | |
39 | |
42 | // managed by the font object |
40 | // managed by the font object |
43 | bool prop; // wether this is a proportional font or has other funny characteristics |
41 | bool slow; // wether this is a proportional font or has other funny characteristics |
44 | int ascent, descent, |
42 | int ascent, descent, |
45 | width, height; |
43 | width, height; |
46 | |
44 | |
47 | void set_name (char *name) |
45 | void set_name (char *name) |
48 | { |
46 | { |
… | |
… | |
55 | |
53 | |
56 | void clear_rect (int x, int y, int w, int h, int color); |
54 | void clear_rect (int x, int y, int w, int h, int color); |
57 | |
55 | |
58 | virtual void clear () { }; |
56 | virtual void clear () { }; |
59 | |
57 | |
60 | virtual bool load (int maxheight) = 0; |
58 | virtual rxvt_fontprop properties () = 0; |
|
|
59 | |
|
|
60 | virtual bool load (const rxvt_fontprop &prop) = 0; |
61 | virtual bool has_codepoint (uint32_t unicode) = 0; |
61 | virtual bool has_codepoint (uint32_t unicode) = 0; |
62 | |
62 | |
63 | virtual void draw (int x, int y, |
63 | virtual void draw (int x, int y, |
64 | const text_t *text, int len, |
64 | const text_t *text, int len, |
65 | int fg, int bg) = 0; |
65 | int fg, int bg) = 0; |
… | |
… | |
70 | #define FONT_UNREF(f) delete f |
70 | #define FONT_UNREF(f) delete f |
71 | |
71 | |
72 | struct rxvt_fallback_font; |
72 | struct rxvt_fallback_font; |
73 | |
73 | |
74 | struct rxvt_fontset { |
74 | struct rxvt_fontset { |
75 | rxvt_fontset (pR); |
75 | rxvt_fontset (rxvt_t r); |
76 | ~rxvt_fontset (); |
76 | ~rxvt_fontset (); |
77 | |
77 | |
78 | rxvt_font *new_font (const char *name, codeset cs); |
78 | rxvt_font *new_font (const char *name, codeset cs); |
79 | |
79 | |
80 | void populate (const char *desc); |
80 | void populate (const char *desc); |
… | |
… | |
89 | { |
89 | { |
90 | return fonts[base_id]; |
90 | return fonts[base_id]; |
91 | } |
91 | } |
92 | |
92 | |
93 | private: |
93 | private: |
94 | #ifdef EXPLICIT_CONTEXT |
94 | rxvt_t r; |
95 | rxvt_t *rxvt_term; |
|
|
96 | #endif |
|
|
97 | simplevec<rxvt_font *> fonts; |
95 | simplevec<rxvt_font *> fonts; |
98 | const rxvt_fallback_font *fallback; |
96 | const rxvt_fallback_font *fallback; |
99 | |
97 | |
100 | int height; |
98 | rxvt_fontprop base_prop; |
101 | int base_id; |
99 | int base_id; |
102 | |
100 | |
103 | bool realize_font (int i); |
101 | bool realize_font (int i); |
104 | void add_fonts (const char *desc); |
102 | void add_fonts (const char *desc); |
105 | void clear (); |
103 | void clear (); |