ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.h
Revision: 1.3
Committed: Tue Nov 25 09:29:11 2003 UTC (20 years, 6 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +1 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 /*
2 pcg 1.3 * $Id: defaultfont.h,v 1.2 2003/11/24 17:31:27 pcg Exp $
3 pcg 1.1 */
4    
5     #ifndef _DEFAULTFONT_H_
6     #define _DEFAULTFONT_H_
7    
8     #ifdef HAVE_XSETLOCALE
9     # define X_LOCALE
10     # include <X11/Xlocale.h>
11     #else
12     # ifdef HAVE_SETLOCALE
13     # include <locale.h>
14     # endif
15     #endif /* HAVE_XLOCALE */
16    
17     #ifdef HAVE_NL_LANGINFO
18     # include <langinfo.h>
19     #endif
20    
21     #include "rxvtlib.h"
22     #include "feature.h"
23     #include "encoding.h"
24     #include "rxvtvec.h"
25    
26     typedef struct rxvt_vars rxvt_t;
27    
28     struct rxvt_font {
29     // managed by the fontset
30     #if EXPLICIT_CONTEXT
31     rxvt_t *rxvt_term;
32     void set_term (pR) { this->rxvt_term = R; }
33     #else
34     void set_term (pR) { }
35     #endif
36     char *name;
37     codeset cs;
38     bool loaded;
39    
40     // managed by the font object
41     bool prop; // wether this is a proportional font or has other funny characteristics
42     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     ~rxvt_font () { free (name); clear (); };
53    
54     void clear_rect (int x, int y, int w, int h, int color);
55    
56     virtual void clear () { };
57    
58     virtual bool load (int maxheight) = 0;
59     virtual bool has_codepoint (uint32_t unicode) = 0;
60    
61     virtual void draw (int x, int y,
62     const text_t *text, int len,
63     int fg, int bg) = 0;
64     };
65    
66     //#define FONT_REF(obj) (obj)->refcnt++
67     //#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj)
68     #define FONT_UNREF(f) delete f
69    
70     struct rxvt_fallback_font;
71    
72     struct rxvt_fontset {
73     rxvt_fontset (pR);
74     ~rxvt_fontset ();
75    
76     rxvt_font *new_font (const char *name, codeset cs);
77    
78     void populate (const char *desc);
79     int find_font (uint32_t unicode);
80    
81     rxvt_font *operator [](int id) const
82     {
83     return fonts[id];
84     }
85    
86     rxvt_font *base_font () const
87     {
88     return fonts[base_id];
89     }
90    
91     private:
92     #ifdef EXPLICIT_CONTEXT
93     rxvt_t *rxvt_term;
94     #endif
95     simplevec<rxvt_font *> fonts;
96     const rxvt_fallback_font *fallback;
97    
98     int height;
99     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