ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.h
(Generate patch)

Comparing rxvt-unicode/src/rxvtfont.h (file contents):
Revision 1.24 by ayin, Thu Oct 18 09:11:43 2007 UTC vs.
Revision 1.40 by sf-exg, Thu Jun 2 17:43:43 2011 UTC

6# include <X11/Xft/Xft.h> 6# include <X11/Xft/Xft.h>
7#endif 7#endif
8 8
9#include <inttypes.h> 9#include <inttypes.h>
10 10
11#include "feature.h"
12#include "encoding.h" 11#include "encoding.h"
13#include "rxvtutil.h" 12#include "rxvtutil.h"
14#include "rxvttoolkit.h" 13#include "rxvttoolkit.h"
15 14
16struct rxvt_term; 15struct rxvt_term;
17 16
18struct rxvt_fontprop { 17struct rxvt_fontprop
18{
19 enum { 19 enum {
20 unset = -1, 20 unset = -1,
21 medium = 100, bold = 200, 21 medium = 100, bold = 200,
22 roman = 0, italic = 100, 22 roman = 0, italic = 100,
23 }; 23 };
24 int width, height, ascent; 24 int width, height, ascent;
25 int weight, slant; 25 int weight, slant;
26}; 26};
27 27
28struct rxvt_font { 28struct rxvt_font
29{
29 // managed by the fontset 30 // managed by the fontset
30 rxvt_term *term; 31 rxvt_term *term;
31 void set_term (rxvt_term *term) { this->term = term; } 32 void set_term (rxvt_term *term) { this->term = term; }
32 33
33 char *name; 34 char *name;
34 codeset cs; 35 codeset cs;
35 bool loaded; // wether we tried loading it before (not wether it's loaded) 36 bool loaded; // whether we tried loading it before (not whether it's loaded)
36 37
37 // managed by the font object 38 // managed by the font object
38 int ascent, descent, 39 int ascent, descent,
39 width, height; 40 width, height;
40 41
41 void set_name (char *name); 42 void set_name (char *name_);
42 43
43 rxvt_font (); 44 rxvt_font ();
44 virtual ~rxvt_font () { free (name); }; 45 virtual ~rxvt_font () { free (name); };
45 46
46 virtual void clear () { }; 47 virtual void clear () { };
54 55
55 virtual void draw (rxvt_drawable &d, 56 virtual void draw (rxvt_drawable &d,
56 int x, int y, 57 int x, int y,
57 const text_t *text, int len, 58 const text_t *text, int len,
58 int fg, int bg) = 0; 59 int fg, int bg) = 0;
60
61 void unref ()
62 {
63 clear ();
64 delete this;
65 }
59}; 66};
60
61#define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0)
62 67
63struct rxvt_fallback_font; 68struct rxvt_fallback_font;
64 69
65struct rxvt_fontset { 70struct rxvt_fontset
71{
66 char *fontdesc; 72 char *fontdesc;
73
74 // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h
75#if USE_256_COLORS
76 enum { fontCount = 7 }; // 4 extra colors bits, 4 fewer fontcount bits
77#else
78 enum { fontCount = 127 };
79#endif
80
81 // index of first font in set
82 enum { firstFont = 2 };
67 83
68 rxvt_fontset (rxvt_term *term); 84 rxvt_fontset (rxvt_term *term);
69 ~rxvt_fontset (); 85 ~rxvt_fontset ();
70 86
71 bool populate (const char *desc); 87 bool populate (const char *desc);
72 void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; } 88 void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; }
73 int find_font (uint32_t unicode); 89 int find_font_idx (uint32_t unicode);
74 int find_font (const char *name) const; 90 int find_font (const char *name) const;
75 bool realize_font (int i); 91 bool realize_font (int i);
76 92
77 // font-id's MUST fit into a signed 16 bit integer, and within 0..255
78 rxvt_font *operator [] (int id) const 93 rxvt_font *operator [] (int id) const
79 { 94 {
80 return fonts[id & 0x7f]; 95 return fonts[id >> 1];
96 }
97
98 int
99 find_font (unicode_t unicode)
100 {
101 return min<int> ((fontCount << 1) | 1, find_font_idx (unicode));
81 } 102 }
82 103
83private: 104private:
84 rxvt_term *term; 105 rxvt_term *term;
85 rxvt_fontprop prop; 106 rxvt_fontprop prop;
90 typedef unsigned char pagemap[256]; 111 typedef unsigned char pagemap[256];
91 vector<pagemap *> fmap; 112 vector<pagemap *> fmap;
92 113
93 void clear (); 114 void clear ();
94 rxvt_font *new_font (const char *name, codeset cs); 115 rxvt_font *new_font (const char *name, codeset cs);
116 void prepare_font (rxvt_font *font, codeset cs);
95 void add_fonts (const char *desc); 117 void add_fonts (const char *desc);
118 void push_font (rxvt_font *font);
96}; 119};
97 120
98#endif /* _DEFAULTFONT_H_ */ 121#endif /* _DEFAULTFONT_H_ */
99 122

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines