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