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