From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: face-font-rescale-alist Date: Tue, 1 Apr 2003 21:36:36 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200304011236.VAA03253@etlken.m17n.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1049201512 4546 80.91.224.249 (1 Apr 2003 12:51:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 1 Apr 2003 12:51:52 +0000 (UTC) Cc: emacs-indian@m17n.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Apr 01 14:51:50 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 190LDs-00016Y-00 for ; Tue, 01 Apr 2003 14:50:40 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 190LES-0001UR-00 for ; Tue, 01 Apr 2003 14:51:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 190LCj-0005hW-03 for emacs-devel@quimby.gnus.org; Tue, 01 Apr 2003 07:49:29 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 190LBv-0005Ry-00 for emacs-devel@gnu.org; Tue, 01 Apr 2003 07:48:39 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 190LBO-0005B5-00 for emacs-devel@gnu.org; Tue, 01 Apr 2003 07:48:08 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 190L0K-0001cD-00 for emacs-devel@gnu.org; Tue, 01 Apr 2003 07:36:40 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h31Cab920346 for ; Tue, 1 Apr 2003 21:36:37 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h31CaaA08021; Tue, 1 Apr 2003 21:36:37 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id VAA03253; Tue, 1 Apr 2003 21:36:36 +0900 (JST) Original-To: emacs-devel@gnu.org User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:12798 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12798 I'd like to install the attached patch for HEAD. It provides the variable face-font-rescale-alist to tell Emacs to choose a font of different size. This is necessary especially for a TrueType font which has wrong or incompatible (with the other X fonts) size information. For instance, for Indian scripts, we are currently using CDAC fonts, but they are too small compared with the ASCII fonts opened by the same size. What do people think about this feature? To Indian script users: Could you please try this patch and use this setting? (setq face-font-rescale-alist '(("-cdac$" . 1.3))) How is the ballance of the font sizes? --- Ken'ichi HANDA handa@m17n.org *** xfaces.c.~1.271.~ Mon Feb 24 11:15:33 2003 --- xfaces.c Tue Apr 1 21:08:32 2003 *************** *** 373,378 **** --- 373,382 ---- Lisp_Object Vface_ignored_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. */ *************** *** 1940,1945 **** --- 1944,1954 ---- split_font_name for which these are. */ int numeric[XLFD_LAST]; + /* 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; }; *************** *** 2270,2275 **** --- 2279,2302 ---- } + /* Return a resizing ratio of a font of NAME. */ + + static double + font_rescale_ratio (char *name) + { + Lisp_Object tail, 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; + } + + /* Split XLFD font name FONT->name destructively into NUL-terminated, lower-case fields in FONT->fields. NUMERIC_P non-zero means compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, *************** *** 2286,2291 **** --- 2313,2323 ---- { int i = 0; int success_p; + 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 == '-') { *************** *** 2345,2350 **** --- 2377,2383 ---- 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->rescale_ratio = rescale_ratio; } /* Initialize it to zero. It will be overridden by font_list while *************** *** 5992,6003 **** if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) { ! int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); ! int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); - if (xlfd_idx == XLFD_POINT_SIZE - && abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM) - continue; if (delta1 > delta2) return 0; else if (delta1 < delta2) --- 6025,6047 ---- if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) { ! int delta1, delta2; ! ! if (xlfd_idx == XLFD_POINT_SIZE) ! { ! delta1 = abs (values[i] - (font1->numeric[xlfd_idx] ! / font1->rescale_ratio)); ! delta2 = abs (values[i] - (font2->numeric[xlfd_idx] ! / font2->rescale_ratio)); ! if (abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM) ! continue; ! } ! else ! { ! delta1 = abs (values[i] - font1->numeric[xlfd_idx]); ! delta2 = abs (values[i] - font2->numeric[xlfd_idx]); ! } if (delta1 > delta2) return 0; else if (delta1 < delta2) *************** *** 6080,6090 **** --- 6124,6140 ---- pt = specified_pt; pixel_value = resy / (PT_PER_INCH * 10.0) * pt; } + /* We may need a font of the different size. */ + 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); *************** *** 7675,7680 **** --- 7725,7739 ---- Each element is a regular expression that matches names of fonts to ignore. */); Vface_ignored_fonts = Qnil; + + + 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 + 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 * RESCALE-RATIO points. */); #ifdef HAVE_WINDOW_SYSTEM defsubr (&Sbitmap_spec_p);