unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs's algorithm for glyph substitution
@ 2018-06-29  2:54 Elias Mårtenson
  2018-06-29  6:35 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Elias Mårtenson @ 2018-06-29  2:54 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

How does Emacs choose which glyph to use (i.e. from which font to pick the
glyph from) in case the required character is missing from the user's
chosen font?

I have noticed that if I use Source Code Pro and insert some greek
characters into the buffer, it picks those characters from the font Noto
Sans Display instead.

I have a need to do the same thing (I've been implementing a new font
renderer for McCLIM) and since Emacs does such a good job with it, I wanted
to see how Emacs does it, but I have been unable to find the code where
this substitution happens.

Does anyone know where in the Emacs code base this happens, and what the
algorithm is?

Regards,
Elias

[-- Attachment #2: Type: text/html, Size: 807 bytes --]

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

* Re: Emacs's algorithm for glyph substitution
  2018-06-29  2:54 Emacs's algorithm for glyph substitution Elias Mårtenson
@ 2018-06-29  6:35 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2018-06-29  6:35 UTC (permalink / raw)
  To: Elias Mårtenson; +Cc: emacs-devel

> From: Elias Mårtenson <lokedhs@gmail.com>
> Date: Fri, 29 Jun 2018 10:54:51 +0800
> 
> How does Emacs choose which glyph to use (i.e. from which font to pick the glyph from) in case the required
> character is missing from the user's chosen font?

The general answer is it uses the data in the fontsets, moderated by
the fonts you have installed.

> I have noticed that if I use Source Code Pro and insert some greek characters into the buffer, it picks those
> characters from the font Noto Sans Display instead.
> 
> I have a need to do the same thing (I've been implementing a new font renderer for McCLIM) and since Emacs
> does such a good job with it, I wanted to see how Emacs does it, but I have been unable to find the code
> where this substitution happens.

Fonts declare their support for scripts in various ways, and they also
declare support for various OTF features which Emacs knows are needed
for rendering certain scripts.  This provides the general
infrastructure that Emacs uses to do the job.  Users can help Emacs
DTRT by customizing the fontsets via set-fontset-font, if the result
of the default selection is sub-optimal.

> Does anyone know where in the Emacs code base this happens, and what the algorithm is?

The places to look are font.c and fontset.c.  These use various "font
back-ends", I suggest to look at ftfont.c and xftfont.c where you need
to see the back-end implementation of the accessing the fonts.  Most
of the data used by Emacs for the job is set up in fontest.el.  The
algorithm is unfortunately not very well documented (in the comments
to the code), so you will need to make some digging and tracing.  If
you succeed to reach some understandings that are not in the comments,
please do describe them here, so that we could enhance the
documentation.



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

end of thread, other threads:[~2018-06-29  6:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-29  2:54 Emacs's algorithm for glyph substitution Elias Mårtenson
2018-06-29  6:35 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).