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

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

Re: list available fonts/fontsets


From: Edward O'Connor
Subject: Re: list available fonts/fontsets
Date: Tue, 21 Jun 2005 11:00:58 -0700
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (darwin)

> I'm trying to make my .emacs work on MS Windows and X on Solaris,

Excellent.

> but on X when I setup my initial-frame-alist, and default-frame-alist,
> it chokes on an invalid font, namely,
> -outline-Courier New-normal-r-normal-normal-12-90-96-96-c-*-iso10646-1.
> Is there a method which will display all that's available? M-x
> list-fontsets didn't seem to be what I needed.

Well, here's something resembling what I do to make fonts happy under
different system types.

(require 'cl)
(set-frame-parameter nil 'font
  (or (find-if (lambda (font)
                 (ignore-errors (x-list-fonts font)))
               '("-*-andale mono-medium-r-*--14-*-*-*-*-*-*-*"
                 "-*-bitstream vera sans 
mono-medium-r-*-*-14-*-*-*-*-*-iso8859-*"
                 "-*-Lucida Console-normal-r-*-*-18-*-*-*-c-*-iso8859-1"))
      "-adobe-courier-medium-r-*-*-14-*-*-*-*-*-*-*"))

The explanation: we want to set Emacs' font to one we like, but not all
machines have the same fonts available. First, we look for Andale Mono
14 (a common font on Mac OS X). If such a font is available
(`x-list-fonts' returns non-null), we use it. Otherwise, we try
Bitstream Vera Sans Mono 14 (common under X11). If we can't find that,
we'll try Lucida Console 18 (common under Windows). If all of the above
have failed, we'll use Courier 14 (common everywhere, so good as a
default).

Disclaimer: the actual code in my .emacs file is a bit more complicated
than the above, and I haven't tested what appears above. But it should
convey the idea I think.


Ted

-- 
Edward O'Connor
hober0@gmail.com

Ense petit placidam sub libertate quietem.





reply via email to

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