/[emacs]/emacs/src/xfaces.c
ViewVC logotype

Diff of /emacs/src/xfaces.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.255.2.1 by miles, Fri Apr 4 06:21:08 2003 UTC revision 1.255.2.2 by miles, Tue Oct 14 23:22:49 2003 UTC
# Line 228  Boston, MA 02111-1307, USA.  */ Line 228  Boston, MA 02111-1307, USA.  */
228  #define check_x check_w32  #define check_x check_w32
229  #define x_list_fonts w32_list_fonts  #define x_list_fonts w32_list_fonts
230  #define GCGraphicsExposures 0  #define GCGraphicsExposures 0
 /* For historic reasons, FONT_WIDTH refers to average width on W32,  
    not maximum as on X. Redefine here. */  
 #undef FONT_WIDTH  
 #define FONT_WIDTH FONT_MAX_WIDTH  
231  #endif /* WINDOWSNT */  #endif /* WINDOWSNT */
232    
233  #ifdef MAC_OS  #ifdef MAC_OS
# Line 368  Lisp_Object Vscalable_fonts_allowed, Qsc Line 364  Lisp_Object Vscalable_fonts_allowed, Qsc
364    
365  Lisp_Object Vface_ignored_fonts;  Lisp_Object Vface_ignored_fonts;
366    
367    /* Alist of font name patterns vs the rescaling factor.  */
368    
369    Lisp_Object Vface_font_rescale_alist;
370    
371  /* Maximum number of fonts to consider in font_list.  If not an  /* Maximum number of fonts to consider in font_list.  If not an
372     integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead.  */     integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead.  */
373    
# Line 1211  load_pixmap (f, name, w_ptr, h_ptr) Line 1211  load_pixmap (f, name, w_ptr, h_ptr)
1211    
1212    
1213  /***********************************************************************  /***********************************************************************
                          Minimum font bounds  
  ***********************************************************************/  
   
 #ifdef HAVE_WINDOW_SYSTEM  
   
 /* Update the line_height of frame F.  Return non-zero if line height  
    changes.  */  
   
 int  
 frame_update_line_height (f)  
      struct frame *f;  
 {  
   int line_height, changed_p;  
   
   line_height = FONT_HEIGHT (FRAME_FONT (f));  
   changed_p = line_height != FRAME_LINE_HEIGHT (f);  
   FRAME_LINE_HEIGHT (f) = line_height;  
   return changed_p;  
 }  
   
 #endif /* HAVE_WINDOW_SYSTEM */  
   
   
 /***********************************************************************  
1214                                  Fonts                                  Fonts
1215   ***********************************************************************/   ***********************************************************************/
1216    
# Line 1935  struct font_name Line 1911  struct font_name
1911       split_font_name for which these are.  */       split_font_name for which these are.  */
1912    int numeric[XLFD_LAST];    int numeric[XLFD_LAST];
1913    
1914      /* If the original name matches one of Vface_font_rescale_alist,
1915         the value is the corresponding rescale ratio.  Otherwise, the
1916         value is 1.0.  */
1917      double rescale_ratio;
1918    
1919    /* Lower value mean higher priority.  */    /* Lower value mean higher priority.  */
1920    int registry_priority;    int registry_priority;
1921  };  };
# Line 2265  pixel_point_size (f, pixel) Line 2246  pixel_point_size (f, pixel)
2246  }  }
2247    
2248    
2249    /* Return a rescaling ratio of a font of NAME.  */
2250    
2251    static double
2252    font_rescale_ratio (name)
2253         char *name;
2254    {
2255      Lisp_Object tail, elt;  
2256    
2257      for (tail = Vface_font_rescale_alist; CONSP (tail); tail = XCDR (tail))
2258        {
2259          elt = XCAR (tail);
2260          if (STRINGP (XCAR (elt)) && FLOATP (XCDR (elt))
2261              && fast_c_string_match_ignore_case (XCAR (elt), name) >= 0)
2262            return XFLOAT_DATA (XCDR (elt));
2263        }
2264      return 1.0;
2265    }
2266    
2267    
2268  /* Split XLFD font name FONT->name destructively into NUL-terminated,  /* Split XLFD font name FONT->name destructively into NUL-terminated,
2269     lower-case fields in FONT->fields.  NUMERIC_P non-zero means     lower-case fields in FONT->fields.  NUMERIC_P non-zero means
2270     compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH,     compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH,
# Line 2281  split_font_name (f, font, numeric_p) Line 2281  split_font_name (f, font, numeric_p)
2281  {  {
2282    int i = 0;    int i = 0;
2283    int success_p;    int success_p;
2284      double rescale_ratio;
2285    
2286      if (numeric_p)
2287        /* This must be done before splitting the font name.  */
2288        rescale_ratio = font_rescale_ratio (font->name);
2289    
2290    if (*font->name == '-')    if (*font->name == '-')
2291      {      {
# Line 2340  split_font_name (f, font, numeric_p) Line 2345  split_font_name (f, font, numeric_p)
2345        font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font);        font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font);
2346        font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font);        font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font);
2347        font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]);        font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]);
2348          font->rescale_ratio = rescale_ratio;
2349      }      }
2350    
2351    /* Initialize it to zero.  It will be overridden by font_list while    /* Initialize it to zero.  It will be overridden by font_list while
# Line 2930  the WIDTH times as wide as FACE on FRAME Line 2936  the WIDTH times as wide as FACE on FRAME
2936                             ? NULL                             ? NULL
2937                             : FACE_FROM_ID (f, face_id));                             : FACE_FROM_ID (f, face_id));
2938    
2939    #ifdef WINDOWSNT
2940    /* For historic reasons, FONT_WIDTH refers to average width on W32,
2941       not maximum as on X.  Redefine here. */
2942    #undef FONT_WIDTH
2943    #define FONT_WIDTH FONT_MAX_WIDTH
2944    #endif
2945    
2946        if (face && face->font)        if (face && face->font)
2947          size = FONT_WIDTH (face->font);          size = FONT_WIDTH (face->font);
2948        else        else
2949          size = FONT_WIDTH (FRAME_FONT (f));          size = FONT_WIDTH (FRAME_FONT (f));  /* FRAME_COLUMN_WIDTH (f) */
2950    
2951        if (!NILP (width))        if (!NILP (width))
2952          size *= XINT (width);          size *= XINT (width);
# Line 4123  FRAME 0 means change the face on all fra Line 4136  FRAME 0 means change the face on all fra
4136            struct frame *f;            struct frame *f;
4137            Lisp_Object tmp;            Lisp_Object tmp;
4138    
           CHECK_STRING (value);  
