From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Do Emacs support font ligatures? Date: Tue, 27 Sep 2016 17:26:10 +0300 Message-ID: <838tudctbx.fsf@gnu.org> References: <874m537q1r.fsf@gavenkoa.example.com> <83y42f9ytm.fsf@gnu.org> <87zimuh061.fsf@gavenkoa.example.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1474987454 15354 195.159.176.226 (27 Sep 2016 14:44:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 27 Sep 2016 14:44:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 27 16:44:05 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1botbl-0000wq-Da for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Sep 2016 16:43:45 +0200 Original-Received: from localhost ([::1]:51528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1botbj-0008Ea-U3 for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Sep 2016 10:43:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1botKr-0008Q2-Ui for help-gnu-emacs@gnu.org; Tue, 27 Sep 2016 10:26:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1botKm-0002tK-4E for help-gnu-emacs@gnu.org; Tue, 27 Sep 2016 10:26:16 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1botKm-0002t3-0s for help-gnu-emacs@gnu.org; Tue, 27 Sep 2016 10:26:12 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1844 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1botKk-0007QD-7d for help-gnu-emacs@gnu.org; Tue, 27 Sep 2016 10:26:10 -0400 In-reply-to: <87zimuh061.fsf@gavenkoa.example.com> (message from Oleksandr Gavenko on Mon, 26 Sep 2016 23:32:38 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111408 Archived-At: > From: Oleksandr Gavenko > Date: Mon, 26 Sep 2016 23:32:38 +0300 > > Opened "geany" GTK based editor and select Monoid-9 font. > > Put text: > > == => -> --> > > It was shown as 4 ligatures. > > With "emacs -Q" and: > > (set-frame-font "Monoid-9") > > I see separate glyphs for "=", ">", "-" instead of 4 ligatures. If that is what you meant, then prettify-symbols-mode is exactly for you. I don't think I understand what caused you to think it is not the feature you are looking for. In your original message you wrote: > Of course Emacs has trick with > > (font-lock-add-keywords > 'emacs-lisp-mode > `(("(\\<\\(lambda\\)\\>" > (1 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char > 'greek-iso8859-7 107)) font-lock-keyword-face)) ))) > > and I think even formalized library: > > prettify-symbols-mode The prettify-symbols-mode is _not_ a "trick". The way to tell Emacs to shape a certain character sequence together as a single unit is by defining a "composition rule", like shown above. Emacs already has composition rules defined for character sequences for which either Unicode or some language or script mandate that. For symbols such as the arrows etc. there are no such rules, so by default Emacs displays those characters as separate glyphs (and I'm not even sure it's appropriate to ligate them by default in all buffers). But if you write such rules, or use prettify-symbols-mode with its infrastructure to create those rules, these sequences will be displayed as ligatures if the underlying font supports that. > but I interested if ligatures supported by font rendering engines behind > Emacs. The way Emacs shapes sequences of characters together _is_ by asking the shaping engine how to display them. The shaping engine gets passed the sequence of characters to display, and it returns a sequence of one or more glyphs to display them with. If your Emacs is built with "complex script support" libraries, that is what happens under the hood all the time, whether there are composition rules or not. Some scripts, such as Arabic, are actually barely legible if shaping is not used, because those scripts define how the same character should look in various parts of a word and when adjacent to other characters. So Emacs must shape them correctly to be relevant in the cultures that use these scripts. > Actually author of FiraCode collect tricks how to achieve similar effect in > Emacs with his font: > > https://github.com/tonsky/FiraCode/wiki/Setting-up-Emacs Again, these are not "tricks", this is how this stuff should be done in Emacs, since Emacs users should be able to control whether these character sequences are or aren't displayed as ligatures, and in what buffers/modes. Doing that always is IMO not the Emacsy way for implementing such features. > Under page: > > http://larsenwork.com/monoid/ > > there is "Ligatures" section and site CSS uses embedded fonts. > > If you open in modern Web browser (I've succeeded with Firefox 49) you see > different arrows ligature instead of groups of 2/3 separated glyphs for > =//- characters. Then perhaps EWW, the Emacs Web browser, should also support prettify-symbols-mode, or maybe even turn it on by default. Feel free to file a feature request bug report about that. > Is that usual for Emacs bug-report to include PNG screenshot? You can attach any benign attachment that is relevant to the bug report. However, the only issue worth reporting in this case I can think of is extension of prettify-symbols-mode to more symbols and more major modes, so that users won't need to write such complex Lisp if they don't want to. And maybe also EWW support for that.