ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.h
Revision: 1.8
Committed: Wed Dec 24 09:07:01 2003 UTC (20 years, 5 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: stable, rel-1-3, rel-1-2
Changes since 1.7: +3 -4 lines
Log Message:
*** empty log message ***

File Contents

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