diff options
| author | Kenichi Handa | 2006-08-01 01:21:08 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-08-01 01:21:08 +0000 |
| commit | 6e34c9c13fe8f2a6e7b7c15b854d53d15683c46f (patch) | |
| tree | 20755050e90a028b6b19433a422cfa646e41fffe /src | |
| parent | 3a91626ca069cd509325dddea469e10714768972 (diff) | |
| download | emacs-6e34c9c13fe8f2a6e7b7c15b854d53d15683c46f.tar.gz emacs-6e34c9c13fe8f2a6e7b7c15b854d53d15683c46f.zip | |
(xfont_match): New function.
(xfont_driver): Set xfont_driver.match to xfont_match.
(xfont_draw): Set font in GC if necessary.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfont.c | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/src/xfont.c b/src/xfont.c index a2b8c5d1d70..1f81657df76 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -239,6 +239,7 @@ xfont_registry_charsets (registry, encoding, repertory) | |||
| 239 | 239 | ||
| 240 | static Lisp_Object xfont_get_cache P_ ((Lisp_Object)); | 240 | static Lisp_Object xfont_get_cache P_ ((Lisp_Object)); |
| 241 | static Lisp_Object xfont_list P_ ((Lisp_Object, Lisp_Object)); | 241 | static Lisp_Object xfont_list P_ ((Lisp_Object, Lisp_Object)); |
| 242 | static Lisp_Object xfont_match P_ ((Lisp_Object, Lisp_Object)); | ||
| 242 | static Lisp_Object xfont_list_family P_ ((Lisp_Object)); | 243 | static Lisp_Object xfont_list_family P_ ((Lisp_Object)); |
| 243 | static struct font *xfont_open P_ ((FRAME_PTR, Lisp_Object, int)); | 244 | static struct font *xfont_open P_ ((FRAME_PTR, Lisp_Object, int)); |
| 244 | static void xfont_close P_ ((FRAME_PTR, struct font *)); | 245 | static void xfont_close P_ ((FRAME_PTR, struct font *)); |
| @@ -257,6 +258,7 @@ struct font_driver xfont_driver = | |||
| 257 | (Lisp_Object) NULL, /* Qx */ | 258 | (Lisp_Object) NULL, /* Qx */ |
| 258 | xfont_get_cache, | 259 | xfont_get_cache, |
| 259 | xfont_list, | 260 | xfont_list, |
| 261 | xfont_match, | ||
| 260 | xfont_list_family, | 262 | xfont_list_family, |
| 261 | NULL, | 263 | NULL, |
| 262 | xfont_open, | 264 | xfont_open, |
| @@ -433,6 +435,53 @@ xfont_list (frame, spec) | |||
| 433 | return (NILP (list) ? null_vector : Fvconcat (1, &list)); | 435 | return (NILP (list) ? null_vector : Fvconcat (1, &list)); |
| 434 | } | 436 | } |
| 435 | 437 | ||
| 438 | static Lisp_Object | ||
| 439 | xfont_match (frame, spec) | ||
| 440 | Lisp_Object frame, spec; | ||
| 441 | { | ||
| 442 | FRAME_PTR f = XFRAME (frame); | ||
| 443 | Display *display = FRAME_X_DISPLAY_INFO (f)->display; | ||
| 444 | Lisp_Object extra, val, entity; | ||
| 445 | char *name; | ||
| 446 | XFontStruct *xfont; | ||
| 447 | unsigned long value; | ||
| 448 | |||
| 449 | extra = AREF (spec, FONT_EXTRA_INDEX); | ||
| 450 | val = assq_no_quit (QCname, extra); | ||
| 451 | if (! CONSP (val) || ! STRINGP (XCDR (val))) | ||
| 452 | return Qnil; | ||
| 453 | |||
| 454 | entity = Qnil; | ||
| 455 | name = (char *) SDATA (XCDR (val)); | ||
| 456 | xfont = XLoadQueryFont (display, name); | ||
| 457 | if (xfont) | ||
| 458 | { | ||
| 459 | if (XGetFontProperty (xfont, XA_FONT, &value)) | ||
| 460 | { | ||
| 461 | int len; | ||
| 462 | |||
| 463 | name = (char *) XGetAtomName (display, (Atom) value); | ||
| 464 | len = strlen (name); | ||
| 465 | |||
| 466 | /* If DXPC (a Differential X Protocol Compressor) | ||
| 467 | Ver.3.7 is running, XGetAtomName will return null | ||
| 468 | string. We must avoid such a name. */ | ||
| 469 | if (len > 0) | ||
| 470 | { | ||
| 471 | entity = Fmake_vector (make_number (FONT_ENTITY_MAX), Qnil); | ||
| 472 | ASET (entity, FONT_TYPE_INDEX, Qx); | ||
| 473 | ASET (entity, FONT_FRAME_INDEX, frame); | ||
| 474 | if (font_parse_xlfd (name, entity) < 0) | ||
| 475 | entity = Qnil; | ||
| 476 | } | ||
| 477 | XFree (name); | ||
| 478 | } | ||
| 479 | XFreeFont (display, xfont); | ||
| 480 | } | ||
| 481 | |||
| 482 | return entity; | ||
| 483 | } | ||
| 484 | |||
| 436 | static int | 485 | static int |
| 437 | memq_no_quit (elt, list) | 486 | memq_no_quit (elt, list) |
| 438 | Lisp_Object elt, list; | 487 | Lisp_Object elt, list; |
| @@ -805,6 +854,17 @@ xfont_draw (s, from, to, x, y, with_background) | |||
| 805 | { | 854 | { |
| 806 | XFontStruct *xfont = s->face->font; | 855 | XFontStruct *xfont = s->face->font; |
| 807 | int len = to - from; | 856 | int len = to - from; |
| 857 | GC gc = s->gc; | ||
| 858 | |||
| 859 | if (gc != s->face->gc) | ||
| 860 | { | ||
| 861 | XGCValues xgcv; | ||
| 862 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (s->f); | ||
| 863 | |||
| 864 | XGetGCValues (s->display, gc, GCFont, &xgcv); | ||
| 865 | if (xgcv.font != xfont->fid) | ||
| 866 | XSetFont (s->display, gc, xfont->fid); | ||
| 867 | } | ||
| 808 | 868 | ||
| 809 | if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) | 869 | if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) |
| 810 | { | 870 | { |
| @@ -817,20 +877,20 @@ xfont_draw (s, from, to, x, y, with_background) | |||
| 817 | str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); | 877 | str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); |
| 818 | if (with_background > 0) | 878 | if (with_background > 0) |
| 819 | XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), | 879 | XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
| 820 | s->gc, x, y, str, len); | 880 | gc, x, y, str, len); |
| 821 | else | 881 | else |
| 822 | XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), | 882 | XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
| 823 | s->gc, x, y, str, len); | 883 | gc, x, y, str, len); |
| 824 | SAFE_FREE (); | 884 | SAFE_FREE (); |
| 825 | return s->nchars; | 885 | return s->nchars; |
| 826 | } | 886 | } |
| 827 | 887 | ||
| 828 | if (with_background > 0) | 888 | if (with_background > 0) |
| 829 | XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), | 889 | XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
| 830 | s->gc, x, y, s->char2b + from, len); | 890 | gc, x, y, s->char2b + from, len); |
| 831 | else | 891 | else |
| 832 | XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), | 892 | XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
| 833 | s->gc, x, y, s->char2b + from, len); | 893 | gc, x, y, s->char2b + from, len); |
| 834 | 894 | ||
| 835 | return len; | 895 | return len; |
| 836 | } | 896 | } |