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.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.19 by root, Mon Jul 26 14:57:12 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines