From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Ligature support Date: Fri, 05 Nov 2021 16:33:16 +0200 Message-ID: <83v916d64z.fsf@gnu.org> References: <87cznths5j.fsf@gnus.org> <834k91vgie.fsf@gnu.org> <8ff3b131c5fa370d9eaf@heytings.org> <83mtmttsxz.fsf@gnu.org> <8ff3b131c56b7b2d1d6f@heytings.org> <83bl39tqnl.fsf@gnu.org> <8ff3b131c531f5254799@heytings.org> <83a6ittp5r.fsf@gnu.org> <8ff3b131c53b9df49236@heytings.org> <834k91th5c.fsf@gnu.org> <8ff3b131c5fe09753ca0@heytings.org> <83mtmtru6l.fsf@gnu.org> <8ff3b131c57f741d04e5@heytings.org> <83lf2drqx6.fsf@gnu.org> <87lf2c3k0z.fsf@gnus.org> <83wnlwqocq.fsf@gnu.org> <87wnlwyox9.fsf@gnus.org> <83lf2cq7n5.fsf@gnu.org> <87wnlnkxbo.fsf@gnus.org> <83cznfdohr.fsf@gnu.org> <87zgqik9bk.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18098"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mattiase@acm.org, raman@google.com, gregory@heytings.org, schwab@linux-m68k.org, stefankangas@gmail.com, emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 05 15:36:52 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mj0Kj-0004L6-E0 for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Nov 2021 15:36:45 +0100 Original-Received: from localhost ([::1]:55814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mj0Kh-0006U2-DH for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Nov 2021 10:36:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mj0Hi-0001h7-IJ for emacs-devel@gnu.org; Fri, 05 Nov 2021 10:33:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mj0Hg-00058N-U3; Fri, 05 Nov 2021 10:33:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=oeaXhlsr2q30W95zjoMV7OYoLo7ZD9Ojl5MhLy560ow=; b=qeo8joVGPzve 6YHzdNI54CqM40pIXeQy6kH/6XgPvYxdbcuBezIgqoRZb7AbBcUBiCHIiurd8tjaED2h7yqE0+7cI jFCxBsDXJFx4YfJil26l5PBmW5h52lV+GK4D0fN01n6UMg2TNQ/7sI6ncgy2g02BNbVRE4yjQvLmC ifuOprnrswMO9we6sON/SYSZVM6EIeT4gmqnEBgMvI+KA82JJ9xEjmlO+yjG+Nh1UdPnvG9FQIIVj 9KHowWPuo6nos8gikNvqNUqQoSF8RwGyTTgZ/t1w1sNAYUAbMyd41mmrMaczvngwGRgP+W7xga0wU vx8psXOPUQsFbITYP4rbog==; Original-Received: from [87.69.77.57] (port=1842 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mj0Hf-0003Gr-He; Fri, 05 Nov 2021 10:33:36 -0400 In-Reply-To: <87zgqik9bk.fsf@gnus.org> (message from Lars Ingebrigtsen on Fri, 05 Nov 2021 14:42:39 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:278770 Archived-At: > From: Lars Ingebrigtsen > Cc: gregory@heytings.org, mattiase@acm.org, emacs-devel@gnu.org, > schwab@linux-m68k.org, stefankangas@gmail.com, raman@google.com > Date: Fri, 05 Nov 2021 14:42:39 +0100 > > Eli Zaretskii writes: > > > We have font-shape-gstring. If the font being used doesn't have a > > ligature for the character sequence we pass to it, that function > > returns nil, and we then display those characters "normally". Isn't > > that enough? > > That's what I thought the design here was originally -- but that's not > what's happening in general in Emacs. If I instrument > font-shape-gstring and start "emacs -Q", that function is never called. > It's not until I insert something that we've set up something in... > composition-function-table?... that the function is called and harfbuzz > is consulted. (You can confirm by setting a breakpoint on > hbfont_shape.) Yes, because characters whose slot in composition-function-table is nil aren't handed to the shaping engine; we display them directly. > I thought we'd just send all the text through hb_shape_full, and it > would handle all this stuff. But we don't -- we only send a very small > subset of the strings through that function, as far as I can tell. Right, and by design. Character composition is somewhat slow in Emacs: the display code calls into Lisp, and Lisp then turns around and calls into C. Doing that for every piece of text would slow down redisplay, so we don't do that unless composition-function-table tells us we should. So for having ligatures you need to set up composition-function-table for the characters that could/should ligate. This article is a good starting point: https://en.wikipedia.org/wiki/Ligature_(writing) But please read the TODO item: there are pitfalls here that we need to solve before this could be considered a reasonable user-level feature. Setting up composition-function-table to produce ligatures for, say, "fi" and "ff" is easy for testing, but if you do that in production, every word with these characters, everywhere on display in Emacs, will display as that ligature, and that is hardly TRT. We need to make this more fine-tunable. TODO has the details.