GNU bug report logs - #30746
window-text-pixel-width includes width of following propertized space

Previous Next

Package: emacs;

Reported by: Clément Pit-Claudel <clement.pitclaudel <at> live.com>

Date: Wed, 7 Mar 2018 22:14:01 UTC

Severity: normal

Fixed in version 26.1

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit-Claudel <clement.pitclaudel <at> live.com>
To: bug-gnu-emacs <at> gnu.org
Subject: window-text-pixel-width includes width of following propertized space
Date: Wed, 7 Mar 2018 17:13:32 -0500
[Message part 1 (text/plain, inline)]
Hi all,

I'm trying to measure strings in an Emacs buffer.  The current code is yielding surprising results:

(progn
  (save-excursion
    (insert #("s " 1 2 (display (space :width (50))))))
  (window-text-pixel-size nil (point) (1+ (point))))

On my machine a single 's' is 8 pixels wide, but this snippet returns 58.  

The following snippet, however, returns 8 as expected:

(progn
  (save-excursion
    (insert "s "))
  (window-text-pixel-size nil (point) (1+ (point))))

It seems that adding a display property on the space changes the return value of window-text-pixel-size; is that expected?

Thanks,
Clément.

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 5 years and 232 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.