From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eduardo Ochs Newsgroups: gmane.emacs.devel Subject: `set-frame-font' doesn't support font aliases Date: Sun, 01 Jun 2008 01:24:44 -0400 Message-ID: <87fxrxpw0z.fsf@dekooning.omnisys.int.com.br> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1212305106 8891 80.91.229.12 (1 Jun 2008 07:25:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Jun 2008 07:25:06 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 01 09:25:44 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K2hwk-0004A4-BP for ged-emacs-devel@m.gmane.org; Sun, 01 Jun 2008 09:25:43 +0200 Original-Received: from localhost ([127.0.0.1]:46165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2hvw-0001fv-6J for ged-emacs-devel@m.gmane.org; Sun, 01 Jun 2008 03:24:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K2hvr-0001eG-0a for emacs-devel@gnu.org; Sun, 01 Jun 2008 03:24:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K2hvp-0001cC-Cj for emacs-devel@gnu.org; Sun, 01 Jun 2008 03:24:46 -0400 Original-Received: from [199.232.76.173] (port=57097 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2hvo-0001bo-B4 for emacs-devel@gnu.org; Sun, 01 Jun 2008 03:24:44 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:57446 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K2hvn-0003ok-OS for emacs-devel@gnu.org; Sun, 01 Jun 2008 03:24:44 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K2hvf-0005ow-Hm for emacs-devel@gnu.org; Sun, 01 Jun 2008 07:24:35 +0000 Original-Received: from 189.25.54.57 ([189.25.54.57]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 01 Jun 2008 07:24:35 +0000 Original-Received: from eduardoochs by 189.25.54.57 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 01 Jun 2008 07:24:35 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 119 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 189.25.54.57 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:vGepBsnd2LUDvalTI8LnuddgaDQ= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:98168 Archived-At: Part 1 - Problem ---------------- The current code for `set-frame-font' doesn't support font aliases - for example, these sexps don't work: (set-frame-font "5x7") ;; error: "Font `5x7' is not defined" (set-frame-font "fixed") ;; uses some unexpected font but these ones do work: ;; "5x7": (set-frame-font "-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-1") ;; "fixed" (same as "6x13" in my machine - see below): (set-frame-font "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1") As far as I can tell, the expansion of aliased fonts is done using this file: (find-file "/usr/share/fonts/X11/misc/fonts.alias") and pgas (Pierre Gaston) pointed to me that "xlsfonts -l" can be used to show the real name of a font. Typical command lines are: xlsfonts -l -fn 5x7 xlsfonts -ll -fn 5x7 I am using a recent CVS Emacs on Debian 4.0 ("Etch", stable, xorg). Running (emacs-version) here returns this: "GNU Emacs 23.0.60.2 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2008-05-30 on dekooning" Part 2 - Workaround ------------------- (defun ee-aref (alist idx) "Like `aref', but for alists. Example: (ee-aref '((1 . one) (2 . two) (3 . three)) 2) -> two" (cdr (assoc idx alist))) (defun ee-font-alias (fontname &optional use-ucs) "Expand FONTNAME when it is an alias; when USE-UCS is non-nil, use \"iso10646\". The list of aliases has been built by hand from data found at this file: (find-file \"/usr/share/fonts/X11/misc/fonts.alias\")" (let ((aliases '( ("fixed" . "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1") ("variable" . "-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1") ("5x7" . "-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-1") ("5x8" . "-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1") ("6x9" . "-misc-fixed-medium-r-normal--9-90-75-75-c-60-iso8859-1") ("6x10" . "-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1") ("6x12" . "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-iso8859-1") ("6x13" . "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1") ("6x13bold" . "-misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1") ("7x13" . "-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-1") ("7x13bold" . "-misc-fixed-bold-r-normal--13-120-75-75-c-70-iso8859-1") ("7x13euro" . "-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-15") ("7x13eurobold" . "-misc-fixed-bold-r-normal--13-120-75-75-c-70-iso8859-15") ("7x14" . "-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1") ("7x14bold" . "-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1") ("8x13" . "-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1") ("8x13bold" . "-misc-fixed-bold-r-normal--13-120-75-75-c-80-iso8859-1") ("8x16" . "-sony-fixed-medium-r-normal--16-120-100-100-c-80-iso8859-1") ("9x15" . "-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1") ("9x15bold" . "-misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-1") ("10x20" . "-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-1") ("12x24" . "-sony-fixed-medium-r-normal--24-170-100-100-c-120-iso8859-1") ))) (setq fontname (or (ee-aref aliases fontname) fontname)) (if use-ucs (setq fontname (replace-regexp-in-string "iso8859" "iso10646" fontname))) fontname)) (defun ee-set-frame-font (fontname &optional use-ucs) "Like `set-frame-font', but uses `ee-font-alias' to expand FONTNAME." (set-frame-font (ee-font-alias fontname use-ucs))) ;; For tests (defun ee-insert (&rest rest) "Insert characters, strings, or ranges of characters. Example: (ee-insert '(?a ?z) 10 \"Foo!\")" (while rest (let ((o (car rest))) (cond ((stringp o) (insert o)) ((numberp o) (if (char-valid-p o) (insert o))) ((consp o) (mapc 'ee-insert (apply 'number-sequence o))) (t (error "Not string/int/pair: %S" o)))) (setq rest (cdr rest)))) ;; Tests: ;; (ee-font-alias "fixed") ;; (ee-font-alias "fixed" t) ;; (ee-set-frame-font "5x7" t) ;; (ee-set-frame-font "6x10" t) ;; (ee-set-frame-font "fixed" t) ;; (ee-set-frame-font "9x15" t) ;; (ee-set-frame-font "10x20" t) ;; (ee-insert "\n" '(32 126) "\n" '(913 981) "\n" '(8592 9675) "\n") Part 3 - Suggestion ------------------- It would be nice to have an Emacs function that would do this expansion - like the (ee-aref aliases fontname) above - cleanly and reliably... Cheers, Eduardo Ochs eduardoochs@gmail.com http://angg.twu.net/