From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.bugs Subject: bug#43058: 27.1; Support for other colour font formats Date: Thu, 22 Sep 2022 11:45:02 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <83v9h537tj.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30975"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: 43058@debbugs.gnu.org, Eli Zaretskii To: Peter Oliver Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 22 04:46:18 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1obCEC-0007tn-PD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Sep 2022 04:46:16 +0200 Original-Received: from localhost ([::1]:58202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obCEA-0006bt-UF for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Sep 2022 22:46:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obCDz-0006bk-4z for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2022 22:46:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obCDy-00063s-TL for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2022 22:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obCDy-0007T2-28 for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2022 22:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: YAMAMOTO Mitsuharu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Sep 2022 02:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43058 X-GNU-PR-Package: emacs Original-Received: via spool by 43058-submit@debbugs.gnu.org id=B43058.166381470828636 (code B ref 43058); Thu, 22 Sep 2022 02:46:02 +0000 Original-Received: (at 43058) by debbugs.gnu.org; 22 Sep 2022 02:45:08 +0000 Original-Received: from localhost ([127.0.0.1]:35671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obCD6-0007Ro-9F for submit@debbugs.gnu.org; Wed, 21 Sep 2022 22:45:08 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:60078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obCD4-0007Ra-LW for 43058@debbugs.gnu.org; Wed, 21 Sep 2022 22:45:07 -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 AD03FF08E8; Thu, 22 Sep 2022 11:45:02 +0900 (JST) (envelope-from mituharu@math.s.chiba-u.ac.jp) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:243380 Archived-At: On Thu, 27 Aug 2020 00:12:06 +0900, Peter Oliver wrote: >=20 > Observation: >=20 > First I grabbed a COLR TTF (e.g., https://github.com/hfg-gmuend/openmoji/= raw/47c9efe5449ba2ef77b77cdcae28b00811dea843/font/untouchedsvgz/OpenMoji-Co= lor.ttf) and saved it to ~/.local/share/fonts/. Then: >=20 > ELISP> (x-list-fonts "OpenMoji Color") > ("-NONE-OpenMoji Color-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1") > ELISP> (font-info (car (x-list-fonts "OpenMoji Color"))) > nil >=20 > This makes me suspect that the problem isn=A2t with outputting with the f= ont, but in finding the font in the first place. I=A2m not sure how to go = about debugging this. The above font does not have the 'COLR' table, but the 'SVG ' one. So I think it is an SVG-in-OpenType font. This font is rejected by the ftcr(hb) font backend because its average width is computed as 0. The average width is approximated by that of all ASCII chars, and the width of glyph ID 0 is used for missing ones. OpenMoji Color does not have several ASCII chars, and the width of glyph ID 0 is 0. That's why the average width becomes 0 there. The patch below avoids this by taking the average of non-zero width of the ASCII chars. But glyphs are not displayed because SVG-in-OpenType support in cairo is still in progress: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/319 YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp diff --git a/src/ftcrfont.c b/src/ftcrfont.c index e089f9dea8..9e83ad00d4 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -233,6 +233,7 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int= pixel_size) cairo_glyph_t stack_glyph; font->min_width =3D font->max_width =3D 0; font->average_width =3D font->space_width =3D 0; + int n =3D 0; for (char c =3D 32; c < 127; c++) { cairo_glyph_t *glyphs =3D &stack_glyph; @@ -252,17 +253,20 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, i= nt pixel_size) stack_glyph.index =3D 0; } int this_width =3D ftcrfont_glyph_extents (font, stack_glyph.index, = NULL); - if (this_width > 0 - && (! font->min_width - || font->min_width > this_width)) - font->min_width =3D this_width; - if (this_width > font->max_width) - font->max_width =3D this_width; - if (c =3D=3D 32) - font->space_width =3D this_width; - font->average_width +=3D this_width; + if (this_width > 0) + { + if (! font->min_width || font->min_width > this_width) + font->min_width =3D this_width; + if (this_width > font->max_width) + font->max_width =3D this_width; + if (c =3D=3D 32) + font->space_width =3D this_width; + font->average_width +=3D this_width; + n++; + } } - font->average_width /=3D 95; + if (n) + font->average_width /=3D n; =20 cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents); font->ascent =3D lround (extents.ascent);