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

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

Re: Calculate window size in pixels


From: Ehud Karni
Subject: Re: Calculate window size in pixels
Date: Mon, 9 May 2005 14:02:21 +0300

On 06 May 2005 17:40:41 +0200, Mathias Dahl wrote:
>
> (defun window-height-pixels ()
>   (let ((line-pixel-height-ratio (/ (+ (frame-pixel-height) 0.0) 
> (frame-height))))
>     (truncate (* (window-height) line-pixel-height-ratio))))
>
> (defun window-width-pixels ()
>   (let ((column-pixel-width-ratio (/ (+ (frame-pixel-width) 0.0) 
> (frame-width))))
>     (truncate (* (window-width) column-pixel-width-ratio))))

I think that `frame-char-height' and `frame-char-width' is what you
are looking for.

I use the following to change the font without resizing the frames. This uses
only the `editable' part of the frame - without the border and menus areas.

(defun set-font-keep-size (font)
  "set font to use, keep window size"
       (let ((fht (* (frame-parameter nil 'height) (frame-char-height)))
             (fwd (* (frame-parameter nil 'width)  (frame-char-width))))
           (set-default-font font)
           (set-frame-value-all 'font font)
           (set-frame-value-all 'height (/ fht (frame-char-height)))
           (set-frame-value-all 'width  (/ fwd (frame-char-width)))))

`set-frame-value-all is my function to set a value on all frames.

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry




reply via email to

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