diff options
| author | Gerd Moellmann | 1999-11-25 15:01:15 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-11-25 15:01:15 +0000 |
| commit | 3221576ba2f2c074227dc4ca28843e1d8d578db5 (patch) | |
| tree | 6400fc3b485ca2668328a0157ede56f83abebb67 /src | |
| parent | b185f63a8c2db0e5d5f0269db3733508ab8708cc (diff) | |
| download | emacs-3221576ba2f2c074227dc4ca28843e1d8d578db5.tar.gz emacs-3221576ba2f2c074227dc4ca28843e1d8d578db5.zip | |
(set_lface_from_font_name): New parameter may_fail_p.
Callers changed. If specified font name is bogus, and mail_fail_p
is set, try to use a reasonable default.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/xfaces.c | 69 |
2 files changed, 51 insertions, 22 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4a9160ae5de..6c23fdb3eb3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 1999-11-25 Gerd Moellmann <gerd@gnu.org> | 1 | 1999-11-25 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * xfaces.c (set_lface_from_font_name): New parameter may_fail_p. | ||
| 4 | Callers changed. If specified font name is bogus, and mail_fail_p | ||
| 5 | is not set, try to use a reasonable default. | ||
| 6 | |||
| 3 | * dispnew.c (direct_output_for_insert): Set glyph row's | 7 | * dispnew.c (direct_output_for_insert): Set glyph row's |
| 4 | displays_text_p flag. Correct window's window_end_vpos if | 8 | displays_text_p flag. Correct window's window_end_vpos if |
| 5 | necessary. | 9 | necessary. |
diff --git a/src/xfaces.c b/src/xfaces.c index 9004a2d65e9..963c8ed10ff 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -461,7 +461,7 @@ static void merge_face_vectors P_ ((Lisp_Object *from, Lisp_Object *)); | |||
| 461 | static void merge_face_vector_with_property P_ ((struct frame *, Lisp_Object *, | 461 | static void merge_face_vector_with_property P_ ((struct frame *, Lisp_Object *, |
| 462 | Lisp_Object)); | 462 | Lisp_Object)); |
| 463 | static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, char *, | 463 | static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, char *, |
| 464 | int)); | 464 | int, int)); |
| 465 | static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); | 465 | static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); |
| 466 | static struct face *make_realized_face P_ ((Lisp_Object *, int, Lisp_Object)); | 466 | static struct face *make_realized_face P_ ((Lisp_Object *, int, Lisp_Object)); |
| 467 | static void free_realized_faces P_ ((struct face_cache *)); | 467 | static void free_realized_faces P_ ((struct face_cache *)); |
| @@ -2705,29 +2705,33 @@ lface_fully_specified_p (attrs) | |||
| 2705 | 2705 | ||
| 2706 | /* Set font-related attributes of Lisp face LFACE from XLFD font name | 2706 | /* Set font-related attributes of Lisp face LFACE from XLFD font name |
| 2707 | FONT_NAME. If FORCE_P is zero, set only unspecified attributes of | 2707 | FONT_NAME. If FORCE_P is zero, set only unspecified attributes of |
| 2708 | LFACE. Ignore fields of FONT_NAME containing wildcards. Value is | 2708 | LFACE. MAY_FAIL_P non-zero means return 0 if FONT_NAME isn't a |
| 2709 | zero if not successful because FONT_NAME was not in a valid format. | 2709 | valid font name; otherwise this function tries to use a reasonable |
| 2710 | A valid format is one that is suitable for split_font_name, see the | 2710 | default font. |
| 2711 | comment there. */ | 2711 | |
| 2712 | Ignore fields of FONT_NAME containing wildcards. Value is zero if | ||
| 2713 | not successful because FONT_NAME was not in a valid format and | ||
| 2714 | MAY_FAIL_P was non-zero. A valid format is one that is suitable | ||
| 2715 | for split_font_name, see the comment there. */ | ||
| 2712 | 2716 | ||
| 2713 | static int | 2717 | static int |
| 2714 | set_lface_from_font_name (f, lface, font_name, force_p) | 2718 | set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p) |
| 2715 | struct frame *f; | 2719 | struct frame *f; |
| 2716 | Lisp_Object lface; | 2720 | Lisp_Object lface; |
| 2717 | char *font_name; | 2721 | char *font_name; |
| 2718 | int force_p; | 2722 | int force_p, may_fail_p; |
| 2719 | { | 2723 | { |
| 2720 | struct font_name font; | 2724 | struct font_name font; |
| 2721 | char *buffer; | 2725 | char *buffer; |
| 2722 | int pt; | 2726 | int pt; |
| 2723 | int free_font_name_p = 0; | 2727 | int free_font_name_p = 0; |
| 2728 | int have_font_p = 0; | ||
| 2724 | 2729 | ||
| 2725 | /* If FONT_NAME contains wildcards, use the first matching font. */ | 2730 | /* If FONT_NAME contains wildcards, use the first matching font. */ |
| 2726 | if (index (font_name, '*') || index (font_name, '?')) | 2731 | if (index (font_name, '*') || index (font_name, '?')) |
| 2727 | { | 2732 | { |
| 2728 | if (!first_font_matching (f, font_name, &font)) | 2733 | if (first_font_matching (f, font_name, &font)) |
| 2729 | return 0; | 2734 | free_font_name_p = have_font_p = 1; |
| 2730 | free_font_name_p = 1; | ||
| 2731 | } | 2735 | } |
| 2732 | else | 2736 | else |
| 2733 | { | 2737 | { |
| @@ -2742,18 +2746,39 @@ set_lface_from_font_name (f, lface, font_name, force_p) | |||
| 2742 | font_info = fs_load_font (f, FRAME_X_FONT_TABLE (f), | 2746 | font_info = fs_load_font (f, FRAME_X_FONT_TABLE (f), |
| 2743 | CHARSET_ASCII, font_name, -1); | 2747 | CHARSET_ASCII, font_name, -1); |
| 2744 | UNBLOCK_INPUT; | 2748 | UNBLOCK_INPUT; |
| 2745 | 2749 | ||
| 2746 | if (!font_info) | 2750 | if (font_info) |
| 2747 | return 0; | 2751 | { |
| 2748 | 2752 | font.name = STRDUPA (font_info->full_name); | |
| 2749 | font.name = STRDUPA (font_info->full_name); | 2753 | split_font_name (f, &font, 1); |
| 2750 | split_font_name (f, &font, 1); | 2754 | have_font_p = 1; |
| 2755 | } | ||
| 2751 | } | 2756 | } |
| 2752 | |||
| 2753 | /* FONT_NAME should not be a fontset name, here. */ | ||
| 2754 | xassert (xstricmp (font.fields[XLFD_REGISTRY], "fontset") != 0); | ||
| 2755 | } | 2757 | } |
| 2756 | 2758 | ||
| 2759 | /* If FONT_NAME is completely bogus try to use something reasonable | ||
| 2760 | if this function must succeed. Otherwise, give up. */ | ||
| 2761 | if (!have_font_p) | ||
| 2762 | { | ||
| 2763 | if (may_fail_p) | ||
| 2764 | return 0; | ||
| 2765 | else if (first_font_matching (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1", | ||
| 2766 | &font) | ||
| 2767 | || first_font_matching (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1", | ||
| 2768 | &font) | ||
| 2769 | || first_font_matching (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1", | ||
| 2770 | &font) | ||
| 2771 | || first_font_matching (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1", | ||
| 2772 | &font) | ||
| 2773 | || first_font_matching (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1", | ||
| 2774 | &font) | ||
| 2775 | || first_font_matching (f, "fixed", &font)) | ||
| 2776 | free_font_name_p = 1; | ||
| 2777 | else | ||
| 2778 | abort (); | ||
| 2779 | } | ||
| 2780 | |||
| 2781 | |||
| 2757 | /* Set attributes only if unspecified, otherwise face defaults for | 2782 | /* Set attributes only if unspecified, otherwise face defaults for |
| 2758 | new frames would never take effect. */ | 2783 | new frames would never take effect. */ |
| 2759 | 2784 | ||
| @@ -3410,7 +3435,7 @@ frame.") | |||
| 3410 | else | 3435 | else |
| 3411 | f = check_x_frame (frame); | 3436 | f = check_x_frame (frame); |
| 3412 | 3437 | ||
| 3413 | if (!set_lface_from_font_name (f, lface, XSTRING (value)->data, 1)) | 3438 | if (!set_lface_from_font_name (f, lface, XSTRING (value)->data, 1, 1)) |
| 3414 | signal_error ("Invalid font name", value); | 3439 | signal_error ("Invalid font name", value); |
| 3415 | 3440 | ||
| 3416 | font_related_attr_p = 1; | 3441 | font_related_attr_p = 1; |
| @@ -5526,7 +5551,7 @@ realize_default_face (f) | |||
| 5526 | UNBLOCK_INPUT; | 5551 | UNBLOCK_INPUT; |
| 5527 | 5552 | ||
| 5528 | /* Set weight etc. from the ASCII font. */ | 5553 | /* Set weight etc. from the ASCII font. */ |
| 5529 | if (!set_lface_from_font_name (f, lface, font_info->full_name, 0)) | 5554 | if (!set_lface_from_font_name (f, lface, font_info->full_name, 0, 0)) |
| 5530 | return 0; | 5555 | return 0; |
| 5531 | 5556 | ||
| 5532 | /* Remember registry and encoding of the frame font. */ | 5557 | /* Remember registry and encoding of the frame font. */ |
| @@ -5554,7 +5579,7 @@ realize_default_face (f) | |||
| 5554 | /* Frame parameters contain a real font. Fill default face | 5579 | /* Frame parameters contain a real font. Fill default face |
| 5555 | attributes from that font. */ | 5580 | attributes from that font. */ |
| 5556 | if (!set_lface_from_font_name (f, lface, | 5581 | if (!set_lface_from_font_name (f, lface, |
| 5557 | XSTRING (frame_font)->data, 0)) | 5582 | XSTRING (frame_font)->data, 0, 0)) |
| 5558 | return 0; | 5583 | return 0; |
| 5559 | 5584 | ||
| 5560 | /* Remember registry and encoding of the frame font. */ | 5585 | /* Remember registry and encoding of the frame font. */ |