4139            if (EQ (frame, Qt))            if (EQ (frame, Qt))
4140              f = SELECTED_FRAME ();              f = SELECTED_FRAME ();
4141            else            else
4142              f = check_x_frame (frame);              f = check_x_frame (frame);
4143    
4144            /* VALUE may be a fontset name or an alias of fontset.  In            if (!UNSPECIFIEDP (value))
4145               such a case, use the base fontset name.  */              {
4146            tmp = Fquery_fontset (value, Qnil);                CHECK_STRING (value);
           if (!NILP (tmp))  
             value = tmp;  
4147    
4148            if (!set_lface_from_font_name (f, lface, value, 1, 1))                /* VALUE may be a fontset name or an alias of fontset.  In
4149              signal_error ("Invalid font or fontset name", value);                   such a case, use the base fontset name.  */
4150                  tmp = Fquery_fontset (value, Qnil);
4151                  if (!NILP (tmp))
4152                    value = tmp;
4153    
4154                  if (!set_lface_from_font_name (f, lface, value, 1, 1))
4155                    signal_error ("Invalid font or fontset name", value);
4156                }
4157    
4158            font_attr_p = 1;            font_attr_p = 1;
4159          }          }
# Line 4323  set_font_frame_param (frame, lface) Line 4340  set_font_frame_param (frame, lface)
4340            xfree (font);            xfree (font);
4341          }          }
4342    
4343          f->default_face_done_p = 0;
4344        Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font_name), Qnil));        Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font_name), Qnil));
4345      }      }
4346  }  }
# Line 4405  DEFUN ("internal-face-x-get-resource", F Line 4423  DEFUN ("internal-face-x-get-resource", F
4423       Lisp_Object resource, class, frame;       Lisp_Object resource, class, frame;
4424  {  {
4425    Lisp_Object value = Qnil;    Lisp_Object value = Qnil;
 #ifndef WINDOWSNT  
 #ifndef MAC_OS  
4426    CHECK_STRING (resource);    CHECK_STRING (resource);
4427    CHECK_STRING (class);    CHECK_STRING (class);
4428    CHECK_LIVE_FRAME (frame);    CHECK_LIVE_FRAME (frame);
# Line 4414  DEFUN ("internal-face-x-get-resource", F Line 4430  DEFUN ("internal-face-x-get-resource", F
4430    value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)),    value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)),
4431                                    resource, class, Qnil, Qnil);                                    resource, class, Qnil, Qnil);
4432    UNBLOCK_INPUT;    UNBLOCK_INPUT;
 #endif /* not MAC_OS */  
 #endif /* not WINDOWSNT */  
