[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calculate window size in pixels
From: |
Mathias Dahl |
Subject: |
Re: Calculate window size in pixels |
Date: |
Tue, 10 May 2005 12:28:45 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (windows-nt) |
"Ehud Karni" <ehud@unix.mvs.co.il> writes:
> 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.
That seems to be exactly what I wanted. Strange I missed it. I will
try using that instead and see how it works.
Thanks!
/Mathias