Fix for segfault in top_name stuff.
[monky] / src / fonts.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  *
3  * Conky, a system monitor, based on torsmo
4  *
5  * Any original torsmo code is licensed under the BSD license
6  *
7  * All code written since the fork of torsmo is licensed under the GPL
8  *
9  * Please see COPYING for details
10  *
11  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
12  * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
13  *      (see AUTHORS)
14  * All rights reserved.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * You should have received a copy of the GNU General Public License
26  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29 #ifdef X11
30 #ifndef _FONTS_H
31 #define _FONTS_H
32
33 #include "x11.h"
34
35 /* for fonts */
36 struct font_list {
37
38         char name[DEFAULT_TEXT_BUFFER_SIZE];
39         int num;
40         XFontStruct *font;
41
42 #ifdef XFT
43         XftFont *xftfont;
44         int font_alpha;
45 #endif
46 };
47
48 #ifdef XFT
49
50 #define font_height() (use_xft ? (fonts[selected_font].xftfont->ascent + \
51         fonts[selected_font].xftfont->descent) \
52         : (fonts[selected_font].font->max_bounds.ascent + \
53         fonts[selected_font].font->max_bounds.descent))
54 #define font_ascent() (use_xft ? fonts[selected_font].xftfont->ascent \
55         : fonts[selected_font].font->max_bounds.ascent)
56 #define font_descent() (use_xft ? fonts[selected_font].xftfont->descent \
57         : fonts[selected_font].font->max_bounds.descent)
58
59 #else
60
61 #define font_height() (fonts[selected_font].font->max_bounds.ascent + \
62         fonts[selected_font].font->max_bounds.descent)
63 #define font_ascent() fonts[selected_font].font->max_bounds.ascent
64 #define font_descent() fonts[selected_font].font->max_bounds.descent
65
66 #endif
67
68 #define MAX_FONTS 256
69
70 /* direct access to registered fonts (FIXME: bad encapsulation) */
71 extern struct font_list *fonts;
72 extern int selected_font;
73 extern int font_count;
74
75 void setup_fonts(void);
76 void set_font(void);
77 int add_font(const char *);
78 void set_first_font(const char *);
79 void free_fonts(void);
80 void load_fonts(void);
81
82 #endif /* _FONTS_H */
83 #endif /* X11 */