File: 03_font_setting_fix.diff

package info (click to toggle)
dclock 2.2.2-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772 kB
  • sloc: ansic: 2,071; makefile: 749
file content (281 lines) | stat: -rw-r--r-- 8,405 bytes parent folder | download | duplicates (9)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
Subject: fix setting font via toolkit options
Author: "Robert J. Macomber" <xbylpv@rojoma.com>
Bug-Debian: http://bugs.debian.org/514277
--- a/Dclock.c
+++ b/Dclock.c
@@ -165,7 +165,7 @@ static XtResource resources[] = {
 	XtOffset(DclockWidget,dclock.font), XtRString, "fixed"},
 #ifdef XFT_SUPPORT
     { XftNfontName, "fontName", XtRString, sizeof(String),
-	XtOffset(DclockWidget,dclock.xftfontname), XtRString, "charter"},
+	XtOffset(DclockWidget,dclock.xftfontname), XtRString, NULL},
 #endif
     { XtNangle, "Slope", XtRFloat, sizeof(float),
 	XtOffset(DclockWidget,dclock.angle), XtRFloat, (caddr_t)&sslope},
@@ -344,6 +344,12 @@ typedef XfPoint segment_pts[NUM_SEGS][MAX_PTS];
 segment_pts tiny_segment_pts;
 segment_pts norm_segment_pts;
 
+#ifdef XFT_SUPPORT
+#define XFT_COND(dclock) ((dclock).xftfontname)
+#else
+#define XFT_COND(dclock) (0)
+#endif
+
 /* ARGSUSED */
 static void
 Initialize (request, new)
@@ -386,11 +392,13 @@ DclockWidget   new;
     if (new->dclock.sec_gap < 0.0) new->dclock.sec_gap = 0.0;
 
 #ifdef XFT_SUPPORT
