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.6 by pcg, Thu Dec 4 00:43:26 2003 UTC vs.
Revision 1.12 by pcg, Fri Feb 13 13:28:17 2004 UTC

1/*
2 * $Id: defaultfont.h,v 1.6 2003/12/04 00:43:26 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"
21
22struct rxvt_fontprop {
23 enum {
24 medium = 100, bold = 200,
25 roman = 0, italic = 100,
26 };
27 int width, height;
28 int weight, slant;
29};
25 30
26struct rxvt_font { 31struct rxvt_font {
27 // managed by the fontset 32 // managed by the fontset
28 rxvt_t r; 33 rxvt_t r;
29 void set_term (rxvt_t r) { this->r = r; } 34 void set_term (rxvt_t r) { this->r = r; }
31 char *name; 36 char *name;
32 codeset cs; 37 codeset cs;
33 bool loaded; // wether we tried loading it before (not wether it's loaded) 38 bool loaded; // wether we tried loading it before (not wether it's loaded)
34 39
35 // managed by the font object 40 // managed by the font object
36 bool prop; // wether this is a proportional font or has other funny characteristics 41 bool slow; // wether this is a proportional font or has other funny characteristics
37 int ascent, descent, 42 int ascent, descent,
38 width, height; 43 width, height;
39 44
40 void set_name (char *name) 45 void set_name (char *name)
41 { 46 {
42 if (this->name) free (this->name); // let the compiler optimize 47 if (this->name) free (this->name); // let the compiler optimize
43 this->name = name; 48 this->name = name;
44 } 49 }
45 50
46 rxvt_font () { name = 0; } 51 rxvt_font () { name = 0; }
47 ~rxvt_font () { free (name); clear (); }; 52 ~rxvt_font () { free (name); };
48 53
49 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);
50 55
51 virtual void clear () { }; 56 virtual void clear () { };
52 57
53 virtual bool load (int maxheight) = 0; 58 virtual rxvt_fontprop properties () = 0;
59
60 virtual bool load (const rxvt_fontprop &prop) = 0;
54 virtual bool has_codepoint (uint32_t unicode) = 0; 61 virtual bool has_codepoint (uint32_t unicode) = 0;
55 62
56 virtual void draw (int x, int y, 63 virtual void draw (int x, int y,
57 const text_t *text, int len, 64 const text_t *text, int len,
58 int fg, int bg) = 0; 65 int fg, int bg) = 0;
59}; 66};
60 67
61//#define FONT_REF(obj) (obj)->refcnt++ 68#define FONT_UNREF(f) do { (f)->clear (); delete (f); } while (0)
62//#define FONT_UNREF(obj) if (!--(obj)->refcnt) delete (obj)
63#define FONT_UNREF(f) delete f
64 69
65struct rxvt_fallback_font; 70struct rxvt_fallback_font;
66 71
67struct rxvt_fontset { 72struct rxvt_fontset {
68 rxvt_fontset (rxvt_t r); 73 rxvt_fontset (rxvt_t r);
71 rxvt_font *new_font (const char *name, codeset cs); 76 rxvt_font *new_font (const char *name, codeset cs);
72 77
73 void populate (const char *desc); 78 void populate (const char *desc);
74 int find_font (uint32_t unicode); 79 int find_font (uint32_t unicode);
75 80
76 rxvt_font *operator [](int id) const 81 rxvt_font *operator [] (int id) const
77 { 82 {
78 return fonts[id]; 83 return fonts[id];
79 } 84 }
80 85
81 rxvt_font *base_font () const 86 rxvt_font *base_font () const
86private: 91private:
87 rxvt_t r; 92 rxvt_t r;
88 simplevec<rxvt_font *> fonts; 93 simplevec<rxvt_font *> fonts;
89 const rxvt_fallback_font *fallback; 94 const rxvt_fallback_font *fallback;
90 95
91 int height; 96 rxvt_fontprop base_prop;
92 int base_id; 97 int base_id;
93 98
94 bool realize_font (int i); 99 bool realize_font (int i);
95 void add_fonts (const char *desc); 100 void add_fonts (const char *desc);
96 void clear (); 101 void clear ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines