ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.h
Revision: 1.11
Committed: Fri Feb 13 12:16:21 2004 UTC (20 years, 3 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.10: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.9 #ifndef DEFAULTFONT_H_
2     #define DEFAULTFONT_H_
3 pcg 1.1
4     #ifdef HAVE_XSETLOCALE
5     # define X_LOCALE
6     # include <X11/Xlocale.h>
7     #else
8     # ifdef HAVE_SETLOCALE
9     # include <locale.h>
10     # endif
11     #endif /* HAVE_XLOCALE */
12    
13     #ifdef HAVE_NL_LANGINFO
14     # include <langinfo.h>
15     #endif
16    
17     #include "rxvtlib.h"
18     #include "feature.h"
19     #include "encoding.h"
20 pcg 1.9 #include "rxvtstl.h"
21 pcg 1.1
22 pcg 1.7 struct rxvt_fontprop {
23     enum {
24     medium = 100, bold = 200,
25     roman = 0, italic = 100,
26     };
27 pcg 1.8 int width, height;
28     int weight, slant;
29 pcg 1.7 };
30    
31 pcg 1.1 struct rxvt_font {
32     // managed by the fontset
33 pcg 1.5 rxvt_t r;
34     void set_term (rxvt_t r) { this->r = r; }
35    
36 pcg 1.1 char *name;
37     codeset cs;
38 pcg 1.6 bool loaded; // wether we tried loading it before (not wether it's loaded)
39 pcg 1.1
40     // managed by the font object
41 pcg 1.7 bool slow; // wether this is a proportional font or has other funny characteristics
42 pcg 1.1 int ascent, descent,
43     width, height;
44    
45     void set_name (char *name)
46     {
47     if (this->name) free (this->name); // let the compiler optimize
48     this->name = name;
49     }
50    
51     rxvt_font () { name = 0; }
52 pcg 1.10 ~rxvt_font () { clear (); free (name); };
53 pcg 1.1
54     void clear_rect (int x, int y, int w, int h, int color);
55    
56     virtual void clear () { };
57    
58 pcg 1.7 virtual rxvt_fontprop properties () = 0;
59    
60     virtual bool load (const rxvt_fontprop &prop) = 0;
61 pcg 1.1 virtual bool has_codepoint (uint32_t unicode) = 0;
62    
63     virtual void draw (int x, int y,
64     const text_t *text, int len,
65     int fg, int bg) = 0;
66     };
67    
68     //#define FONT_REF(obj) (obj)->refcnt++
69     //#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj)
70     #define FONT_UNREF(f) delete f
71    
72     struct rxvt_fallback_font;
73    
74     struct rxvt_fontset {
75 pcg 1.5 rxvt_fontset (rxvt_t r);
76 pcg 1.1 ~rxvt_fontset ();
77    
78     rxvt_font *new_font (const char *name, codeset cs);
79    
80     void populate (const char *desc);
81     int find_font (uint32_t unicode);
82    
83 pcg 1.11 rxvt_font *operator [] (int id) const
84 pcg 1.1 {
85     return fonts[id];
86     }
87    
88     rxvt_font *base_font () const
89     {
90     return fonts[base_id];
91     }
92    
93     private:
94 pcg 1.5 rxvt_t r;
95 pcg 1.1 simplevec<rxvt_font *> fonts;
96     const rxvt_fallback_font *fallback;
97    
98 pcg 1.7 rxvt_fontprop base_prop;
99 pcg 1.1 int base_id;
100    
101     bool realize_font (int i);
102     void add_fonts (const char *desc);
103     void clear ();
104     };
105    
106     #endif /* _DEFAULTFONT_H_ */
107