ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.h
Revision: 1.24
Committed: Thu Oct 18 09:11:43 2007 UTC (16 years, 7 months ago) by ayin
Content type: text/plain
Branch: MAIN
CVS Tags: rel-8_5a, rel-8_9, rel-8_8, rel-8_4, rel-9_0, rel-8_6, rel-8_7, rel-9_02, rel-9_01, rel-9_05
Changes since 1.23: +0 -13 lines
Log Message:
include cleanup.

File Contents

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