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