diff options
| author | Gerd Moellmann | 2000-11-10 14:40:10 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-11-10 14:40:10 +0000 |
| commit | 32fcc231a095a3aee7938679cc3d03b9ef48b345 (patch) | |
| tree | 369bdfa404dd082cf78a4c28f1f30887a192677b /src | |
| parent | 18f1dcb44938de767e7e8b4640870dedb9b6d844 (diff) | |
| download | emacs-32fcc231a095a3aee7938679cc3d03b9ef48b345.tar.gz emacs-32fcc231a095a3aee7938679cc3d03b9ef48b345.zip | |
(Vface_alternative_font_registry_alist): New variable.
(font_list_1): Renamed from font_list.
(font_list): New function, trying alternative registries from
Vface_alternative_font_registry_alist.
(Finternal_set_alternative_font_registry_alist): New function.
(syms_of_xfaces): Initialize and Staticpro
Vface_alternative_font_registry_alist. Defsubr
Finternal_set_alternative_font_registry_alist.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfaces.c | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index a9066a619cc..732acbd0163 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -375,6 +375,12 @@ Lisp_Object Vface_default_stipple; | |||
| 375 | 375 | ||
| 376 | Lisp_Object Vface_alternative_font_family_alist; | 376 | Lisp_Object Vface_alternative_font_family_alist; |
| 377 | 377 | ||
| 378 | /* Alist of alternative font registries. Each element is of the form | ||
| 379 | (REGISTRY REGISTRY1 REGISTRY2...). If fonts of REGISTRY can't be | ||
| 380 | loaded, try REGISTRY1, then REGISTRY2, ... */ | ||
| 381 | |||
| 382 | Lisp_Object Vface_alternative_font_registry_alist; | ||
| 383 | |||
| 378 | /* Allowed scalable fonts. A value of nil means don't allow any | 384 | /* Allowed scalable fonts. A value of nil means don't allow any |
| 379 | scalable fonts. A value of t means allow the use of any scalable | 385 | scalable fonts. A value of t means allow the use of any scalable |
| 380 | font. Otherwise, value must be a list of regular expressions. A | 386 | font. Otherwise, value must be a list of regular expressions. A |
| @@ -502,6 +508,8 @@ static void free_font_names P_ ((struct font_name *, int)); | |||
| 502 | static int sorted_font_list P_ ((struct frame *, char *, | 508 | static int sorted_font_list P_ ((struct frame *, char *, |
| 503 | int (*cmpfn) P_ ((const void *, const void *)), | 509 | int (*cmpfn) P_ ((const void *, const void *)), |
| 504 | struct font_name **)); | 510 | struct font_name **)); |
| 511 | static int font_list_1 P_ ((struct frame *, Lisp_Object, Lisp_Object, | ||
| 512 | Lisp_Object, struct font_name **)); | ||
| 505 | static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, | 513 | static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, |
| 506 | Lisp_Object, struct font_name **)); | 514 | Lisp_Object, struct font_name **)); |
| 507 | static int try_font_list P_ ((struct frame *, Lisp_Object *, Lisp_Object, | 515 | static int try_font_list P_ ((struct frame *, Lisp_Object *, Lisp_Object, |
| @@ -2504,7 +2512,7 @@ cmp_font_names (a, b) | |||
| 2504 | Value is the number of fonts found. */ | 2512 | Value is the number of fonts found. */ |
| 2505 | 2513 | ||
| 2506 | static int | 2514 | static int |
| 2507 | font_list (f, pattern, family, registry, fonts) | 2515 | font_list_1 (f, pattern, family, registry, fonts) |
| 2508 | struct frame *f; | 2516 | struct frame *f; |
| 2509 | Lisp_Object pattern, family, registry; | 2517 | Lisp_Object pattern, family, registry; |
| 2510 | struct font_name **fonts; | 2518 | struct font_name **fonts; |
| @@ -2538,6 +2546,49 @@ font_list (f, pattern, family, registry, fonts) | |||
| 2538 | } | 2546 | } |
| 2539 | 2547 | ||
| 2540 | 2548 | ||
| 2549 | /* Get a sorted list of fonts of family FAMILY on frame F. | ||
| 2550 | |||
| 2551 | If PATTERN is non-nil list fonts matching that pattern. | ||
| 2552 | |||
| 2553 | If REGISTRY is non-nil, retur fonts with that registry. If none | ||
| 2554 | are found, try alternative registries from | ||
| 2555 | Vface_alternative_font_registry_alist. | ||
| 2556 | |||
| 2557 | If REGISTRY is nil return fonts of any registry. | ||
| 2558 | |||
| 2559 | Set *FONTS to a vector of font_name structures allocated from the | ||
| 2560 | heap containing the fonts found. Value is the number of fonts | ||
| 2561 | found. */ | ||
| 2562 | |||
| 2563 | static int | ||
| 2564 | font_list (f, pattern, family, registry, fonts) | ||
| 2565 | struct frame *f; | ||
| 2566 | Lisp_Object pattern, family, registry; | ||
| 2567 | struct font_name **fonts; | ||
| 2568 | { | ||
| 2569 | int nfonts = font_list_1 (f, pattern, family, registry, fonts); | ||
| 2570 | |||
| 2571 | if (nfonts == 0 | ||
| 2572 | && !NILP (registry) | ||
| 2573 | && CONSP (Vface_alternative_font_registry_alist)) | ||
| 2574 | { | ||
| 2575 | Lisp_Object alter; | ||
| 2576 | |||
| 2577 | alter = Fassoc (registry, Vface_alternative_font_registry_alist); | ||
| 2578 | if (CONSP (alter)) | ||
| 2579 | { | ||
| 2580 | for (alter = XCDR (alter); | ||
| 2581 | CONSP (alter) && nfonts == 0; | ||
| 2582 | alter = XCDR (alter)) | ||
| 2583 | if (STRINGP (XCAR (alter))) | ||
| 2584 | nfonts = font_list_1 (f, pattern, family, XCAR (alter), fonts); | ||
| 2585 | } | ||
| 2586 | } | ||
| 2587 | |||
| 2588 | return nfonts; | ||
| 2589 | } | ||
| 2590 | |||
| 2591 | |||
| 2541 | /* Remove elements from LIST whose cars are `equal'. Called from | 2592 | /* Remove elements from LIST whose cars are `equal'. Called from |
| 2542 | x-family-fonts and x-font-family-list to remove duplicate font | 2593 | x-family-fonts and x-font-family-list to remove duplicate font |
| 2543 | entries. */ | 2594 | entries. */ |
| @@ -5521,6 +5572,23 @@ be found. Value is ALIST.") | |||
| 5521 | } | 5572 | } |
| 5522 | 5573 | ||
| 5523 | 5574 | ||
| 5575 | DEFUN ("internal-set-alternative-font-registry-alist", | ||
| 5576 | Finternal_set_alternative_font_registry_alist, | ||
| 5577 | Sinternal_set_alternative_font_registry_alist, 1, 1, 0, | ||
| 5578 | "Define alternative font registries to try in face font selection.\n\ | ||
| 5579 | ALIST is an alist of (REGISTRY ALTERNATIVE1 ALTERNATIVE2 ...) entries.\n\ | ||
| 5580 | Each ALTERNATIVE is tried in order if no fonts of font registry REGISTRY can\n\ | ||
| 5581 | be found. Value is ALIST.") | ||
| 5582 | (alist) | ||
| 5583 | Lisp_Object alist; | ||
| 5584 | { | ||
| 5585 | CHECK_LIST (alist, 0); | ||
| 5586 | Vface_alternative_font_registry_alist = alist; | ||
| 5587 | free_all_realized_faces (Qnil); | ||
| 5588 | return alist; | ||
| 5589 | } | ||
| 5590 | |||
| 5591 | |||
| 5524 | #ifdef HAVE_WINDOW_SYSTEM | 5592 | #ifdef HAVE_WINDOW_SYSTEM |
| 5525 | 5593 | ||
| 5526 | /* Value is non-zero if FONT is the name of a scalable font. The | 5594 | /* Value is non-zero if FONT is the name of a scalable font. The |
| @@ -5824,13 +5892,11 @@ try_font_list (f, attrs, pattern, family, registry, fonts) | |||
| 5824 | family = attrs[LFACE_FAMILY_INDEX]; | 5892 | family = attrs[LFACE_FAMILY_INDEX]; |
| 5825 | 5893 | ||
| 5826 | nfonts = font_list (f, pattern, family, registry, fonts); | 5894 | nfonts = font_list (f, pattern, family, registry, fonts); |
| 5827 | |||
| 5828 | if (nfonts == 0 && !NILP (family)) | 5895 | if (nfonts == 0 && !NILP (family)) |
| 5829 | { | 5896 | { |
| 5830 | Lisp_Object alter; | 5897 | Lisp_Object alter; |
| 5831 | 5898 | ||
| 5832 | /* Try alternative font families from | 5899 | /* Try alternative font families. */ |
| 5833 | Vface_alternative_font_family_alist. */ | ||
| 5834 | alter = Fassoc (family, Vface_alternative_font_family_alist); | 5900 | alter = Fassoc (family, Vface_alternative_font_family_alist); |
| 5835 | if (CONSP (alter)) | 5901 | if (CONSP (alter)) |
| 5836 | for (alter = XCDR (alter); | 5902 | for (alter = XCDR (alter); |
| @@ -7066,6 +7132,8 @@ syms_of_xfaces () | |||
| 7066 | staticpro (&Vparam_value_alist); | 7132 | staticpro (&Vparam_value_alist); |
| 7067 | Vface_alternative_font_family_alist = Qnil; | 7133 | Vface_alternative_font_family_alist = Qnil; |
| 7068 | staticpro (&Vface_alternative_font_family_alist); | 7134 | staticpro (&Vface_alternative_font_family_alist); |
| 7135 | Vface_alternative_font_registry_alist = Qnil; | ||
| 7136 | staticpro (&Vface_alternative_font_registry_alist); | ||
| 7069 | 7137 | ||
| 7070 | defsubr (&Sinternal_make_lisp_face); | 7138 | defsubr (&Sinternal_make_lisp_face); |
| 7071 | defsubr (&Sinternal_lisp_face_p); | 7139 | defsubr (&Sinternal_lisp_face_p); |
| @@ -7085,6 +7153,7 @@ syms_of_xfaces () | |||
| 7085 | defsubr (&Sframe_face_alist); | 7153 | defsubr (&Sframe_face_alist); |
| 7086 | defsubr (&Sinternal_set_font_selection_order); | 7154 | defsubr (&Sinternal_set_font_selection_order); |
| 7087 | defsubr (&Sinternal_set_alternative_font_family_alist); | 7155 | defsubr (&Sinternal_set_alternative_font_family_alist); |
| 7156 | defsubr (&Sinternal_set_alternative_font_registry_alist); | ||
| 7088 | #if GLYPH_DEBUG | 7157 | #if GLYPH_DEBUG |
| 7089 | defsubr (&Sdump_face); | 7158 | defsubr (&Sdump_face); |
| 7090 | defsubr (&Sshow_face_resources); | 7159 | defsubr (&Sshow_face_resources); |