aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2003-04-09 07:26:59 +0000
committerKenichi Handa2003-04-09 07:26:59 +0000
commitf70400f256c3ad4b01d379669efc2df431041ce5 (patch)
tree51098225eeb01df8ad8bc52a15a82b9ad9eca90d /src
parent50ebc53dd0daa339a6e6b14603fcc5ef2f181082 (diff)
downloademacs-f70400f256c3ad4b01d379669efc2df431041ce5.tar.gz
emacs-f70400f256c3ad4b01d379669efc2df431041ce5.zip
(Vface_font_rescale_alist): New variable.
(struct font_name): New member rescale_ratio. (font_rescale_ratio): New function. (split_font_name): If NUMERIC_P is nonzero, set font->rescale_ratio. (better_font_p): On comparing point sized, pay attention to recale_ratio member of fonts. (build_scalable_font_name): Reflect font->rescale_ratio in the font name. (syms_of_xfaces): Declare Vface_font_rescale_alist as a Lisp variable.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c69
1 files changed, 64 insertions, 5 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index ab91fc24de9..4f32e9f9e90 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -368,6 +368,10 @@ Lisp_Object Vscalable_fonts_allowed, Qscalable_fonts_allowed;
368 368
369Lisp_Object Vface_ignored_fonts; 369Lisp_Object Vface_ignored_fonts;
370 370
371/* Alist of font name patterns vs the rescaling factor. */
372
373Lisp_Object Vface_font_rescale_alist;
374
371/* Maximum number of fonts to consider in font_list. If not an 375/* Maximum number of fonts to consider in font_list. If not an
372 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ 376 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */
373 377
@@ -1935,6 +1939,11 @@ struct font_name
1935 split_font_name for which these are. */ 1939 split_font_name for which these are. */
1936 int numeric[XLFD_LAST]; 1940 int numeric[XLFD_LAST];
1937 1941
1942 /* If the original name matches one of Vface_font_rescale_alist,
1943 the value is the corresponding rescale ratio. Otherwise, the
1944 value is 1.0. */
1945 double rescale_ratio;
1946
1938 /* Lower value mean higher priority. */ 1947 /* Lower value mean higher priority. */
1939 int registry_priority; 1948 int registry_priority;
1940}; 1949};
@@ -2265,6 +2274,24 @@ pixel_point_size (f, pixel)
2265} 2274}
2266 2275
2267 2276
2277/* Return a rescaling ratio of a font of NAME. */
2278
2279static double
2280font_rescale_ratio (char *name)
2281{
2282 Lisp_Object tail, elt;
2283
2284 for (tail = Vface_font_rescale_alist; CONSP (tail); tail = XCDR (tail))
2285 {
2286 elt = XCAR (tail);
2287 if (STRINGP (XCAR (elt)) && FLOATP (XCDR (elt))
2288 && fast_c_string_match_ignore_case (XCAR (elt), name) >= 0)
2289 return XFLOAT_DATA (XCDR (elt));
2290 }
2291 return 1.0;
2292}
2293
2294
2268/* Split XLFD font name FONT->name destructively into NUL-terminated, 2295/* Split XLFD font name FONT->name destructively into NUL-terminated,
2269 lower-case fields in FONT->fields. NUMERIC_P non-zero means 2296 lower-case fields in FONT->fields. NUMERIC_P non-zero means
2270 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, 2297 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH,
@@ -2281,6 +2308,11 @@ split_font_name (f, font, numeric_p)
2281{ 2308{
2282 int i = 0; 2309 int i = 0;
2283 int success_p; 2310 int success_p;
2311 double rescale_ratio;
2312
2313 if (numeric_p)
2314 /* This must be done before splitting the font name. */
2315 rescale_ratio = font_rescale_ratio (font->name);
2284 2316
2285 if (*font->name == '-') 2317 if (*font->name == '-')
2286 { 2318 {
@@ -2340,6 +2372,7 @@ split_font_name (f, font, numeric_p)
2340 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); 2372 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font);
2341 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); 2373 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font);
2342 font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]); 2374 font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]);
2375 font->rescale_ratio = rescale_ratio;
2343 } 2376 }
2344 2377
2345 /* Initialize it to zero. It will be overridden by font_list while 2378 /* Initialize it to zero. It will be overridden by font_list while
@@ -5987,12 +6020,23 @@ better_font_p (values, font1, font2, compare_pt_p, avgwidth)
5987 6020
5988 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) 6021 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE)
5989 { 6022 {
5990 int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); 6023 int delta1, delta2;
5991 int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); 6024
6025 if (xlfd_idx == XLFD_POINT_SIZE)
6026 {
6027 delta1 = abs (values[i] - (font1->numeric[xlfd_idx]
6028 / font1->rescale_ratio));
6029 delta2 = abs (values[i] - (font2->numeric[xlfd_idx]
6030 / font2->rescale_ratio));
6031 if (abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)
6032 continue;
6033 }
6034 else
6035 {
6036 delta1 = abs (values[i] - font1->numeric[xlfd_idx]);
6037 delta2 = abs (values[i] - font2->numeric[xlfd_idx]);
6038 }
5992 6039
5993 if (xlfd_idx == XLFD_POINT_SIZE
5994 && abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)
5995 continue;
5996 if (delta1 > delta2) 6040 if (delta1 > delta2)
5997 return 0; 6041 return 0;
5998 else if (delta1 < delta2) 6042 else if (delta1 < delta2)
@@ -6075,11 +6119,17 @@ build_scalable_font_name (f, font, specified_pt)
6075 pt = specified_pt; 6119 pt = specified_pt;
6076 pixel_value = resy / (PT_PER_INCH * 10.0) * pt; 6120 pixel_value = resy / (PT_PER_INCH * 10.0) * pt;
6077 } 6121 }
6122 /* We may need a font of the different size. */
6123 pixel_value *= font->rescale_ratio;
6078 6124
6125 /* We should keep POINT_SIZE 0. Otherwise, X server can't open a
6126 font of the specified PIXEL_SIZE. */
6127#if 0
6079 /* Set point size of the font. */ 6128 /* Set point size of the font. */
6080 sprintf (point_size, "%d", (int) pt); 6129 sprintf (point_size, "%d", (int) pt);
6081 font->fields[XLFD_POINT_SIZE] = point_size; 6130 font->fields[XLFD_POINT_SIZE] = point_size;
6082 font->numeric[XLFD_POINT_SIZE] = pt; 6131 font->numeric[XLFD_POINT_SIZE] = pt;
6132#endif
6083 6133
6084 /* Set pixel size. */ 6134 /* Set pixel size. */
6085 sprintf (pixel_size, "%d", pixel_value); 6135 sprintf (pixel_size, "%d", pixel_value);
@@ -7674,6 +7724,15 @@ Each element is a regular expression that matches names of fonts to
7674ignore. */); 7724ignore. */);
7675 Vface_ignored_fonts = Qnil; 7725 Vface_ignored_fonts = Qnil;
7676 7726
7727 DEFVAR_LISP ("face-font-rescale-alist", &Vface_font_rescale_alist,
7728 doc: /* Alist of fonts vs the rescaling factors.
7729Each element is a cons (FONT-NAME-PATTERN . RESCALE-RATIO), where
7730FONT-NAME-PATTERN is a regular expression matching a font name, and
7731RESCALE-RATIO is a floating point number to specify how much larger
7732\(or smaller) font we should use. For instance, if a face requests
7733a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point. */);
7734 Vface_font_rescale_alist = Qnil;
7735
7677#ifdef HAVE_WINDOW_SYSTEM 7736#ifdef HAVE_WINDOW_SYSTEM
7678 defsubr (&Sbitmap_spec_p); 7737 defsubr (&Sbitmap_spec_p);
7679 defsubr (&Sx_list_fonts); 7738 defsubr (&Sx_list_fonts);