From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan =?UTF-8?Q?Dj=C3=A4rv?= Newsgroups: gmane.emacs.bugs Subject: bug#7913: 23.2; Mac OS X Dual Spacing Fonts Fix (Patch supplied) Date: Tue, 01 Feb 2011 08:49:55 +0100 Message-ID: <4D47BB23.8020007@swipnet.se> References: <20110125.121401.462117088.idragan@clip.dia.fi.upm.es> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1296547555 2791 80.91.229.12 (1 Feb 2011 08:05:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 Feb 2011 08:05:55 +0000 (UTC) Cc: 7913@debbugs.gnu.org To: Dragan Ivanovic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 01 09:05:50 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PkBFF-0000L9-Kj for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Feb 2011 09:05:50 +0100 Original-Received: from localhost ([127.0.0.1]:54201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkBFE-00046r-Hz for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Feb 2011 03:05:48 -0500 Original-Received: from [140.186.70.92] (port=34313 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkBF6-00046E-7T for bug-gnu-emacs@gnu.org; Tue, 01 Feb 2011 03:05:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PkBF4-000494-Ti for bug-gnu-emacs@gnu.org; Tue, 01 Feb 2011 03:05:40 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PkBF4-000490-PX for bug-gnu-emacs@gnu.org; Tue, 01 Feb 2011 03:05:38 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PkAsD-0003a6-Tn; Tue, 01 Feb 2011 02:42:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jan =?UTF-8?Q?Dj=C3=A4rv?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Feb 2011 07:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7913 X-GNU-PR-Package: emacs,ns X-GNU-PR-Keywords: patch Original-Received: via spool by 7913-submit@debbugs.gnu.org id=B7913.129654610813746 (code B ref 7913); Tue, 01 Feb 2011 07:42:01 +0000 Original-Received: (at 7913) by debbugs.gnu.org; 1 Feb 2011 07:41:48 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PkArz-0003Ze-ML for submit@debbugs.gnu.org; Tue, 01 Feb 2011 02:41:47 -0500 Original-Received: from smtprelay-h22.telenor.se ([195.54.99.197]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PkArw-0003ZP-15 for 7913@debbugs.gnu.org; Tue, 01 Feb 2011 02:41:45 -0500 Original-Received: from ipb4.telenor.se (ipb4.telenor.se [195.54.127.167]) by smtprelay-h22.telenor.se (Postfix) with ESMTP id 847AFC36B for <7913@debbugs.gnu.org>; Tue, 1 Feb 2011 08:50:05 +0100 (CET) X-SENDER-IP: [85.225.45.100] X-LISTENER: [smtp.bredband.net] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao81AG5KR01V4S1kPGdsb2JhbACIYJwiDAEBAQE1L7sqhVEEj2M X-IronPort-AV: E=Sophos;i="4.60,409,1291590000"; d="scan'208";a="1710796674" Original-Received: from c-642de155.25-1-64736c10.cust.bredbandsbolaget.se (HELO coolsville.localdomain) ([85.225.45.100]) by ipb4.telenor.se with ESMTP; 01 Feb 2011 08:50:05 +0100 Original-Received: from [172.20.199.2] (gaffa [172.20.199.2]) by coolsville.localdomain (Postfix) with ESMTP id 1D38E7FA05A; Tue, 1 Feb 2011 08:50:04 +0100 (CET) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 In-Reply-To: <20110125.121401.462117088.idragan@clip.dia.fi.upm.es> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 01 Feb 2011 02:42:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:43805 Archived-At: > > Emacs (v23.2 distro in my case) has a known problem with determining > pixel width of frames when using dual-space (Japanese) fonts. It > arises because the maximum pixel width of characters in those fonts is > way bigger than (usually double the size of) the printable ASCII > characters. Therefore, windows open twice as wide, and the > intelligent line wrapping (as in man or Mew, my favorite email reader) > gets the metrics wrong and forces the text to be wrapped to about one > third of the frame width. > > Patches for X-Windows versions are known, and can be found on Ubuntu > mailing lists. The same problem appears on NextSTEP, i.e., Mac OS > X/Cocoa version. Below is the patch that solves the problem: > > % .................................................................. > > --- nsfont-old.m 2011-01-18 13:36:39.000000000 +0100 > +++ nsfont.m 2011-01-18 13:36:17.000000000 +0100 > @@ -885,9 +885,29 @@ nsfont_open (FRAME_PTR f, Lisp_Object fo > font->ascent = lrint([sfont ascender]); > font->descent = -lrint(floor([sfont descender])); > font->min_width = ns_char_width(sfont, '|'); > - font->space_width = lrint (ns_char_width (sfont, ' ')); > - font->average_width = lrint (font_info->width); > - font->max_width = lrint (font_info->max_bounds.width); > + if([nsfont isFixedPitch]) { > + /* This is a "dirty" fix to avoid problem with some (mostly > + Japanese) fonts that use dual spacing. Unlike in the patches > + to "ftfont.c" and "xftfont.c", in Cocoa we cannot rely on a > + flag (FC_DUAL) to tell us if a fixed width font uses dual > + spacing or not. > + > + To avoid some problems with spaces (e.g. inside the vebatim > + LaTeX environment when using AUCTeX), we measure the width of > + a "regular" character, e.g. M (the size of em-space). */ > + font->space_width = lrint (ns_char_width (sfont, 'M')); > + /* We assume it is the average width. */ > + font->average_width = font->space_width; > + /* We also assume it is the maximal width. This may possibly > + cause some side effects, but I am not aware of any right > + now. */ > + font->max_width = font->space_width; > + } else { > + /* This is the normal v23.2 code */ > + font->space_width = lrint (ns_char_width (sfont, ' ')); > + font->average_width = lrint (font_info->width); > + font->max_width = lrint (font_info->max_bounds.width); > + } > font->height = lrint (font_info->height); > font->underline_position = lrint (font_info->underpos); > font->underline_thickness = lrint (font_info->underwidth); Basically what you do is replace average width with the width of 'M'? If it is a fixed pitch font, max_width, average_width and space_width should all be the same so I don't understand why you substituted space for 'M'. I'm guessing it is the setting of max_width that fixes the problem? Does this make your frames half as big as they where before? Do you have a font I can use to see the problem? Jan D. Jan D.