unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* proper setting of default font (and string-handling in elisp?)
@ 2009-08-26  2:11 Tom Roche
  2009-08-26  7:44 ` Peter Dyballa
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Roche @ 2009-08-26  2:11 UTC (permalink / raw)
  To: help-gnu-emacs


summary:

I'm running an emacs-23 and am wanting to set my default font for
every frame in init.el. How to do so properly?

details:

This morning I was happily running an up-to-date ubuntu 9.04 (jaunty)
and its stock emacs=22.2.1 when installing the Sun JRE somehow broke
my default emacs font. After much googling and twiddling of emacs=22,
some posts convinced me to go to emacs=23 for

mainmenu>Options>Set Default Font...

So I installed emacs-snapshot-gtk, and it indeed works as advertised.
Unfortunately

0 I want to set the default font automagically on each start of emacs.
  Putting

(setq tlr-default-font "Courier 10 Pitch-9")
(if (>= emacs-major-version 23)
  (progn
    (set-frame-font tlr-default-font)))

  in my init.el sorta fixes that, except ...

1 I would like emacs to come up showing the default font I set. If
  it's possible to make that happen via init.el (rather than, e.g.,
  `emacs --font=...`) I'd like to know. However this is not as
  important to me as the next item ...

2 I also want every new frame I open (with e.g. C-x 5 b) to use my
  default font. From googling, my impression is that I should do
  something like

(setq tlr-default-font "Courier 10 Pitch-9")
(if (>= emacs-major-version 23)
  (progn
    (set-frame-font tlr-default-font)
;    (add-to-list 'default-frame-alist '(font . tlr-default-font))
;    (add-to-list 'default-frame-alist '(font . 'tlr-default-font))
))

  but the commented lines fail. Is this solely an elisp problem (which
  I'd like to know how to fix anyway)? Or is there also a better way
  to set the default font for every frame I open?

TIA, Tom Roche <Tom_Roche@pobox.com>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: proper setting of default font (and string-handling in elisp?)
       [not found] <mailman.5382.1251252804.2239.help-gnu-emacs@gnu.org>
@ 2009-08-26  5:13 ` Xah Lee
  2009-08-26  5:22   ` Xah Lee
  0 siblings, 1 reply; 6+ messages in thread
From: Xah Lee @ 2009-08-26  5:13 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 25, 7:11 pm, Tom Roche <Tom_Ro...@pobox.com> wrote:
> summary:
>
> I'm running an emacs-23 and am wanting to set my default font for
> every frame in init.el. How to do so properly?
>
> details:
>
> This morning I was happily running an up-to-date ubuntu 9.04 (jaunty)
> and its stock emacs=22.2.1 when installing the Sun JRE somehow broke
> my default emacs font. After much googling and twiddling of emacs=22,
> some posts convinced me to go to emacs=23 for
>
> mainmenu>Options>Set Default Font...
>
> So I installed emacs-snapshot-gtk, and it indeed works as advertised.
> Unfortunately
>
> 0 I want to set the default font automagically on each start of emacs.
>   Putting
>
> (setq tlr-default-font "Courier 10 Pitch-9")
> (if (>= emacs-major-version 23)
>   (progn
>     (set-frame-font tlr-default-font)))
>
>   in my init.el sorta fixes that, except ...
>
> 1 I would like emacs to come up showing the default font I set. If
>   it's possible to make that happen via init.el (rather than, e.g.,
>   `emacs --font=...`) I'd like to know. However this is not as
>   important to me as the next item ...
>
> 2 I also want every new frame I open (with e.g. C-x 5 b) to use my
>   default font. From googling, my impression is that I should do
>   something like
>
> (setq tlr-default-font "Courier 10 Pitch-9")
> (if (>= emacs-major-version 23)
>   (progn
>     (set-frame-font tlr-default-font)
> ;    (add-to-list 'default-frame-alist '(font . tlr-default-font))
> ;    (add-to-list 'default-frame-alist '(font . 'tlr-default-font))
> ))
>
>   but the commented lines fail. Is this solely an elisp problem (which
>   I'd like to know how to fix anyway)? Or is there also a better way
>   to set the default font for every frame I open?

yeah, there's a better way.

pull the menu “Options‣Set Default Font”. Choose a font. Then pull
“Options‣Save Options”. That should do it. However, on Windows, i
noticed there's a bug that doesn't save the font. A work around is
that, once you did the above, then type M-x customize. Then randomly
choose something to customize. Then press Save for Future Sessions.
That should save the font you've choosen. In particular, you should
add something like the following in your emacs init file:

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background
"honeydew" :foreground "SystemWindowText" :inverse-video nil :box
nil :strike-through nil :overline nil :underline nil :slant
normal :weight normal :height 98 :width normal :foundry
"outline" :family "Lucida Sans Unicode"))))
 '(completions-common-part ((t (:inherit default :foreground "red"))))
 '(pp^L-highlight ((((type x w32 mac graphic) (class color))
(:underline "maroon"))))
 '(show-paren-match ((((class color) (background light)) (:background
"azure2")))))

I am also interested in the raw elisp code to save the font or other
face related things, without the custom-set-faces.

Given a (custome-set-faces ...) code, how do i pull things out and
create the equivalent elisp code? setq certainly won't work.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: proper setting of default font (and string-handling in elisp?)
  2009-08-26  5:13 ` proper setting of default font (and string-handling in elisp?) Xah Lee
