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.4 by pcg, Tue Nov 25 11:52:42 2003 UTC vs.
Revision 1.21 by root, Wed Aug 11 01:36:51 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines