Lines 14-20
Link Here
|
14 |
#include <libtu/objp.h> |
14 |
#include <libtu/objp.h> |
15 |
#include <ioncore/common.h> |
15 |
#include <ioncore/common.h> |
16 |
#include "font.h" |
16 |
#include "font.h" |
|
|
17 |
#ifndef XFT |
17 |
#include "fontset.h" |
18 |
#include "fontset.h" |
|
|
19 |
#endif /* ! XFT */ |
18 |
#include "brush.h" |
20 |
#include "brush.h" |
19 |
|
21 |
|
20 |
|
22 |
|
Lines 26-31
Link Here
|
26 |
|
28 |
|
27 |
DEFont *de_load_font(const char *fontname) |
29 |
DEFont *de_load_font(const char *fontname) |
28 |
{ |
30 |
{ |
|
|
31 |
#ifdef XFT |
32 |
XftFont *font; |
33 |
#endif |
29 |
DEFont *fnt; |
34 |
DEFont *fnt; |
30 |
XFontSet fontset=NULL; |
35 |
XFontSet fontset=NULL; |
31 |
XFontStruct *fontstruct=NULL; |
36 |
XFontStruct *fontstruct=NULL; |
Lines 40-45
Link Here
|
40 |
} |
45 |
} |
41 |
} |
46 |
} |
42 |
|
47 |
|
|
|
48 |
#ifndef XFT |
43 |
if(ioncore_g.use_mb){ |
49 |
if(ioncore_g.use_mb){ |
44 |
fontset=de_create_font_set(fontname); |
50 |
fontset=de_create_font_set(fontname); |
45 |
if(fontset!=NULL){ |
51 |
if(fontset!=NULL){ |
Lines 66-78
Link Here
|
66 |
return NULL; |
72 |
return NULL; |
67 |
} |
73 |
} |
68 |
|
74 |
|
|
|
75 |
#else /* XFT */ |
76 |
if(strncmp(fontname, "xft:", 4)==0){ |
77 |
font=XftFontOpenName(ioncore_g.dpy, DefaultScreen(ioncore_g.dpy), |
78 |
fontname+4); |
79 |
}else{ |
80 |
font=XftFontOpenXlfd(ioncore_g.dpy, DefaultScreen(ioncore_g.dpy), fontname); |
81 |
} |
82 |
|
83 |
if(font==NULL){ |
84 |
if(strcmp(fontname, CF_FALLBACK_FONT_NAME)!=0){ |
85 |
warn(TR("Could not load font \"%s\", trying \"%s\""), |
86 |
fontname, CF_FALLBACK_FONT_NAME); |
87 |
return de_load_font(CF_FALLBACK_FONT_NAME); |
88 |
} |
89 |
return NULL; |
90 |
} |
91 |
#endif /* XFT */ |
69 |
fnt=ALLOC(DEFont); |
92 |
fnt=ALLOC(DEFont); |
70 |
|
93 |
|
71 |
if(fnt==NULL) |
94 |
if(fnt==NULL) |
72 |
return NULL; |
95 |
return NULL; |
73 |
|
96 |
|
|
|
97 |
#ifndef XFT |
74 |
fnt->fontset=fontset; |
98 |
fnt->fontset=fontset; |
75 |
fnt->fontstruct=fontstruct; |
99 |
fnt->fontstruct=fontstruct; |
|
|
100 |
#else |
101 |
fnt->font=font; |
102 |
#endif |
76 |
fnt->pattern=scopy(fontname); |
103 |
fnt->pattern=scopy(fontname); |
77 |
fnt->next=NULL; |
104 |
fnt->next=NULL; |
78 |
fnt->prev=NULL; |
105 |
fnt->prev=NULL; |
Lines 92-102
Link Here
|
92 |
style->font=font; |
119 |
style->font=font; |
93 |
font->refcount++; |
120 |
font->refcount++; |
94 |
|
121 |
|
|
|
122 |
#ifndef XFT |
95 |
if(style->font->fontstruct!=NULL){ |
123 |
if(style->font->fontstruct!=NULL){ |
96 |
XSetFont(ioncore_g.dpy, style->normal_gc, |
124 |
XSetFont(ioncore_g.dpy, style->normal_gc, |
97 |
style->font->fontstruct->fid); |
125 |
style->font->fontstruct->fid); |
98 |
} |
126 |
} |
99 |
|
127 |
|
|
|
128 |
#endif /* ! XFT */ |
100 |
return TRUE; |
129 |
return TRUE; |
101 |
} |
130 |
} |
102 |
|
131 |
|
Lines 111-121
Link Here
|
111 |
if(style->font==NULL) |
140 |
if(style->font==NULL) |
112 |
return FALSE; |
141 |
return FALSE; |
113 |
|
142 |
|
|
|
143 |
#ifndef XFT |
114 |
if(style->font->fontstruct!=NULL){ |
144 |
if(style->font->fontstruct!=NULL){ |
115 |
XSetFont(ioncore_g.dpy, style->normal_gc, |
145 |
XSetFont(ioncore_g.dpy, style->normal_gc, |
116 |
style->font->fontstruct->fid); |
146 |
style->font->fontstruct->fid); |
117 |
} |
147 |
} |
118 |
|
148 |
|
|
|
149 |
#endif /* ! XFT */ |
119 |
return TRUE; |
150 |
return TRUE; |
120 |
} |
151 |
} |
121 |
|
152 |
|
Lines 125-134
Link Here
|
125 |
if(--font->refcount!=0) |
156 |
if(--font->refcount!=0) |
126 |
return; |
157 |
return; |
127 |
|
158 |
|
|
|
159 |
#ifndef XFT |
128 |
if(font->fontset!=NULL) |
160 |
if(font->fontset!=NULL) |
129 |
XFreeFontSet(ioncore_g.dpy, font->fontset); |
161 |
XFreeFontSet(ioncore_g.dpy, font->fontset); |
130 |
if(font->fontstruct!=NULL) |
162 |
if(font->fontstruct!=NULL) |
131 |
XFreeFont(ioncore_g.dpy, font->fontstruct); |
163 |
XFreeFont(ioncore_g.dpy, font->fontstruct); |
|
|
164 |
#else /* XFT */ |
165 |
if(font->font!=NULL) |
166 |
XftFontClose(ioncore_g.dpy, font->font); |
167 |
#endif /* XFT */ |
132 |
if(font->pattern!=NULL) |
168 |
if(font->pattern!=NULL) |
133 |
free(font->pattern); |
169 |
free(font->pattern); |
134 |
|
170 |
|
Lines 156-161
Link Here
|
156 |
|
192 |
|
157 |
void defont_get_font_extents(DEFont *font, GrFontExtents *fnte) |
193 |
void defont_get_font_extents(DEFont *font, GrFontExtents *fnte) |
158 |
{ |
194 |
{ |
|
|
195 |
#ifndef XFT |
159 |
if(font->fontset!=NULL){ |
196 |
if(font->fontset!=NULL){ |
160 |
XFontSetExtents *ext=XExtentsOfFontSet(font->fontset); |
197 |
XFontSetExtents *ext=XExtentsOfFontSet(font->fontset); |
161 |
if(ext==NULL) |
198 |
if(ext==NULL) |
Lines 171-177
Link Here
|
171 |
fnte->baseline=fnt->ascent; |
208 |
fnte->baseline=fnt->ascent; |
172 |
return; |
209 |
return; |
173 |
} |
210 |
} |
174 |
|
211 |
#else /* XFT */ |
|
|
212 |
if(font->font!=NULL){ |
213 |
fnte->max_height=font->font->ascent+font->font->descent; |
214 |
fnte->max_width=font->font->max_advance_width; |
215 |
fnte->baseline=font->font->ascent; |
216 |
return; |
217 |
} |
218 |
#endif /* XFT */ |
175 |
fail: |
219 |
fail: |
176 |
DE_RESET_FONT_EXTENTS(fnte); |
220 |
DE_RESET_FONT_EXTENTS(fnte); |
177 |
} |
221 |
} |
Lines 188-207
Link Here
|
188 |
|
232 |
|
189 |
uint defont_get_text_width(DEFont *font, const char *text, uint len) |
233 |
uint defont_get_text_width(DEFont *font, const char *text, uint len) |
190 |
{ |
234 |
{ |
|
|
235 |
#ifndef XFT |
191 |
if(font->fontset!=NULL){ |
236 |
if(font->fontset!=NULL){ |
192 |
XRectangle lext; |
237 |
XRectangle lext; |
193 |
#ifdef CF_DE_USE_XUTF8 |
238 |
#ifdef CF_DE_USE_XUTF8 |
194 |
if(ioncore_g.enc_utf8) |
239 |
if(ioncore_g.enc_utf8) |
195 |
Xutf8TextExtents(font->fontset, text, len, NULL, &lext); |
240 |
Xutf8TextExtents(font->fontset, text, len, NULL, &lext); |
196 |
else |
241 |
else |
197 |
#endif |
242 |
#endif |
198 |
XmbTextExtents(font->fontset, text, len, NULL, &lext); |
243 |
XmbTextExtents(font->fontset, text, len, NULL, &lext); |
199 |
return lext.width; |
244 |
return lext.width; |
200 |
}else if(font->fontstruct!=NULL){ |
245 |
}else if(font->fontstruct!=NULL){ |
201 |
return XTextWidth(font->fontstruct, text, len); |
246 |
return XTextWidth(font->fontstruct, text, len); |
202 |
}else{ |
247 |
}else{ |
203 |
return 0; |
248 |
return 0; |
204 |
} |
249 |
} |
|
|
250 |
#else /* XFT */ |
251 |
if(font->font!=NULL){ |
252 |
XGlyphInfo extents; |
253 |
if(ioncore_g.enc_utf8) |
254 |
XftTextExtentsUtf8(ioncore_g.dpy, font->font, (XftChar8 *)text, len, |
255 |
&extents); |
256 |
else |
257 |
XftTextExtents8(ioncore_g.dpy, font->font, (XftChar8 *)text, len, |
258 |
&extents); |
259 |
return extents.xOff; |
260 |
}else{ |
261 |
return 0; |
262 |
} |
263 |
#endif /* XFT */ |
205 |
} |
264 |
} |
206 |
|
265 |
|
207 |
|
266 |
|
Lines 211-216
Link Here
|
211 |
/*{{{ String drawing */ |
270 |
/*{{{ String drawing */ |
212 |
|
271 |
|
213 |
|
272 |
|
|
|
273 |
#ifndef XFT |
214 |
void debrush_do_draw_string_default(DEBrush *brush, int x, int y, |
274 |
void debrush_do_draw_string_default(DEBrush *brush, int x, int y, |
215 |
const char *str, int len, bool needfill, |
275 |
const char *str, int len, bool needfill, |
216 |
DEColourGroup *colours) |
276 |
DEColourGroup *colours) |
Lines 256-261
Link Here
|
256 |
} |
316 |
} |
257 |
} |
317 |
} |
258 |
|
318 |
|
|
|
319 |
#else /* XFT */ |
320 |
void debrush_do_draw_string_default(DEBrush *brush, |
321 |
int x, int y, const char *str, |
322 |
int len, bool needfill, |
323 |
DEColourGroup *colours) |
324 |
{ |
325 |
Window win = brush->win; |
326 |
GC gc=brush->d->normal_gc; |
327 |
XftDraw *draw; |
328 |
XftFont *font; |
329 |
|
330 |
if(brush->d->font==NULL) |
331 |
return; |
332 |
|
333 |
font=brush->d->font->font; |
334 |
draw=debrush_get_draw(brush, win); |
335 |
|
336 |
if(needfill){ |
337 |
XGlyphInfo extents; |
338 |
if(ioncore_g.enc_utf8) |
339 |
XftTextExtentsUtf8(ioncore_g.dpy, font, (XftChar8 *)str, len, |
340 |
&extents); |
341 |
else |
342 |
XftTextExtents8(ioncore_g.dpy, font, (XftChar8 *)str, len, &extents); |
343 |
XftDrawRect(draw, &(colours->bg), x-extents.x, y-extents.y, |
344 |
extents.width+10, extents.height); |
345 |
} |
346 |
|
347 |
if(ioncore_g.enc_utf8) |
348 |
XftDrawStringUtf8(draw, &(colours->fg), font, x, y, (XftChar8 *)str, |
349 |
len); |
350 |
else |
351 |
XftDrawString8(draw, &(colours->fg), font, x, y, (XftChar8 *)str, len); |
352 |
} |
353 |
#endif /* XFT */ |
259 |
|
354 |
|
260 |
void debrush_do_draw_string(DEBrush *brush, int x, int y, |
355 |
void debrush_do_draw_string(DEBrush *brush, int x, int y, |
261 |
const char *str, int len, bool needfill, |
356 |
const char *str, int len, bool needfill, |