|
From: | Daniel Mendler |
Subject: | bug#47712: 27.1; Provide `string-display-width` function, which takes properties into account, `substring-width` |
Date: | Mon, 12 Apr 2021 11:08:52 +0200 |
On 4/12/21 10:53 AM, Lars Ingebrigtsen wrote:
I can see how that may be useful in some cases (and is very different from `window-text-pixel-size'), so I think adding something like that would be nice. But the name is confusing -- it sounds like it's computing the displayed width, and it's not -- if there's images or text with a different font in there, it's not taken into account?
Yes, a better name could be `string-property-width`? I proposed `string-display-width` since it takes the 'display property into account, but maybe this gives false associations.
Note that I would like to have an implementation of `substring-width`/`string-display-width`/`substring-display-width` which does not allocate, since this reduces the GC pressure when formatting many items. How do you think about this?
Regarding images, different fonts, maybe a `string-property-pixel-width` would be useful too. But for the use cases I have in mind (formatting monospaced text) computing columns is sufficient.
[Prev in Thread] | Current Thread | [Next in Thread] |