forked from jgmenu/jgmenu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont.c
75 lines (64 loc) · 1.32 KB
/
font.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* font.c - a helper to find 'the' font */
#include "font.h"
#include "xsettings-helper.h"
#include "t2conf.h"
#include "config.h"
#include "gtkconf.h"
#include "sbuf.h"
#include "util.h"
static struct sbuf font;
static int font_has_been_set;
char *font_get(void)
{
if (!font_has_been_set)
die("font_get() requires font to have been set");
return font.buf;
}
void font_set(void)
{
char *t = NULL;
int i;
char *fb = config.font_fallback;
if (font_has_been_set)
warn("font_set() is only meant to be run once");
font_has_been_set = 1;
sbuf_init(&font);
if (config.font && config.font[0]) {
sbuf_cpy(&font, config.font);
info("got font from jgmenurc");
return;
}
/* Use fall back options */
for (i = 0; fb[i]; i++)
switch (fb[i]) {
case 'x':
if (t2conf_get_override_xsettings())
break;
if (xsettings_get(&font, "Gtk/FontName") == 0) {
info("got font from xsettings");
return;
}
break;
case 't':
t2conf_get_font(&t);
if (t) {
sbuf_cpy(&font, t);
info("got font from tint2rc");
return;
}
break;
case 'g':
gtkconf_get(&font, "gtk-font-name");
if (font.len) {
info("got font from gtk config file");
return;
}
break;
}
warn("set font to 'Sans 11' because all else failed");
sbuf_cpy(&font, "Sans 10");
}
void font_cleanup(void)
{
xfree(font.buf);
}