-    new->dclock.xftfont = XftFontOpen(dpy, DefaultScreen(dpy),
+    if (XFT_COND(new->dclock)) {
+       new->dclock.xftfont = XftFontOpen(dpy, DefaultScreen(dpy),
 		XFT_FAMILY, XftTypeString, new->dclock.xftfontname,
 		XFT_SIZE, XftTypeDouble, ((float)new->core.height / 6.0) - 4.0,
 		NULL);
-    new->dclock.xftdraw = NULL;
+       new->dclock.xftdraw = NULL;
+    }
 #endif
 
     GetGC(new);
@@ -447,11 +455,11 @@ DclockWidget   new;
     if (new->dclock.date_fmt && !*new->dclock.date_fmt)
 	new->dclock.date_fmt = NULL;
     if (new->dclock.dateup && new->dclock.date_fmt)
-#ifdef XFT_SUPPORT
+    if (XFT_COND(new->dclock)) {
 	TopOffset = new->core.height / 6;
-#else
+    } else {
 	TopOffset = new->dclock.font->ascent + new->dclock.font->descent;
-#endif
+    }
 
     else
 	TopOffset = 0;
@@ -519,7 +527,7 @@ XSetWindowAttributes *attrs;
     XtCreateWindow(w, InputOutput, (Visual *)CopyFromParent, *valueMask, attrs);
 
 #ifdef XFT_SUPPORT
-    if (dw->dclock.xftdraw == NULL) {
+    if (XFT_COND(dw->dclock) && dw->dclock.xftdraw == NULL) {
 	XColor color;
 	Colormap cm = DefaultColormap(dp, sc);
 
@@ -574,7 +582,8 @@ DclockWidget w;
     XDestroyRegion(clip_colon);
 
 #ifdef XFT_SUPPORT
-    XftFontClose(XtDisplay(w), w->dclock.xftfont);
+    if (XFT_COND(w->dclock))
+	XftFontClose(XtDisplay(w), w->dclock.xftfont);
 #endif
 }
 
@@ -596,11 +605,13 @@ DclockWidget    w;
     winheight = w->core.height;
 
 #ifdef XFT_SUPPORT
-    XftFontClose(dpy, w->dclock.xftfont);
-    w->dclock.xftfont = XftFontOpen(dpy, DefaultScreen(dpy),
+    if(XFT_COND(w->dclock)) {
+	XftFontClose(dpy, w->dclock.xftfont);
+	w->dclock.xftfont = XftFontOpen(dpy, DefaultScreen(dpy),
 		XFT_FAMILY, XftTypeString, w->dclock.xftfontname,
 		XFT_SIZE, XftTypeDouble, ((float)winheight / 6.0) - 4.0,
 		NULL);
+    }
 #endif
 
     y_ratio = (float)winheight / CLOCK_HEIGHT;
@@ -608,11 +619,13 @@ DclockWidget    w;
     if (w->dclock.date_fmt || !w->dclock.display_time || w->dclock.alarm ||
 	w->dclock.bell)
 	/* make win temporarily shorter so digits will fit on top of date */
-#ifdef XFT_SUPPORT
-	winheight -= w->core.height / 6;
-#else
-	winheight -= w->dclock.font->ascent + w->dclock.font->descent;
-#endif
+    {
+	if(XFT_COND(w->dclock)) {
+	    winheight -= w->core.height / 6;
+	} else {
+	    winheight -= w->dclock.font->ascent + w->dclock.font->descent;
+	}
+    }
 
     /*
      * if the width of all segments are equal, then the width in x is the
@@ -1669,51 +1682,60 @@ struct tm *now;
     char datestr[128];
     register char *p;
     int x, datep;
+    int tsize;
 #ifdef XFT_SUPPORT
-    int tsize = w->core.height / 6;
     XGlyphInfo xftextents;
-#else
-    int tsize = w->dclock.font->ascent + w->dclock.font->descent;
 #endif
 
+    if (XFT_COND(w->dclock)) {
+	tsize = w->core.height / 6;
+    } else {
+	tsize = w->dclock.font->ascent + w->dclock.font->descent;
+    }
+
     if (!w->dclock.display_time)
 	datep = strlen(strcpy(datestr, "Push HERE to Set/Unset Alarm"));
     else
         datep = strftime(datestr, 128, w->dclock.date_fmt, now);
 
+    if (XFT_COND(w->dclock)) {
 #ifdef XFT_SUPPORT
-    XftTextExtents8(dpy, w->dclock.xftfont, datestr, datep, &xftextents);
-    x = (w->core.width - xftextents.width) / 2;
-#else
-    x = (w->core.width - XTextWidth(w->dclock.font, datestr, datep)) / 2;
+	XftTextExtents8(dpy, w->dclock.xftfont, datestr, datep, &xftextents);
+	x = (w->core.width - xftextents.width) / 2;
 #endif
+    } else {
+	x = (w->core.width - XTextWidth(w->dclock.font, datestr, datep)) / 2;
+    }
+
     if (x < 2)
 	x = 2;
     if (TopOffset) {
-
+	if (XFT_COND(w->dclock)) {
 #ifdef XFT_SUPPORT
-	XftDrawRect(w->dclock.xftdraw, &w->dclock.xftbg, 0, 0, winwidth, tsize);
-	XftDrawString8(w->dclock.xftdraw, &w->dclock.xftfg, w->dclock.xftfont, x,
+	    XftDrawRect(w->dclock.xftdraw, &w->dclock.xftbg, 0, 0, winwidth, tsize);
+	    XftDrawString8(w->dclock.xftdraw, &w->dclock.xftfg, w->dclock.xftfont, x,
 		(BORDER/2) + tsize - 2, datestr, datep);
-#else
-	XFillRectangle(dpy, win, w->dclock.backGC,
-	    0, 0, winwidth, tsize);
-	XDrawString(dpy, win, w->dclock.foreGC,
-		x, ((BORDER/2)+w->dclock.xftfont->height), datestr, datep);
 #endif
+	} else {
+	    XFillRectangle(dpy, win, w->dclock.backGC,
+		0, 0, winwidth, tsize);
+	    XDrawString(dpy, win, w->dclock.foreGC,
+		x, ((BORDER/2)+tsize), datestr, datep);
+	}
     } else {
-
+	if (XFT_COND(w->dclock)) {
 #ifdef XFT_SUPPORT
-	XftDrawRect(w->dclock.xftdraw, &w->dclock.xftbg, 0, winheight - tsize,
+	    XftDrawRect(w->dclock.xftdraw, &w->dclock.xftbg, 0, winheight - tsize,
 		winwidth, tsize);
-	XftDrawString8(w->dclock.xftdraw, &w->dclock.xftfg, w->dclock.xftfont, x,
+	    XftDrawString8(w->dclock.xftdraw, &w->dclock.xftfg, w->dclock.xftfont, x,
 		winheight - BORDER - 2, datestr, datep);
-#else
-	XFillRectangle(dpy, win, w->dclock.backGC,
-	    0, winheight - tsize, winwidth, tsize);
-	XDrawString(dpy, win, w->dclock.foreGC,
-		x, winheight - BORDER, datestr, datep);
 #endif
+	} else {
+	    XFillRectangle(dpy, win, w->dclock.backGC,
+		0, winheight - tsize, winwidth, tsize);
+	    XDrawString(dpy, win, w->dclock.foreGC,
+		x, winheight - BORDER, datestr, datep);
+	}
     }
 }
 
@@ -1992,13 +2014,13 @@ DclockWidget w;
     w->dclock.date_fmt = saved_date;
     saved_date = tmp;
 
-    if (w->dclock.dateup && w->dclock.date_fmt)
-#ifdef XFT_SUPPORT
-	TopOffset = w->core.height / 6;
-#else
-	TopOffset = w->dclock.font->ascent + w->dclock.font->descent;
-#endif
-    else
+    if (w->dclock.dateup && w->dclock.date_fmt) {
+	if (XFT_COND(w->dclock)) {
+	    TopOffset = w->core.height / 6;
+	} else {
+	    TopOffset = w->dclock.font->ascent + w->dclock.font->descent;
+	}
+    } else
 	TopOffset = 0;
 
     before.tm_wday = -1;
@@ -2021,13 +2043,13 @@ DclockWidget w;
     XtSetArg(arg, XtNdateUp, !w->dclock.dateup);
     XtSetValues((Widget)w, &arg, 1);
 
-    if (w->dclock.dateup && w->dclock.date_fmt)
-#ifdef XFT_SUPPORT
-	TopOffset = w->core.height / 6;
-#else
-	TopOffset = w->dclock.font->ascent + w->dclock.font->descent;
-#endif
-    else
+    if (w->dclock.dateup && w->dclock.date_fmt) {
+	if (XFT_COND(w->dclock)) {
+	    TopOffset = w->core.height / 6;
+	} else {
+	    TopOffset = w->dclock.font->ascent + w->dclock.font->descent;
+	}
+    } else
 	TopOffset = 0;
 
     ResizeNow(w);
@@ -2184,20 +2206,20 @@ XButtonEvent *event;
 	 */
 	int i, x, y = (int)((BORDER/2)*y_ratio) + TopOffset;
 	/* first check to see if user toggles the alarm */
-#ifdef XFT_SUPPORT
-	if (TopOffset)
+	if (XFT_COND(w->dclock)) {
+	    if (TopOffset)
 		i = (BORDER + (w->core.height / 6))
 			- event->y;
-	else
+	    else
 		i = event->y - (winheight - (w->core.height / 6));
-#else
-	if (TopOffset)
+	} else {
+	    if (TopOffset)
 		i = (BORDER + (w->dclock.font->ascent + w->dclock.font->descent))
 			- event->y;
-	else
+	    else
 		i = event->y - (winheight - (w->dclock.font->ascent
 			+ w->dclock.font->descent));
-#endif
+	}
 	if (i >= 0)
 	    toggle_alarm(w);
 	else for (i = 0; i < 4; i++) {
diff --git a/DclockP.h b/DclockP.h
index bb2c29e..ded7802 100644
--- a/DclockP.h
+++ b/DclockP.h
@@ -9,8 +9,9 @@
 #include "Dclock.h"
 
 /* Add -DXFT_SUPPORT in the Imakefile for freefont support */
+#ifdef XFT_SUPPORT
 #include <X11/Xft/Xft.h>
-
+#endif
 
 typedef struct {
     Pixel      		foreground;