Subject: bug#76519: 30.1; Unexpected Results from window-text-pixel-size

From: Eli Zaretskii <[email-masked]>
Date: Wed, 26 Feb 2025 14:55:18 +0200

> From: AKIYAMA Kouhei <[email-masked]>
> Date: Tue, 25 Feb 2025 20:24:07 +0900
> Cc: [email-masked]
> 
> > By the way, is there any reason you didn't use string-pixel-width
> > instead? Or does it also have problems in this case?
> 
> The reason I did not use `string-pixel-width` is that I wanted to
> measure the width of text that includes icons and thumbnail images
> displayed via overlays (using the `after-string` and `before-string`
> properties). While the test case used a temporary buffer, in reality,
> the measurement was performed in a `dired-mode` buffer, and the timing
> was within `dired-after-readin-hook` (after `nerd-icons-dired` had
> added icons).

Yes, overlays cannot be part of a string, so string-pixel-width will
not do the job when the buffer text has overlay strings.

> By the way, while looking at the manual, I noticed that the arguments
> of the `buffer-text-pixel-size` function differ between the manual and
> Emacs itself.
> 
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Size-of-Displayed-Text.html#index-buffer_002dtext_002dpixel_002dsize

Thanks, fixed.

> > > * Issue 2: Negative Width Returned When Full-Width Characters Are Present
> > >
> > > If the buffer contains full-width characters, `window-text-pixel-size`
> > > sometimes returns negative widths. This can be reproduced as follows:
> >
> > This was due to a stupid typo in the code, and is now fixed on the
> > release branch (to be merged to master in a few days).
> 
> You've already fixed it? Amazing!
> Thank you very much!

You're welcome.