From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Emacs's algorithm for glyph substitution Date: Fri, 29 Jun 2018 09:35:34 +0300 Message-ID: <83o9funlqh.fsf@gnu.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1530254012 6774 195.159.176.226 (29 Jun 2018 06:33:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Jun 2018 06:33:32 +0000 (UTC) Cc: emacs-devel@gnu.org To: Elias =?utf-8?Q?M=C3=A5rtenson?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 29 08:33:28 2018 Return-path: Envelope-to: ged-emacs-devel@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 1fYmyF-0001fb-Ch for ged-emacs-devel@m.gmane.org; Fri, 29 Jun 2018 08:33:27 +0200 Original-Received: from localhost ([::1]:40191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYn0L-0002on-6K for ged-emacs-devel@m.gmane.org; Fri, 29 Jun 2018 02:35:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYn0E-0002og-TU for emacs-devel@gnu.org; Fri, 29 Jun 2018 02:35:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYn0B-0005x7-PF for emacs-devel@gnu.org; Fri, 29 Jun 2018 02:35:30 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYn0B-0005wu-GU; Fri, 29 Jun 2018 02:35:27 -0400 Original-Received: from [176.228.60.248] (port=4265 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fYn0A-0003Xt-M9; Fri, 29 Jun 2018 02:35:27 -0400 In-reply-to: (message from Elias =?utf-8?Q?M=C3=A5rtenson?= on Fri, 29 Jun 2018 10:54:51 +0800) 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226831 Archived-At: > From: Elias MÃ¥rtenson > 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.