[Top][All Lists]

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

Re: Add a function that returns pixel distance between points?

From: Yuan Fu
Subject: Re: Add a function that returns pixel distance between points?
Date: Sun, 31 Jan 2021 00:17:58 -0500

>> For aligning text according to their display size, I need to calculate the 
>> width of some text. Currently I’m using window-text-pixel-size, but it has 
>> some problem: if the text I’m measuring has line-prefix or wrap-prefix, the 
>> size returned will include the width of the prefix. So if the prefix is 14 
>> pixels wide and the text is 7 pixels wide, the returned value is 21 instead 
>> of 7. Line number width is sometimes included in the result and sometimes 
>> not.
>> There is also posn-at-point but that requires the point to be visible in the 
>> window. My alignment function wants to run in jit-lock so point is not 
>> always visible, so I can’t use posn-at-point.
> Please explain what you mean by "align text according to display
> size".  It isn't clear what you want to accomplish, and therefore the
> full set of requirements and restrictions is not evident, which makes
> it hard to provide useful advice.

Sorry for that. I want to align text-based tables by pixel size, as in:

| header | header | header |
| 1      | 1      | 8      |
| 2      | 6      | 3      |

When the text is displayed in variable-pitch font, the bars aren’t aligned. I’m 
using display property (space :align-to) to align those bars. To know with 
pixel position to align to, I need to calculate each column’s pixel width, and 
met the difficulties mentioned earlier.


reply via email to

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