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

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

bug#19395: 25.0.50; Setting left fringe to 0 messes up window-width


From: Eli Zaretskii
Subject: bug#19395: 25.0.50; Setting left fringe to 0 messes up window-width
Date: Fri, 19 Dec 2014 21:35:41 +0200

> Date: Fri, 19 Dec 2014 18:09:31 +0100
> From: martin rudalics <rudalics@gmx.at>
> CC: 19395@debbugs.gnu.org
> 
>  > Given the changes I pushed in commit b197822, you will no longer need
>  > all this complexity.  Just
>  >
>  >     (aref (font-info (face-font 'default)) 11)
>  >
>  > (For bullet-proof code, check that this is not zero, and if it is, use
>  > the 10th member instead; see the docs.)
> 
> Very good.  IIUC this means that I could use something like
> 
> (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)))))
> 
> (defun window-char-height (&optional window)
>    "Return default character height 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)
>      (aref (font-info (face-font 'default)) 3)))
> 
> in window.el.

Yes, that's the idea.

> If that is the case, then the doc of `font-info' should
> be somehow amended.  It currently says
> 
> Return information about a font named NAME on frame FRAME.
> 
> and nowhere mentions which buffer must be current or maybe even which
> window must be selected.

I don't think the results of font-info depend on that.  It's the
result of face-font that depend on the buffer and frame, but once you
have the font's name, all the rest doesn't matter, since Emacs already
have the font data structure set up and stored in memory.





reply via email to

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