From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?6buE5bu65b+g?= Newsgroups: gmane.emacs.devel Subject: Re: A patch for enforcing double-width CJK character display Date: Thu, 12 Apr 2012 19:18:39 +0800 Message-ID: <4F86BA0F.4080301@i-soft.com.cn> References: <4F85A138.6090900@i-soft.com.cn> <87vcl646c7.fsf@isil.kanru.info> <4F85AE69.9050002@i-soft.com.cn> <4F8698B0.2030703@i-soft.com.cn> <83hawp46p7.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1334229562 7306 80.91.229.3 (12 Apr 2012 11:19:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 12 Apr 2012 11:19:22 +0000 (UTC) Cc: kanru@kanru.info, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 12 13:19:21 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SII3c-0004BU-Kp for ged-emacs-devel@m.gmane.org; Thu, 12 Apr 2012 13:19:20 +0200 Original-Received: from localhost ([::1]:43015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SII3Z-0000ck-Mg for ged-emacs-devel@m.gmane.org; Thu, 12 Apr 2012 07:19:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SII3S-0000SW-JB for emacs-devel@gnu.org; Thu, 12 Apr 2012 07:19:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SII3N-0001Dk-OY for emacs-devel@gnu.org; Thu, 12 Apr 2012 07:19:10 -0400 Original-Received: from mta319.sina.net ([202.108.3.197]:33738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SII3D-0000uf-Nf; Thu, 12 Apr 2012 07:18:56 -0400 X-Originating-IP: [111.161.71.1] Original-Received: from unknown (HELO mta319.sina.net) ([10.54.5.29]) by irxd5-206.sina.net with ESMTP; 12 Apr 2012 19:18:42 +0800 Original-Received: by smtp-5-29.sina.net (SINAMAIL, from userid 1040) id D32FA3028CD; Thu, 12 Apr 2012 19:18:42 +0800 (CST) Original-Received: from piggy.pure64.org (unknown [111.161.71.1]) by smtp-5-29.sina.net (SINAMAIL) with ESMTPA id C16B83028CA; Thu, 12 Apr 2012 19:18:42 +0800 (CST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120327 Thunderbird/10.0.2 In-Reply-To: <83hawp46p7.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.108.3.197 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:149609 Archived-At: 于 2012年04月12日 17:53, Eli Zaretskii 写道: >> Date: Thu, 12 Apr 2012 16:56:16 +0800 >> From: 黄建忠 >> Cc: emacs-devel@gnu.org >> >> FRAME_COLUMN_WIDTH and FRAME_SPACE_WIDTH never changed, it only be >> initialized when first font loaded. > Right, and that's by design. Can be understood, since the width/height of a lot of UI components was determined via these values. > >> Can anybody provide a clue how to catch the new width of default font >> via FRAME_PTR when scale happened? > I don't think there is a way to do that, if all you have is the frame > pointer. text-scale-mode does not modify the frame's default font, it > remaps the 'default' face to another face which specifies a larger or > a smaller font. So the way to find the width of the font after > scaling is to get hold of the font itself, or of the face to which > 'default' was remapped. Then you can use FONT_WIDTH, I think (but I > didn't test this). I can get the default font(the first font loaded when frame be initialized) via FRAME_FONT, it's great that it can not be changed after first font loaded. But I still can not get the current width after scale, since the props of FRAME_FONT also not be changed. Since FRAME_FONT always return the initial value, FONT_WIDTH defined in xterm.h and FONT_WIDTH_NUMERIC defined in font.h DO works but only get the initial value of font width. Of couse a new FcPattern can be created, the family of default font and the pixel_size of current loaded font can be set to the newly created FcPattern, After a FcPatternMatch call , width/average_width can be caculated. But since this function will be involked by "xftfont_text_extents" and "xftfont_draw" many many times, It should not be too complex and time consuming, Otherwise it will affect the performance of font drawing. The problem exist in current patch is the "global variable" and a "dirty workaround function that a little bit difficult to be understood", I need to find a better and clean way to accomplish it. I noticed there were some global Lisp_Object such as "f_Vface_font_rescale_alist"/"f_Vface_remapping_alist"/"f_Vface_new_frame_defaults", maybe I can use them, Hope so. Thanks.