emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs's algorithm for glyph substitution


From: Eli Zaretskii
Subject: Re: Emacs's algorithm for glyph substitution
Date: Fri, 29 Jun 2018 09:35:34 +0300

> From: Elias MÃ¥rtenson <address@hidden>
> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]