1 | /* |
|
|
2 | * $Id: defaultfont.h,v 1.7 2003/12/18 04:14:30 pcg Exp $ |
|
|
3 | */ |
|
|
4 | |
|
|
5 | #ifndef _DEFAULTFONT_H_ |
1 | #ifndef DEFAULTFONT_H_ |
6 | #define _DEFAULTFONT_H_ |
2 | #define DEFAULTFONT_H_ |
7 | |
3 | |
8 | #ifdef HAVE_XSETLOCALE |
4 | #ifdef HAVE_XSETLOCALE |
9 | # define X_LOCALE |
5 | # define X_LOCALE |
10 | # include <X11/Xlocale.h> |
6 | # include <X11/Xlocale.h> |
11 | #else |
7 | #else |
… | |
… | |
19 | #endif |
15 | #endif |
20 | |
16 | |
21 | #include "rxvtlib.h" |
17 | #include "rxvtlib.h" |
22 | #include "feature.h" |
18 | #include "feature.h" |
23 | #include "encoding.h" |
19 | #include "encoding.h" |
24 | #include "rxvtvec.h" |
20 | #include "rxvtstl.h" |
25 | |
21 | |
26 | struct rxvt_fontprop { |
22 | struct rxvt_fontprop { |
27 | enum { |
23 | enum { |
28 | medium = 100, bold = 200, |
24 | medium = 100, bold = 200, |
29 | roman = 0, italic = 100, |
25 | roman = 0, italic = 100, |
30 | }; |
26 | }; |
31 | int height; |
27 | int width, height; |
32 | int weight; |
28 | int weight, slant; |
33 | int slant; |
|
|
34 | }; |
29 | }; |
35 | |
30 | |
36 | struct rxvt_font { |
31 | struct rxvt_font { |
37 | // managed by the fontset |
32 | // managed by the fontset |
38 | rxvt_t r; |
33 | rxvt_t r; |
… | |
… | |
52 | if (this->name) free (this->name); // let the compiler optimize |
47 | if (this->name) free (this->name); // let the compiler optimize |
53 | this->name = name; |
48 | this->name = name; |
54 | } |
49 | } |
55 | |
50 | |
56 | rxvt_font () { name = 0; } |
51 | rxvt_font () { name = 0; } |
57 | ~rxvt_font () { free (name); clear (); }; |
52 | ~rxvt_font () { free (name); }; |
58 | |
53 | |
59 | void clear_rect (int x, int y, int w, int h, int color); |
54 | void clear_rect (int x, int y, int w, int h, int color); |
60 | |
55 | |
61 | virtual void clear () { }; |
56 | virtual void clear () { }; |
62 | |
57 | |
… | |
… | |
68 | virtual void draw (int x, int y, |
63 | virtual void draw (int x, int y, |
69 | const text_t *text, int len, |
64 | const text_t *text, int len, |
70 | int fg, int bg) = 0; |
65 | int fg, int bg) = 0; |
71 | }; |
66 | }; |
72 | |
67 | |
73 | //#define FONT_REF(obj) (obj)->refcnt++ |
68 | #define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0) |
74 | //#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj) |
|
|
75 | #define FONT_UNREF(f) delete f |
|
|
76 | |
69 | |
77 | struct rxvt_fallback_font; |
70 | struct rxvt_fallback_font; |
78 | |
71 | |
79 | struct rxvt_fontset { |
72 | struct rxvt_fontset { |
80 | rxvt_fontset (rxvt_t r); |
73 | rxvt_fontset (rxvt_t r); |
81 | ~rxvt_fontset (); |
74 | ~rxvt_fontset (); |
82 | |
75 | |
83 | rxvt_font *new_font (const char *name, codeset cs); |
76 | rxvt_font *new_font (const char *name, codeset cs); |
84 | |
77 | |
85 | void populate (const char *desc); |
78 | bool populate (const char *desc); |
86 | int find_font (uint32_t unicode); |
79 | int find_font (uint32_t unicode); |
87 | |
80 | |
88 | rxvt_font *operator [](int id) const |
81 | rxvt_font *operator [] (int id) const |
89 | { |
82 | { |
90 | return fonts[id]; |
83 | return fonts[id]; |
91 | } |
84 | } |
92 | |
85 | |
93 | rxvt_font *base_font () const |
86 | rxvt_font *base_font () const |