From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: A patch for enforcing double-width CJK character display Date: Thu, 12 Apr 2012 17:27:18 +0300 Message-ID: <83ehrt3u0p.fsf@gnu.org> 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> <4F86BA0F.4080301@i-soft.com.cn> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: dough.gmane.org 1334241047 10701 80.91.229.3 (12 Apr 2012 14:30:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 12 Apr 2012 14:30:47 +0000 (UTC) Cc: kanru@kanru.info, emacs-devel@gnu.org To: =?utf-8?B?6buE5bu65b+g?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 12 16:30:46 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 1SIL2q-0001DS-Jx for ged-emacs-devel@m.gmane.org; Thu, 12 Apr 2012 16:30:44 +0200 Original-Received: from localhost ([::1]:42779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIL2p-0003ru-Mj for ged-emacs-devel@m.gmane.org; Thu, 12 Apr 2012 10:30:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIL2h-0003qu-MH for emacs-devel@gnu.org; Thu, 12 Apr 2012 10:30:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIL2c-0006bx-At for emacs-devel@gnu.org; Thu, 12 Apr 2012 10:30:35 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:45036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIL2c-0006b3-1V for emacs-devel@gnu.org; Thu, 12 Apr 2012 10:30:30 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0M2D00900E3JQN00@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Thu, 12 Apr 2012 17:29:20 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.229.57.204]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M2D009QREWVQ1F0@a-mtaout23.012.net.il>; Thu, 12 Apr 2012 17:29:20 +0300 (IDT) In-reply-to: <4F86BA0F.4080301@i-soft.com.cn> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.175 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:149610 Archived-At: > Date: Thu, 12 Apr 2012 19:18:39 +0800 > From: =E9=BB=84=E5=BB=BA=E5=BF=A0 > CC: kanru@kanru.info, emacs-devel@gnu.org >=20 > >> 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 f= rame > > pointer. text-scale-mode does not modify the frame's default fon= t, it > > remaps the 'default' face to another face which specifies a large= r 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 whic= h > > 'default' was remapped. Then you can use FONT_WIDTH, I think (bu= t I > > didn't test this). > I can get the default font(the first font loaded when frame be=20 > initialized) via FRAME_FONT, it's great that it can not be changed = after=20 > first font loaded. > But I still can not get the current width after scale, since the pr= ops=20 > of FRAME_FONT also not be changed. > [...] > I noticed there were some global Lisp_Object such as=20 > "f_Vface_font_rescale_alist"/"f_Vface_remapping_alist"/"f_Vface_new= _frame_defaults",=20 > maybe I can use them, Hope so. This will retrieve the numerical ID of the default face on frame F: int id =3D lookup_basic_face (F, DEFAULT_FACE_ID); lookup_basic_face consults f_Vface_remapping_alist. If the value of id above is different from DEFAULT_FACE_ID, that means the default face was remapped. Then you can get the remapped face like this: struct face *face =3D FACE_FROM_ID (F, id); Now the font of the face is available as struct font *font =3D face->font; And I think FONT_WIDTH (font) will give you the width you want to use instead of FRAME_COLUMN_WIDTH. Again, this is 100% untested. Good luck!