413 |
|
|
414 |
Lisp_Object Vface_ignored_fonts; |
Lisp_Object Vface_ignored_fonts; |
415 |
|
|
416 |
|
/* Alist of font name patterns vs the resizing factor. */ |
417 |
|
|
418 |
|
Lisp_Object Vface_resizing_fonts; |
419 |
|
|
420 |
/* Maximum number of fonts to consider in font_list. If not an |
/* Maximum number of fonts to consider in font_list. If not an |
421 |
integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ |
integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ |
422 |
|
|
1882 |
split_font_name for which these are. */ |
split_font_name for which these are. */ |
1883 |
int numeric[XLFD_LAST]; |
int numeric[XLFD_LAST]; |
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 |
|
|
1890 |
/* Lower value mean higher priority. */ |
/* Lower value mean higher priority. */ |
1891 |
int registry_priority; |
int registry_priority; |
1892 |
}; |
}; |
2290 |
} |
} |
2291 |
|
|
2292 |
|
|
2293 |
|
/* Return a resizing ratio of a font of NAME. */ |
2294 |
|
|
2295 |
|
static INLINE double |
2296 |
|
font_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 |
|
|
2317 |
/* Split XLFD font name FONT->name destructively into NUL-terminated, |
/* Split XLFD font name FONT->name destructively into NUL-terminated, |
2318 |
lower-case fields in FONT->fields. NUMERIC_P non-zero means |
lower-case fields in FONT->fields. NUMERIC_P non-zero means |
2319 |
compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, |
compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, |
2330 |
{ |
{ |
2331 |
int i = 0; |
int i = 0; |
2332 |
int success_p; |
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); |
2337 |
|
|
2338 |
if (*font->name == '-') |
if (*font->name == '-') |
2339 |
{ |
{ |
2393 |
font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); |
font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); |
2394 |
font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); |
font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); |
2395 |
font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]); |
font->numeric[XLFD_AVGWIDTH] = atoi (font->fields[XLFD_AVGWIDTH]); |
2396 |
|
font->resizing_ratio = resizing_ratio; |
2397 |
} |
} |
2398 |
|
|
2399 |
/* Initialize it to zero. It will be overridden by font_list while |
/* Initialize it to zero. It will be overridden by font_list while |
5859 |
|
|
5860 |
if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) |
if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) |
5861 |
{ |
{ |
5862 |
int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); |
int delta1, delta2; |
5863 |
int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); |
|
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 |
|
} |
5878 |
|
|
|
if (xlfd_idx == XLFD_POINT_SIZE |
|
|
&& abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM) |
|
|
continue; |
|
5879 |
if (delta1 > delta2) |
if (delta1 > delta2) |
5880 |
return 0; |
return 0; |
5881 |
else if (delta1 < delta2) |
else if (delta1 < delta2) |
5958 |
pt = specified_pt; |
pt = specified_pt; |
5959 |
pixel_value = resy / (PT_PER_INCH * 10.0) * pt; |
pixel_value = resy / (PT_PER_INCH * 10.0) * pt; |
5960 |
} |
} |
5961 |
|
/* We may need a font of the different size. */ |
5962 |
/* Set point size of the font. */ |
pixel_value *= font->resizing_ratio; |
|
sprintf (point_size, "%d", (int) pt); |
|
|
font->fields[XLFD_POINT_SIZE] = point_size; |
|
|
font->numeric[XLFD_POINT_SIZE] = pt; |
|
5963 |
|
|
5964 |
/* Set pixel size. */ |
/* Set pixel size. */ |
5965 |
sprintf (pixel_size, "%d", pixel_value); |
sprintf (pixel_size, "%d", pixel_value); |
5966 |
font->fields[XLFD_PIXEL_SIZE] = pixel_size; |
font->fields[XLFD_PIXEL_SIZE] = pixel_size; |
5967 |
font->numeric[XLFD_PIXEL_SIZE] = pixel_value; |
font->numeric[XLFD_PIXEL_SIZE] = pixel_value; |
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 |
|
|
5977 |
/* If font doesn't specify its resolution, use the |
/* If font doesn't specify its resolution, use the |
5978 |
resolution of the display. */ |
resolution of the display. */ |
5979 |
if (font->numeric[XLFD_RESY] == 0) |
if (font->numeric[XLFD_RESY] == 0) |
5992 |
font->fields[XLFD_RESX] = buffer; |
font->fields[XLFD_RESX] = buffer; |
5993 |
font->numeric[XLFD_RESX] = resx; |
font->numeric[XLFD_RESX] = resx; |
5994 |
} |
} |
5995 |
|
#endif |
5996 |
|
|
5997 |
return build_font_name (font); |
return build_font_name (font); |
5998 |
} |
} |
6180 |
} |
} |
6181 |
|
|
6182 |
/* Try scalable fonts before giving up. */ |
/* Try scalable fonts before giving up. */ |
6183 |
if (nfonts == 0 && NILP (Vscalable_fonts_allowed)) |
if (nfonts == 0 && ! EQ (Vscalable_fonts_allowed, Qt)) |
6184 |
{ |
{ |
6185 |
int count = BINDING_STACK_SIZE (); |
int count = BINDING_STACK_SIZE (); |
6186 |
specbind (Qscalable_fonts_allowed, Qt); |
specbind (Qscalable_fonts_allowed, Qt); |
7561 |
ignore. */); |
ignore. */); |
7562 |
Vface_ignored_fonts = Qnil; |
Vface_ignored_fonts = Qnil; |
7563 |
|
|
7564 |
|
DEFVAR_LISP ("face-resizing-fonts", &Vface_resizing_fonts, |
7565 |
|
doc: /* Alist of fonts vs the resizing factors. |
7566 |
|
Each element is a cons (FONT-NAME-PATTERN . RESIZING-RATIO), where |
7567 |
|
FONT-NAME-PATTERN is a regular expression matching a font name, and |
7568 |
|
RESIZING-RATIO is a floating point number to specify how much larger |
7569 |
|
\(or smaller) font we should use. For instance, if a face requests |
7570 |
|
a font of 10 point, we actually use a font of 10 * RESIZING-FACE points. */); |
7571 |
|
|
7572 |
#ifdef HAVE_WINDOW_SYSTEM |
#ifdef HAVE_WINDOW_SYSTEM |
7573 |
defsubr (&Sbitmap_spec_p); |
defsubr (&Sbitmap_spec_p); |
7574 |
defsubr (&Sx_list_fonts); |
defsubr (&Sx_list_fonts); |