*** empty log message ***
[bpt/emacs.git] / src / xfaces.c
index 9121497..c588527 100644 (file)
@@ -1376,7 +1376,7 @@ tty_defined_color (f, color_name, color_def, alloc)
   color_def->green = 0;
 
   if (*color_name)
-    status = tty_lookup_color (f, build_string (color_name), color_def, 0);
+    status = tty_lookup_color (f, build_string (color_name), color_def, NULL);
 
   if (color_def->pixel == FACE_TTY_DEFAULT_COLOR && *color_name)
     {
@@ -2108,7 +2108,7 @@ face_value (table, dim, symbol)
 static INLINE int
 face_numeric_value (table, dim, symbol)
      struct table_entry *table;
-     int dim;
+     size_t dim;
      Lisp_Object symbol;
 {
   struct table_entry *p = face_value (table, dim, symbol);
@@ -2230,7 +2230,9 @@ xlfd_fixed_p (font)
    72dpi versions, only.)
 
    Value is the real point size of FONT on frame F, or 0 if it cannot
-   be determined.  */
+   be determined.
+
+   By side effect, set FONT->numeric[XLFD_PIXEL_SIZE].  */
 
 static INLINE int
 xlfd_point_size (f, font)
@@ -2269,6 +2271,7 @@ xlfd_point_size (f, font)
   else
     pixel = atoi (pixel_field);
 
+  font->numeric[XLFD_PIXEL_SIZE] = pixel;
   if (pixel == 0)
     real_pt = 0;
   else
@@ -3354,13 +3357,18 @@ set_lface_from_font_name (f, lface, fontname, force_p, may_fail_p)
     LFACE_SLANT (lface)
       = have_xlfd_p ? xlfd_symbolic_slant (&font) : Qnormal;
 
-  if (fontset)
+  if (fontset > 0)
     {
       LFACE_FONT (lface) = build_string (font_info->full_name);
       LFACE_FONTSET (lface) = fontset_name (fontset);
     }
   else
-    LFACE_FONT (lface) = fontname;
+    {
+      LFACE_FONT (lface) = fontname;
+      fontset
+       = new_fontset_from_font_name (build_string (font_info->full_name));
+      LFACE_FONTSET (lface) = fontset_name (fontset);
+    }
   return 1;
 }
 
@@ -4860,15 +4868,18 @@ Default face attributes override any local face attributes.  */)
    return fonts with the same size as the font of a face.  This is
    done in fontset.el.  */
 
-DEFUN ("face-font", Fface_font, Sface_font, 1, 2, 0,
+DEFUN ("face-font", Fface_font, Sface_font, 1, 3, 0,
        doc: /* Return the font name of face FACE, or nil if it is unspecified.
+The font name is, by default, for ASCII characters.
 If the optional argument FRAME is given, report on face FACE in that frame.
 If FRAME is t, report on the defaults for face FACE (for new frames).
   The font default for a face is either nil, or a list
   of the form (bold), (italic) or (bold italic).
-If FRAME is omitted or nil, use the selected frame.  */)
-     (face, frame)
-     Lisp_Object face, frame;
+If FRAME is omitted or nil, use the selected frame.  And, in this case,
+if the optional third argument CHARACTER is given,
+return the font name used for CHARACTER.  */)
+     (face, frame, character)
+     Lisp_Object face, frame, character;
 {
   if (EQ (frame, Qt))
     {
@@ -4890,7 +4901,17 @@ If FRAME is omitted or nil, use the selected frame.  */)
       struct frame *f = frame_or_selected_frame (frame, 1);
       int face_id = lookup_named_face (f, face);
       struct face *face = FACE_FROM_ID (f, face_id);
-      return face ? build_string (face->font_name) : Qnil;
+
+      if (! face)
+       return Qnil;
+      if (NILP (character))
+       return build_string (face->font_name);
+      CHECK_CHARACTER (character);
+      face_id = FACE_FOR_CHAR (f, face, XINT (character), -1, Qnil);
+      face = FACE_FROM_ID (f, face_id);
+      return (face->font && face->font_name
+             ? build_string (face->font_name)
+             : Qnil);
     }
 }
 
@@ -4953,18 +4974,8 @@ If FRAME is omitted or nil, use the selected frame.  */)
      Lisp_Object face1, face2, frame;
 {
   int equal_p;
-  struct frame *f;
   Lisp_Object lface1, lface2;
 
-  if (EQ (frame, Qt))
-    f = NULL;
-  else
-    /* Don't use check_x_frame here because this function is called
-       before X frames exist.  At that time, if FRAME is nil,
-       selected_frame will be used which is the frame dumped with
-       Emacs.  That frame is not an X frame.  */
-    f = frame_or_selected_frame (frame, 2);
-
   lface1 = lface_from_face_name (NULL, face1, 1);
   lface2 = lface_from_face_name (NULL, face2, 1);
   equal_p = lface_equal_p (XVECTOR (lface1)->contents,
@@ -6207,6 +6218,12 @@ build_scalable_font_name (f, font, specified_pt)
   double resy = FRAME_X_DISPLAY_INFO (f)->resy;
   double pt;
 
+  if (font->numeric[XLFD_PIXEL_SIZE] != 0
+      || font->numeric[XLFD_POINT_SIZE] != 0)
+    /* This is a scalable font but is requested for a specific size.
+       We should not change that size.  */
+    return build_font_name (font);
+
   /* If scalable font is for a specific resolution, compute
      the point size we must specify from the resolution of
      the display and the specified resolution of the font.  */
@@ -6503,7 +6520,16 @@ try_font_list (f, pattern, family, registry, fonts)
   int nfonts = 0;
 
   if (STRINGP (pattern))
-    nfonts = font_list (f, pattern, Qnil, Qnil, fonts);
+    {
+      nfonts = font_list (f, pattern, Qnil, Qnil, fonts);
+      if (nfonts == 0 && ! EQ (Vscalable_fonts_allowed, Qt))
+       {
+         int count = SPECPDL_INDEX ();
+         specbind (Qscalable_fonts_allowed, Qt);
+         nfonts = font_list (f, pattern, Qnil, Qnil, fonts);
+         unbind_to (count, Qnil);
+       }
+    }
   else
     {
       Lisp_Object tail;
@@ -7311,7 +7337,7 @@ compute_char_face (f, ch, prop)
   if (NILP (prop))
     {
       struct face *face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
-      face_id = FACE_FOR_CHAR (f, face, ch);
+      face_id = FACE_FOR_CHAR (f, face, ch, -1, Qnil);
     }
   else
     {
@@ -7323,7 +7349,7 @@ compute_char_face (f, ch, prop)
       if (! ASCII_CHAR_P (ch))
        {
          face = FACE_FROM_ID (f, face_id);
-         face_id = FACE_FOR_CHAR (f, face, ch);
+         face_id = FACE_FOR_CHAR (f, face, ch, -1, Qnil);
        }
     }