From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Display certain glyphs with paddings on the side Date: Tue, 03 Dec 2019 21:13:23 +0200 Message-ID: <83a789jk8c.fsf@gnu.org> References: <87CA0401-1087-45C1-A952-DB8624C04D32@gmail.com> <83immylmpu.fsf@gnu.org> <83d0d5jom5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="30654"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 03 21:02:47 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1icENi-0007qE-P5 for ged-emacs-devel@m.gmane.org; Tue, 03 Dec 2019 21:02:46 +0100 Original-Received: from localhost ([::1]:58058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icENg-0001xD-Ll for ged-emacs-devel@m.gmane.org; Tue, 03 Dec 2019 15:02:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59751) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icDcP-0003cu-L6 for emacs-devel@gnu.org; Tue, 03 Dec 2019 14:13:54 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1icDcA-0001ue-UW; Tue, 03 Dec 2019 14:13:43 -0500 Original-Received: from [176.228.60.248] (port=3223 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1icDc5-0007dV-Qw; Tue, 03 Dec 2019 14:13:34 -0500 In-reply-to: (message from =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel on Tue, 3 Dec 2019 13:43:33 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.org gmane.emacs.devel:243086 Archived-At: > Cc: emacs-devel@gnu.org > From: Clément Pit-Claudel > Date: Tue, 3 Dec 2019 13:43:33 -0500 > > > No, character composition does nothing to the width of glyphs on > > display. We take the width from the glyph metrics reported by the > > font. > > For the OP's purpose, I think character composition is "enough", in the sense that it can be used to display a glyphs with padding on the sides (as far as I know, composition can't be used to shrink a glyph, however). > > Concretely, I'm think of this: > >   (insert (compose-string "a" 0 1 '(?\s (br . bl) ?\s (bc . bc) ?我))) > > If I'm reading the spec correctly, this should draw the character 我 with padding on both sides to reach the width of two spaces (assuming the choice of fonts is such as 我 is narrower than two spaces to being with). This isn't really workable in practice. First, you'd need to do this for every CJK character, which means redisplay will be much slower for them (since character composition calls Lisp from the display engine, and will have to references a huge char-table). Second, not all CJK characters need to be padded, and you have no easy way of knowing that from Lisp, certainly no fast way. And third, you assume that the width of the space is identical to the width of other characters, which may be true for many fonts, but not for all of them. IOW, as I said in another message, doing layout in Lisp will get you rotten layout. It is only "good enough" for simplistic subsets of the real-life problems, IME.