Mercurial > emacs
comparison src/xfaces.c @ 33372:2a665186a9e9
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 10 Nov 2000 14:40:10 +0000 |
parents | 8c453c73a11b |
children | 2e6d343c238d |
comparison
equal
deleted
inserted
replaced
33371:8259eb8d96c2 | 33372:2a665186a9e9 |
---|---|
372 /* Alist of alternative font families. Each element is of the form | 372 /* Alist of alternative font families. Each element is of the form |
373 (FAMILY FAMILY1 FAMILY2 ...). If fonts of FAMILY can't be loaded, | 373 (FAMILY FAMILY1 FAMILY2 ...). If fonts of FAMILY can't be loaded, |
374 try FAMILY1, then FAMILY2, ... */ | 374 try FAMILY1, then FAMILY2, ... */ |
375 | 375 |
376 Lisp_Object Vface_alternative_font_family_alist; | 376 Lisp_Object Vface_alternative_font_family_alist; |
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; | |
377 | 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 |
381 font may be scaled if its name matches a regular expression in the | 387 font may be scaled if its name matches a regular expression in the |
500 static char *build_font_name P_ ((struct font_name *)); | 506 static char *build_font_name P_ ((struct font_name *)); |
501 static void free_font_names P_ ((struct font_name *, int)); | 507 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, |
508 Lisp_Object, Lisp_Object, struct font_name **)); | 516 Lisp_Object, Lisp_Object, struct font_name **)); |
509 static int cmp_font_names P_ ((const void *, const void *)); | 517 static int cmp_font_names P_ ((const void *, const void *)); |
2502 return fonts of any registry. Set *FONTS to a vector of font_name | 2510 return fonts of any registry. Set *FONTS to a vector of font_name |
2503 structures allocated from the heap containing the fonts found. | 2511 structures allocated from the heap containing the fonts found. |
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; |
2511 { | 2519 { |
2512 char *pattern_str, *family_str, *registry_str; | 2520 char *pattern_str, *family_str, *registry_str; |
2533 } | 2541 } |
2534 else | 2542 else |
2535 pattern_str = (char *) XSTRING (pattern)->data; | 2543 pattern_str = (char *) XSTRING (pattern)->data; |
2536 | 2544 |
2537 return sorted_font_list (f, pattern_str, cmp_font_names, fonts); | 2545 return sorted_font_list (f, pattern_str, cmp_font_names, fonts); |
2546 } | |
2547 | |
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; | |
2538 } | 2589 } |
2539 | 2590 |
2540 | 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 |
5519 free_all_realized_faces (Qnil); | 5570 free_all_realized_faces (Qnil); |
5520 return alist; | 5571 return 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 |
5527 X11R6 XLFD spec says that point size, pixel size, and average width | 5595 X11R6 XLFD spec says that point size, pixel size, and average width |
5528 are zero for scalable fonts. Intlfonts contain at least one | 5596 are zero for scalable fonts. Intlfonts contain at least one |
5822 | 5890 |
5823 if (NILP (family) && STRINGP (attrs[LFACE_FAMILY_INDEX])) | 5891 if (NILP (family) && STRINGP (attrs[LFACE_FAMILY_INDEX])) |
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); |
5837 CONSP (alter) && nfonts == 0; | 5903 CONSP (alter) && nfonts == 0; |
5838 alter = XCDR (alter)) | 5904 alter = XCDR (alter)) |
7064 | 7130 |
7065 Vparam_value_alist = Fcons (Fcons (Qnil, Qnil), Qnil); | 7131 Vparam_value_alist = Fcons (Fcons (Qnil, Qnil), Qnil); |
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); |
7072 defsubr (&Sinternal_set_lisp_face_attribute); | 7140 defsubr (&Sinternal_set_lisp_face_attribute); |
7073 #ifdef HAVE_WINDOW_SYSTEM | 7141 #ifdef HAVE_WINDOW_SYSTEM |
7083 defsubr (&Sinternal_merge_in_global_face); | 7151 defsubr (&Sinternal_merge_in_global_face); |
7084 defsubr (&Sface_font); | 7152 defsubr (&Sface_font); |
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); |
7091 #endif /* GLYPH_DEBUG */ | 7160 #endif /* GLYPH_DEBUG */ |
7092 defsubr (&Sclear_face_cache); | 7161 defsubr (&Sclear_face_cache); |