unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Elias Mårtenson" <lokedhs@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Emacs's algorithm for glyph substitution
Date: Fri, 29 Jun 2018 09:35:34 +0300	[thread overview]
Message-ID: <83o9funlqh.fsf@gnu.org> (raw)
In-Reply-To: <CADtN0WJc5wT26_yvvLF=FPM62SXSOwyaBV-JGN68gEsp-M-rxA@mail.gmail.com> (message from Elias Mårtenson on Fri, 29 Jun 2018 10:54:51 +0800)

> 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.



      reply	other threads:[~2018-06-29  6:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29  2:54 Emacs's algorithm for glyph substitution Elias Mårtenson
2018-06-29  6:35 ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83o9funlqh.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lokedhs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).