From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: Cairo font selection for Ethiopic Date: Fri, 21 Jun 2019 10:54:03 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <87pnn8cawu.fsf@rub.de> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="131689"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: emacs-devel@gnu.org To: Stephen Berman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 21 04:13:45 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1he93g-000Y89-Qe for ged-emacs-devel@m.gmane.org; Fri, 21 Jun 2019 04:13:44 +0200 Original-Received: from localhost ([::1]:54164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he93f-0001hQ-4l for ged-emacs-devel@m.gmane.org; Thu, 20 Jun 2019 22:13:43 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60260) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8zw-0000MA-UE for emacs-devel@gnu.org; Thu, 20 Jun 2019 22:09:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he8kg-0007Lf-Ag for emacs-devel@gnu.org; Thu, 20 Jun 2019 21:54:07 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:56158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1he8kf-0007HB-SQ for emacs-devel@gnu.org; Thu, 20 Jun 2019 21:54:06 -0400 Original-Received: from mathent.math.s.chiba-u.ac.jp (mathent [192.168.32.5]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 712C0F08D5; Fri, 21 Jun 2019 10:54:03 +0900 (JST) (envelope-from mituharu@math.s.chiba-u.ac.jp) In-Reply-To: <87pnn8cawu.fsf@rub.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 133.82.132.2 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:237992 Archived-At: On Fri, 21 Jun 2019 04:30:09 +0900, Stephen Berman wrote: > > I don't know if this is a bug or just the way Cairo works. On two > different GNU/Linux systems I have built Emacs both --with-cairo and > without. The non-Cairo builds use Xft as the font backend. On those > builds the Ethiopic scripts (Amharic and Tigrinya) in HELLO are > displayed with the Goha-Tibeb Zemen font. In the Cairo builds this font > is not used for these scripts; instead, on one system they are displayed > with a mix of GNU Unifont and mutt-clearlyu, and on the other system, > which lacks these fonts, only hex boxes are displayed. Is there > something about Goha-Tibeb Zemen that is incompatible with Cairo? Goha-Tibeb Zemen does not have glyphs for ASCII printables that the ftcr font backend relies on computing minimum/average/space width when opening the font. The patch below should simulate the Xft behavior. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp diff --git a/src/ftcrfont.c b/src/ftcrfont.c index a019fe8294a..0cc40b4c944 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -187,7 +187,6 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) block_input (); cairo_glyph_t stack_glyph; - int n = 0; font->min_width = font->average_width = font->space_width = 0; for (char c = 32; c < 127; c++) { @@ -198,28 +197,25 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) 0, 0, &c, 1, &glyphs, &num_glyphs, NULL, NULL, NULL); - if (status == CAIRO_STATUS_SUCCESS) + /* In order to simulate the Xft behavior, we use metrics of + glyph ID 0 if there is no glyph for an ASCII printable. */ + if (status != CAIRO_STATUS_SUCCESS) + stack_glyph.index = 0; + else if (glyphs != &stack_glyph) { - if (glyphs != &stack_glyph) - cairo_glyph_free (glyphs); - else if (stack_glyph.index) - { - int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, - NULL); - - if (this_width > 0 - && (! font->min_width - || font->min_width > this_width)) - font->min_width = this_width; - if (c == 32) - font->space_width = this_width; - font->average_width += this_width; - n++; - } + cairo_glyph_free (glyphs); + stack_glyph.index = 0; } + int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, NULL); + if (this_width > 0 + && (! font->min_width + || font->min_width > this_width)) + font->min_width = this_width; + if (c == 32) + font->space_width = this_width; + font->average_width += this_width; } - if (n > 0) - font->average_width /= n; + font->average_width /= 95; cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents); font->ascent = lround (extents.ascent);