help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to get the actual face attribute?


From: Eli Zaretskii
Subject: Re: How to get the actual face attribute?
Date: Mon, 22 Jun 2020 21:47:33 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Mon, 22 Jun 2020 13:21:15 -0400
> Cc: help-gnu-emacs@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
> 
> 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)))

Did you try using window-text-pixel-size?



reply via email to

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