X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4da9c1365a222952e8a22471b541fb34bd8edcdb..8acf0c0e204877d3c24fcbea6b9e2f84af23678a:/src/xfaces.c diff --git a/src/xfaces.c b/src/xfaces.c index a5c5a21f58..c408a7d368 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -486,7 +486,6 @@ static int font_scalable_p P_ ((struct font_name *)); static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); static unsigned char *xstrlwr P_ ((unsigned char *)); -static void signal_error P_ ((char *, Lisp_Object)); static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); static void load_face_font P_ ((struct frame *, struct face *, int)); static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); @@ -855,17 +854,6 @@ xstrlwr (s) } -/* Signal `error' with message S, and additional argument ARG. */ - -static void -signal_error (s, arg) - char *s; - Lisp_Object arg; -{ - Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil))); -} - - /* If FRAME is nil, return a pointer to the selected frame. Otherwise, check that FRAME is a live frame, and return a pointer to it. NPARAM is the parameter number of FRAME, for @@ -1171,14 +1159,11 @@ load_pixmap (f, name, w_ptr, h_ptr) unsigned int *w_ptr, *h_ptr; { int bitmap_id; - Lisp_Object tem; if (NILP (name)) return 0; - tem = Fbitmap_spec_p (name); - if (NILP (tem)) - wrong_type_argument (Qbitmap_spec_p, name); + CHECK_TYPE (!NILP (Fbitmap_spec_p (name)), Qbitmap_spec_p, name); BLOCK_INPUT; if (CONSP (name)) @@ -1204,7 +1189,7 @@ load_pixmap (f, name, w_ptr, h_ptr) if (bitmap_id < 0) { - add_to_log ("Invalid or undefined bitmap %s", name, Qnil); + add_to_log ("Invalid or undefined bitmap `%s'", name, Qnil); bitmap_id = 0; if (w_ptr) @@ -3276,7 +3261,7 @@ resolve_face_name (face_name, signal_p) if (EQ (hare, tortoise)) { if (signal_p) - Fsignal (Qcircular_list, Fcons (orig_face, Qnil)); + xsignal1 (Qcircular_list, orig_face); return Qdefault; } } @@ -4799,7 +4784,14 @@ x_update_menu_appearance (f) DEFUN ("face-attribute-relative-p", Fface_attribute_relative_p, Sface_attribute_relative_p, 2, 2, 0, - doc: /* Return non-nil if face ATTRIBUTE VALUE is relative. */) + doc: /* Check whether a face attribute value is relative. +Specifically, this function returns t if the attribute ATTRIBUTE +with the value VALUE is relative. + +A relative value is one that doesn't entirely override whatever is +inherited from another face. For most possible attributes, +the only relative value that users see is `unspecified'. +However, for :height, floating point values are also relative. */) (attribute, value) Lisp_Object attribute, value; { @@ -5725,6 +5717,8 @@ lookup_named_face (f, symbol, c, signal_p) if (!realize_basic_faces (f)) return -1; default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + if (default_face == NULL) + abort (); /* realize_basic_faces must have set it up */ } if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p)) @@ -6229,6 +6223,8 @@ face for italic. */) if (! realize_basic_faces (f)) error ("Cannot realize default face"); def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + if (def_face == NULL) + abort (); /* realize_basic_faces must have set it up */ } /* Dispatch to the appropriate handler. */ @@ -6383,6 +6379,12 @@ better_font_p (values, font1, font2, compare_pt_p, avgwidth) { int i; + /* Any font is better than no font. */ + if (! font1) + return 0; + if (! font2) + return 1; + for (i = 0; i < DIM (font_sort_order); ++i) { int xlfd_idx = font_sort_order[i]; @@ -6627,29 +6629,19 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike) if (needs_overstrike) *needs_overstrike = 0; - /* Start with the first non-scalable font in the list. */ - for (i = 0; i < nfonts; ++i) - if (!font_scalable_p (fonts + i)) - break; + best = NULL; /* Find the best match among the non-scalable fonts. */ - if (i < nfonts) - { - best = fonts + i; - - for (i = 1; i < nfonts; ++i) - if (!font_scalable_p (fonts + i) - && better_font_p (specified, fonts + i, best, 1, avgwidth)) - { - best = fonts + i; + for (i = 0; i < nfonts; ++i) + if (!font_scalable_p (fonts + i) + && better_font_p (specified, fonts + i, best, 1, avgwidth)) + { + best = fonts + i; - exact_p = exact_face_match_p (specified, best, avgwidth); - if (exact_p) - break; - } - } - else - best = NULL; + exact_p = exact_face_match_p (specified, best, avgwidth); + if (exact_p) + break; + } /* Unless we found an exact match among non-scalable fonts, see if we can find a better match among scalable fonts. */ @@ -6673,8 +6665,7 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike) for (i = 0; i < nfonts; ++i) if (font_scalable_p (fonts + i)) { - if (best == NULL - || better_font_p (specified, fonts + i, best, 0, 0) + if (better_font_p (specified, fonts + i, best, 0, 0) || (!non_scalable_has_exact_height_p && !better_font_p (specified, best, fonts + i, 0, 0))) { @@ -6682,23 +6673,27 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike) best = fonts + i; } } + } - if (needs_overstrike) - { - enum xlfd_weight want_weight = specified[XLFD_WEIGHT]; - enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT]; + /* We should have found SOME font. */ + if (best == NULL) + abort (); - if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight) - { - /* We want a bold font, but didn't get one; try to use - overstriking instead to simulate bold-face. However, - don't overstrike an already-bold fontn unless the - desired weight grossly exceeds the available weight. */ - if (got_weight > XLFD_WEIGHT_MEDIUM) - *needs_overstrike = (got_weight - want_weight) > 2; - else - *needs_overstrike = 1; - } + if (! exact_p && needs_overstrike) + { + enum xlfd_weight want_weight = specified[XLFD_WEIGHT]; + enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT]; + + if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight) + { + /* We want a bold font, but didn't get one; try to use + overstriking instead to simulate bold-face. However, + don't overstrike an already-bold font unless the + desired weight grossly exceeds the available weight. */ + if (got_weight > XLFD_WEIGHT_MEDIUM) + *needs_overstrike = (want_weight - got_weight) > 2; + else + *needs_overstrike = 1; } } @@ -7074,7 +7069,7 @@ realize_default_face (f) face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID); #ifdef HAVE_WINDOW_SYSTEM -#ifdef HAVE_X_WINDOWS +#ifdef HAVE_X_WINDOWS if (face->font != FRAME_FONT (f)) /* As the font specified for the frame was not acceptable as a font for the default face (perhaps because auto-scaled fonts