GNU bug report logs -
#56808
29.0.50; Elusive display problem on macOS
Previous Next
Reported by: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Date: Thu, 28 Jul 2022 05:10:02 UTC
Severity: normal
Found in version 29.0.50
Done: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Bug is archived. No further changes may be made.
Full log
Message #56 received at 56808 <at> debbugs.gnu.org (full text, mbox):
On Fri, 29 Jul 2022 23:32:03 +0900,
Gerd Möllmann wrote:
>
> YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> writes:
>
> > Does initializing font->space_width to 0 work for you?
>
> 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 CTFontDescriptorCreateMatchingFontDescriptor (no
font->pixel_size = size;
font->driver = &macfont_driver;
font->encoding_charset = font->repertory_charset = -1;
+ /* Clear font->space_width so macfont_monospace_width_multiplier may
+ not be confused by an uninitialized value. */
+ font->space_width = 0;
block_input ();
> Can we be sure that other uses of space_width don't run into problems?
> For instance:
>
> case MACFONT_SPACING_MONO:
> if (cache->width_frac)
> bounds.origin.x += - ((cache->width_frac
> / (CGFloat) (WIDTH_FRAC_SCALE * 2))
> * (cache->width_int / font->space_width));
> break;
>
> 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 = 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 == MACFONT_SPACING_MONO and cache->width_frac != 0.
if (macfont_info->spacing == 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 = macfont_monospace_width_multiplier (font, fwidth);
if (multiplier)
{
cache->width_int = font->space_width * multiplier;
cache->width_frac = lround ((fwidth / multiplier
- font->space_width)
* WIDTH_FRAC_SCALE);
}
else
{
cache->width_int = lround (fwidth);
cache->width_frac = 0;
}
}
YAMAMOTO Mitsuharu
mituharu <at> math.s.chiba-u.ac.jp
This bug report was last modified 3 years and 11 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.