[Top][All Lists]

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

Re: Change `set-frame-font' to allow keeping of frame size

From: Ehud Karni
Subject: Re: Change `set-frame-font' to allow keeping of frame size
Date: Mon, 7 Apr 2003 13:03:07 +0300

Hash: SHA1

On Sun, 06 Apr 2003 19:07:36 -0400, Richard Stallman <address@hidden> wrote:
>       (defun set-frame-font (font-name)

Sorry, the 2nd arg was omitted on copying (I tested this defun).

> Whether this is a good change, I am not sure.  I do not understand the
> description of the feature.  What does it mean to "keep the current
> size"?  And what is the other alternative?

The "Keep size" means keeping the pixel size (its footprint on the
screen) of the frame. From your question it is clear that the wording
should be changed to clarify this. How about:

(defun set-frame-font (font-name keep-size)
  "Set the font of the selected frame to FONT-NAME.
When called interactively, prompt for the name of the font to use.
To get the frame's current default font, use `frame-parameters'.
If optional KEEP-SIZE is non nil the current frame size (in pixels)
is kept by adjusting the frame `height' and `width' parameters"
   (let* ((completion-ignore-case t)
          (font (completing-read "Font name: "
                         (mapcar #'list
                                 ;; x-list-fonts will fail with an error
                                 ;; if this frame doesn't support fonts.
                                 (x-list-fonts "*" nil (selected-frame)))))
          (keep (yes-or-no-p
                 "Keep the frame size (in pixels) after changing font ? ")))
     (list font keep)))
  (let (fht fwd)
    (if keep-size
        (setq fht (* (frame-parameter nil 'height) (frame-char-height))
              fwd (* (frame-parameter nil 'width)  (frame-char-width))))
    (modify-frame-parameters (selected-frame)
                             (list (cons 'font font-name)))
    (if keep-size
         (list (cons 'height (round fht (frame-char-height)))
               (cons 'width (round fwd (frame-char-width)))))))
  (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))


- -- 
 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  / \
 mailto:address@hidden                  Better  Safe  Than  Sorry
Comment: use http://www.keyserver.net/ to get my key (and others)


reply via email to

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