ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.h
(Generate patch)

Comparing rxvt-unicode/src/defaultfont.h (file contents):
Revision 1.3 by pcg, Tue Nov 25 09:29:11 2003 UTC vs.
Revision 1.15 by pcg, Fri Feb 27 02:52:51 2004 UTC

1/* 1#ifndef DEFAULTFONT_H_
2 * $Id: defaultfont.h,v 1.3 2003/11/25 09:29:11 pcg Exp $ 2#define DEFAULTFONT_H_
3 */
4 3
5#ifndef _DEFAULTFONT_H_ 4#include <X11/Xlib.h>
6#define _DEFAULTFONT_H_ 5#if XFT
6# include <X11/Xft/Xft.h>
7#endif
7 8
8#ifdef HAVE_XSETLOCALE 9#ifdef HAVE_XSETLOCALE
9# define X_LOCALE 10# define X_LOCALE
10# include <X11/Xlocale.h> 11# include <X11/Xlocale.h>
11#else 12#else
19#endif 20#endif
20 21
21#include "rxvtlib.h" 22#include "rxvtlib.h"
22#include "feature.h" 23#include "feature.h"
23#include "encoding.h" 24#include "encoding.h"
24#include "rxvtvec.h" 25#include "rxvtstl.h"
25 26
26typedef struct rxvt_vars rxvt_t; 27struct rxvt_fontprop {
28 enum {
29 medium = 100, bold = 200,
30 roman = 0, italic = 100,
31 };
32 int width, height;
33 int weight, slant;
34};
35
36struct rxvt_drawable {
37 rxvt_display *display;
38 Drawable drawable;
39#if XFT
40 XftDraw *xftdrawable;
41 operator XftDraw *();
42#endif
43
44 rxvt_drawable (rxvt_display *display, Drawable drawable)
45 : display(display),
46#if XFT
47 xftdrawable(0),
48#endif
49 drawable(drawable)
50 { }
51
52#if XFT
53 ~rxvt_drawable ();
54#endif
55
56 operator Drawable() { return drawable; }
57};
27 58
28struct rxvt_font { 59struct rxvt_font {
29 // managed by the fontset 60 // managed by the fontset
30#if EXPLICIT_CONTEXT 61 rxvt_t r;
31 rxvt_t *rxvt_term; 62 void set_term (rxvt_t r) { this->r = r; }
32 void set_term (pR) { this->rxvt_term = R; } 63
33#else
34 void set_term (pR) { }
35#endif
36 char *name; 64 char *name;
37 codeset cs; 65 codeset cs;
38 bool loaded; 66 bool loaded; // wether we tried loading it before (not wether it's loaded)
39 67
40 // managed by the font object 68 // managed by the font object
41 bool prop; // wether this is a proportional font or has other funny characteristics 69 bool slow; // wether this is a proportional font or has other funny characteristics
42 int ascent, descent, 70 int ascent, descent,
43 width, height; 71 width, height;
44 72
45 void set_name (char *name) 73 void set_name (char *name)
46 { 74 {
47 if (this->name) free (this->name); // let the compiler optimize 75 if (this->name) free (this->name); // let the compiler optimize
48 this->name = name; 76 this->name = name;
49 } 77 }
50 78
51 rxvt_font () { name = 0; } 79 rxvt_font () { name = 0; }
52 ~rxvt_font () { free (name); clear (); }; 80 ~rxvt_font () { free (name); };
53 81
54 void clear_rect (int x, int y, int w, int h, int color); 82 void clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color);
55 83
56 virtual void clear () { }; 84 virtual void clear () { };
57 85
58 virtual bool load (int maxheight) = 0; 86 virtual rxvt_fontprop properties () = 0;
87
88 virtual bool load (const rxvt_fontprop &prop) = 0;
59 virtual bool has_codepoint (uint32_t unicode) = 0; 89 virtual bool has_codepoint (uint32_t unicode) = 0;
60 90
61 virtual void draw (int x, int y, 91 virtual void draw (rxvt_drawable &d,
92 int x, int y,
62 const text_t *text, int len, 93 const text_t *text, int len,
63 int fg, int bg) = 0; 94 int fg, int bg) = 0;
64}; 95};
65 96
66//#define FONT_REF(obj) (obj)->refcnt++ 97#define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0)
67//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj)
68#define FONT_UNREF(f) delete f
69 98
70struct rxvt_fallback_font; 99struct rxvt_fallback_font;
71 100
72struct rxvt_fontset { 101struct rxvt_fontset {
73 rxvt_fontset (pR); 102 rxvt_fontset (rxvt_t r);
74 ~rxvt_fontset (); 103 ~rxvt_fontset ();
75 104
76 rxvt_font *new_font (const char *name, codeset cs); 105 rxvt_font *new_font (const char *name, codeset cs);
77 106
78 void populate (const char *desc); 107 bool populate (const char *desc);
79 int find_font (uint32_t unicode); 108 int find_font (uint32_t unicode);
80 109
81 rxvt_font *operator [](int id) const 110 rxvt_font *operator [] (int id) const
82 { 111 {
83 return fonts[id]; 112 return fonts[id];
84 } 113 }
85 114
86 rxvt_font *base_font () const 115 rxvt_font *base_font () const
87 { 116 {
88 return fonts[base_id]; 117 return fonts[base_id];
89 } 118 }
90 119
91private: 120private:
92#ifdef EXPLICIT_CONTEXT 121 rxvt_t r;
93 rxvt_t *rxvt_term;
94#endif
95 simplevec<rxvt_font *> fonts; 122 simplevec<rxvt_font *> fonts;
96 const rxvt_fallback_font *fallback; 123 const rxvt_fallback_font *fallback;
97 124
98 int height; 125 rxvt_fontprop base_prop;
99 int base_id; 126 int base_id;
100 127
101 bool realize_font (int i); 128 bool realize_font (int i);
102 void add_fonts (const char *desc); 129 void add_fonts (const char *desc);
103 void clear (); 130 void clear ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines