| 1 |
root |
1.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 |
root |
1.12 |
#include "rxvttoolkit.h" |
| 15 |
|
|
|
| 16 |
|
|
struct rxvt_term; |
| 17 |
root |
1.1 |
|
| 18 |
root |
1.25 |
struct rxvt_fontprop |
| 19 |
|
|
{ |
| 20 |
root |
1.1 |
enum { |
| 21 |
root |
1.12 |
unset = -1, |
| 22 |
root |
1.1 |
medium = 100, bold = 200, |
| 23 |
|
|
roman = 0, italic = 100, |
| 24 |
|
|
}; |
| 25 |
root |
1.17 |
int width, height, ascent; |
| 26 |
root |
1.1 |
int weight, slant; |
| 27 |
|
|
}; |
| 28 |
|
|
|
| 29 |
root |
1.25 |
struct rxvt_font |
| 30 |
|
|
{ |
| 31 |
root |
1.1 |
// managed by the fontset |
| 32 |
root |
1.18 |
rxvt_term *term; |
| 33 |
|
|
void set_term (rxvt_term *term) { this->term = term; } |
| 34 |
root |
1.1 |
|
| 35 |
|
|
char *name; |
| 36 |
|
|
codeset cs; |
| 37 |
sf-exg |
1.31 |
bool loaded; // whether we tried loading it before (not whether it's loaded) |
| 38 |
root |
1.1 |
|
| 39 |
|
|
// managed by the font object |
| 40 |
|
|
int ascent, descent, |
| 41 |
|
|
width, height; |
| 42 |
|
|
|
| 43 |
root |
1.26 |
void set_name (char *name_); |
| 44 |
root |
1.1 |
|
| 45 |
root |
1.20 |
rxvt_font (); |
| 46 |
root |
1.12 |
virtual ~rxvt_font () { free (name); }; |
| 47 |
|
|
|
| 48 |
|
|
virtual void clear () { }; |
| 49 |
root |
1.1 |
|
| 50 |
root |
1.18 |
void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const; |
| 51 |
root |
1.1 |
|
| 52 |
|
|
virtual rxvt_fontprop properties () = 0; |
| 53 |
|
|
|
| 54 |
root |
1.22 |
virtual bool load (const rxvt_fontprop &morph, bool force_prop) = 0; |
| 55 |
root |
1.18 |
virtual bool has_char (uint32_t unicode, const rxvt_fontprop *prop, bool &careful) const = 0; |
| 56 |
root |
1.1 |
|
| 57 |
|
|
virtual void draw (rxvt_drawable &d, |
| 58 |
|
|
int x, int y, |
| 59 |
|
|
const text_t *text, int len, |
| 60 |
|
|
int fg, int bg) = 0; |
| 61 |
root |
1.37 |
|
| 62 |
|
|
void unref () |
| 63 |
|
|
{ |
| 64 |
|
|
clear (); |
| 65 |
|
|
delete this; |
| 66 |
|
|
} |
| 67 |
root |
1.1 |
}; |
| 68 |
|
|
|
| 69 |
|
|
struct rxvt_fallback_font; |
| 70 |
|
|
|
| 71 |
root |
1.25 |
struct rxvt_fontset |
| 72 |
|
|
{ |
| 73 |
root |
1.1 |
char *fontdesc; |
| 74 |
|
|
|
| 75 |
sf-exg |
1.36 |
enum { fontCount = 7 }; // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h |
| 76 |
root |
1.35 |
enum { firstFont = 2 }; // index of first font in set |
| 77 |
root |
1.27 |
|
| 78 |
root |
1.18 |
rxvt_fontset (rxvt_term *term); |
| 79 |
root |
1.1 |
~rxvt_fontset (); |
| 80 |
|
|
|
| 81 |
root |
1.13 |
bool populate (const char *desc); |
| 82 |
root |
1.22 |
void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; } |
| 83 |
sf-exg |
1.32 |
int find_font_idx (uint32_t unicode); |
| 84 |
root |
1.1 |
int find_font (const char *name) const; |
| 85 |
root |
1.12 |
bool realize_font (int i); |
| 86 |
root |
1.1 |
|
| 87 |
root |
1.30 |
rxvt_font *operator [] (int id) const |
| 88 |
root |
1.1 |
{ |
| 89 |
root |
1.33 |
return fonts[id >> 1]; |
| 90 |
root |
1.1 |
} |
| 91 |
|
|
|
| 92 |
root |
1.34 |
int |
| 93 |
|
|
find_font (unicode_t unicode) |
| 94 |
|
|
{ |
| 95 |
|
|
return min<int> ((fontCount << 1) | 1, find_font_idx (unicode)); |
| 96 |
|
|
} |
| 97 |
|
|
|
| 98 |
root |
1.1 |
private: |
| 99 |
root |
1.18 |
rxvt_term *term; |
| 100 |
root |
1.13 |
rxvt_fontprop prop; |
| 101 |
root |
1.22 |
bool force_prop; |
| 102 |
root |
1.1 |
simplevec<rxvt_font *> fonts; |
| 103 |
|
|
const rxvt_fallback_font *fallback; |
| 104 |
|
|
|
| 105 |
root |
1.12 |
typedef unsigned char pagemap[256]; |
| 106 |
|
|
vector<pagemap *> fmap; |
| 107 |
root |
1.1 |
|
| 108 |
root |
1.13 |
void clear (); |
| 109 |
|
|
rxvt_font *new_font (const char *name, codeset cs); |
| 110 |
root |
1.34 |
void prepare_font (rxvt_font *font, codeset cs); |
| 111 |
root |
1.1 |
void add_fonts (const char *desc); |
| 112 |
root |
1.34 |
void push_font (rxvt_font *font); |
| 113 |
root |
1.1 |
}; |
| 114 |
|
|
|
| 115 |
|
|
#endif /* _DEFAULTFONT_H_ */ |
| 116 |
|
|
|