aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-10-29 12:02:20 +0000
committerKenichi Handa2002-10-29 12:02:20 +0000
commit9ca584523ba1ef618b1bd2c5ba11387149ee1e2f (patch)
tree14ce1c6cc651642105d25a9e85a77ef178ac2732 /src
parentbafe00270d95c1e20a6c08af5fb2e525edcd6782 (diff)
downloademacs-9ca584523ba1ef618b1bd2c5ba11387149ee1e2f.tar.gz
emacs-9ca584523ba1ef618b1bd2c5ba11387149ee1e2f.zip
(Vface_resizing_fonts): New variable.
(struct font_name): New member `resizing_ratio'. (font_resizing_ratio): New function. (split_font_name): Set font->resizing_ratio. (better_font_p): Pay attention to font->resizing_ratio. (build_scalable_font_name): Likewise. Don't change POINT_SIZE, RESX, and RESY fields. (try_alternative_families): Try scalable fonts if Vscalable_fonts_allowed is not Qt. (syms_of_xfaces): Declare Vface_resizing_fonts as a Lisp variable.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c85
1 files changed, 74 insertions, 11 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 4af9ceec260..4747681c3bc 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -413,6 +413,10 @@ Lisp_Object Vscalable_fonts_allowed, Qscalable_fonts_allowed;
413 413
414Lisp_Object Vface_ignored_fonts; 414Lisp_Object Vface_ignored_fonts;
415 415
416/* Alist of font name patterns vs the resizing factor. */
417
418Lisp_Object Vface_resizing_fonts;
419
416/* Maximum number of fonts to consider in font_list. If not an 420/* Maximum number of fonts to consider in font_list. If not an
417 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ 421 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */
418 422
@@ -1878,6 +1882,11 @@ struct font_name
1878 split_font_name for which these are. */ 1882 split_font_name for which these are. */
1879 int numeric[XLFD_LAST]; 1883 int numeric[XLFD_LAST];
1880 1884
1885 /* If the original name matches one of Vface_resizing_fonts, the
1886 value is the corresponding resizing ratio. Otherwise, the value
1887 is 1.0. */
1888 double resizing_ratio;
1889
1881 /* Lower value mean higher priority. */ 1890 /* Lower value mean higher priority. */
1882 int registry_priority; 1891 int registry_priority;
1883}; 1892};
@@ -2281,6 +2290,30 @@ pixel_point_size (f, pixel)
2281} 2290}
2282 2291
2283 2292
2293/* Return a resizing ratio of a font of NAME. */
2294
2295static INLINE double
2296font_resizing_ratio (char *name)
2297{
2298 Lisp_Object tail, elt;
2299
2300 if (CONSP (Vface_resizing_fonts))
2301 {
2302 for (tail = Vface_resizing_fonts; CONSP (tail); tail = XCDR (tail))
2303 {
2304 elt = XCAR (tail);
2305 if (STRINGP (XCAR (elt)) && FLOATP (XCDR (elt))
2306 && fast_c_string_match_ignore_case (XCAR (elt), name) >= 0)
2307 {
2308 fprintf (stderr, "resized: %s\n", name);
2309 return XFLOAT_DATA (XCDR (elt));
2310 }
2311 }
2312 }
2313 return 1.0;
2314}
2315
2316
2284/* Split XLFD font name FONT->name destructively into NUL-terminated, 2317/* Split XLFD font name FONT->name destructively into NUL-terminated,
2285 lower-case fields in FONT->fields. NUMERIC_P non-zero means 2318 lower-case fields in FONT->fields. NUMERIC_P non-zero means
2286 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, 2319 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH,
@@ -2297,6 +2330,10 @@ split_font_name (f, font, numeric_p)
2297{ 2330{
2298 int i = 0; 2331 int i = 0;
2299 int success_p; 2332 int success_p;
2333 double resizing_ratio = 1.0;
2334
2335 if (numeric_p && CONSP (Vface_resizing_fonts))
2336 resizing_ratio = font_resizing_ratio (font->name);
2300 2337
2301 if (*font->name == '-') 2338 if (*font->name == '-')
2302 { 2339 {
@@ -2356,6 +2393,7 @@ split_font_name (f, font, numeric_p)
2356 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); 2393 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font);
2357 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); 2394 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font);
2358 font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]); 2395 font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]);
2396 font->resizing_ratio = resizing_ratio;
2359 } 2397 }
2360 2398
2361 /* Initialize it to zero. It will be overridden by font_list while 2399 /* Initialize it to zero. It will be overridden by font_list while
@@ -5821,12 +5859,23 @@ better_font_p (values, font1, font2, compare_pt_p, avgwidth)
5821 5859
5822 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) 5860 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE)
5823 { 5861 {
5824 int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); 5862 int delta1, delta2;
5825 int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); 5863
5864 if (xlfd_idx == XLFD_POINT_SIZE)
5865 {
5866 delta1 = abs (values[i] - (font1->numeric[xlfd_idx]
5867 / font1->resizing_ratio));
5868 delta2 = abs (values[i] - (font2->numeric[xlfd_idx]
5869 / font2->resizing_ratio));
5870 if (abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)
5871 continue;
5872 }
5873 else
5874 {
5875 delta1 = abs (values[i] - font1->numeric[xlfd_idx]);
5876 delta2 = abs (values[i] - font2->numeric[xlfd_idx]);
5877 }
5826 5878
5827 if (xlfd_idx == XLFD_POINT_SIZE
5828 && abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM)
5829 continue;
5830 if (delta1 > delta2) 5879 if (delta1 > delta2)
5831 return 0; 5880 return 0;
5832 else if (delta1 < delta2) 5881 else if (delta1 < delta2)
@@ -5909,17 +5958,22 @@ build_scalable_font_name (f, font, specified_pt)
5909 pt = specified_pt; 5958 pt = specified_pt;
5910 pixel_value = resy / (PT_PER_INCH * 10.0) * pt; 5959 pixel_value = resy / (PT_PER_INCH * 10.0) * pt;
5911 } 5960 }
5912 5961 /* We may need a font of the different size. */
5913 /* Set point size of the font. */ 5962 pixel_value *= font->resizing_ratio;
5914 sprintf (point_size, "%d", (int) pt);
5915 font->fields[XLFD_POINT_SIZE] = point_size;
5916 font->numeric[XLFD_POINT_SIZE] = pt;
5917 5963
5918 /* Set pixel size. */ 5964 /* Set pixel size. */
5919 sprintf (pixel_size, "%d", pixel_value); 5965 sprintf (pixel_size, "%d", pixel_value);
5920 font->fields[XLFD_PIXEL_SIZE] = pixel_size; 5966 font->fields[XLFD_PIXEL_SIZE] = pixel_size;
5921 font->numeric[XLFD_PIXEL_SIZE] = pixel_value; 5967 font->numeric[XLFD_PIXEL_SIZE] = pixel_value;
5922 5968
5969 /* We don't have to change POINT_SIZE, RESX, and RESY of the font
5970 name. */
5971#if 0
5972 /* Set point size of the font. */
5973 sprintf (point_size, "%d", (int) pt);
5974 font->fields[XLFD_POINT_SIZE] = point_size;
5975 font->numeric[XLFD_POINT_SIZE] = pt;
5976
5923 /* If font doesn't specify its resolution, use the 5977 /* If font doesn't specify its resolution, use the
5924 resolution of the display. */ 5978 resolution of the display. */
5925 if (font->numeric[XLFD_RESY] == 0) 5979 if (font->numeric[XLFD_RESY] == 0)
@@ -5938,6 +5992,7 @@ build_scalable_font_name (f, font, specified_pt)
5938 font->fields[XLFD_RESX] = buffer; 5992 font->fields[XLFD_RESX] = buffer;
5939 font->numeric[XLFD_RESX] = resx; 5993 font->numeric[XLFD_RESX] = resx;
5940 } 5994 }
5995#endif
5941 5996
5942 return build_font_name (font); 5997 return build_font_name (font);
5943} 5998}
@@ -6125,7 +6180,7 @@ try_alternative_families (f, family, registry, fonts)
6125 } 6180 }
6126 6181
6127 /* Try scalable fonts before giving up. */ 6182 /* Try scalable fonts before giving up. */
6128 if (nfonts == 0 && NILP (Vscalable_fonts_allowed)) 6183 if (nfonts == 0 && ! EQ (Vscalable_fonts_allowed, Qt))
6129 { 6184 {
6130 int count = BINDING_STACK_SIZE (); 6185 int count = BINDING_STACK_SIZE ();
6131 specbind (Qscalable_fonts_allowed, Qt); 6186 specbind (Qscalable_fonts_allowed, Qt);
@@ -7506,6 +7561,14 @@ Each element is a regular expression that matches names of fonts to
7506ignore. */); 7561ignore. */);
7507 Vface_ignored_fonts = Qnil; 7562 Vface_ignored_fonts = Qnil;
7508 7563
7564 DEFVAR_LISP ("face-resizing-fonts", &Vface_resizing_fonts,
7565 doc: /* Alist of fonts vs the resizing factors.
7566Each element is a cons (FONT-NAME-PATTERN . RESIZING-RATIO), where
7567FONT-NAME-PATTERN is a regular expression matching a font name, and
7568RESIZING-RATIO is a floating point number to specify how much larger
7569\(or smaller) font we should use. For instance, if a face requests
7570a font of 10 point, we actually use a font of 10 * RESIZING-FACE points. */);
7571
7509#ifdef HAVE_WINDOW_SYSTEM 7572#ifdef HAVE_WINDOW_SYSTEM
7510 defsubr (&Sbitmap_spec_p); 7573 defsubr (&Sbitmap_spec_p);
7511 defsubr (&Sx_list_fonts); 7574 defsubr (&Sx_list_fonts);