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#56808: 29.0.50; Elusive display problem on macOS Date: Sat, 30 Jul 2022 16:49:46 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <83r125ai2n.fsf@gnu.org> <83czdpacoi.fsf@gnu.org> <83v8rh8ikg.fsf@gnu.org> <83r1258e4q.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33041"; 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.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Eli Zaretskii , 56808@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 30 09:50:31 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 1oHhF1-0008NK-7Q for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Jul 2022 09:50:31 +0200 Original-Received: from localhost ([::1]:55482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHhEy-0000Xo-JN for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Jul 2022 03:50:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHhEY-0000XO-QD for bug-gnu-emacs@gnu.org; Sat, 30 Jul 2022 03:50:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHhEY-0003mM-HN for bug-gnu-emacs@gnu.org; Sat, 30 Jul 2022 03:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oHhEY-0004V1-8P for bug-gnu-emacs@gnu.org; Sat, 30 Jul 2022 03:50: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: Sat, 30 Jul 2022 07:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56808 X-GNU-PR-Package: emacs Original-Received: via spool by 56808-submit@debbugs.gnu.org id=B56808.165916739417273 (code B ref 56808); Sat, 30 Jul 2022 07:50:02 +0000 Original-Received: (at 56808) by debbugs.gnu.org; 30 Jul 2022 07:49:54 +0000 Original-Received: from localhost ([127.0.0.1]:33945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHhEP-0004UX-Nc for submit@debbugs.gnu.org; Sat, 30 Jul 2022 03:49:53 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:53776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHhEM-0004UK-JN for 56808@debbugs.gnu.org; Sat, 30 Jul 2022 03:49:52 -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 EA89EF08E4; Sat, 30 Jul 2022 16:49:46 +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:238236 Archived-At: On Fri, 29 Jul 2022 23:32:03 +0900, Gerd M=F6llmann wrote: >=20 > YAMAMOTO Mitsuharu writes: >=20 > > Does initializing font->space_width to 0 work for you? >=20 > Yes it works. Thanks! Thanks for checking. Eli, is it OK to install the following change to the emacs-28 branch? diff --git a/src/macfont.m b/src/macfont.m index dfdd9bc6ba..eec1707c3c 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -2651,6 +2651,9 @@ So we use CTFontDescriptorCreateMatchingFontDescripto= r (no font->pixel_size =3D size; font->driver =3D &macfont_driver; font->encoding_charset =3D font->repertory_charset =3D -1; + /* Clear font->space_width so macfont_monospace_width_multiplier may + not be confused by an uninitialized value. */ + font->space_width =3D 0; =20 block_input (); =20 > Can we be sure that other uses of space_width don't run into problems? > For instance: >=20 > case MACFONT_SPACING_MONO: > if (cache->width_frac) > bounds.origin.x +=3D - ((cache->width_frac > / (CGFloat) (WIDTH_FRAC_SCALE * 2)) > * (cache->width_int / font->space_width)); > break; >=20 > That would be an integer division by 0. And it's a bit strange because > of the integer division in a float expression... This part is inside `if (metrics) ...' where `metrics' is the third arg of macfont_glyph_extents, so it is not executed in the following call in macfont_open: font->space_width =3D macfont_glyph_extents (font, glyph, NULL, NULL, 0= ); The reason for the integer division is that cache->width_int has already been adjusted to a multiple of font->space_width if macfont_info->spacing =3D=3D MACFONT_SPACING_MONO and cache->width_frac != =3D 0. if (macfont_info->spacing =3D=3D MACFONT_SPACING_MONO) { /* Some monospace fonts for programming languages contain wider ligature glyphs consisting of multiple characters. For such glyphs, simply rounding the combined fractional width to an integer can result in a value that is not a multiple of the (rounded) font width. */ int multiplier =3D macfont_monospace_width_multiplier (font, fwidth); if (multiplier) { cache->width_int =3D font->space_width * multiplier; cache->width_frac =3D lround ((fwidth / multiplier - font->space_width) * WIDTH_FRAC_SCALE); } else { cache->width_int =3D lround (fwidth); cache->width_frac =3D 0; } } YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp