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

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

bug#19194: 24.4.50; `window-body-width' is not dynamic relative to font


From: Eli Zaretskii
Subject: bug#19194: 24.4.50; `window-body-width' is not dynamic relative to font size changes
Date: Sat, 20 Dec 2014 18:18:22 +0200

> Date: Sat, 20 Dec 2014 15:49:39 +0100
> From: martin rudalics <rudalics@gmx.at>
> CC: Eli Zaretskii <eliz@gnu.org>, 19194@debbugs.gnu.org
> 
>  > The one thing I'd add is an explanation of how "character width" is
>  > found or computed for variable-width fonts.  (E.g. is it the width of an
>  > "M"?)
> 
> Elsewhere I proposed:
> 
> (defun window-char-width (&optional window)
>    "Return default character width for WINDOW.
> WINDOW must be a live window and defaults to the selected one."
>    (setq window (window-normalize-window window t))
>    (with-current-buffer (window-buffer window)
>      (let* ((info (font-info (face-font 'default)))
>         (width (aref info 11)))
>        (if (> width 0)
>        width
>      (aref info 10)))))
> 
> You could try to experiment with this and either use
> 
> (width (aref info 10))
> 
> or
> 
> (width (aref info 7))
> 
> instead of (aref info 11).  Or use something like
> 
> (face-font 'default ?M) instead of (face-font 'default).
> 
> I use variable width fonts only in customization buffers, so I'm not
> very qualified at checking this myself.  We can use whatever you find
> here provided we can pack it into an argument of `window-body-width'.
> 
> And Eli certainly knows better, so wait.  Maybe my idea is silly.

I actually don't really understand the question.  What does "character
width" mean when each character has a different width?  Do you (Joe)
mean you want to know the actual width of each and every character?
If so, what for?

In any case, if you do need the width of individual characters, take a
look at font-get-glyphs (and font-at to get you the font for that).





reply via email to

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