GNU bug report logs - #78621
Pixelwise display specified spaces less precise than min-width

Previous Next

Package: emacs;

Reported by: Ship Mints <shipmints <at> gmail.com>

Date: Wed, 28 May 2025 19:46:01 UTC

Severity: normal

Tags: notabug

Done: Ship Mints <shipmints <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Porter <jporterbugs <at> gmail.com>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 78621 <at> debbugs.gnu.org
Subject: bug#78621: Pixelwise display specified spaces less precise than min-width
Date: Wed, 28 May 2025 16:07:48 -0700
On 5/28/2025 3:40 PM, Ship Mints wrote:
> Okay I applied the one-liner correctly this time and now I see good 
> results on my mac laptop.
> 
> My contention still stands, though, that with identical inputs, 'display 
> 'space :width and 'display 'min-width should produce identical results.  
> Does that make sense?

From my read of this bug, the issue was originally that these snippets 
should have the same display width:

  (concat "some text"
          (propertize " " 'display
                      `(space :width (,(- width width-of-some-text)))))

  (propertize "some text" 'display `(min-width ((,width))))

I agree with that, but only if 'width-of-some-text' is computed correctly.

For variable-pitch text, each character cell (I hope I'm using the right 
term here) in the display is a different width, rounded to the nearest 
integer, which means that computing the pixel-width as in your original 
reproducer accumulates small rounding errors for every character.

That's not an issue for fixed-pitch text, since in that case you can 
reduce this expression as follows:

  (* (string-pixel-width str)
     (/ (float (default-font-width)) (frame-char-width)))

  ;; For simple cases, the pixel width is just the length times the
  ;; frame's char width.
  (* (length str) (frame-char-width)
     (/ (float (default-font-width)) (frame-char-width)))

  ;; Cancel out (frame-char-width).
  (* (length str) (float (default-font-width)))

  ;; Remove unnecessary float call.
  (* (length str) (default-font-width))

Thanks to '(frame-char-width)' canceling out, that expression doesn't 
accumulate rounding errors like it would for variable-pitch text.




This bug report was last modified 50 days ago.

Previous Next


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