unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Ehud Karni" <ehud@unix.mvs.co.il>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Calculate window size in pixels
Date: Mon, 9 May 2005 14:02:21 +0300	[thread overview]
Message-ID: <200505091102.j49B2Lxk026669@beta.mvs.co.il> (raw)
In-Reply-To: <m2br7ol5vq.fsf@hotmail.com> (message from Mathias Dahl on 06 May 2005 17:40:41 +0200)

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

  parent reply	other threads:[~2005-05-09 11:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-06  9:12 Calculate window size in pixels Mathias Dahl
2005-05-06 10:40 ` Pascal Bourguignon
2005-05-06 14:12 ` Stefan Monnier
2005-05-06 14:40   ` Klaus Straubinger
2005-05-06 15:36   ` Mathias Dahl
2005-05-06 15:40     ` Mathias Dahl
2005-05-06 17:12       ` Mathias Dahl
2005-05-06 17:55       ` Kevin Rodgers
     [not found]       ` <mailman.3776.1115402969.2819.help-gnu-emacs@gnu.org>
2005-05-07 17:51         ` Mathias Dahl
2005-05-09 11:02       ` Ehud Karni [this message]
     [not found]       ` <mailman.4226.1115637000.2819.help-gnu-emacs@gnu.org>
2005-05-10 10:28         ` Mathias Dahl
2005-05-11  6:36           ` Mathias Dahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200505091102.j49B2Lxk026669@beta.mvs.co.il \
    --to=ehud@unix.mvs.co.il \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).