ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.h
Revision: 1.21
Committed: Sat Feb 18 14:14:43 2006 UTC (18 years, 3 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-7_8, rel-7_9, rel-7_7
Changes since 1.20: +0 -23 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #ifndef DEFAULTFONT_H_
2     #define DEFAULTFONT_H_
3    
4     #include <X11/Xlib.h>
5     #if XFT
6     # include <X11/Xft/Xft.h>
7     #endif
8    
9     #ifdef HAVE_XSETLOCALE
10     # define X_LOCALE
11     # include <X11/Xlocale.h>
12     #else
13     # ifdef HAVE_SETLOCALE
14     # include <clocale>
15     # endif
16     #endif /* HAVE_XLOCALE */
17    
18     #ifdef HAVE_NL_LANGINFO
19     # include <langinfo.h>
20     #endif
21    
22     #include <inttypes.h>
23    
24     #include "feature.h"
25     #include "encoding.h"
26     #include "rxvtutil.h"
27 root 1.12 #include "rxvttoolkit.h"
28    
29     struct rxvt_term;
30 root 1.1
31     struct rxvt_fontprop {
32     enum {
33 root 1.12 unset = -1,
34 root 1.1 medium = 100, bold = 200,
35     roman = 0, italic = 100,
36     };
37 root 1.17 int width, height, ascent;
38 root 1.1 int weight, slant;
39     };
40    
41     struct rxvt_font {
42     // managed by the fontset
43 root 1.18 rxvt_term *term;
44     void set_term (rxvt_term *term) { this->term = term; }
45 root 1.1
46     char *name;
47     codeset cs;
48     bool loaded; // wether we tried loading it before (not wether it's loaded)
49    
50     // managed by the font object
51     int ascent, descent,
52     width, height;
53    
54 root 1.12 void set_name (char *name);
55 root 1.1
56 root 1.20 rxvt_font ();
57 root 1.12 virtual ~rxvt_font () { free (name); };
58    
59     virtual void clear () { };
60 root 1.1
61 root 1.18 void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const;
62 root 1.1
63     virtual rxvt_fontprop properties () = 0;
64    
65 root 1.12 virtual bool load (const rxvt_fontprop &morph) = 0;
66 root 1.18 virtual bool has_char (uint32_t unicode, const rxvt_fontprop *prop, bool &careful) const = 0;
67 root 1.1
68     virtual void draw (rxvt_drawable &d,
69     int x, int y,
70     const text_t *text, int len,
71     int fg, int bg) = 0;
72     };
73    
74     #define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0)
75    
76     struct rxvt_fallback_font;
77    
78     struct rxvt_fontset {
79     char *fontdesc;
80    
81 root 1.18 rxvt_fontset (rxvt_term *term);
82 root 1.1 ~rxvt_fontset ();
83    
84 root 1.13 bool populate (const char *desc);
85     void set_prop (const rxvt_fontprop &prop) { this->prop = prop; }
86 root 1.12 int find_font (uint32_t unicode);
87 root 1.1 int find_font (const char *name) const;
88 root 1.12 bool realize_font (int i);
89 root 1.1
90 root 1.12 // font-id's MUST fit into a signed 16 bit integer, and within 0..255
91 root 1.1 rxvt_font *operator [] (int id) const
92     {
93 root 1.12 return fonts[id & 0x7f];
94 root 1.1 }
95    
96     private:
97 root 1.18 rxvt_term *term;
98 root 1.13 rxvt_fontprop prop;
99 root 1.1 simplevec<rxvt_font *> fonts;
100     const rxvt_fallback_font *fallback;
101    
102 root 1.12 typedef unsigned char pagemap[256];
103     vector<pagemap *> fmap;
104 root 1.1
105 root 1.13 void clear ();
106     rxvt_font *new_font (const char *name, codeset cs);
107 root 1.1 void add_fonts (const char *desc);
108     };
109    
110     #endif /* _DEFAULTFONT_H_ */
111