Ah, I didn't know about 'window-lines-pixel-dimensions'.
I knew 'window-line-height' and thought there was no equivalent for the width.
However 'window-lines-pixel-dimensions' has differences with the implementation I proposed:
- It counts the glyphs 'inserted by redisplay for its own purposes' .
On a line with no characters, the function often return a width > 0 (1 or 2 characters, in my tests).
Similarly, on a line with characters it returns more pixels than there really is.
- It allocates a cons and 2 integer for each line.
In my use case, I have to get the width of _all_ the lines on the current window every time the cursor is
changing line or when a character is inserted/removed in the buffer. So it occurs quite often.
But that's micro optimization and I am not sure if there is a big impact.
- We can't choose the area in the window (left_margin_area, text_area or right_margin_area),
but I don't need this for my use case, so it's not important to me.
The first point is important for my use case, so if 'window-line-width' is not accepted, would you agree for a patch
adding a parameter to 'window-lines-pixel-dimensions' controlling this behavior ?
'window-text-pixel-size' uses a display iterator to compute values, I don't know the details of this iterator but it seems to
be slower than fetching values directly from the glyph matrix. As mentioned, I need the width of all lines on window.