@ 2009-08-26  5:22   ` Xah Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Xah Lee @ 2009-08-26  5:22 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 25, 10:13 pm, Xah Lee <xah...@gmail.com> wrote:
> In particular, you should
> add something like the following in your emacs init file:

correction. The “you should” should be “it should”.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: proper setting of default font (and string-handling in elisp?)
  2009-08-26  2:11 Tom Roche
@ 2009-08-26  7:44 ` Peter Dyballa
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2009-08-26  7:44 UTC (permalink / raw)
  To: help-gnu-emacs, Tom Roche


Am 26.08.2009 um 04:11 schrieb Tom Roche:

> I'm running an emacs-23 and am wanting to set my default font for
> every frame in init.el. How to do so properly?

	(setq initial-frame-alist
	  (append (list
	    '(border-color      . "#4e3832")
	    '(foreground-color  . "grey10")
	    '(background-color  . "AliceBlue")
	    '(active-alpha      . 0.875)
	    '(inactive-alpha    . 0.75)
	    '(font . "fontset-10pt_lucidatypewriter")
	    '(top . 136) '(left . 666) '(width . 100) '(height . 57)
	  ) initial-frame-alist))

There is also default-frame-alist. As you can see you can append to  
some basic structure elements for this or that GNU Emacs version.  
There may be much more frame-specific entities.

--
Greetings

   Pete

Isn't vi that text editor with two modes... one that beeps and one  
that corrupts your file?
				– Dan Jacobson, on comp.os.linux.advocacy








^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: proper setting of default font (and string-handling in elisp?)
@ 2009-08-26 12:59 Tom Roche
  2009-08-26 13:45 ` Peter Dyballa
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Roche @ 2009-08-26 12:59 UTC (permalink / raw)
  To: help-gnu-emacs


Tom Roche Tue, 25 Aug 2009 22:11:44 -0400 (EDT)
>> [I'm] wanting to set my default font for every frame[,] in init.el.
>> How to do so properly?

Peter Dyballa Wed, 26 Aug 2009 09:44:36 +0200
> (setq initial-frame-alist
>       (append (list
>         '(border-color      . "#4e3832")
>         '(foreground-color  . "grey10")
>         '(background-color  . "AliceBlue")
>         '(active-alpha      . 0.875)
>         '(inactive-alpha    . 0.75)
>         '(font . "fontset-10pt_lucidatypewriter")
>         '(top . 136) '(left . 666) '(width . 100) '(height . 57)
>       ) initial-frame-alist))

> There is also default-frame-alist.

Thanks, that looks good. However I'm still confused about

* font syntax: how to translate the font spec format that works for
  set-frame-font (e.g. "Courier 10 Pitch-9") to that used for
  initial-frame-alist and default-frame-alist (e.g.
  "fontset-10pt_lucidatypewriter")? I've looked @, e.g.,

http://www.gnu.org/software/emacs/manual/html_node/elisp/Initial-Parameters.html

  but I'm not seeing where these font-related formats are documented.
  Is there a .el file @ which I should look?

* variable usage: how to set the font spec in one or more variables
  and use those in the list? E.g., presuming the string inside the
  variable was correct, would either of

(font . tlr-default-font)
(font . 'tlr-default-font)

  be appropriate? I'm sure it's in the GNU Emacs Lisp Reference Manual
  somewhere, but am not sure where to look.

TIA, Tom Roche <Tom_Roche@pobox.com>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: proper setting of default font (and string-handling in elisp?)
  2009-08-26 12:59 Tom Roche
@ 2009-08-26 13:45 ` Peter Dyballa
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2009-08-26 13:45 UTC (permalink / raw)
  To: help-gnu-emacs, Tom Roche


Am 26.08.2009 um 14:59 schrieb Tom Roche:

> * font syntax: how to translate the font spec format that works for
>   set-frame-font (e.g. "Courier 10 Pitch-9") to that used for
>   initial-frame-alist and default-frame-alist (e.g.
>   "fontset-10pt_lucidatypewriter")?


