Subject: Re: bug#38485: Customizing glyph widths

From: Eli Zaretskii <[email-masked]>
Date: Wed, 04 Dec 2019 17:52:12 +0200

> From: Clément Pit-Claudel <[email-masked]>
> Date: Tue, 3 Dec 2019 23:22:35 -0500
> 
> Interestingly, both of these cases are handled quite nicely in emacs -nw, because there the display is purely grid-like.

FTR, I'd like to clarify that Emacs doesn't "handle" the -nw case in
any way, it's taken care for us of by the terminal itself.  Assuming
that the terminal has the same notion of character width as Emacs
does, that is; if they use different tables, the characters will not
align.

> For my use case, it would be enough to have this available as a minor mode, but Yuan Fu mentioned the following on emacs-devel: "I’d like to see it as a face attribute instead of a mode. (Because I want to align my org table). Maybe there could be a face attribute (:grid WIDTH) that instructs the display engine to pad each glyph to have width that is a multiple of WIDTH in pixel, and if WIDTH is t, default to “base character width”?  I remembered that ‘window-width’ gives width in char widths and had a look at its source. It knows the character width from FRAME_COLUMN_WIDTH; the comment says the value currently equals to the average width of the default font of the frame. I think this value can be used as the “base character width”."

I don't think I understand the rationale for using a face.  It sounds
like a subset of the general case, and why would someone want this
alignment only for one special face?

Using a face also means that the same characters from a larger font
will not be aligned.

> Now that I think of it, though, I could see the use for a text property.  For example, prettify-symbols-mode could have an option to make each n-characters prettification n-characters wide, so that composing ~~> into ⟿ would produce a wide arrow occupying the exact same amount of space as the original uncomposed characters.

So what kind of text property would that be, and where and how will it
come into play in the above scenario?

Thanks.