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

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

Re: increasing font size


From: Colin S. Miller
Subject: Re: increasing font size
Date: Sat, 18 Feb 2006 17:47:14 +0000
User-agent: Debian Thunderbird 1.0.2 (X11/20051002)

Senthil wrote:
how do i increase the size of font appearing in emacs
should i edit something in my .emacs file

--
--------S.Senthil Kumaran-------
blog : http://sskganesan.blogspot.com


Senthl,

I've written this module which will do this, assuming you are not running in a 
console.
However it only changes the base-font; if an emacs face sets the font size, 
then it
won't be changed.
This code was written for XEmacs, I haven't tested it on Emacs.
You might need to tweek the list of font sizes, depending on which font face 
you use.

However, if don't want to dynmically change the font size, you can use
Options/Font Size to set the default and Options/Advanced (Customize)/Face to 
overide
this for some faces.

HTH,
Colin S. Miller


(defvar csm-base-font-sizes [14 16 17 19 20 22 25 26 27 29 31 32 33 35 38 40] "* 
Font list")


(defun csm-base-font-inc ()
  "Increases the default font"
  (interactive)

  (let ((curr-val) (index) (elem) (num-elems))
    (progn
      (setq curr-val (string-to-number (custom-face-font-size 'default)))
      (setq index 0)
      (setq num-elems (length csm-base-font-sizes))

      (while
          (progn
            (setq elem (elt csm-base-font-sizes index))
            (setq index (+ index 1))
            (and (<   index num-elems)
                 (<  elem  curr-val)
                 )                      ; or
            )                           ; progn
        )

      (progn
        (if (< index num-elems)
            (progn

              (setq new-val (elt csm-base-font-sizes index))
              (if new-val
                  (progn
                    (custom-set-face-font-size 'default
                                               new-val)
                    (display-message 'command (concat "New font size is " 
(number-to-string new-val) " points")))))
          (display-message 'command "Font already at largest size")
          )                             ; if
        )                               ; progn
      )                                 ; progn
    )                                   ; let
  )                                     ; defun




(defun csm-base-font-dec ()
  "Decreases the default font"
  (interactive)

  (let ((curr-val) (index) (elem) (num-elems))
    (progn
      (setq curr-val (string-to-number (custom-face-font-size 'default)))
      (setq index 0)
      (setq num-elems (length csm-base-font-sizes))

      (while
          (progn
            (setq elem (elt csm-base-font-sizes index))
            (setq index (+ index 1))
            (and (<  index num-elems)
                 (<  elem  curr-val)
                 )                      ; or
            )                           ; progn
        )

      (progn
        (if (> index 1)
            (progn
              (setq index (- index 2))
              (setq new-val (elt csm-base-font-sizes index))
              (if new-val
                  (progn
                    (custom-set-face-font-size 'default
                                               new-val)

                    (display-message 'command (concat "New font size is " 
(number-to-string new-val) " points")))))
          (display-message 'command "Font already at smallest size")
          )                               ; if
        )                               ; progn
      )                                 ; progn
    )                                   ; let
  )                                     ; defun


(define-key global-map
  [(control kp-subtract)]
  'csm-base-font-dec
  )

(define-key global-map
  [(control kp-add)]
  'csm-base-font-inc
  )


--
Replace the obvious in my email address with the first three letters of the 
hostname to reply.


reply via email to

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