From c64d66eb3afaf6323cda2f1bde16df4ef25cf76d Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Wed, 9 Apr 2003 08:35:07 +0000 Subject: [PATCH] (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. --- src/ChangeLog | 24 +++++++++++++++++ src/xfaces.c | 74 +++++++++++++++++++++++++-------------------------- 2 files changed, 61 insertions(+), 37 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a3b8c0d4d3a..b7c3c33061d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,27 @@ +2003-04-09 Kenichi Handa + + The following changes are to make the font rescaling facility + compatible with Emacs 21. + + * xfaces.c (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. + +2003-03-28 Kenichi Handa + + * coding.c (Qutf_16_be_nosig, Qutf_16_be, Qutf_16_le_nosig) + (Qutf_16_le): Remove these variables. + (syms_of_coding): Don't DEFSYM them. + (decode_coding_utf_16): Fix handling of BOM. + (encode_coding_utf_16): Fix handling of BOM. + 2003-03-14 Kenichi Handa * fileio.c (Finsert_file_contents): On replacing, before decoding diff --git a/src/xfaces.c b/src/xfaces.c index 277f1908810..cb976c33153 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -413,9 +413,9 @@ Lisp_Object Vscalable_fonts_allowed, Qscalable_fonts_allowed; Lisp_Object Vface_ignored_fonts; -/* Alist of font name patterns vs the resizing factor. */ +/* Alist of font name patterns vs the rescaling factor. */ -Lisp_Object Vface_resizing_fonts; +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 @@ struct font_name 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 @@ pixel_point_size (f, pixel) } -/* Return a resizing ratio of a font of NAME. */ +/* Return a rescaling ratio of a font of NAME. */ -static INLINE double -font_resizing_ratio (char *name) +static double +font_rescale_ratio (char *name) { Lisp_Object tail, elt; - if (CONSP (Vface_resizing_fonts)) + for (tail = Vface_font_rescale_alist; CONSP (tail); tail = XCDR (tail)) { - 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)); - } + 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 @@ split_font_name (f, font, numeric_p) { int i = 0; int success_p; - double resizing_ratio = 1.0; + double rescale_ratio; - if (numeric_p && CONSP (Vface_resizing_fonts)) - resizing_ratio = font_resizing_ratio (font->name); + 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 @@ split_font_name (f, font, numeric_p) 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 @@ better_font_p (values, font1, font2, compare_pt_p, avgwidth) 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,20 +5941,21 @@ build_scalable_font_name (f, font, specified_pt) pixel_value = resy / (PT_PER_INCH * 10.0) * pt; } /* We may need a font of the different size. */ - pixel_value *= font->resizing_ratio; - - /* Set pixel size. */ - sprintf (pixel_size, "%d", pixel_value); - font->fields[XLFD_PIXEL_SIZE] = pixel_size; - font->numeric[XLFD_PIXEL_SIZE] = pixel_value; + pixel_value *= font->rescale_ratio; - /* We don't have to change POINT_SIZE, RESX, and RESY of the font - name. */ + /* 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; /* If font doesn't specify its resolution, use the resolution of the display. */ @@ -5976,7 +5975,6 @@ build_scalable_font_name (f, font, specified_pt) font->fields[XLFD_RESX] = buffer; font->numeric[XLFD_RESX] = resx; } -#endif return build_font_name (font); } @@ -7570,13 +7568,15 @@ Each element is a regular expression that matches names of fonts to 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); -- 2.39.5