diff options
| author | Jim Blandy | 1993-05-25 02:18:33 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-05-25 02:18:33 +0000 |
| commit | f0614854a5d18eab37fc76b2f38b8f916a191e92 (patch) | |
| tree | 75068fd79183d28c644f32d563ed08a797d39ba9 | |
| parent | 316aafd641d561e1fbd491cf39817db74ed533e8 (diff) | |
| download | emacs-f0614854a5d18eab37fc76b2f38b8f916a191e92.tar.gz emacs-f0614854a5d18eab37fc76b2f38b8f916a191e92.zip | |
* xfns.c (select_visual): Include the screen number in the
template of things XGetVisualInfo must match.
* xfns.c (Fx_list_fonts): New function.
(same_size_fonts): Function moved here from xfaces.c.
(face_name_id_number): Add extern declaration for this.
| -rw-r--r-- | src/xfns.c | 99 |
1 files changed, 98 insertions, 1 deletions
diff --git a/src/xfns.c b/src/xfns.c index b4413e2e940..369532b87ef 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -2325,6 +2325,99 @@ x_rubber_band (f, x, y, width, height, geo, str, hscroll, vscroll) | |||
| 2325 | } | 2325 | } |
| 2326 | #endif /* not HAVE_X11 */ | 2326 | #endif /* not HAVE_X11 */ |
| 2327 | 2327 | ||
| 2328 | extern int face_name_id_number (); | ||
| 2329 | |||
| 2330 | /* Return non-zero if FONT1 and FONT2 have the same size bounding box. | ||
| 2331 | We assume that they're both character-cell fonts. */ | ||
| 2332 | int | ||
| 2333 | same_size_fonts (font1, font2) | ||
| 2334 | XFontStruct *font1, *font2; | ||
| 2335 | { | ||
| 2336 | XCharStruct *bounds1 = &font1->min_bounds; | ||
| 2337 | XCharStruct *bounds2 = &font2->min_bounds; | ||
| 2338 | |||
| 2339 | return (bounds1->width == bounds2->width | ||
| 2340 | && bounds1->ascent == bounds2->ascent | ||
| 2341 | && bounds1->descent == bounds2->descent); | ||
| 2342 | } | ||
| 2343 | |||
| 2344 | |||
| 2345 | DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 3, 0, | ||
| 2346 | "Return a list of the names of available fonts matching PATTERN.\n\ | ||
| 2347 | If optional arguments FACE and FRAME are specified, return only fonts\n\ | ||
| 2348 | the same size as FACE on FRAME.\n\ | ||
| 2349 | \n\ | ||
| 2350 | PATTERN is a string, perhaps with wildcard characters;\n\ | ||
| 2351 | the * character matches any substring, and\n\ | ||
| 2352 | the ? character matches any single character.\n\ | ||
| 2353 | PATTERN is case-insensitive.\n\ | ||
| 2354 | FACE is a face name - a symbol.\n\ | ||
| 2355 | \n\ | ||
| 2356 | The return value is a list of strings, suitable as arguments to\n\ | ||
| 2357 | set-face-font.\n\ | ||
| 2358 | \n\ | ||
| 2359 | The list does not include fonts Emacs can't use (i.e. proportional\n\ | ||
| 2360 | fonts), even if they match PATTERN and FACE.") | ||
| 2361 | (pattern, face, frame) | ||
| 2362 | Lisp_Object pattern, face, frame; | ||
| 2363 | { | ||
| 2364 | int num_fonts; | ||
| 2365 | char **names; | ||
| 2366 | XFontStruct *info; | ||
| 2367 | XFontStruct *size_ref; | ||
| 2368 | Lisp_Object list; | ||
| 2369 | |||
| 2370 | CHECK_STRING (pattern, 0); | ||
| 2371 | if (!NILP (face)) | ||
| 2372 | CHECK_SYMBOL (face, 1); | ||
| 2373 | if (!NILP (frame)) | ||
| 2374 | CHECK_SYMBOL (frame, 2); | ||
| 2375 | |||
| 2376 | if (NILP (face)) | ||
| 2377 | size_ref = 0; | ||
| 2378 | else | ||
| 2379 | { | ||
| 2380 | FRAME_PTR f = NILP (frame) ? selected_frame : XFRAME (frame); | ||
| 2381 | int face_id = face_name_id_number (f, face); | ||
| 2382 | |||
| 2383 | if (face_id < 0 || face_id > FRAME_N_FACES (f)) | ||
| 2384 | face_id = 0; | ||
| 2385 | size_ref = FRAME_FACES (f) [face_id]->font; | ||
| 2386 | if (size_ref == (XFontStruct *) (~0)) | ||
| 2387 | size_ref = FRAME_DEFAULT_FACE (f)->font; | ||
| 2388 | } | ||
| 2389 | |||
| 2390 | BLOCK_INPUT; | ||
| 2391 | names = XListFontsWithInfo (x_current_display, | ||
| 2392 | XSTRING (pattern)->data, | ||
| 2393 | 30000, /* maxnames */ | ||
| 2394 | &num_fonts, /* count_return */ | ||
| 2395 | &info); /* info_return */ | ||
| 2396 | UNBLOCK_INPUT; | ||
| 2397 | |||
| 2398 | { | ||
| 2399 | Lisp_Object *tail; | ||
| 2400 | int i; | ||
| 2401 | |||
| 2402 | list = Qnil; | ||
| 2403 | tail = &list; | ||
| 2404 | for (i = 0; i < num_fonts; i++) | ||
| 2405 | /* Is this an acceptable font? */ | ||
| 2406 | if (! info[i].per_char | ||
| 2407 | && (! size_ref | ||
| 2408 | || same_size_fonts (&info[i], size_ref))) | ||
| 2409 | { | ||
| 2410 | *tail = Fcons (build_string (names[i]), Qnil); | ||
| 2411 | tail = &XCONS (*tail)->cdr; | ||
| 2412 | } | ||
| 2413 | |||
| 2414 | XFreeFontInfo (names, info, num_fonts); | ||
| 2415 | } | ||
| 2416 | |||
| 2417 | return list; | ||
| 2418 | } | ||
| 2419 | |||
| 2420 | |||
| 2328 | DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0, | 2421 | DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0, |
| 2329 | "Return t if the current X display supports the color named COLOR.") | 2422 | "Return t if the current X display supports the color named COLOR.") |
| 2330 | (color) | 2423 | (color) |
| @@ -3577,7 +3670,10 @@ select_visual (screen, depth) | |||
| 3577 | vinfo_template.visualid = v->visualid; | 3670 | vinfo_template.visualid = v->visualid; |
| 3578 | #endif | 3671 | #endif |
| 3579 | 3672 | ||
| 3580 | vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template, | 3673 | vinfo_template.screen = XScreenNumberOfScreen (screen); |
| 3674 | |||
| 3675 | vinfo = XGetVisualInfo (x_current_display, | ||
| 3676 | VisualIDMask | VisualScreenMask, &vinfo_template, | ||
| 3581 | &n_visuals); | 3677 | &n_visuals); |
| 3582 | if (n_visuals != 1) | 3678 | if (n_visuals != 1) |
| 3583 | fatal ("Can't get proper X visual info"); | 3679 | fatal ("Can't get proper X visual info"); |
| @@ -3820,6 +3916,7 @@ unless you set the mouse color."); | |||
| 3820 | defsubr (&Sx_uncontour_region); | 3916 | defsubr (&Sx_uncontour_region); |
| 3821 | #endif | 3917 | #endif |
| 3822 | defsubr (&Sx_display_color_p); | 3918 | defsubr (&Sx_display_color_p); |
| 3919 | defsubr (&Sx_list_fonts); | ||
| 3823 | defsubr (&Sx_color_defined_p); | 3920 | defsubr (&Sx_color_defined_p); |
| 3824 | defsubr (&Sx_server_vendor); | 3921 | defsubr (&Sx_server_vendor); |
| 3825 | defsubr (&Sx_server_version); | 3922 | defsubr (&Sx_server_version); |