Package: conky / 1.9.0-6

fix-font-check.patch Patch series | download
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
Description: Check if a font has been loaded before instead of adding it possibly multiple times
Origin: upstream, https://github.com/brndnmtthws/conky/pull/47
Bug-Debian: https://bugs.debian.org/746477

--- a/src/specials.c
+++ b/src/specials.c
@@ -330,6 +330,15 @@
 }
 
 #ifdef X11
+int find_font(char *name)
+{
+	int i;
+	for (i = 0; i < font_count; i++)
+		if (strncmp(name, fonts[i].name, DEFAULT_TEXT_BUFFER_SIZE) == EQUAL)
+			return i;
+	return 0;
+}
+
 void new_font(char *buf, char *args)
 {
 	if ((output_methods & TO_X) == 0)
@@ -337,6 +346,12 @@
 
 	if (args) {
 		struct special_t *s = new_special(buf, FONT);
+		int index;
+		if (index = find_font(args))
+		{
+			s->font_added = index;
+			return;
+		}
 
 		if (s->font_added > font_count || !s->font_added || (strncmp(args, fonts[s->font_added].name, DEFAULT_TEXT_BUFFER_SIZE) != EQUAL) ) {
 			int tmp = selected_font;