On 8/24/2024 10:05 PM, Eli Zaretskii wrote: > Again, the simplicity here is deceptive. Since you seemed so unsure about my earlier patch, I figured I should be extra careful to think about whether there's a better way. Previously, you'd suggested using 'string-pixel-width' using a few characters to compute an average width. After thinking about it, I realized that it's actually possible to get the real 'font->average_width' value using 'string-pixel-width': just use a display spec! (string-pixel-width (propertize some-length-1-string 'display '(space :width 1))) That works out nicely since then the only function I'm using to compute string widths in this code is 'string-pixel-width', so there's less risk of different functions having slightly different font handling. As an added bonus, this new implementation is even simpler than the original code that prompted this bug. See attached. >> Thanks for prompting me to re-read the manual on this. I'd >> misinterpreted this passage in the documentation for 'query-font': [snip] > I don't see how this is different from the text we already have, > sorry. Here's another variation on the documentation that might be clearer? "The average width of the font characters. Emacs uses this value when calculating text layout on display. If this is zero, Emacs uses the value of space-width instead." (Maybe this could cross reference the section on pixel specifications too, or some other documentation about text layout.) If that doesn't seem any better, that's ok. I'll stop suggesting further variations. :)