all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Do Emacs support font ligatures?
@ 2016-09-25 19:11 Oleksandr Gavenko
  2016-09-26  2:31 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Oleksandr Gavenko @ 2016-09-25 19:11 UTC (permalink / raw)
  To: help-gnu-emacs

Today raising popularity of programming fonts with ligatures:

* https://github.com/i-tu/Hasklig
* https://github.com/tonsky/FiraCode
* https://github.com/larsenwork/monoid

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

but I interested if ligatures supported by font rendering engines behind
Emacs.

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

-- 
http://defun.work/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Do Emacs support font ligatures?
  2016-09-25 19:11 Do Emacs support font ligatures? Oleksandr Gavenko
@ 2016-09-26  2:31 ` Eli Zaretskii
  2016-09-26 20:32   ` Oleksandr Gavenko
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2016-09-26  2:31 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Oleksandr Gavenko <gavenkoa@gmail.com>
> Date: Sun, 25 Sep 2016 22:11:28 +0300
> 
> I interested if ligatures supported by font rendering engines behind
> Emacs.

Unless I misunderstand what you mean, Emacs should already treat
ligatures correctly.  If you see something else, please tell the
details, it could be a bug or a missing feature.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Do Emacs support font ligatures?
  2016-09-26  2:31 ` Eli Zaretskii
@ 2016-09-26 20:32   ` Oleksandr Gavenko
  2016-09-27 14:26     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Oleksandr Gavenko @ 2016-09-26 20:32 UTC (permalink / raw)
  To: help-gnu-emacs

On 2016-09-26, Eli Zaretskii wrote:

>> From: Oleksandr Gavenko <gavenkoa@gmail.com>
>> Date: Sun, 25 Sep 2016 22:11:28 +0300
>> 
>> I interested if ligatures supported by font rendering engines behind
>> Emacs.
>
> Unless I misunderstand what you mean, Emacs should already treat
> ligatures correctly.  If you see something else, please tell the
> details, it could be a bug or a missing feature.

I got font Monoid from:

  http://larsenwork.com/monoid/

Put .ttf files to $HOME/.local/share/fonts:

  -rw-r--r--  1 user user  73052 2016-07-17 04:11:53 Monoid-Bold.ttf
  -rw-r--r--  1 user user  95128 2016-07-17 04:12:14 Monoid-Italic.ttf
  -rw-r--r--  1 user user  79248 2016-07-17 04:13:04 Monoid-Regular.ttf
  -rw-r--r--  1 user user  81928 2016-07-17 04:12:39 Monoid-Retina.ttf

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.

  GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.21.5) of 2016-09-05 on trouble, modified by Debian

================

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.

================

Is that usual for Emacs bug-report to include PNG screenshot?

-- 
http://defun.work/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Do Emacs support font ligatures?
  2016-09-26 20:32   ` Oleksandr Gavenko
@ 2016-09-27 14:26     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2016-09-27 14:26 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Oleksandr Gavenko <gavenkoa@gmail.com>
> 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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-27 14:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-25 19:11 Do Emacs support font ligatures? Oleksandr Gavenko
2016-09-26  2:31 ` Eli Zaretskii
2016-09-26 20:32   ` Oleksandr Gavenko
2016-09-27 14:26     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.