Subject: bug#68374: min-width is not correctly treated by buffer-text-pixel-size

From: JD Smith <[email-masked]>
Date: Wed, 10 Jan 2024 17:22:53 -0500

When the ‘display min-width property is used on characters in a buffer, window/buffer-text-pixel-size does not include this min-width padding in its calculation of the text's pixel width.  

This can be seen by using a range of minimum character widths and noticing that the width is identical; see below.  Other ‘display properties like space :width and space :align-to do seem to be correctly handled by pixel size calculations. 

This is relevant because various elements on the mode-line use ‘display min-width, so performing pixel alignment on the mode-line text is impacted.

+++

(eval-when-compile 'cl-lib)
(cl-loop
 for w from 0. to 100. by 20. 
 collect
 (with-current-buffer (get-buffer-create "*pixel-sizes*")
   (erase-buffer)
   (insert ">>>" (propertize " " 'display `(min-width (,w))) "<<<")
   (cons w (buffer-text-pixel-size))))
  
;; ((0 49 . 14) (20 49 . 14) (40 49 . 14) (60 49 . 14) (80 49 . 14) (100 49 . 14))