Japanese translation of message catalog for Sawfish Window-Manager
Revision | f7fae490993a405e1f0c722798058931cd90749a (tree) |
---|---|
Time | 2002-11-03 13:56:15 |
Author | John Harper <jsh@src....> |
Commiter | John Harper |
merged font changes from HEAD
@@ -1,3 +1,8 @@ | ||
1 | +2002-11-02 John Harper <jsh@unfactored.org> | |
2 | + | |
3 | + * configure.in, config.h.in, Makedefs.in: check for Xft | |
4 | + libraries and headers (merged from HEAD) | |
5 | + | |
1 | 6 | 2002-09-26 Stanislav Brabec <sbrabec@suse.cz> |
2 | 7 | |
3 | 8 | * po/cs.po: Updated Czech translation from Miloslav Trmac |
@@ -54,7 +54,7 @@ LIBS=@LIBS@ | ||
54 | 54 | LIBOBJS= |
55 | 55 | X11_CFLAGS=@X_CFLAGS@ |
56 | 56 | X11_LIBS=@X_PRE_LIBS@ -lX11 @X_LIBS@ @X_EXTRA_LIBS@ |
57 | -EXTRA_X11_LIBS=@XINERAMA_LIBS@ -lXext | |
57 | +EXTRA_X11_LIBS=@XINERAMA_LIBS@ @XFT_LIBS@ -lXext | |
58 | 58 | IMLIB_CFLAGS=@IMLIB_CFLAGS@ |
59 | 59 | IMLIB_LIBS=@IMLIB_LIBS@ |
60 | 60 | GDK_PIXBUF_CFLAGS=@GDK_PIXBUF_CFLAGS@ |
@@ -98,6 +98,13 @@ AC_CHECK_LIB(Xinerama, XineramaQueryScreens, | ||
98 | 98 | AC_CHECK_HEADERS(X11/extensions/Xinerama.h)], |
99 | 99 | [],[$X_LIBS -lX11 -lXext]) |
100 | 100 | |
101 | +XFT_LIBS="" | |
102 | +AC_SUBST(XFT_LIBS) | |
103 | +AC_CHECK_LIB(Xft, XftDrawCreate, | |
104 | + [XFT_LIBS="-lXft -lXrender" | |
105 | + AC_CHECK_HEADERS(X11/Xft/Xft.h)], | |
106 | + [], [$X_LIBS -lX11 -lXext]) | |
107 | + | |
101 | 108 | CPPFLAGS="${_cppflags}" |
102 | 109 | |
103 | 110 | dnl Check for librep |
@@ -1,3 +1,34 @@ | ||
1 | +2002-11-02 John Harper <jsh@unfactored.org> | |
2 | + | |
3 | + * merged font changes from HEAD: | |
4 | + | |
5 | + 2002-11-02 John Harper <jsh@unfactored.org> | |
6 | + | |
7 | + * fonts.c, sawmill.h: different font rendering methods are now | |
8 | + better abstracted, using the Lisp_Font_Class structure | |
9 | + | |
10 | + (get-font-typed, font-type-exists-p, font-type): new functions, | |
11 | + allows a font to be loaded from a type+name combination, | |
12 | + instead of just a name, which may be ambiguous when multiple | |
13 | + renderers are being used | |
14 | + | |
15 | + Current types are "xlfd" for traditional X fonts, and "Xft" for | |
16 | + Xft client-side rendered fonts. The old get-font function | |
17 | + always tries to load xlfd fonts, for backwards compatibility | |
18 | + | |
19 | + For now, Xft fonts can be used like this: | |
20 | + | |
21 | + (when (and (boundp 'font-type-exists-p) | |
22 | + (font-type-exists-p "Xft")) | |
23 | + (setq default-font (get-font-typed "Xft" "Trebuchet MS-11"))) | |
24 | + | |
25 | + 2002-11-02 John Harper <jsh@unfactored.org> | |
26 | + | |
27 | + * fonts.c (x_draw_string): now takes an explicit foreground | |
28 | + color parameter, instead of using the one in the gc | |
29 | + | |
30 | + * x.c, sawmill_subrs.h, functions.c, frames.c: updated callers | |
31 | + | |
1 | 32 | 2002-10-20 John Harper <jsh@unfactored.org> |
2 | 33 | |
3 | 34 | * more merging: |
@@ -42,13 +42,80 @@ | ||
42 | 42 | #include <X11/Xlocale.h> |
43 | 43 | #include <ctype.h> |
44 | 44 | |
45 | +#ifdef HAVE_X11_XFT_XFT_H | |
46 | +# include <X11/Xft/Xft.h> | |
47 | +#endif | |
48 | + | |
45 | 49 | static Lisp_Font *font_list; |
46 | 50 | int font_type; |
47 | 51 | |
48 | 52 | DEFSYM(default_font, "default-font"); |
49 | 53 | |
54 | +struct Lisp_Font_Class_struct { | |
55 | + const char *type; | |
56 | + bool (*load) (Lisp_Font *f); | |
57 | + void (*finalize) (Lisp_Font *f); | |
58 | + int (*measure) (Lisp_Font *f, u_char *string, size_t length); | |
59 | + void (*draw) (Lisp_Font *f, u_char *string, size_t length, | |
60 | + Window id, GC gc, Lisp_Color *fg, int x, int y); | |
61 | +}; | |
62 | + | |
63 | + | |
64 | +/* Xlib font structs */ | |
65 | + | |
66 | +static bool | |
67 | +fontstruct_load (Lisp_Font *f) | |
68 | +{ | |
69 | + XFontStruct *font_struct; | |
70 | + | |
71 | + font_struct = XLoadQueryFont (dpy, rep_STR (f->name)); | |
72 | + | |
73 | + if (font_struct == 0) | |
74 | + return FALSE; | |
75 | + | |
76 | + f->font = font_struct; | |
77 | + f->ascent = font_struct->ascent; | |
78 | + f->descent = font_struct->descent; | |
79 | + | |
80 | + return TRUE; | |
81 | +} | |
82 | + | |
83 | +static void | |
84 | +fontstruct_finalize (Lisp_Font *f) | |
85 | +{ | |
86 | + XFreeFont (dpy, f->font); | |
87 | +} | |
88 | + | |
89 | +static int | |
90 | +fontstruct_measure (Lisp_Font *f, u_char *string, size_t length) | |
91 | +{ | |
92 | + return XTextWidth (f->font, string, length); | |
93 | +} | |
94 | + | |
95 | +static void | |
96 | +fontstruct_draw (Lisp_Font *f, u_char *string, size_t length, | |
97 | + Window id, GC gc, Lisp_Color *fg, int x, int y) | |
98 | +{ | |
99 | + XFontStruct *fs; | |
100 | + XGCValues gcv; | |
101 | + | |
102 | + fs = f->font; | |
103 | + | |
104 | + gcv.foreground = fg->pixel; | |
105 | + gcv.font = fs->fid; | |
106 | + XChangeGC (dpy, gc, GCForeground | GCFont, &gcv); | |
107 | + | |
108 | + XDrawString (dpy, id, gc, x, y, string, length); | |
109 | +} | |
110 | + | |
111 | +static const Lisp_Font_Class fontstruct_class = { | |
112 | + "xlfd", | |
113 | + fontstruct_load, fontstruct_finalize, | |
114 | + fontstruct_measure, fontstruct_draw, | |
115 | +}; | |
116 | + | |
50 | 117 | |
51 | -/* XLFD pattern matching */ | |
118 | +/* Xlib font sets */ | |
52 | 119 | |
53 | 120 | static char * |
54 | 121 | xlfd_get_element (const char *xlfd, int idx) |
@@ -111,7 +178,7 @@ generalize_xlfd (const char *xlfd) | ||
111 | 178 | } |
112 | 179 | |
113 | 180 | static XFontSet |
114 | -x_create_font_set (char *xlfd, char ***missing, | |
181 | +x_create_fontset (char *xlfd, char ***missing, | |
115 | 182 | int *nmissing, char **def_string) |
116 | 183 | { |
117 | 184 | XFontSet fs = XCreateFontSet (dpy, xlfd, missing, nmissing, def_string); |
@@ -171,11 +238,8 @@ x_create_font_set (char *xlfd, char ***missing, | ||
171 | 238 | return fs; |
172 | 239 | } |
173 | 240 | |
174 | - | |
175 | -/* font creation */ | |
176 | - | |
177 | -static void * | |
178 | -get_font_set (const char *name, int *typep, int *ascentp, int *descentp) | |
241 | +static bool | |
242 | +fontset_load (Lisp_Font *f) | |
179 | 243 | { |
180 | 244 | XFontSet font_set; |
181 | 245 | int ascent, descent; |
@@ -183,10 +247,10 @@ get_font_set (const char *name, int *typep, int *ascentp, int *descentp) | ||
183 | 247 | char **missing_charset_list, *def_string; |
184 | 248 | int num_missing_charset_list; |
185 | 249 | |
186 | - font_set = x_create_font_set (rep_STR(name), | |
187 | - &missing_charset_list, | |
188 | - &num_missing_charset_list, | |
189 | - &def_string); | |
250 | + font_set = x_create_fontset (rep_STR (f->name), | |
251 | + &missing_charset_list, | |
252 | + &num_missing_charset_list, | |
253 | + &def_string); | |
190 | 254 | |
191 | 255 | if (font_set != 0) |
192 | 256 | { |
@@ -194,15 +258,17 @@ get_font_set (const char *name, int *typep, int *ascentp, int *descentp) | ||
194 | 258 | char **font_names; |
195 | 259 | int i, j, num_fonts; |
196 | 260 | |
261 | + f->font = font_set; | |
262 | + | |
197 | 263 | num_fonts = XFontsOfFontSet (font_set, &fstrs, &font_names); |
198 | 264 | ascent = descent = 0; |
199 | 265 | |
200 | 266 | for (i = 0; i < num_fonts; i++) |
201 | 267 | { |
202 | 268 | if (fstrs[i]->ascent > ascent) |
203 | - ascent = fstrs[i]->ascent; | |
269 | + f->ascent = fstrs[i]->ascent; | |
204 | 270 | if (fstrs[i]->descent > descent) |
205 | - descent = fstrs[i]->descent; | |
271 | + f->descent = fstrs[i]->descent; | |
206 | 272 | } |
207 | 273 | |
208 | 274 | if (num_missing_charset_list > 0) |
@@ -213,89 +279,242 @@ get_font_set (const char *name, int *typep, int *ascentp, int *descentp) | ||
213 | 279 | XFreeStringList (missing_charset_list); |
214 | 280 | } |
215 | 281 | |
216 | - *typep = FF_FONT_SET; | |
217 | - *ascentp = ascent; | |
218 | - *descentp = descent; | |
282 | + return TRUE; | |
219 | 283 | } |
220 | 284 | |
221 | - return font_set; | |
285 | + return FALSE; | |
222 | 286 | } |
223 | 287 | |
224 | -static void * | |
225 | -get_font_struct (const char *name, int *typep, int *ascentp, int *descentp) | |
288 | +static void | |
289 | +fontset_finalize (Lisp_Font *f) | |
226 | 290 | { |
227 | - XFontStruct *font_struct; | |
291 | + XFreeFontSet (dpy, f->font); | |
292 | +} | |
228 | 293 | |
229 | - font_struct = XLoadQueryFont (dpy, name); | |
294 | +static int | |
295 | +fontset_measure (Lisp_Font *f, u_char *string, size_t length) | |
296 | +{ | |
297 | + return XmbTextEscapement (f->font, string, length); | |
298 | +} | |
230 | 299 | |
231 | - if (font_struct != 0) | |
232 | - { | |
233 | - *typep = FF_FONT_STRUCT; | |
234 | - *ascentp = font_struct->ascent; | |
235 | - *descentp = font_struct->descent; | |
236 | - } | |
300 | +static void | |
301 | +fontset_draw (Lisp_Font *f, u_char *string, size_t length, | |
302 | + Window id, GC gc, Lisp_Color *fg, int x, int y) | |
303 | +{ | |
304 | + XGCValues gcv; | |
305 | + | |
306 | + gcv.foreground = fg->pixel; | |
307 | + XChangeGC (dpy, gc, GCForeground, &gcv); | |
237 | 308 | |
238 | - return font_struct; | |
309 | + XmbDrawString (dpy, id, f->font, gc, x, y, string, length); | |
239 | 310 | } |
240 | 311 | |
312 | +static const Lisp_Font_Class fontset_class = { | |
313 | + "xlfd", | |
314 | + fontset_load, fontset_finalize, | |
315 | + fontset_measure, fontset_draw, | |
316 | +}; | |
317 | + | |
241 | 318 | |
319 | +/* Xft fonts */ | |
242 | 320 | |
243 | -DEFUN("get-font", Fget_font, Sget_font, (repv name), rep_Subr1) /* | |
244 | -::doc:sawfish.wm.fonts#get-font:: | |
245 | -get-font NAME | |
321 | +#ifdef HAVE_X11_XFT_XFT_H | |
246 | 322 | |
247 | -Return the font object representing the font named NAME (a standard X | |
248 | -font specifier string). | |
323 | +static bool | |
324 | +xft_load (Lisp_Font *f) | |
325 | +{ | |
326 | + XftFont *xft_font; | |
327 | + | |
328 | + xft_font = XftFontOpenName (dpy, screen_num, rep_STR (f->name)); | |
329 | + | |
330 | + if (xft_font == 0) | |
331 | + return FALSE; | |
332 | + | |
333 | + f->font = xft_font; | |
334 | + f->ascent = xft_font->ascent; | |
335 | + f->descent = xft_font->descent; | |
336 | + | |
337 | + return TRUE; | |
338 | +} | |
339 | + | |
340 | +static void | |
341 | +xft_finalize (Lisp_Font *f) | |
342 | +{ | |
343 | + XftFontClose (dpy, f->font); | |
344 | +} | |
345 | + | |
346 | +static int | |
347 | +xft_measure (Lisp_Font *f, u_char *string, size_t length) | |
348 | +{ | |
349 | + XGlyphInfo info; | |
350 | + | |
351 | + XftTextExtents8 (dpy, f->font, string, length, &info); | |
352 | + | |
353 | + return info.xOff; | |
354 | +} | |
355 | + | |
356 | +static void | |
357 | +xft_draw (Lisp_Font *f, u_char *string, size_t length, | |
358 | + Window id, GC gc, Lisp_Color *fg, int x, int y) | |
359 | +{ | |
360 | + static XftDraw *draw; | |
361 | + | |
362 | + XftColor xft_color; | |
363 | + | |
364 | + if (draw == 0) | |
365 | + draw = XftDrawCreate (dpy, id, image_visual, image_cmap); | |
366 | + else | |
367 | + XftDrawChange (draw, id); | |
368 | + | |
369 | + xft_color.pixel = fg->pixel; | |
370 | + xft_color.color.red = fg->red; | |
371 | + xft_color.color.green = fg->green; | |
372 | + xft_color.color.blue = fg->blue; | |
373 | + xft_color.color.alpha = 65535; /* FIXME: */ | |
374 | + | |
375 | + XftDrawString8 (draw, &xft_color, f->font, | |
376 | + x, y, string, length); | |
377 | +} | |
378 | + | |
379 | +static const Lisp_Font_Class xft_class = { | |
380 | + "Xft", | |
381 | + xft_load, xft_finalize, | |
382 | + xft_measure, xft_draw, | |
383 | +}; | |
384 | + | |
385 | +#endif /* HAVE_X11_XFT_XFT_H */ | |
386 | + | |
387 | + | |
388 | +/* All classes */ | |
389 | + | |
390 | +static const Lisp_Font_Class *classes[] = { | |
391 | + &fontstruct_class, | |
392 | + &fontset_class, | |
393 | +#ifdef HAVE_X11_XFT_XFT_H | |
394 | + &xft_class, | |
395 | +#endif | |
396 | + 0, | |
397 | +}; | |
398 | + | |
399 | + | |
400 | +/* Entry points */ | |
401 | + | |
402 | +DEFUN ("font-type-exists-p", Ffont_type_exists_p, | |
403 | + Sfont_type_exists_p, (repv type), rep_Subr1) /* | |
404 | +::doc:sawfish.wm.fonts#font-type-exists-p:: | |
405 | +font-type-exists-p TYPE | |
406 | + | |
407 | +Returns true if fonts with the type described by the string TYPE can be | |
408 | +loaded. | |
409 | +::end:: */ | |
410 | +{ | |
411 | + int i; | |
412 | + | |
413 | + rep_DECLARE1 (type, rep_STRINGP); | |
414 | + | |
415 | + for (i = 0; classes[i] != 0; i++) | |
416 | + { | |
417 | + if (strcasecmp (rep_STR (type), classes[i]->type) == 0) | |
418 | + return Qt; | |
419 | + } | |
420 | + | |
421 | + return Qnil; | |
422 | +} | |
423 | + | |
424 | +DEFUN("get-font-typed", Fget_font_typed, Sget_font_typed, | |
425 | + (repv type, repv name), rep_Subr2) /* | |
426 | +::doc:sawfish.wm.fonts#get-font-typed:: | |
427 | +get-font-typed TYPE NAME | |
428 | + | |
429 | +Return the font object representing the font named NAME. NAME is | |
430 | +interpreted based on the value of the string TYPE. | |
249 | 431 | ::end:: */ |
250 | 432 | { |
251 | 433 | Lisp_Font *f; |
434 | + const Lisp_Font_Class *class; | |
435 | + repv tem; | |
436 | + int i; | |
437 | + | |
252 | 438 | rep_DECLARE1(name, rep_STRINGP); |
439 | + rep_DECLARE2(type, rep_STRINGP); | |
253 | 440 | |
254 | 441 | if (dpy == 0) |
255 | 442 | return Qnil; |
256 | 443 | |
257 | - f = font_list; | |
258 | - while (f != 0 && strcmp (rep_STR(name), rep_STR(f->name)) != 0) | |
259 | - f = f->next; | |
260 | - | |
261 | - if (f == 0) | |
444 | + for (f = font_list; f != NULL; f = f->next) | |
262 | 445 | { |
263 | - repv tem = global_symbol_value (Qfonts_are_fontsets); | |
264 | - | |
265 | - void *font = 0; | |
266 | - int type = -1; | |
267 | - int ascent, descent; | |
268 | - | |
269 | - if (font == 0 && tem != Qnil) | |
446 | + if (strcmp (rep_STR(name), rep_STR(f->name)) == 0 | |
447 | + && strcmp (rep_STR (type), rep_STR (f->name)) == 0) | |
270 | 448 | { |
271 | - font = get_font_set (rep_STR(name), &type, &ascent, &descent); | |
449 | + return rep_VAL (f); | |
272 | 450 | } |
451 | + } | |
273 | 452 | |
274 | - if (font == 0) | |
275 | - { | |
276 | - font = get_font_struct (rep_STR(name), &type, &ascent, &descent); | |
277 | - } | |
453 | + class = 0; | |
278 | 454 | |
279 | - if (font == 0) | |
455 | + if (strcasecmp (rep_STR (type), "xlfd") == 0) | |
456 | + { | |
457 | + /* Boring old X core fonts */ | |
458 | + | |
459 | + tem = global_symbol_value (Qfonts_are_fontsets); | |
460 | + if (tem != Qnil) | |
461 | + class = &fontset_class; | |
462 | + else | |
463 | + class = &fontstruct_class; | |
464 | + } | |
465 | + else | |
466 | + { | |
467 | + for (i = 0; classes[i] != 0; i++) | |
280 | 468 | { |
281 | - return Fsignal (Qerror, rep_list_2 (rep_string_dup ("no such font"), name)); | |
469 | + if (strcasecmp (rep_STR (type), classes[i]->type) == 0) | |
470 | + { | |
471 | + class = classes[i]; | |
472 | + break; | |
473 | + } | |
282 | 474 | } |
475 | + } | |
283 | 476 | |
284 | - f = rep_ALLOC_CELL(sizeof(Lisp_Font)); | |
285 | - rep_data_after_gc += sizeof (Lisp_Font); | |
477 | + if (class == 0) | |
478 | + { | |
479 | + DEFSTRING (err, "unknown font type"); | |
480 | + return Fsignal (Qerror, rep_list_2 (rep_VAL (&err), type)); | |
481 | + } | |
482 | + | |
483 | + f = rep_ALLOC_CELL(sizeof(Lisp_Font)); | |
286 | 484 | |
287 | - f->next = font_list; | |
288 | - font_list = f; | |
485 | + f->car = font_type; | |
486 | + f->class = class; | |
487 | + f->type = type; | |
488 | + f->name = name; | |
489 | + f->plist = Qnil; | |
289 | 490 | |
290 | - f->car = font_type | type; | |
291 | - f->name = name; | |
292 | - f->font = font; | |
293 | - f->plist = Qnil; | |
294 | - f->ascent = ascent; | |
295 | - f->descent = descent; | |
491 | + if (!(*class->load) (f)) | |
492 | + { | |
493 | + DEFSTRING (err, "unknown font"); | |
494 | + | |
495 | + rep_FREE_CELL (f); | |
496 | + return Fsignal (Qerror, rep_list_2 (rep_VAL (&err), name)); | |
296 | 497 | } |
297 | 498 | |
298 | - return rep_VAL(f); | |
499 | + rep_data_after_gc += sizeof (Lisp_Font); | |
500 | + | |
501 | + f->next = font_list; | |
502 | + font_list = f; | |
503 | + | |
504 | + return rep_VAL (f); | |
505 | +} | |
506 | + | |
507 | +DEFUN("get-font", Fget_font, Sget_font, (repv name), rep_Subr1) /* | |
508 | +::doc:sawfish.wm.fonts#get-font:: | |
509 | +get-font NAME | |
510 | + | |
511 | +Return the font object representing the font named NAME (a standard X | |
512 | +font specifier string). | |
513 | +::end:: */ | |
514 | +{ | |
515 | + DEFSTRING (type, "xlfd"); | |
516 | + | |
517 | + return Fget_font_typed (rep_VAL (&type), name); | |
299 | 518 | } |
300 | 519 | |
301 | 520 | DEFUN("font-get", Ffont_get, Sfont_get, (repv win, repv prop), rep_Subr2) /* |
@@ -348,6 +567,17 @@ Set the property PROPERTY (a symbol) associated with FONT to VALUE. | ||
348 | 567 | return val; |
349 | 568 | } |
350 | 569 | |
570 | +DEFUN("font-type", Ffont_type, Sfont_type, (repv font), rep_Subr1) /* | |
571 | +::doc:sawfish.wm.fonts#font-type:: | |
572 | +font-type FONT | |
573 | + | |
574 | +Return the type of the font represented by the font object FONT. | |
575 | +::end:: */ | |
576 | +{ | |
577 | + rep_DECLARE1(font, FONTP); | |
578 | + return VFONT(font)->type; | |
579 | +} | |
580 | + | |
351 | 581 | DEFUN("font-name", Ffont_name, Sfont_name, (repv font), rep_Subr1) /* |
352 | 582 | ::doc:sawfish.wm.fonts#font-name:: |
353 | 583 | font-name FONT |
@@ -372,36 +602,16 @@ Return t if ARG is a font object. | ||
372 | 602 | int |
373 | 603 | x_text_width (repv font, u_char *string, size_t len) |
374 | 604 | { |
375 | - switch (FONT_TYPE (font)) | |
376 | - { | |
377 | - case FF_FONT_STRUCT: | |
378 | - return XTextWidth (VFONT(font)->font, string, len); | |
379 | - | |
380 | - case FF_FONT_SET: | |
381 | - return XmbTextEscapement (VFONT(font)->font, string, len); | |
382 | - | |
383 | - default: | |
384 | - return 0; | |
385 | - } | |
605 | + return (*VFONT (font)->class->measure) (VFONT (font), string, len); | |
386 | 606 | } |
387 | 607 | |
608 | +/* The foreground pixel of GC is undefined after this function returns. */ | |
388 | 609 | void |
389 | -x_draw_string (Window id, repv font, GC gc, | |
610 | +x_draw_string (Window id, repv font, GC gc, Lisp_Color *fg_color, | |
390 | 611 | int x, int y, u_char *string, size_t len) |
391 | 612 | { |
392 | - switch (FONT_TYPE (font)) | |
393 | - { | |
394 | - case FF_FONT_STRUCT: { | |
395 | - XFontStruct *fs = VFONT(font)->font; | |
396 | - | |
397 | - XSetFont (dpy, gc, fs->fid); | |
398 | - XDrawString (dpy, id, gc, x, y, string, len); | |
399 | - break; } | |
400 | - | |
401 | - case FF_FONT_SET: | |
402 | - XmbDrawString (dpy, id, VFONT(font)->font, gc, x, y, string, len); | |
403 | - break; | |
404 | - } | |
613 | + return (*VFONT (font)->class->draw) (VFONT (font), string, len, | |
614 | + id, gc, fg_color, x, y); | |
405 | 615 | } |
406 | 616 | |
407 | 617 | DEFUN("text-width", Ftext_width, Stext_width, (repv string, repv font), rep_Subr2) /* |
@@ -475,13 +685,15 @@ static void | ||
475 | 685 | font_prin (repv stream, repv obj) |
476 | 686 | { |
477 | 687 | char buf[256]; |
478 | - sprintf (buf, "#<font %s>", rep_STR(VFONT(obj)->name)); | |
688 | + sprintf (buf, "#<font %s:%s>", | |
689 | + rep_STR(VFONT(obj)->type), rep_STR(VFONT(obj)->name)); | |
479 | 690 | rep_stream_puts (stream, buf, -1, FALSE); |
480 | 691 | } |
481 | 692 | |
482 | 693 | static void |
483 | 694 | font_mark (repv obj) |
484 | 695 | { |
696 | + rep_MARKVAL(VFONT(obj)->type); | |
485 | 697 | rep_MARKVAL(VFONT(obj)->name); |
486 | 698 | rep_MARKVAL(VFONT(obj)->plist); |
487 | 699 | } |
@@ -494,18 +706,10 @@ font_sweep (void) | ||
494 | 706 | while (w != 0) |
495 | 707 | { |
496 | 708 | Lisp_Font *next = w->next; |
709 | + | |
497 | 710 | if (!rep_GC_CELL_MARKEDP(rep_VAL(w))) |
498 | 711 | { |
499 | - switch (FONT_TYPE (rep_VAL (w))) | |
500 | - { | |
501 | - case FF_FONT_STRUCT: | |
502 | - XFreeFont (dpy, w->font); | |
503 | - break; | |
504 | - | |
505 | - case FF_FONT_SET: | |
506 | - XFreeFontSet (dpy, w->font); | |
507 | - break; | |
508 | - } | |
712 | + (*w->class->finalize) (w); | |
509 | 713 | rep_FREE_CELL(w); |
510 | 714 | } |
511 | 715 | else |
@@ -528,9 +732,13 @@ fonts_init (void) | ||
528 | 732 | font_type = rep_register_new_type ("font", font_cmp, font_prin, font_prin, |
529 | 733 | font_sweep, font_mark, |
530 | 734 | 0, 0, 0, 0, 0, 0, 0); |
735 | + | |
736 | + rep_ADD_SUBR(Sfont_type_exists_p); | |
737 | + rep_ADD_SUBR(Sget_font_typed); | |
531 | 738 | rep_ADD_SUBR(Sget_font); |
532 | 739 | rep_ADD_SUBR(Sfont_get); |
533 | 740 | rep_ADD_SUBR(Sfont_put); |
741 | + rep_ADD_SUBR(Sfont_type); | |
534 | 742 | rep_ADD_SUBR(Sfont_name); |
535 | 743 | rep_ADD_SUBR(Sfontp); |
536 | 744 | rep_ADD_SUBR(Stext_width); |
@@ -541,10 +749,13 @@ fonts_init (void) | ||
541 | 749 | rep_INTERN_SPECIAL(default_font); |
542 | 750 | if (!batch_mode_p ()) |
543 | 751 | { |
544 | - repv font = Fget_font (rep_string_dup("fixed")); | |
752 | + DEFSTRING (type, "xlfd"); | |
753 | + DEFSTRING (name, "fixed"); | |
754 | + | |
755 | + repv font = Fget_font_typed (rep_VAL (&type), rep_VAL (&name)); | |
545 | 756 | if (font == rep_NULL || !FONTP(font)) |
546 | 757 | { |
547 | - fputs ("can't load fixed font during initialisation", stderr); | |
758 | + fputs ("can't load 'fixed' font during initialisation", stderr); | |
548 | 759 | rep_throw_value = rep_NULL; |
549 | 760 | font = Qnil; |
550 | 761 | } |
@@ -658,8 +658,6 @@ set_frame_part_fg (struct frame_part *fp) | ||
658 | 658 | { |
659 | 659 | int state = current_state (fp); |
660 | 660 | repv font = fp->font[state], fg = fp->fg[state]; |
661 | - XGCValues gcv; | |
662 | - u_long gcv_mask = 0; | |
663 | 661 | repv string = rep_NULL; |
664 | 662 | int length = 0, width, height, x, y; |
665 | 663 | Lisp_Window *win = fp->win; |
@@ -743,6 +741,8 @@ set_frame_part_fg (struct frame_part *fp) | ||
743 | 741 | |
744 | 742 | if (IMAGEP(fg)) |
745 | 743 | { |
744 | + XGCValues gcv; | |
745 | + u_long gcv_mask = 0; | |
746 | 746 | Pixmap fg_pixmap, fg_mask; |
747 | 747 | |
748 | 748 | if (fp->drawn.fg == fg |
@@ -816,14 +816,8 @@ set_frame_part_fg (struct frame_part *fp) | ||
816 | 816 | set_frame_part_bg (fp); |
817 | 817 | } |
818 | 818 | |
819 | - if (COLORP(fg)) | |
820 | - { | |
821 | - gcv.foreground = VCOLOR(fg)->pixel; | |
822 | - gcv_mask |= GCForeground; | |
823 | - } | |
824 | - | |
825 | - XChangeGC (dpy, fp->gc, gcv_mask, &gcv); | |
826 | - x_draw_string (fp->id, font, fp->gc, x, y + VFONT(font)->ascent, | |
819 | + x_draw_string (fp->id, font, fp->gc, VCOLOR(fg), | |
820 | + x, y + VFONT(font)->ascent, | |
827 | 821 | rep_STR(string), length); |
828 | 822 | |
829 | 823 | fp->drawn.text = string; |
@@ -1041,10 +1041,9 @@ refresh_message_window () | ||
1041 | 1041 | char *ptr; |
1042 | 1042 | int row = 0; |
1043 | 1043 | |
1044 | - values.foreground = VCOLOR(message.fg)->pixel; | |
1045 | 1044 | values.background = VCOLOR(message.bg)->pixel; |
1046 | 1045 | values.graphics_exposures = False; |
1047 | - mask = GCForeground | GCBackground | GCGraphicsExposures; | |
1046 | + mask = GCBackground | GCGraphicsExposures; | |
1048 | 1047 | |
1049 | 1048 | if (message.gc == 0) |
1050 | 1049 | message.gc = XCreateGC (dpy, message_win, mask, &values); |
@@ -1071,7 +1070,7 @@ refresh_message_window () | ||
1071 | 1070 | offset = (message.width - width) / 2; |
1072 | 1071 | } |
1073 | 1072 | x_draw_string (message_win, message.font, |
1074 | - message.gc, offset, | |
1073 | + message.gc, VCOLOR(message.fg), offset, | |
1075 | 1074 | MSG_PAD_Y |
1076 | 1075 | + row * (VFONT(message.font)->ascent |
1077 | 1076 | + VFONT(message.font)->descent |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* sawmill.h -- Main include file, brings in all the rest |
2 | - $Id: sawmill.h,v 1.2 1999/07/25 15:02:21 john Exp | |
2 | + $Id$ | |
3 | 3 | |
4 | 4 | Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk> |
5 | 5 |
@@ -168,10 +168,14 @@ typedef struct lisp_window { | ||
168 | 168 | #define WINDOW_FOCUSED_P(w) (focus_window == w) |
169 | 169 | #define WINDOW_IS_GONE_P(w) (w->id == 0) |
170 | 170 | |
171 | +typedef struct Lisp_Font_Class_struct Lisp_Font_Class; | |
172 | + | |
171 | 173 | /* An allocated font */ |
172 | 174 | typedef struct lisp_font { |
173 | 175 | repv car; |
174 | 176 | struct lisp_font *next; |
177 | + const Lisp_Font_Class *class; | |
178 | + repv type; | |
175 | 179 | repv name; |
176 | 180 | void *font; |
177 | 181 | repv plist; |
@@ -181,14 +185,6 @@ typedef struct lisp_font { | ||
181 | 185 | #define FONTP(v) rep_CELL16_TYPEP(v, font_type) |
182 | 186 | #define VFONT(v) ((Lisp_Font *)rep_PTR(v)) |
183 | 187 | |
184 | -#define FF_FONT_SET (0 << (rep_CELL16_TYPE_BITS + 0)) | |
185 | -#define FF_FONT_STRUCT (1 << (rep_CELL16_TYPE_BITS + 0)) | |
186 | -#define FF_FONT_MASK (3 << (rep_CELL16_TYPE_BITS + 0)) | |
187 | - | |
188 | -#define FONT_TYPE(v) (VFONT(v)->car & FF_FONT_MASK) | |
189 | -#define FONT_SET_P(v) (FONT_TYPE (v) == FF_FONT_SET) | |
190 | -#define FONT_STRUCT_P(v) (FONT_TYPE (v) == FF_FONT_STRUCT) | |
191 | - | |
192 | 188 | /* An allocated color */ |
193 | 189 | typedef struct lisp_color { |
194 | 190 | repv car; |
@@ -108,7 +108,7 @@ extern void events_kill (void); | ||
108 | 108 | extern int font_type; |
109 | 109 | extern repv Qdefault_font; |
110 | 110 | extern int x_text_width (repv font, u_char *string, size_t len); |
111 | -extern void x_draw_string (Window id, repv font, GC gc, | |
111 | +extern void x_draw_string (Window id, repv font, GC gc, Lisp_Color *fg_color, | |
112 | 112 | int x, int y, u_char *string, size_t len); |
113 | 113 | extern repv Fget_font(repv name); |
114 | 114 | extern repv Ffont_get(repv font, repv prop); |