[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get the actual face attribute?
From: |
Yuan Fu |
Subject: |
Re: How to get the actual face attribute? |
Date: |
Mon, 22 Jun 2020 13:21:15 -0400 |
> On Jun 22, 2020, at 1:15 PM, Perry Smith <pedz@easesoftware.com> wrote:
>
>
>
>> On Jun 22, 2020, at 12:00 PM, Yuan Fu <casouri@gmail.com
>> <mailto:casouri@gmail.com>> wrote:
>>
>>
>>
>>> On Jun 21, 2020, at 11:54 AM, Stefan Monnier <monnier@iro.umontreal.ca>
>>> wrote:
>>>
>>>> When writing my package I need to get height of the face at point.
>>>
>>> Note that there may be simultaneously several different such heights if
>>> point is shown simultaneously in different frames.
>>>
>>
>> Thanks. Unfortunately I think I asked an x-y question. What I really want to
>> know is the width of the glyph and I thought I can just multiply the height
>> factor to the original width of the glyph. It seems not to be the case. The
>> multiplied result doesn’t match with the width on glass. More precisely
>> :height * glyph width != posn of point after - posn of point. Is this
>> expected?
>>
>> Also I can’t use posn for calculation since sometimes the text might not be
>> on screen.
>
> It might help to explain what the bigger objective is.
I have a package that aligns org tables even for variable pitch text, CJK text,
images, etc are in the table:
Some one reported that when they change the text size with text-scale-adjust,
the alignment are messed up. That’s because the package aligns by calculating
the pixel width of each cell, and when the text size are adjusted that width is
no accurate anymore. I’m using this function to calculate the width of a glyph
(which adds up to the width of a cell):
(let* ((p (or point (point))))
(if (eq (char-after point) ?\t)
(valign--tab-width (font-at p))
;; (font-at 0 nil (buffer-substring p (1+ p))) doesn’t work, the
;; font is sometimes wrong. (font-at p) doesn’t work, because
;; it requires the buffer to be visible.
(aref (aref (font-get-glyphs (font-at p) p (1+ p)) 0) 4)))
Yuan
- How to get the actual face attribute?, Yuan Fu, 2020/06/21
- Re: How to get the actual face attribute?, Eli Zaretskii, 2020/06/21
- Re: How to get the actual face attribute?, Stefan Monnier, 2020/06/21
- Re: How to get the actual face attribute?, Yuan Fu, 2020/06/22
- Re: How to get the actual face attribute?, Stefan Monnier, 2020/06/22
- Re: How to get the actual face attribute?, Yuan Fu, 2020/06/22
- Re: How to get the actual face attribute?, Stefan Monnier, 2020/06/22
- Re: How to get the actual face attribute?, Yuan Fu, 2020/06/22
- Re: How to get the actual face attribute?, Stefan Monnier, 2020/06/22
- Emacs hackers all around the world (was: Re: How to get the actual face attribute?), Emanuel Berg, 2020/06/22
- Re: How to get the actual face attribute?, Yuan Fu, 2020/06/24
- Re: How to get the actual face attribute?, Emanuel Berg, 2020/06/22