1 |
pcg |
1.1 |
/* |
2 |
|
|
* $Id: defaultfont.h,v 1.15 2003/11/24 04:23:20 root Exp $ |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#ifndef _DEFAULTFONT_H_ |
6 |
|
|
#define _DEFAULTFONT_H_ |
7 |
|
|
|
8 |
|
|
#ifdef HAVE_XSETLOCALE |
9 |
|
|
# define X_LOCALE |
10 |
|
|
# include <X11/Xlocale.h> |
11 |
|
|
#else |
12 |
|
|
# ifdef HAVE_SETLOCALE |
13 |
|
|
# include <locale.h> |
14 |
|
|
# endif |
15 |
|
|
#endif /* HAVE_XLOCALE */ |
16 |
|
|
|
17 |
|
|
#ifdef HAVE_NL_LANGINFO |
18 |
|
|
# include <langinfo.h> |
19 |
|
|
#endif |
20 |
|
|
|
21 |
|
|
#include "rxvtlib.h" |
22 |
|
|
#include "feature.h" |
23 |
|
|
#include "encoding.h" |
24 |
|
|
#include "rxvtvec.h" |
25 |
|
|
|
26 |
|
|
#include "defaultfont.intpro" /* PROTOS for internal routines */ |
27 |
|
|
|
28 |
|
|
typedef struct rxvt_vars rxvt_t; |
29 |
|
|
|
30 |
|
|
struct rxvt_font { |
31 |
|
|
// managed by the fontset |
32 |
|
|
#if EXPLICIT_CONTEXT |
33 |
|
|
rxvt_t *rxvt_term; |
34 |
|
|
void set_term (pR) { this->rxvt_term = R; } |
35 |
|
|
#else |
36 |
|
|
void set_term (pR) { } |
37 |
|
|
#endif |
38 |
|
|
char *name; |
39 |
|
|
codeset cs; |
40 |
|
|
bool loaded; |
41 |
|
|
|
42 |
|
|
// managed by the font object |
43 |
|
|
bool prop; // wether this is a proportional font or has other funny characteristics |
44 |
|
|
int ascent, descent, |
45 |
|
|
width, height; |
46 |
|
|
|
47 |
|
|
void set_name (char *name) |
48 |
|
|
{ |
49 |
|
|
if (this->name) free (this->name); // let the compiler optimize |
50 |
|
|
this->name = name; |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
rxvt_font () { name = 0; } |
54 |
|
|
~rxvt_font () { free (name); clear (); }; |
55 |
|
|
|
56 |
|
|
void clear_rect (int x, int y, int w, int h, int color); |
57 |
|
|
|
58 |
|
|
virtual void clear () { }; |
59 |
|
|
|
60 |
|
|
virtual bool load (int maxheight) = 0; |
61 |
|
|
virtual bool has_codepoint (uint32_t unicode) = 0; |
62 |
|
|
|
63 |
|
|
virtual void draw (int x, int y, |
64 |
|
|
const text_t *text, int len, |
65 |
|
|
int fg, int bg) = 0; |
66 |
|
|
}; |
67 |
|
|
|
68 |
|
|
//#define FONT_REF(obj) (obj)->refcnt++ |
69 |
|
|
//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj) |
70 |
|
|
#define FONT_UNREF(f) delete f |
71 |
|
|
|
72 |
|
|
struct rxvt_fallback_font; |
73 |
|
|
|
74 |
|
|
struct rxvt_fontset { |
75 |
|
|
rxvt_fontset (pR); |
76 |
|
|
~rxvt_fontset (); |
77 |
|
|
|
78 |
|
|
rxvt_font *new_font (const char *name, codeset cs); |
79 |
|
|
|
80 |
|
|
void populate (const char *desc); |
81 |
|
|
int find_font (uint32_t unicode); |
82 |
|
|
|
83 |
|
|
rxvt_font *operator [](int id) const |
84 |
|
|
{ |
85 |
|
|
return fonts[id]; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
rxvt_font *base_font () const |
89 |
|
|
{ |
90 |
|
|
return fonts[base_id]; |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
private: |
94 |
|
|
#ifdef EXPLICIT_CONTEXT |
95 |
|
|
rxvt_t *rxvt_term; |
96 |
|
|
#endif |
97 |
|
|
simplevec<rxvt_font *> fonts; |
98 |
|
|
const rxvt_fallback_font *fallback; |
99 |
|
|
|
100 |
|
|
int height; |
101 |
|
|
int base_id; |
102 |
|
|
|
103 |
|
|
bool realize_font (int i); |
104 |
|
|
void add_fonts (const char *desc); |
105 |
|
|
void clear (); |
106 |
|
|
}; |
107 |
|
|
|
108 |
|
|
#endif /* _DEFAULTFONT_H_ */ |
109 |
|
|
|