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

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

Re: Help in querying xlsfonts for a particular font from elisp


From: Kevin Rodgers
Subject: Re: Help in querying xlsfonts for a particular font from elisp
Date: Mon, 28 Aug 2006 09:16:23 -0600
User-agent: Thunderbird 1.5.0.5 (Windows/20060719)

Andrew M. Scott wrote:
I really like the "vera sans mono" font, but it's only available on
some of the platforms I use.
My .emacs currently uses the elisp fragment below, with a simple (getenv 
"PLATFORM")
kludge in the <need-some-help-here> test section; however this fails if I ssh 
from
a supported platform's xterm onto an unsupported platform.

I'd like help with cleaner solution to test for a supported platform
font.

(when (<need-some-help-here>)
   (set-face-font 'default "-bitstream-bitstream vera sans 
mono-medium-r-*-*-16-120-*-*-*-*-*-1")
   ;; AMS: Not clear why I need these next two lines
   (add-to-list 'default-frame-alist '(font . "-bitstream-bitstream vera sans 
mono-medium-r-*-*-16-120-*-*-*-*-*-1"))
   (add-to-list 'initial-frame-alist '(font . "-bitstream-bitstream vera sans 
mono-medium-r-*-*-16-120-*-*-*-*-*-1"))
   (set-frame-position (selected-frame) -8 -100)
   )

The X11 xlsfonts command seems promising, e.g.

xlsfonts -fn "-bitstream-bitstream vera sans 
mono-medium-r-*-*-16-120-*-*-*-*-*-1" | wc -l
returns
2 on a supported platform, and the two lines

xlsfonts: pattern "-bitstream-bitstream vera sans 
mono-medium-r-*-*-16-120-*-*-*-*-*-1" unmatched
0

I've played with variations of shell-command e.g.
(when (shell-command "xlsfonts -fn '-bitstream-bitstream vera sans 
mono-medium-r-*-*-16-120-*-*-*-*-*-1' | wc -l" t)
  (message "font exists")
     (message "font doesn't exist"))

You need `if', not `when' there.

but the shell calling subtleties escape me. Is there a non-interactive
version of shell-command?

First, does (x-list-fonts ""-bitstream-bitstream vera sans mono-medium-r-*-*-16-120-*-*-*-*-*-1") work?

If not, try calling the xlsfonts command with `shell-command-to-string'
instead of `shell'.

--
Kevin





reply via email to

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