I've created font sets to span (almost) the whole Unicode BMP (Basic  
Multilingual Plane):

     (create-fontset-from-fontset-spec "-b&h-lucidatypewriter-medium- 
r-*-*-10-*-*-*-*-*-fontset-10pt_lucidatypewriter" t 'noerror)
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-1  '("lucidatypewriter" . "iso8859-1"))
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-2  '("lucidatypewriter" . "iso8859-2"))
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-3  '("lucidatypewriter" . "iso8859-3"))
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-4  '("lucidatypewriter" . "iso8859-4"))
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-9  '("lucidatypewriter" . "iso8859-9"))
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-14 '("lucidatypewriter" . "iso8859-14"))
	(set-fontset-font "fontset-10pt_lucidatypewriter"       'latin- 
iso8859-15 '("lucidatypewriter" . "iso8859-15"))
	(set-fontset-font "fontset-10pt_lucidatypewriter" 'mule- 
unicode-0100-24ff '("lucidatypewriter" . "iso10646-1"))
	(set-fontset-font "fontset-10pt_lucidatypewriter" 'mule- 
unicode-2500-33ff '("lucidatypewriter" . "iso10646-1"))
	(set-fontset-font "fontset-10pt_lucidatypewriter" 'mule-unicode-e000- 
ffff '("lucidatypewriter" . "iso10646-1"))
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0590) (decode-char 'ucs #x05ff)) '("bpg glaho arial" .  
"iso10646-1"))	; Hebrew
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0600) (decode-char 'ucs #x06ff)) '("bpg glaho arial" .  
"iso10646-1"))	; Arabic
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x10a0) (decode-char 'ucs #x10ff)) '("bpg glaho" .  
"iso10646-1"))	; Georgian
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x2800) (decode-char 'ucs #x28ff)) '("code2000" .  
"iso10646-1"))	; Braille
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0980) (decode-char 'ucs #x09ff)) '("bangla" . "iso10646-1"))	;  
Bengali
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0a00) (decode-char 'ucs #x0a7f)) '("code2000" .  
"iso10646-1"))	; Gurmukhi
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0a80) (decode-char 'ucs #x0aff)) '("code2000" .  
"iso10646-1"))	; Gujarati
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0b00) (decode-char 'ucs #x0b7f)) '("code2000" .  
"iso10646-1"))	; Oriya
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0b80) (decode-char 'ucs #x0bff)) '("code2000" .  
"iso10646-1"))	; Tamil
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0c00) (decode-char 'ucs #x0c7f)) '("code2000" .  
"iso10646-1"))	; Telugu
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0c80) (decode-char 'ucs #x0cff)) '("code2000" .  
"iso10646-1"))	; Kannada
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0d00) (decode-char 'ucs #x0d7f)) '("code2000" .  
"iso10646-1"))	; Malayalam
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0d80) (decode-char 'ucs #x0dff)) '("akshar unicode" .  
"iso10646-1"))	; Sinhala
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0e00) (decode-char 'ucs #x0e7f)) '("code2000" .  
"iso10646-1"))	; Thai
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0e80) (decode-char 'ucs #x0eff)) '("code2000" .  
"iso10646-1"))	; Lao
	(set-fontset-font "fontset-10pt_lucidatypewriter" (cons (decode-char  
'ucs #x0f00) (decode-char 'ucs #x0fff)) '("xtashi" . "iso10646-1"))	;  
Tibetan
(when (= 23 ETyp)	; ETyp is approximately emacs-major-version
       (set-fontset-font "fontset-10pt_lucidatypewriter" (cons  
(decode-char 'ucs #x1d400) (decode-char 'ucs #x1d7ff)) '("code2001" .  
"iso10646-1"))	; Mathe
       (set-fontset-font "fontset-10pt_lucidatypewriter" '(#x1D400 .  
#x1D7FF) (font-spec :family "Unicode Symbols") nil)
)

This font set name can also be used as an initial parameter on the  
command line or as an X resource.


	(font . tlr-default-font)

should work. By quoting the variable you make the variable's name  
(and not its contents) available.

--
Greetings

   Pete

Time is an illusion. Lunchtime, doubly so.







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-26 13:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.5382.1251252804.2239.help-gnu-emacs@gnu.org>
2009-08-26  5:13 ` proper setting of default font (and string-handling in elisp?) Xah Lee
2009-08-26  5:22   ` Xah Lee
2009-08-26 12:59 Tom Roche
2009-08-26 13:45 ` Peter Dyballa
  -- strict thread matches above, loose matches on Subject: below --
2009-08-26  2:11 Tom Roche
2009-08-26  7:44 ` Peter Dyballa

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).