changeset 89405:3293e7645d53

(Vface_font_rescale_alist): Renamed from Vface_resizing_fonts. (struct font_name): Rename member resizing_ratio to rescale_ratio. (font_rescale_ratio): Renamed from font_resizing_ratio. (split_font_name): Set font->rescale_ratio. (better_font_p): Pay attention to font->rescale_ratio. (build_scalable_font_name): Likewise. Change RESX, and RESY fields. (syms_of_xfaces): Declare Vface_font_rescale_alist as a Lisp variable.
author Kenichi Handa <handa@m17n.org>
date Wed, 09 Apr 2003 08:34:54 +0000
parents 3e1d187b52c3
children dabc7bb5ca37
files src/xfaces.c
diffstat 1 files changed, 42 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Fri Mar 28 04:09:32 2003 +0000
+++ b/src/xfaces.c	Wed Apr 09 08:34:54 2003 +0000
@@ -413,9 +413,9 @@
 
 Lisp_Object Vface_ignored_fonts;
 
-/* Alist of font name patterns vs the resizing factor.  */
-
-Lisp_Object Vface_resizing_fonts;
+/* Alist of font name patterns vs the rescaling factor.  */
+
+Lisp_Object Vface_font_rescale_alist;
 
 /* Maximum number of fonts to consider in font_list.  If not an
    integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead.  */
@@ -1882,10 +1882,10 @@
      split_font_name for which these are.  */
   int numeric[XLFD_LAST];
 
-  /* If the original name matches one of Vface_resizing_fonts, the
-     value is the corresponding resizing ratio.  Otherwise, the value
-     is 1.0.  */
-  double resizing_ratio;
+  /* If the original name matches one of Vface_font_rescale_alist,
+     the value is the corresponding rescale ratio.  Otherwise, the
+     value is 1.0.  */
+  double rescale_ratio;
 
   /* Lower value mean higher priority.  */
   int registry_priority;
@@ -2274,22 +2274,19 @@
 }
 
 
-/* Return a resizing ratio of a font of NAME.  */
-
-static INLINE double
-font_resizing_ratio (char *name)
+/* Return a rescaling ratio of a font of NAME.  */
+
+static double
+font_rescale_ratio (char *name)
 {
   Lisp_Object tail, elt;  
 
-  if (CONSP (Vface_resizing_fonts))
-    {
-      for (tail = Vface_resizing_fonts; CONSP (tail); tail = XCDR (tail))
-	{
-	  elt = XCAR (tail);
-	  if (STRINGP (XCAR (elt)) && FLOATP (XCDR (elt))
-	      && fast_c_string_match_ignore_case (XCAR (elt), name) >= 0)
-	    return XFLOAT_DATA (XCDR (elt));
-	}
+  for (tail = Vface_font_rescale_alist; CONSP (tail); tail = XCDR (tail))
+    {
+      elt = XCAR (tail);
+      if (STRINGP (XCAR (elt)) && FLOATP (XCDR (elt))
+	  && fast_c_string_match_ignore_case (XCAR (elt), name) >= 0)
+	return XFLOAT_DATA (XCDR (elt));
     }
   return 1.0;
 }
@@ -2311,10 +2308,11 @@
 {
   int i = 0;
   int success_p;
-  double resizing_ratio = 1.0;
-
-  if (numeric_p && CONSP (Vface_resizing_fonts))
-    resizing_ratio = font_resizing_ratio (font->name);
+  double rescale_ratio;
+
+  if (numeric_p)
+    /* This must be done before splitting the font name.  */
+    rescale_ratio = font_rescale_ratio (font->name);
 
   if (*font->name == '-')
     {
@@ -2374,7 +2372,7 @@
       font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font);
       font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font);
       font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]);
-      font->resizing_ratio = resizing_ratio;
+      font->rescale_ratio = rescale_ratio;
     }
 
   /* Initialize it to zero.  It will be overridden by font_list while
@@ -5848,9 +5846,9 @@
 	  if (xlfd_idx == XLFD_POINT_SIZE)
 	    {
 	      delta1 = abs (values[i] - (font1->numeric[xlfd_idx]
-					 / font1->resizing_ratio));
+					 / font1->rescale_ratio));
 	      delta2 = abs (values[i] - (font2->numeric[xlfd_idx]
-					 / font2->resizing_ratio));
+					 / font2->rescale_ratio));
 	      if (abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)
 		continue;
 	    }
@@ -5943,21 +5941,22 @@
       pixel_value = resy / (PT_PER_INCH * 10.0) * pt;
     }
   /* We may need a font of the different size.  */
-  pixel_value *= font->resizing_ratio;
+  pixel_value *= font->rescale_ratio;
+
+  /* We should keep POINT_SIZE 0.  Otherwise, X server can't open a
+     font of the specified PIXEL_SIZE.  */
+#if 0
+  /* Set point size of the font.  */
+  sprintf (point_size, "%d", (int) pt);
+  font->fields[XLFD_POINT_SIZE] = point_size;
+  font->numeric[XLFD_POINT_SIZE] = pt;
+#endif
 
   /* Set pixel size.  */
   sprintf (pixel_size, "%d", pixel_value);
   font->fields[XLFD_PIXEL_SIZE] = pixel_size;
   font->numeric[XLFD_PIXEL_SIZE] = pixel_value;
 
-  /* We don't have to change POINT_SIZE, RESX, and RESY of the font
-     name.  */
-#if 0
-  /* Set point size of the font.  */
-  sprintf (point_size, "%d", (int) pt);
-  font->fields[XLFD_POINT_SIZE] = point_size;
-  font->numeric[XLFD_POINT_SIZE] = pt;
-
   /* If font doesn't specify its resolution, use the
      resolution of the display.  */
   if (font->numeric[XLFD_RESY] == 0)
@@ -5976,7 +5975,6 @@
       font->fields[XLFD_RESX] = buffer;
       font->numeric[XLFD_RESX] = resx;
     }
-#endif
 
   return build_font_name (font);
 }
@@ -7570,13 +7568,15 @@
 ignore.  */);
   Vface_ignored_fonts = Qnil;
 
-  DEFVAR_LISP ("face-resizing-fonts", &Vface_resizing_fonts,
-	       doc: /* Alist of fonts vs the resizing factors.
-Each element is a cons (FONT-NAME-PATTERN . RESIZING-RATIO), where
+
+  DEFVAR_LISP ("face-font-rescale-alist", &Vface_font_rescale_alist,
+	       doc: /* Alist of fonts vs the rescaling factors.
+Each element is a cons (FONT-NAME-PATTERN . RESCALE-RATIO), where
 FONT-NAME-PATTERN is a regular expression matching a font name, and
-RESIZING-RATIO is a floating point number to specify how much larger
+RESCALE-RATIO is a floating point number to specify how much larger
 \(or smaller) font we should use.  For instance, if a face requests
-a font of 10 point, we actually use a font of 10 * RESIZING-FACE points.  */);
+a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point.  */);
+  Vface_font_rescale_alist = Qnil;
 
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sbitmap_spec_p);