help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enclosing text in a box


From: Yuri Khan
Subject: Re: Enclosing text in a box
Date: Wed, 16 Nov 2022 22:06:22 +0700

On Wed, 16 Nov 2022 at 21:55, Yuri Khan <yuri.v.khan@gmail.com> wrote:

> * OP uses ‘length’ to measure the text, and ‘make-string’ to build a box.
> * You point out that this fails for non-monospace fonts, and suggest
> measuring with ‘string-width’ or ‘string-pixel-width’.
> * OP tries to measure in pixels, realizes one has to divide by the
> width of a box drawing character. The division result turns out
> fractional.

A more-or-less complete solution would probably involve:

* Measuring pixel width of the enclosed text.
* Measuring pixel width of the box drawing character.
* Dividing one by the other, rounding up.
* Appending to the enclosed text a space with a display property
giving it a pixel width that pads the text to an integer number of box
drawing characters.
* (if the enclosed text is editable) Arrange for the above to be
re-done on change.

No, I’m not going to do a prototype.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]