4433    return value;    return value;
4434  }  }
4435    
# Line 5987  better_font_p (values, font1, font2, com Line 6001  better_font_p (values, font1, font2, com
6001    
6002        if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE)        if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE)
6003          {          {
6004            int delta1 = abs (values[i] - font1->numeric[xlfd_idx]);            int delta1, delta2;
6005            int delta2 = abs (values[i] - font2->numeric[xlfd_idx]);  
6006              if (xlfd_idx == XLFD_POINT_SIZE)
6007                {
6008                  delta1 = abs (values[i] - (font1->numeric[xlfd_idx]
6009                                             / font1->rescale_ratio));
6010                  delta2 = abs (values[i] - (font2->numeric[xlfd_idx]
6011                                             / font2->rescale_ratio));
6012                  if (abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)
6013                    continue;
6014                }
6015              else
6016                {
6017                  delta1 = abs (values[i] - font1->numeric[xlfd_idx]);
6018                  delta2 = abs (values[i] - font2->numeric[xlfd_idx]);
6019                }
6020    
           if (xlfd_idx == XLFD_POINT_SIZE  
               && abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)  
             continue;  
6021            if (delta1 > delta2)            if (delta1 > delta2)
6022              return 0;              return 0;
6023            else if (delta1 < delta2)            else if (delta1 < delta2)
# Line 6020  better_font_p (values, font1, font2, com Line 6045  better_font_p (values, font1, font2, com
6045          return 1;          return 1;
6046      }      }
6047    
6048      if (! compare_pt_p)
6049        {
6050          /* We prefer a real scalable font; i.e. not what autoscaled.  */
6051          int auto_scaled_1 = (font1->numeric[XLFD_POINT_SIZE] == 0
6052                               && font1->numeric[XLFD_RESY] > 0);
6053          int auto_scaled_2 = (font2->numeric[XLFD_POINT_SIZE] == 0
6054                               && font2->numeric[XLFD_RESY] > 0);
6055    
6056          if (auto_scaled_1 != auto_scaled_2)
6057            return auto_scaled_2;
6058        }
6059    
6060    return font1->registry_priority < font2->registry_priority;    return font1->registry_priority < font2->registry_priority;
6061  }  }
6062    
# Line 6057  build_scalable_font_name (f, font, speci Line 6094  build_scalable_font_name (f, font, speci
6094       struct font_name *font;       struct font_name *font;
6095       int specified_pt;       int specified_pt;
6096  {  {
6097    char point_size[20], pixel_size[20];    char pixel_size[20];
6098    int pixel_value;    int pixel_value;
6099    double resy = FRAME_X_DISPLAY_INFO (f)->resy;    double resy = FRAME_X_DISPLAY_INFO (f)->resy;
6100    double pt;    double pt;
# Line 6075  build_scalable_font_name (f, font, speci Line 6112  build_scalable_font_name (f, font, speci
6112        pt = specified_pt;        pt = specified_pt;
6113        pixel_value = resy / (PT_PER_INCH * 10.0) * pt;        pixel_value = resy / (PT_PER_INCH * 10.0) * pt;
6114      }      }
6115      /* We may need a font of the different size.  */
6116      pixel_value *= font->rescale_ratio;
6117    
6118    /* Set point size of the font.  */    /* We should keep POINT_SIZE 0.  Otherwise, X server can't open a
6119    sprintf (point_size, "%d", (int) pt);       font of the specified PIXEL_SIZE.  */
6120    font->fields[XLFD_POINT_SIZE] = point_size;  #if 0
6121    font->numeric[XLFD_POINT_SIZE] = pt;    { /* Set point size of the font.  */
6122        char point_size[20];
6123        sprintf (point_size, "%d", (int) pt);
6124        font->fields[XLFD_POINT_SIZE] = point_size;
6125        font->numeric[XLFD_POINT_SIZE] = pt;
6126      }
6127    #endif
6128    
6129    /* Set pixel size.  */    /* Set pixel size.  */
6130    sprintf (pixel_size, "%d", pixel_value);    sprintf (pixel_size, "%d", pixel_value);
# Line 6244  best_matching_font (f, attrs, fonts, nfo Line 6289  best_matching_font (f, attrs, fonts, nfo
6289                  || better_font_p (specified, fonts + i, best, 0, 0)                  || better_font_p (specified, fonts + i, best, 0, 0)
6290                  || (!non_scalable_has_exact_height_p                  || (!non_scalable_has_exact_height_p
6291                      && !better_font_p (specified, best, fonts + i, 0, 0)))                      && !better_font_p (specified, best, fonts + i, 0, 0)))
6292                best = fonts + i;                {
6293                    non_scalable_has_exact_height_p = 1;
6294                    best = fonts + i;
6295                  }
6296            }            }
6297    
6298        if (needs_overstrike)        if (needs_overstrike)
# Line 6391  try_font_list (f, attrs, family, registr Line 6439  try_font_list (f, attrs, family, registr
6439    
6440    /* Try any family with the given registry.  */    /* Try any family with the given registry.  */
6441    if (nfonts == 0)    if (nfonts == 0)
6442      nfonts = font_list (f, Qnil, Qnil, registry, fonts);      nfonts = try_alternative_families (f, Qnil, registry, fonts);
6443    
6444    return nfonts;    return nfonts;
6445  }  }
# Line 6540  realize_default_face (f) Line 6588  realize_default_face (f)
6588    /* If the `default' face is not yet known, create it.  */    /* If the `default' face is not yet known, create it.  */
6589    lface = lface_from_face_name (f, Qdefault, 0);    lface = lface_from_face_name (f, Qdefault, 0);
6590    if (NILP (lface))    if (NILP (lface))
6591      {    {
6592        Lisp_Object frame;         Lisp_Object frame;
6593        XSETFRAME (frame, f);         XSETFRAME (frame, f);
6594        lface = Finternal_make_lisp_face (Qdefault, frame);         lface = Finternal_make_lisp_face (Qdefault, frame);
6595      }    }
6596    
6597    
6598  #ifdef HAVE_WINDOW_SYSTEM  #ifdef HAVE_WINDOW_SYSTEM
6599    if (FRAME_WINDOW_P (f))    if (FRAME_WINDOW_P (f))
# Line 6553  realize_default_face (f) Line 6602  realize_default_face (f)
6602        frame_font = Fassq (Qfont, f->param_alist);        frame_font = Fassq (Qfont, f->param_alist);
6603        xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font)));        xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font)));
6604        frame_font = XCDR (frame_font);        frame_font = XCDR (frame_font);
6605        set_lface_from_font_name (f, lface, frame_font, 1, 1);        set_lface_from_font_name (f, lface, frame_font,
6606                                    f->default_face_done_p, 1);
6607          f->default_face_done_p = 1;
6608      }      }
6609  #endif /* HAVE_WINDOW_SYSTEM */  #endif /* HAVE_WINDOW_SYSTEM */
6610    
# Line 7674  Each element is a regular expression tha Line 7725  Each element is a regular expression tha
7725  ignore.  */);  ignore.  */);
7726    Vface_ignored_fonts = Qnil;    Vface_ignored_fonts = Qnil;
7727    
7728      DEFVAR_LISP ("face-font-rescale-alist", &Vface_font_rescale_alist,
7729                   doc: /* Alist of fonts vs the rescaling factors.
7730    Each element is a cons (FONT-NAME-PATTERN . RESCALE-RATIO), where
7731    FONT-NAME-PATTERN is a regular expression matching a font name, and
7732    RESCALE-RATIO is a floating point number to specify how much larger
7733    \(or smaller) font we should use.  For instance, if a face requests
7734    a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point.  */);
7735      Vface_font_rescale_alist = Qnil;
7736    
7737  #ifdef HAVE_WINDOW_SYSTEM  #ifdef HAVE_WINDOW_SYSTEM
7738    defsubr (&Sbitmap_spec_p);    defsubr (&Sbitmap_spec_p);
7739    defsubr (&Sx_list_fonts);    defsubr (&Sx_list_fonts);
# Line 7682  ignore.  */); Line 7742  ignore.  */);
7742    defsubr (&Sx_font_family_list);    defsubr (&Sx_font_family_list);
7743  #endif /* HAVE_WINDOW_SYSTEM */  #endif /* HAVE_WINDOW_SYSTEM */
7744  }  }
7745    
7746    /* arch-tag: 8a0f7598-5517-408d-9ab3-1da6fcd4c749
7747       (do not change this comment) */

Legend:
Removed from v.1.255.2.1  
changed lines
  Added in v.1.255.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26