Subject: bug#78621: Pixelwise display specified spaces less precise than min-width

From: Ship Mints <[email-masked]>
Date: Wed, 28 May 2025 15:44:38 -0400

This came up as I've been working on improving vtable to operate well in
text-scaled buffers and getting things to align on pixel boundaries is
impacted by this rendering issue.

You can see this in text-scaled buffers when attempting to pad a string to
a specific pixel boundary.  If a pixelwise specified-width space is
inserted after a string with variable-pitch glyphs, it doesn't honor the
net pixel width.  That same string padded using min-width with the same
number of pixels works fine.

I've attached a -Q reproducer which I've run on 30.1 and a recent master
with the same results on macOS.  On master, I run as "src/emacs -Q -l
repro-variable-pitch-pixels.el".

The reproducer shows that a variable-pitch string padded to a specific
pixel width using string+specified space is unreliable vs. string with a
min-width display property.  Fixed-pitch glyphs seem fine and everything
works at scale 0.  There are three buffers created: scale 0, scale -1,
scale +1.

I tried to find where in xdisp.c or in ns*.m this would manifest, but it
wasn't immediately obvious.  I don't have access to another platform this
week, so I do not know if this is NS specific or also manifests with other
toolkits.

-Stephane