ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.h
Revision: 1.22
Committed: Sun Aug 27 10:10:25 2006 UTC (17 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-8_1, rel-8_2, rel-8_0
Changes since 1.21: +3 -2 lines
Log Message:
*** empty log message ***

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 #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 #include "rxvttoolkit.h"
28
29 struct rxvt_term;
30
31 struct rxvt_fontprop {
32 enum {
33 unset = -1,
34 medium = 100, bold = 200,
35 roman = 0, italic = 100,
36 };
37 int width, height, ascent;
38 int weight, slant;
39 };
40
41 struct rxvt_font {
42 // managed by the fontset
43 rxvt_term *term;
44 void set_term (rxvt_term *term) { this->term = term; }
45
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 void set_name (char *name);
55
56 rxvt_font ();
57 virtual ~rxvt_font () { free (name); };
58
59 virtual void clear () { };
60
61 void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const;
62
63 virtual rxvt_fontprop properties () = 0;
64
65 virtual bool load (const rxvt_fontprop &morph, bool force_prop) = 0;
66 virtual bool has_char (uint32_t unicode, const rxvt_fontprop *prop, bool &careful) const = 0;
67
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 rxvt_fontset (rxvt_term *term);
82 ~rxvt_fontset ();
83
84 bool populate (const char *desc);
85 void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; }
86 int find_font (uint32_t unicode);
87 int find_font (const char *name) const;
88 bool realize_font (int i);
89
90 // font-id's MUST fit into a signed 16 bit integer, and within 0..255
91 rxvt_font *operator [] (int id) const
92 {
93 return fonts[id & 0x7f];
94 }
95
96 private:
97 rxvt_term *term;
98 rxvt_fontprop prop;
99 bool force_prop;
100 simplevec<rxvt_font *> fonts;
101 const rxvt_fallback_font *fallback;
102
103 typedef unsigned char pagemap[256];
104 vector<pagemap *> fmap;
105
106 void clear ();
107 rxvt_font *new_font (const char *name, codeset cs);
108 void add_fonts (const char *desc);
109 };
110
111 #endif /* _DEFAULTFONT_H_ */
112